Home Game Development Depth versus Distance cubemaps for level mild shadows: Apparent Close distance drawback with Distance cubemap

Depth versus Distance cubemaps for level mild shadows: Apparent Close distance drawback with Distance cubemap

0
Depth versus Distance cubemaps for level mild shadows: Apparent Close distance drawback with Distance cubemap

[ad_1]

I’ve cubemap for rendering shadows of level mild in common Z buffer mode. Works fantastic however has the disavantage of requiring to retrieve the dice face to get the right matrix for calculating the z/w used for the testing.

Alternatively I noticed the chance to make use of Distance cubemap in GL [here (https://ogldev.org/www/tutorial43/tutorial43.html)]. The main benefit is that it’s direct texture learn and fewer calcul so the velocity is quicker. It works fantastic however I’m dealing with an issue apparently for object near the sunshine place (see image). In the instance the white and purple pointlights are near the vertical aircraft.

I have to miss one thing within the orginal GL code.

My code:
The cubemap is a R16_FLOAT format. Of observe 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

Input.Pos is the item place already remodel to its world area

In gs

float4 LPos = MildPos[LightIndex] //in world area;
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.Color = 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 - MildPositionViewSpace.xyz;
float LN = dot(txProj, txProj);//use the dot as a substitute of the size to avoid wasting directions
txProj = mul(txProj, (float3x3)mInvView);//convert again to world area to make use of shadowcubemap created in world area
float LE = txShadowArrayCubeMap[n].SampleLevel(samPoint, txProj, 0); 

Remember the cubemap shops the true size (LE). Because we use LN = dot within the ps as a substitute of LN = size we have to examine LN to LE*LE

LE*=LE
if ( LE <= LN ) Shadow *= 0.5f;

enter image description here

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here