lit - computes lighting coefficients for ambient, diffuse, and specular lighting contributions
float4 lit(float NdotL, float NdotH, float m);
half4 lit(half NdotL, half NdotH, half m);
fixed4 lit(fixed NdotL, fixed NdotH, fixed m);
The dot product of a normalized surface normal and a normalized light
The dot product of a normalized surface normal and a normalized half-angle
vector (for Blinn-style specular) where the half-angle vector is the sum
of the normalized view vector and normalized light vector. Alternatively,
the dot product of a normlized light vector and a normalized view vector
reflected by a normalized surface normal could be used (for Phong-style
A specular exponent, typically described as a measure of shininess.
The larger the exponent, the shinier the specular highlight, the smaller
the exponent, the duller the specular highlight.
The lit function is a helper function useful to compute lighting
coefficients for ambient, diffuse, and specular lighting contributions.
The function efficiently maps to a native instruction for most GPUs.
lit returns a 4-component vector arranged as follows:
The ambient coefficient that is always 1.0.
The diffuse coefficient that is zero if NdotL is less than zero, and NdotL otherwise.
The specular coefficient that is zero if either NdotL or NdotH are less than zero, and
otherwise NdotH raised to the power m.
lit accepting <float> parameters could be implemented this way:
float4 lit(float NdotL, float NdotH, float m)
float specular = (NdotL > 0) ? pow(max(0.0, NdotH), m);
return float4(1.0, max(0.0, NdotL), specular, 1.0);
lit is supported in all profiles.
dot, max, normalize, pow