Sign in to follow this  
BattleMetalChris

[hlsl] Execute a line once per draw call

Recommended Posts

I'm pulling the near and far clip planes out of the projection matrix in a shader. This is only something which needs to be done once for each draw call, is there any way I can get this line to run just once, rather than for every vertex if I put it in the vertex shader?

Or is it best to calculate them outside of the shader and just pass them to the shader as global variables?

Share this post


Link to post
Share on other sites
allingm    539
I once asked this question, and it turned out the best solution was to do it on the CPU and pass it as a global variable. If you are pulling out the near and far, can't you just pass them in? You should have them lying around somewhere from when you made the matrix.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this