refactor shader constants

This commit is contained in:
Joseph HENRY 2025-12-08 17:14:42 +01:00
parent d09119f9d7
commit d90fccb014
3 changed files with 11 additions and 6 deletions

View File

@ -32,6 +32,11 @@ def create_dashed_line_shader() -> gpu.types.GPUShader:
shader_info = gpu.types.GPUShaderCreateInfo() shader_info = gpu.types.GPUShaderCreateInfo()
shader_info.vertex_in(0, "VEC2", "pos") shader_info.vertex_in(0, "VEC2", "pos")
shader_info.fragment_out(0, "VEC4", "fragColor")
shader_info.push_constant("VEC4", "color")
shader_info.push_constant("MAT4", "viewMatrix")
shader_info.push_constant("FLOAT", "dashSize")
shader_info.push_constant("FLOAT", "gapSize")
shader_info.vertex_source(vertex_shader) shader_info.vertex_source(vertex_shader)
shader_info.fragment_source(fragment_shader) shader_info.fragment_source(fragment_shader)

View File

@ -2,11 +2,11 @@
flat in vec2 startPos; flat in vec2 startPos;
in vec2 vertPos; in vec2 vertPos;
out vec4 fragColor; // out vec4 fragColor;
uniform vec4 color; // uniform vec4 color;
uniform float dashSize; // uniform float dashSize;
uniform float gapSize; // uniform float gapSize;
void main() void main()
{ {
@ -16,4 +16,4 @@ void main()
if (fract(dist / (dashSize + gapSize)) > dashSize/(dashSize + gapSize)) if (fract(dist / (dashSize + gapSize)) > dashSize/(dashSize + gapSize))
discard; discard;
fragColor = color; fragColor = color;
} }

View File

@ -4,7 +4,7 @@
flat out vec2 startPos; flat out vec2 startPos;
out vec2 vertPos; out vec2 vertPos;
uniform mat4 viewMatrix; // uniform mat4 viewMatrix;
void main() void main()
{ {