This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_frag.glsl
Jeroen Bakker 2c391f8877 GPU: Patch GPencil shader for metal support.
The stoke shader of grease pencil uses a geometry shader stage. Apple
devices don't support shaders with geometry shader stage. In the
OpenGL driver there was a pass-through implemented so it didn't fail.

When using the metal backend this needs to be solved more explicitly.
This change patches the grease pencil shader to support both the
backends supporting a geometry stage and those without.

Fixes #105059

Pull Request #105116
2023-02-23 08:26:01 +01:00

38 lines
602 B
GLSL

#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 = fragment_in_color();
/* if alpha < 0, then encap */
if (tColor.a < 0) {
tColor.a = tColor.a * -1.0;
float dist = length(fragment_in_tex_coord() - center);
if (dist > 0.25) {
discard;
}
}
/* Solid */
fragColor = tColor;
}