Graphics Reference
In-Depth Information
// Compute ray termination point , full ray length and view
// direction ; truncate the ray against the top of the atmosphere
float3 f3RlghIn =0;
float3 f3MieIn =0;
float2 f2NetDensFromCam =0;
for ( uint Cascade = g_StartCscd ; Cascade < g_NumCascades ;++ Cascade )
{ // Truncate view ray against min/max z range for the current
// cascade , project onto the shadow map
// Load slice origin and direction , compute integration
// step f3UVAndDepthStep in shadow map space and in world
// space , set up current position f3CurrUVAndDepth
// Compute initial sample location in 1D height/map
uint uiSamplePos =
length ( f2StartUV . xy
f2SliceOriginUV . xy )/ fUVStepLen +0.5;
uint uiLevel =0;
int iDataOffset = g_iSMDim ; // Level 0 is not stored
float fMarchedDist =0;
uint uiMinMaxTexYInd =
uiSliceInd +( Cascade
g_StartCscd ) ￿ g_NumSlices ;
float fStep =1. f ;
while ( fMarchedDist < fRayLength )
{ IsInLight =0;
// If the sample is located at the appropriate position ,
// advance to the next coarser level
if (( uiSamplePos & ((2 << uiLevel ) 1)) == 0 )
{ iDataOffset += g_iSMDim >> uiLevel ;
uiLevel ++;
fStep ￿ =2. f ;
}
while ( uiLevel > 0)
{ // Compute depths at the ends of the current ray section
float2 f2StartEndDepth ;
f2StartEndDepth . x = f3CurrUVAndDepth . z ;
f2StartEndDepth . y = f3CurrUVAndDepth . z +
f3UVAndDepthStep . z ￿ ( fStep
1) ;
// Load min/max depths for the node
float2 f2MinMaxDepth = g_tex2DMinMaxDepth . Load (
uint3 (( uiSamplePos >> uiLevel )+ iDataOffset ,
uiMinMaxTexYInd ,
0) ) ;
IsInShadow = all ( f2StartEndDepth > = f2MinMaxDepth . yy );
IsInLight = all ( f2StartEndDepth <
f2MinMaxDepth . xx );
if ( IsInLight || IsInShadow )
break ; // If the ray section is fully li t or shadowed ,
// we can break the loop
// If the ray section is neither fully lit , nor
// shadowed , we have to go to the finer level
uiLevel −− ;
iDataOffset = g_iSMDim >> uiLevel ;
fStep /= 2 . f ;
} ;
Search WWH ::




Custom Search