Skip to content

Instantly share code, notes, and snippets.

@Samsy
Last active May 3, 2016 16:03
Show Gist options
  • Save Samsy/036f01b38b5d61e91cc537b740aefcbd to your computer and use it in GitHub Desktop.
Save Samsy/036f01b38b5d61e91cc537b740aefcbd to your computer and use it in GitHub Desktop.
Branching
varying vec2 vUv;
uniform sampler2D tDiffuse;
uniform float isPicking;
uniform vec3 pickingColor;
void main() {
vec3 color = texture2D(tDiffuse, vUv).rgb;
gl_FragColor = vec4(color, 1.0);
}
varying vec2 vUv;
uniform sampler2D tDiffuse;
uniform float isPicking;
uniform vec3 pickingColor;
void main() {
gl_FragColor = vec4(pickingColor, 1.0);
}
varying vec2 vUv;
uniform sampler2D tDiffuse;
uniform float isPicking;
uniform vec3 pickingColor;
void main() {
if( isPicking == 0.0 ) {
vec3 color = texture2D(tDiffuse, vUv).rgb;
gl_FragColor = vec4(color, 1.0);
}
else {
gl_FragColor = vec4(pickingColor, 1.0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment