views:

274

answers:

1

Hello all,
I have 2 HLSL ps2.0 shaders. Simplified, they are:

Shader 1

  • Reads texture
  • Outputs colour value based on this texture

Shader 2

  • Problem: Need to read in the colour from Shader 1
  • Outputs the final colour which is a function of the input colour

(They need to be different shaders as I've reached the maximum vertex-shader outputs for 1 shader)


My problem is I cannot work out how Shader 2 can access the existing fragment/pixel colour.

Knowing how to do any of these things with HLSL would solve my problem;

  • Read existing pixel colour (I don't think this is possible)
  • Pass result of Shader 1 to Shader 2 as a float4
  • Render result of Shader 1 as a texture in memory, and have Shader 2 read that in
+1  A: 

To do what you want, you can switch render targets between execution of shader1 and shader2. You output your first shader to a texture and then you pass this texture to your second shader.

This is done in Ogre with Compositor scripts and target.

madgnome
This is exactly what I want to do, but I can't find information on doing it in HLSL and Ogre scripts. Link is OpenGL.
RJFalconer
Ok, so I think you'll have to look for Ogre Compositor scripts and target. (http://www.ogre3d.org/docs/manual/manual_29.html)
madgnome
Ogre tutorial on Render to texture : http://www.ogre3d.org/wiki/index.php/Intermediate_Tutorial_7
madgnome
Bingo. Compositor scripts were what I was after. One of those things you just can't find unless you know the name. If you edit your answer to include your relevant comments I'll mark it as accepted. Thanks very much!
RJFalconer