Shader tricks

Hey all

I was wondering if anyone’s got any information about the following:

  1. is it possible to render more than 4 values out of 1 shader, or do i need to do something like render 2 viewports with the seperate values? Also I’ve played with encoding seperate values in MSB’s and LSB’s in high res outputs, all messy stuff :)

  2. is it possible read back the current colour value (or any information) from the pixel which my pixel shader is going to write to? I presume this is a graphics card limitation / DX9.

  3. are there any other tricks for dealing with values in shaders? whether you’re willing to tell us all what they are or not ;)


ad 1) have you checked girlpower+ Render Targets ?
ad 2) i’d say no.
ad 3) mmmnope.

  1. you should be able to feed whatever you’re going to draw on as a texture to the shader with the correct (inverse?) transform as that of your geometry… at least doable for simple 2D scenarios.

I’ve done something along those lines but didn’t get around to handle rotations but it should be doable. In fact it’s one of my old projects that I’ve intended to get back to.

ah nice, so basically return a struct with semantics for 4 colours, which will come out as seperate textures. Very neat. got it, thanks!

afaik, there’s no way to have a spread of textures on an input, right?

and any examples of using the ‘Technique Pass’ pin?
i think that you can only do 1 pass per renderer, correct?
but the -1 default value of Technique Pass implies that it can do them all at once?

right, no spreaded textures into one pixelshadercall. only up to 16 separate texture pins are possible. a spread of textures leads to the whole mesh being drawn multiple times.

you can do multiple passes in one technique. -1 draws them all, but you can spread the pin and selectively run passes. what you can not do though is using the texture output of one pass in the second pass within the same technique. for those kind of multipass effects you still have to go via Renderer -> DX9Texture…

so just to clarify.
you can run multiple passes ‘in parallel’ which which act in an equivalent way to seperate shader nodes running independantly in a group?


nope, the passes don’t run in parallel. they run one after the other as specified via the Technique Pass pin on the effect. only you cannot pass any data from one pass to the other. the ms-demo example is rendering a mesh normally and in the second pass render it a bit scaled and more transparent…to achieve a bad glow effect.

i’ve never used multipass rendering in one technique myself though…