Integrating PSSM shading with grass


11-11-2009 11:48:20

I'm attempting to use my PSSM shadow code with the grass

From my understanding, I need to override the material automatically generated for the grass with a rewritten vertex program based off BatchPage.cpp, and add in my shadow code. Is this correct?

What might this look like?

Here is me overriding the texture: (alpharejectionbase renders my shadowcode and omits the alpha)

material grass_GrassVS_anim_0_2_15.5_vp : PSSM/AlphaRejectionBase
set $AmbientDiffuseTexture "grass.png"
set $AmbientColour "1 1 1 1"
set $DiffuseColour "1 1 1 1"

^^ The error I get with this is:
Parameter called time does not exist. in GpuProgramParameters::_findNamedConstantDefinition

Which means I haven't implemented the vertex program code from BatchPage.cpp..
Now how/where exactly do I insert the code? Do I just add another vertex program to the material with the code from BatchPage?

Any help is greatly appreciated,


21-11-2009 15:53:47

The code from BatchPage should appear in your material/shader files and be combined with your shadow calculations.

This is the source from BatchPage.cpp:

" float dist = distance(camPos.xz, iPosition.xz); \n"
" oColor.a *= (invisibleDist - dist) / fadeGap; \n";

So in you shader there should be the same code for fading. But the value of "oColor" must be calculated with taking an account of shading:

float dist = distance(camPos.xz, iPosition.xz);
oColor *= shadowing; // that's your shadowing appliment (for example)
oColor.a *= (invisibleDist - dist) / fadeGap;

And of course all the variables from code of BatchPage should be present in your material/shader files in order to PagedGeometry could update them.


21-11-2009 16:14:32