Vulkan: Make Polyline Shaders Vulkan Compatible
Splitting interface stages based on the interpolation of its attributes. Then naming convention that have been used: * use `interp` as instance name when using smooth interpolation * use `interp_noperspective` when using no perpective interpolation * use `interp_flat` when using flat interpolation The same suffix will be added to the struct names. The naming convention will be added to the GLSL code style and applied to other shaders as well. Pull Request: https://projects.blender.org/blender/blender/pulls/111210
This commit is contained in:
parent
a99cccaff8
commit
53396816e4
@ -9,7 +9,8 @@ void main()
|
||||
#endif
|
||||
fragColor = interp.final_color;
|
||||
if (lineSmooth) {
|
||||
fragColor.a *= clamp((lineWidth + SMOOTH_WIDTH) * 0.5 - abs(interp.smoothline), 0.0, 1.0);
|
||||
fragColor.a *= clamp(
|
||||
(lineWidth + SMOOTH_WIDTH) * 0.5 - abs(interp_noperspective.smoothline), 0.0, 1.0);
|
||||
}
|
||||
fragColor = blender_srgb_to_framebuffer_space(fragColor);
|
||||
}
|
||||
|
@ -32,12 +32,12 @@ void do_vertex(const int i, vec4 pos, vec2 ofs)
|
||||
interp_out.clip = interp_in[i].clip;
|
||||
#endif
|
||||
|
||||
interp_out.smoothline = (lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
interp_noperspective_out.smoothline = (lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
gl_Position = pos;
|
||||
gl_Position.xy += ofs * pos.w;
|
||||
EmitVertex();
|
||||
|
||||
interp_out.smoothline = -(lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
interp_noperspective_out.smoothline = -(lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
gl_Position = pos;
|
||||
gl_Position.xy -= ofs * pos.w;
|
||||
EmitVertex();
|
||||
|
@ -45,7 +45,7 @@ void do_vertex(int index, vec4 pos, vec2 ofs, float flip)
|
||||
interp.clip = clip_g[index];
|
||||
#endif
|
||||
|
||||
interp.smoothline = flip * (lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
interp_noperspective.smoothline = flip * (lineWidth + SMOOTH_WIDTH * float(lineSmooth)) * 0.5;
|
||||
gl_Position = pos;
|
||||
gl_Position.xy += flip * ofs * pos.w;
|
||||
}
|
||||
|
@ -11,7 +11,9 @@
|
||||
|
||||
GPU_SHADER_INTERFACE_INFO(gpu_shader_3D_polyline_iface, "interp")
|
||||
.smooth(Type::VEC4, "final_color")
|
||||
.smooth(Type::FLOAT, "clip")
|
||||
.smooth(Type::FLOAT, "clip");
|
||||
|
||||
GPU_SHADER_INTERFACE_INFO(gpu_shader_3D_polyline_noperspective_iface, "interp_noperspective")
|
||||
.no_perspective(Type::FLOAT, "smoothline");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline)
|
||||
@ -22,8 +24,10 @@ GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline)
|
||||
.push_constant(Type::BOOL, "lineSmooth")
|
||||
.vertex_in(0, Type::VEC3, "pos")
|
||||
.vertex_out(gpu_shader_3D_polyline_iface)
|
||||
.vertex_out(gpu_shader_3D_polyline_noperspective_iface)
|
||||
.geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
|
||||
.geometry_out(gpu_shader_3D_polyline_iface)
|
||||
.geometry_out(gpu_shader_3D_polyline_noperspective_iface)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.vertex_source("gpu_shader_3D_polyline_vert.glsl")
|
||||
.geometry_source("gpu_shader_3D_polyline_geom.glsl")
|
||||
@ -38,6 +42,7 @@ GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_no_geom)
|
||||
.push_constant(Type::BOOL, "lineSmooth")
|
||||
.vertex_in(0, Type::VEC3, "pos")
|
||||
.vertex_out(gpu_shader_3D_polyline_iface)
|
||||
.vertex_out(gpu_shader_3D_polyline_noperspective_iface)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
.vertex_source("gpu_shader_3D_polyline_vert_no_geom.glsl")
|
||||
.fragment_source("gpu_shader_3D_polyline_frag.glsl")
|
||||
|
Loading…
Reference in New Issue
Block a user