I am working on a rendering program and I have several effects I need to combine together. I have shadow mapping, SSS, and wrap lighting as described here: http://http.developer.nvidia.com/GPUGems/gpugems_ch16.html
How do I combine these effects? When computing the shadow I get a float [0,1] to multiply by the overall color, and the SSS computation I get a float [0,1] describing how far the light traveled through the object. I cannot multiply these because then the back face will still be in shadow. I am just generally confused about combining many lighting effects.
I am doing typical VSM shadow mapping where a depth map is rendered from each light, and then one final pass from the camera. In this pass I compute the shadow component using VSM and the SSS component using the same depth map ( exp( -(d_o - d_i) * sigma_t ) ). (the body of the code below happens once per light hence the index)
shadow = shadowsVar[i];
NdotL = dot(n,normalize(lightDir[i]));
spotEffect = dot(normalize(gl_LightSource[i].spotDirection), normalize(-lightDir[i]));
if (spotEffect > spotOff[i])
{
spotEffect = smoothstep(spotOff[i], 1.0, spotEffect);
spotEffect *= shadow;
// this is where im trying to incorporate my sss component
#ifdef SUBSURFACE_SCATTERING
spotEffect *= sss_comp;
#endif // SUBSURFACE_SCATTERING
att = spotEffect;
diffuse = gl_FrontMaterial.diffuse * gl_LightSource[i].diffuse * NdotL;
final_color += att * diffuse;
halfV = normalize(gl_LightSource[i].halfVector).xyz;
NdotHV = max(dot(n,halfV),0.0);
specular_color += att * gl_FrontMaterial.specular * gl_LightSource[i].specular * pow(NdotHV,gl_FrontMaterial.shininess);
}
#ifdef USE_TEXTURE
final_color.rgb *= texture2D(colorTexture,gl_TexCoord[0].st).rgb;
#endif // USE_TEXTURE
final_color.rgb += specular_color.rgb;
gl_FragColor = final_color;