I'm trying to implement shadow maps for point lights using Webgl2. To do so, I use a cubemap of depth buffers to which I render 6 axis aligned views from the light position.
In the fragment shader I use to render lighting, I query this cubemap using these lines:
vec3 lightToPos = lightPos-fragPos;
float closestDepth = texture(shadowMap, lightToPos).r;
Note that lightPos and fragPos are in 'view' referential, that is: viewMat * worldMat * objPos
. In the tutorial I'm following this is supposed to be in World Position (http://ogldev.atspace.co.uk/www/tutorial43/tutorial43.html). Now, I don't see a reason why my way of doing it wouldn't work because the difference of two positions should be the same regardless of the point of view their coordinates are expressed in, right? The results I'm getting are not what I'm expecting, everything is in the shadow. I have probably made a mistake elsewhere but I would like to be sure I understood how that works and that the mistake is not from here.