Browse Source

avoid ifs in shaders

feature/replace-renderer
Martin Dørum 3 years ago
parent
commit
94a21688aa
1 changed files with 3 additions and 8 deletions
  1. 3
    8
      libcygnet/src/shaders.cc

+ 3
- 8
libcygnet/src/shaders.cc View File

uniform vec2 size; uniform vec2 size;


void main() { void main() {
// TODO: This probably shouldn't be an if?
if (
v_coord.x < THICKNESS || v_coord.x > size.x - THICKNESS ||
v_coord.y < THICKNESS || v_coord.y > size.y - THICKNESS) {
gl_FragColor = vec4(0.6, 0.6, 0.6, 0.8);
} else {
gl_FragColor = vec4(0, 0, 0, 0);
}
vec2 invCoord = size - v_coord;
float minDist = min(v_coord.x, min(v_coord.y, min(invCoord.x, invCoord.y)));
gl_FragColor = vec4(0.6, 0.6, 0.6, 0.8) * float(minDist < THICKNESS);
} }
)glsl"; )glsl";



Loading…
Cancel
Save