Hey guys as the picture is showing I can now successfully get the armadillo react to light's direction and it becomes green when radio active lightbulb hits it. However I didn't want just green, I want to have a rainbow effect when the bulb gets too close. When I added the else if statements my fs won't load anymore. Did I do something wrong here?
// Create shared variable. The value is given as the interpolation between normals computed in the vertex shader
varying vec3 interpolatedNormal;
varying vec3 arpos;
uniform vec3 lightPosition;
void main() {
vec3 vecToCenter = normalize(lightPosition - arpos);
float distance = length(arpos - lightPosition);
float lightSrc = max(dot(vecToCenter*6.0, normalize(interpolatedNormal)), 0.0)/distance;
if(distance < 2.0){
gl_FragColor = vec4(0.15, lightSrc, 0.15, 1.0); // Rainbow radiation
}
else if(2.0<distance<3.0){
gl_FragColor = vec4(0.15, lightSrc, 0.15, 1.0); // Rainbow radiation
}
else if(3.0<distance<4.0){
gl_FragColor = vec4(0.15, lightSrc, 0.15, 1.0); // Rainbow radiation
}
else if (distance>8.0){
gl_FragColor = vec4(1/lightSrc, lightSrc, lightSrc, 1.0); //
}
else{
gl_FragColor = vec4(lightSrc, lightSrc, lightSrc, 1.0); //
}
}
Aucun commentaire:
Enregistrer un commentaire