RSM indirect Light flickering
float3 irradiance = float3(0.0f,0.0f,0.0f);
...
for(int i = 0; i < 8*8;i++)
{
float3 diff = position.xyz - VPLBuffer[i].position.xyz;
irradiance += VPLBuffer[i].color.rgb(the sample color) * (saturate(dot(VPLBuffer[i].normal.xyz, diff)) * saturate(dot(normal,-diff))) / pow(length(diff),3);
}
irradiance *= diffuse.rgb(the color map);
Code reformatted to see meaning bit easier. Why you do double sided light equation?
Oh thanks that makes sense. Well the double sided equation was my first idea of doing that. Is there an other way to do that ??
Just try to use binary nDotL test to prevent backside lighting. Then use standard distance square fallof. This should be lot less flickery.
But when do I do that ? My first idea was the standart way of indirect lighting with RSM : Create Vector a = reflect( Lightposition - rsm pixel position, rsm pixel normal). Now vector a is the vector which is (maybe) directed to our dest pixel. Now I do nDotL with the dest pixels normal and vector a. Now I have to multiply this float with the rsm color and divide it by the fallof. But I don't realy unterstand what you mean with the binary test. Maybe someone can give me his way of implementing that, because I thing my way is too expensive.