Getting current pass number into a vertex shader

Is this doable? Say I wanted to call a vertex shader over and over using UsePass and just change a value based on the pass number. (Yeah for a basic fur shader)

Or would I need to have duplicate the vertex shader a bunch of times and change one number?

-Jon

Directly - not really. What you can do is define the vertex shader code in separate .cginc file and include that (take a look at grass shaders for example). Or there is an almost-hidden feature with using Cg between CGINCLUDE/ENDCG blocks (not CGPROGRAM/ENDCG); the contents will be “pasted” into any further CGPROGRAM blocks (Reflective water shader uses that).

I’ll do something like that. I’m kind of curious as to how the fur shader code shaunis pasted uses PASSCOUNT and PASSINDEX. It looked like Cg from here.

Thanks for the response!
-Jon

It does look like an .fx file; however there’s no automated way to use pass count/index in .fx files either. Of course, if that shader is from some tech demo, then the tech demo can just set passcount/passindex properties before drawing each pass.

Its a DX9 HLSL shader and has a number of input paramters, namely;

  1. Fur Length (A float between 0.5 and 3)
  2. Fur Thickness (A float between 1 and 5)
  3. A Noise texture for generating the “fibers”

The nearest light and lightcolor parameters are automatically passed from the object.

How is the pass number passed in? I assume it’s also passed in somewhere from “the code”

When writing the Shader - certain manually exposed parameters can be defined, for example:

float myTestParam <float UIMin=0.1; UIMax=5.0;> = 3.0;

UImin and max define the limits of the parameter and the final value is the default.

Other parameters are exposed automatically and change depending on the material and object binding.

This can be modified at runtime. It a Virtools specific feature and not related to standard shader code AFAIK.

Cheers
Shaun