Skip to content

Commit

Permalink
surface shader - fix uniform control flow for texture accesses
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomáš Malý committed Jul 9, 2018
1 parent 59d98f6 commit e2058f0
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions browser/src/vts-librenderer/data/shaders/surface.frag.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,25 @@ void main()
{
// texture color
vec4 color = texture(texColor, varUvTex);
if (uniFlags.y > 0)
color = color.rrra; // monochromatic texture

// mask
if (uniFlags.x > 0)
{
if (texture(texMask, varUvTex).r < 0.5)
discard;
}

// uv clipping
// uv clipping must go after all texture accesses to allow for computation of derivatives in uniform control flow
if (varUvClip.x < uniUvClip.x
|| varUvClip.y < uniUvClip.y
|| varUvClip.x > uniUvClip.z
|| varUvClip.y > uniUvClip.w)
discard;

// mask
if (uniFlags.x > 0)
{
if (texture(texMask, varUvTex).r < 0.5)
discard;
}
// monochromatic texture
if (uniFlags.y > 0)
color = color.rrra;

// base color
if (uniFlags.z > 0)
Expand Down

0 comments on commit e2058f0

Please sign in to comment.