• Create Account

### #ActualL. Spiro

Posted 16 October 2012 - 04:45 PM

The dot product is part of the lighting model.
Each lighting model should be done separately and then added together.

Taking a very basic Lambertian diffuse component on 2 lights, the proper way to combine them would be:
((Light0Color * max( Light0DotNormal, 0.0 )) + (Light1Color * max( Light1DotNormal, 0.0 ))) * DiffuseMaterial.

Simple pseudo-code would be:
vec4 diffuseLight = vec4( 0.0, 0.0, 0.0, 0.0 );
for ( int I = 0; I < lights; I++ ) {
diffuseLight += lightingModel( I );    // Performs L·N as part of the lighting model for light index I.
}
finalColor.xyz = diffuseMaterial.xyz * diffuseLight.xyz;


L. Spiro

### #1L. Spiro

Posted 16 October 2012 - 04:44 PM

The dot product is part of the lighting model.
Each lighting model should be done separately and then added together.

Taking a very basic Lambertian diffuse light on 2 lights, the proper way to combine them would be:
((Light0Color * max( Light0DotNormal, 0.0 )) + (Light1Color * max( Light1DotNormal, 0.0 ))) * DiffuseMaterial.

Simple pseudo-code would be:
vec4 diffuseLight = vec4( 0.0, 0.0, 0.0, 0.0 );
for ( int I = 0; I < lights; I++ ) {
diffuseLight += lightingModel( I );
}
finalColor.xyz = diffuseMaterial.xyz * diffuseLight.xyz;


L. Spiro

PARTNERS