I’ve cubemap for rendering shadows of level mild in common Z buffer mode. Works advantageous however has the disavantage of requiring to retrieve the dice face to get the proper matrix for calculating the z/w used for the testing.
Alternatively I noticed the likelihood to make use of Distance cubemap in GL [here (https://ogldev.org/www/tutorial43/tutorial43.html)]. The foremost benefit is that it’s direct texture learn and fewer calcul so the velocity is quicker. It really works advantageous however I am going through an issue apparently for object near the sunshine place (see image). Within the instance the white and pink pointlights are near the vertical aircraft.
I need to miss one thing within the orginal GL code.
My code:
The cubemap is a R16_FLOAT format. Of be aware utilizing a R16_UNORM and normalized information didn’t take away the issue.
I retailer the size of place of pointlight to place of object
Enter.Pos is the article place already rework to its world house
In gs
float4 LPos = LightPos[LightIndex] //in world house;
for( int f = 0; f < 6; ++f )
{
matrix M = LightViewProjCube[LightIndex][f];
PS_CUBEMAP_IN output;
output.RTIndex = f;
for( int v = 0; v < 3; v++ )
{
output.Coloration = size(enter[v].Pos.xyz - LPos.xyz);
output.Pos = mul( enter[v].Pos, M );
CubeMapStream.Append( output );
}
CubeMapStream.RestartStrip();
}
In ps
float3 txProj = PositionViewSpace.xyz - LightPositionViewSpace.xyz;
float LN = dot(txProj, txProj);//use the dot as an alternative of the size to save lots of directions
txProj = mul(txProj, (float3x3)mInvView);//convert again to world house to make use of shadowcubemap created in world house
float LE = txShadowArrayCubeMap[n].SampleLevel(samPoint, txProj, 0);
Keep in mind the cubemap shops the true size (LE). As a result of we use LN = dot within the ps as an alternative of LN = size we have to examine LN to LE*LE
LE*=LE
if ( LE <= LN ) Shadow *= 0.5f;