Malmer

Hello World,

Running SpriteBatches with a custom pixel shader is no problem. Works perfectly. (For those that wonder how, just write an effect with a sampler state and a pixel shader and no vertex shader and run it around your spritebatch that uses Immediate).

Now If I want the pixelshader to use an additional texture to the one sent to the draw call it simply doesn't work. Every sample state contains the texture in from the drawing call. Can't get access to my custom set texture.

Anyone got a clue to get this working Or should I just give up and draw my own quad and set the textures myself


Re: XNA Framework Using textures with a custom pixelshader SpriteBatch

Shawn Hargreaves - MSFT

SpriteBatch will set the texture for sampler #0, so you need to put your other textures on different samplers.

sampler BaseTexture : register(s0);

sampler OverlayTexture : register(s1);

and in C#:

device.Textures[1] = myOverlayTexture;

sprites.Draw(myBaseTexture, ...);

There may be an easier way, but that approach has worked for me.






Re: XNA Framework Using textures with a custom pixelshader SpriteBatch

Malmer

Thanks! You're great!



Re: XNA Framework Using textures with a custom pixelshader SpriteBatch

pyr0kar

hello :)

 Malmer wrote:
Hello World,

Running SpriteBatches with a custom pixel shader is no problem. Works perfectly. (For those that wonder how, just write an effect with a sampler state and a pixel shader and no vertex shader and run it around your spritebatch that uses Immediate).

Now If I want the pixelshader to use an additional texture to the one sent to the draw call it simply doesn't work. Every sample state contains the texture in from the drawing call. Can't get access to my custom set texture.

Anyone got a clue to get this working Or should I just give up and draw my own quad and set the textures myself


i just dont a get custom pixel shader with a spritebatch to work.
can you please send me an example code and maybe an example shader to jack_dealthy@email.ro Malmer