Reflective Shadow Map anaylis of Implementation

Hello, I’m trying to implement reflective shadow map to extend the regular shadow map and get one bounce indirect ilumination to my scene. i’m basically following this article : http://www.klayge.org/material/3_12/GI/rsm.pdf

All my buffers seem to right in renderDoc. But I believe I’m doing something wrong in the virtual light points calculations, could you give me your opinion if that looks correct and How should I add this indirect diffuse lighting in my current cook torrance implementation?

In this test maybe it doesn’t seems so horrible:

But if I move the wall a bit forward you can see the undesirable result:
PositionRSM ,NormalRSM,diffuseRSM are buffers captured in the directional shadow map pass.They look Ok in the renderdoc.

``````    const int SAMPLECOUNT = 100;

vec3 calcIndirectDiffuse(vec3 N,  vec4 fragPosLightSpace)
{
//fragPosLightSpace is my worldPosition in the lightSpace
vec3 projCoords = fragPosLightSpace.xyz / vec3(fragPosLightSpace.w);
vec3 P = (projCoords * 0.5) + vec3(0.5);

float rMax =3.5 ;
for (int i = 0; i < SAMPLECOUNT ; i++)
{
vec2 rnd = gausianDistribution.points[i];
vec2 coords = vec2 (rMax * rnd.x*sin(2*PI*rnd.y) +
P.x,rMax*rnd.x*cos(2*PI*rnd.y) + P.y);
vec3 vplPosition = texture(positionRSM, coords).xyz;
vec3 vplNormal = texture(normalRSM, coords).xyz;
vec3 flux = texture(diffuseRSM, coords).xyz;
flux*=flux*2.;
vec3 r = (flux * max(0.0, dot(vplNormal, P - vplPosition))) *
max(0.0, dot(N, vplPosition - P));
r /= vec3(pow(length(P - vplPosition), 4.0));
r*=r*4.3;

}
}
``````

this is how I’m integrating the indirect diffuse lighting in the cooktorrance

``````vec3 irradiance = texture(irradianceMap,N).rgb ;
This is result of `calcIndirectLighting` only :