GPU: Patch GPencil shader for metal support. #105114
|
@ -1,12 +1,33 @@
|
|||
#ifdef USE_GEOMETRY_SHADER
|
||||
vec4 fragment_in_color()
|
||||
{
|
||||
return geometry_out.mColor;
|
||||
}
|
||||
|
||||
vec2 fragment_in_tex_coord()
|
||||
{
|
||||
return geometry_out.mTexCoord;
|
||||
}
|
||||
#else
|
||||
vec4 fragment_in_color()
|
||||
{
|
||||
return geometry_in.finalColor;
|
||||
}
|
||||
|
||||
vec2 fragment_in_tex_coord()
|
||||
{
|
||||
return vec2(0.5);
|
||||
}
|
||||
#endif
|
||||
|
||||
void main()
|
||||
{
|
||||
const vec2 center = vec2(0, 0.5);
|
||||
vec4 tColor = vec4(geometry_out.mColor);
|
||||
vec4 tColor = fragment_in_color();
|
||||
/* if alpha < 0, then encap */
|
||||
if (geometry_out.mColor.a < 0) {
|
||||
if (tColor.a < 0) {
|
||||
tColor.a = tColor.a * -1.0;
|
||||
float dist = length(geometry_out.mTexCoord - center);
|
||||
float dist = length(fragment_in_tex_coord() - center);
|
||||
if (dist > 0.25) {
|
||||
discard;
|
||||
}
|
||||
|
|
|
@ -14,13 +14,11 @@ GPU_SHADER_INTERFACE_INFO(gpencil_stroke_geom_iface, "geometry_out")
|
|||
.smooth(Type::VEC4, "mColor")
|
||||
.smooth(Type::VEC2, "mTexCoord");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke)
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke_base)
|
||||
.vertex_in(0, Type::VEC4, "color")
|
||||
.vertex_in(1, Type::VEC3, "pos")
|
||||
.vertex_in(2, Type::FLOAT, "thickness")
|
||||
.vertex_out(gpencil_stroke_vert_iface)
|
||||
.geometry_layout(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::TRIANGLE_STRIP, 13)
|
||||
.geometry_out(gpencil_stroke_geom_iface)
|
||||
.fragment_out(0, Type::VEC4, "fragColor")
|
||||
|
||||
.uniform_buf(0, "GPencilStrokeData", "gpencil_stroke_data")
|
||||
|
@ -28,7 +26,16 @@ GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke)
|
|||
.push_constant(Type::MAT4, "ModelViewProjectionMatrix")
|
||||
.push_constant(Type::MAT4, "ProjectionMatrix")
|
||||
.vertex_source("gpu_shader_gpencil_stroke_vert.glsl")
|
||||
.geometry_source("gpu_shader_gpencil_stroke_geom.glsl")
|
||||
.fragment_source("gpu_shader_gpencil_stroke_frag.glsl")
|
||||
.typedef_source("GPU_shader_shared.h")
|
||||
.typedef_source("GPU_shader_shared.h");
|
||||
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke_geom)
|
||||
.additional_info("gpu_shader_gpencil_stroke_base")
|
||||
.geometry_layout(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::TRIANGLE_STRIP, 13)
|
||||
.geometry_out(gpencil_stroke_geom_iface)
|
||||
.geometry_source("gpu_shader_gpencil_stroke_geom.glsl")
|
||||
.do_static_compilation(true);
|
||||
|
||||
GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke_nogeom)
|
||||
.additional_info("gpu_shader_gpencil_stroke_base")
|
||||
.do_static_compilation(true);
|
||||
|
|
Loading…
Reference in New Issue