Dear All,
I've run into a conflict between ghost object on, shadowing and fog in DBPro and shaders, that probably shows my ignorance of the graphics pipeline.
I have an advanced terrain to which I am applying GG's terrain shader, and a water plain, on which a water shader is running. I've created a ghosted plain above the terrain and water plain, the terrain's texture appears through the ghosted plain, the water shader does not (as shown in the image below). I've also discovered that fog does not affect the terrain object, even when I specifically set object fog to on for this object. DBPro's stencil shadows also do not get applied to the terrain.
I am guessing the problem is something to do with the rendering order of shaders and inherent DBPro functions. My terrain shader being applied before the ghost object, the water shader, which is multi-pass, being applied after the ghost object? GG's terrain shader is applied only when I create the terrain and is not updated, the water object's shader is updated at every time step. Anyway so I am not surprised I can't see the water shader through the ghosted plain, but surprised that the terrain isn't affected by fog and shadows. I would post the code....but it is 20,000 lines so far.
I have a sneaking suspicion the answer will be to control ghosting, fog and shadows with my shaders instead of using DBPro functions. With this in mind, if I was to write a shader to apply to an object to ghost it, I'd want to take the projected texture behind the object and combine it with the texture specified in a sampler weighted by the R bit of the sampler texture. Could a shader Guru suggest how to access the texture behind an object? It's straightforward using tex2D for a sampler but I am uncertain how to pass the background texture and whether I can use tex2D? I've put an illustration below that tries to explain what I mean by this poorly phrased question.
Many thanks,
Mr Grumpy
GrumpyOne - the natural state of the programmer