Is there a way to define 20 passes for example, that all use the same shader code? Like for a shell/layer based fur simulation shader, the same shader could be used, I would just need a passIndex to be updated with the current pass index.
for ( iPass = 0; iPass < 20; iPass++ )
{
set shader constant “_iPassIndex” to iPass;
render shader
}
Right now all I’m seeing is that the shader would need to be defined 20 times redundantly.
Thanks!
Scott
1 Answer
1
Hlsl doesn’t do passes, that’s a renderer specific thing, some have their on scripts to draw passes and set constants, not feasible for doing hundreds of times per frame, but a loop with constant pass index/count would be just as efficent as defining 20 back to back, and would load quicker. I noticed someone just including a shader file in their cg block which has 99% of the shader in it to avoid redundant code. This should work, still not the pretiest thing but all good.
At least one shader language has that sort of "pass loop" (HLSL? The one NVidea likes.) But maybe not in Unity, since it's a bit heavy.
– Owen-Reynolds