author | Florian Link |
package | MeVisLab/Standard |
dll | SoShaderPipeline |
definition | SoShaderPipeline.def |
The SoShaderPipelineLightModel module allows to choose and even replace the lighting model that is used by the SoShaderPipeline.
All built-in lights (SoDirectionalLight, SoPointLight, SoShadowMapping, ...) make use of the light model to apply shading to a surface.
The default light model of SoShaderPipeline is the BlinnPhong model.
Choose the used light model.
Values:
Title | Name | Description |
---|---|---|
Lambert | Lambert | Lambertian diffuse illumination without specular reflections. |
Blinn Phong | BlinnPhong | Default BlinnPhong lighting, using the half vector for specular reflections. |
Phong | Phong | Phong light model, which calculates the reflection vector for specular highlights. |
Custom | Custom | A custom light model, the code is provided in Custom Light Model. The light model needs to implement a function that is named so_Lighting and has the following signature: vec3 so_Lighting(in State state, vec3 lightColor, vec3 lightDirection, vec3 viewDirection, float attenuation)
It needs to calculate the lighting added by the given light using the passed parameters. As an example, the following code implements the Phong model: vec3 so_Lighting(in State state, vec3 lightColor, vec3 lightDirection, vec3 viewDirection, float attenuation)
{
vec3 R = normalize(-reflect(lightDirection,state.vertexEyeNormal));
float nDotLight = so_LightingDot(state.vertexEyeNormal, lightDirection);
float nDotHalf = so_LightingDot(viewDirection, R);
vec3 result = lightColor * state.surfaceDiffuse * nDotLight;
if (nDotLight != 0.0)
{
float powerFactor = pow(nDotHalf, state.surfaceShininess);
result += lightColor.rgb * state.surfaceSpecular * powerFactor;
}
return result * attenuation;
}
|
If you press this button, the current light model is copied to the Custom Light Model and the custom model is enabled.