推送常量完成。
This commit is contained in:
@@ -16,9 +16,18 @@ layout(binding = 0) uniform UniformBufferObject {
|
||||
mat4 view;
|
||||
} ubo;
|
||||
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float myValue;
|
||||
} pushConstants;
|
||||
|
||||
void main() {
|
||||
mat4 worldviewproj = ubo.proj * ubo.view * ubo.model;
|
||||
gl_Position = worldviewproj * vec4(inPosition, 1.0);
|
||||
//gl_Position = worldviewproj * vec4(inPosition, 1.0);
|
||||
|
||||
vec2 position = vec2(inPosition.xy*2 -1);
|
||||
//gl_Position = vec4(inPosition.xy*2 -1, 0.5, 1.0);
|
||||
position = position * pushConstants.myValue;
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
|
||||
fragColor = inColor;
|
||||
|
||||
|
||||
Binary file not shown.
@@ -11,13 +11,20 @@ layout(binding = 0) uniform UniformBufferObject {
|
||||
mat4 view;
|
||||
} ubo;
|
||||
|
||||
layout(push_constant) uniform PushConstants {
|
||||
float myValue;
|
||||
} pushConstants;
|
||||
|
||||
void main() {
|
||||
// 预计算MVP矩阵以减少乘法次数
|
||||
mat4 mvp = ubo.proj * ubo.view * ubo.model;
|
||||
//mat4 mvp = ubo.proj * ubo.view * ubo.model;
|
||||
//vec3 pos = vec3(2.0, inPosition.y, inPosition.z);
|
||||
//gl_Position = mvp * vec4(inPosition, 1.0);
|
||||
|
||||
gl_Position = vec4(inPosition.xy*2 -1, 0.5, 1.0);
|
||||
vec2 position = vec2(inPosition.xy*2 -1);
|
||||
//gl_Position = vec4(inPosition.xy*2 -1, 0.5, 1.0);
|
||||
position = position * pushConstants.myValue;
|
||||
gl_Position = vec4(position, 0.5, 1.0);
|
||||
|
||||
fragColor = inColor;
|
||||
gl_PointSize = 2.0;
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user