• Create Account

#ActualCC Ricers

Posted 20 September 2012 - 09:24 PM

Thanks, it solved the problem

If you want to have a look on my HLSL colored csm sampling functions that use it :
....

PS :
g_CSM_depths[split].x is the minimal depth of the #split map, g_CSM_depths[split+1].x is the maximal depth of the #split map.
g_CSM_depths[split].y is the depth bias of the #split map
Any suggestion or improvement is welcome

Instead of using if statements while looping through split indices get the correct split index by adding up conditional statements for all the split tests. This does away with the need for branching.

For instance, here is what I use for my single-pass CSM function:

cascadeDistances[NUM_CASCADES];

splitIndex = 0;
for (int i = 0; i < NUM_CASCADES; i++)

// Get shadow map position projected in light view



Here, linear Z depth is a value between the near and far world unit distances of the entire view frustum, not the splits. The cascadeDistances array is the list of far split planes in world units, listed from smallest to greatest. If linearZ > cascadeDistances[1], it also follows that linearZ > cascadeDistances[0] is true, therefore splitIndex is 2.

SplitIndex will always be less than the number of cascades, because cascadeDistances[n] is the farthest depth in the view, which linearZ will always be less than.

#1CC Ricers

Posted 20 September 2012 - 09:23 PM

Thanks, it solved the problem

If you want to have a look on my HLSL colored csm sampling functions that use it :
....

PS :
g_CSM_depths[split].x is the minimal depth of the #split map, g_CSM_depths[split+1].x is the maximal depth of the #split map.
g_CSM_depths[split].y is the depth bias of the #split map
Any suggestion or improvement is welcome

Instead of using if statements while looping through split indices get the correct split index by adding up conditional statements for all the split tests.

For instance, here is what I use for my single-pass CSM function:

cascadeDistances[NUM_CASCADES];

splitIndex = 0;
for (int i = 0; i < NUM_CASCADES; i++)