lit

In HLSL the lit function use dotDiffuse, dotSpecular and shininess as parameters and returns a lighting coefficient vector (ambient, diffuse, specular, 1) where:

  • ambient = 1
  • diffuse = ((n • l) < 0) ? 0 : n • l
  • specular = ((n • l) < 0) || ((n • h) < 0) ? 0 : ((n • h) * m)

In GLSL it would be:

vec4 lit(float NdotL, float NdotH, float m) 
{ 
  float ambient = 1.0;
  float diffuse = max(NdotL, 0.0);
  float specular = step(0.0, NdotL) * max(NdotH * m, 0.0); 
  return vec4(ambient, diffuse, specular, 1.0);
}
2010-08-03 Comments

Leave a Reply

Your email address will not be published.