完成背景的推送

This commit is contained in:
xsl
2025-09-24 23:23:39 +08:00
parent c711a90592
commit 8dc5aab8fe
2 changed files with 7 additions and 14 deletions
+7 -14
View File
@@ -25,20 +25,6 @@ const vec2 positions[6] = vec2[6](
); );
//const float offset = (640-480)/(640.0*2); // 假设宽高比为4:3
// const float offset = 0;
// const vec2 positions[6] = vec2[6](
// vec2( -1.0 - offset, 1.0), // 右上 -> 左上
// vec2(-1.0 - offset, -1.0), // 左上 - 左下
// vec2(1.0 + offset, -1.0), // 左下 - 右下
// vec2(1.0 + offset, -1.0), // 左下 - 右下
// vec2( 1.0 + offset, 1.0), // 右下 - 右上
// vec2( -1.0 - offset, 1.0) // 右上 - 左上
// );
const vec2 texCoords[6] = vec2[6]( const vec2 texCoords[6] = vec2[6](
vec2(1.0, 1.0), // 右上 vec2(1.0, 1.0), // 右上
@@ -50,12 +36,19 @@ const vec2 texCoords[6] = vec2[6](
vec2(1.0, 1.0) // 右上 vec2(1.0, 1.0) // 右上
); );
// 定义 Push Constant,只有一个 float
layout(push_constant) uniform PushConstants {
float myValue;
} pushConstants;
// 输出变量 // 输出变量
layout(location = 0) out vec2 outTexCoord; layout(location = 0) out vec2 outTexCoord;
void main() { void main() {
// 获取顶点位置 // 获取顶点位置
vec2 position = positions[gl_VertexIndex]; vec2 position = positions[gl_VertexIndex];
position = position * pushConstants.myValue;
// 设置输出位置(Vulkan使用不同的坐标系) // 设置输出位置(Vulkan使用不同的坐标系)
gl_Position = vec4(position, 0.0, 1.0); gl_Position = vec4(position, 0.0, 1.0);
Binary file not shown.