Jump to content

  • Log In with Google      Sign In   
  • Create Account

Awesome job so far everyone! Please give us your feedback on how our article efforts are going. We still need more finished articles for our May contest theme: Remake the Classics

CSM Split selection


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 TiagoCosta   Crossbones+   -  Reputation: 1074

Like
0Likes
Like

Posted 01 September 2012 - 04:26 AM

Currently I select the CSM split to sample from using a loop and conditional

for(int i = 0; i < numCascades; i++)
{
	 if(viewPos.z < splitEnd[i])
	 {
		   //transform using *i* split proj matrix
		   break;
	 }
}

However I'm looking for faster methods to do the selection because loops/conditionals are usually slow inside pixel shaders.

Can someone explain a faster method? Thanks.

P.S. I calculate each split projection matrix by creating a tight sphere around the world space corners of the view frustum split.

Edited by TiagoCosta, 01 September 2012 - 10:55 AM.

Tiago Costa
Aqua Engine - my DirectX 11 game "engine" - In development

Sponsor:

#2 MJP   Moderators   -  Reputation: 5488

Like
0Likes
Like

Posted 01 September 2012 - 12:30 PM

I usually do it like this:

uint cascadeIdx = 0;

[unroll]
for(uint i = 0; i < NumCascades - 1; ++i)
{
	[flatten]
	if(depthVS > CascadeSplits[i])
		cascadeIdx = i + 1;
}

Where "depthVS" is the view-space Z value of the pixel, and CascadeSplits are the linear view-space Z values of the cascade partitions.

Edited by MJP, 01 September 2012 - 12:32 PM.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS