So i suck with shaders in monogame i really haven’t messed with them too much.
Im trying to get two textures to run in a simple shader.
However the second texture sampler is filled with zeros it seems when i try to read its alpha.
I have no clue why?
Further im not really all to sure what the registers do here especially with multiple textures.
I was never that good to begin with at shader semmantics in xna or hlsl, in monogame im even more confused. Any help or explinations are appreciated feel free to get as short or long winded as you wish.
It seems, you are using the same register for both textures? That said, I don’t use any declaration of registers in any of my shaders. It might be helpful, when setting up the sampler from the C# side. Then you need to know where your texture is, meaning which register it is in. I think the SpriteBatch is always using the same register for its texture…
If i set the s1 register to 0 it fails to compile if i set the texture register t to 0 or 1 i get nothing. This is being used for DrawIndexPrimitves.
Honestly if i knew how to rip the register calls out at the moment i would. There are so few examples of how to do this and google doesn’t help much. I’ve been at this for hours already.
It would also be good to understand how i need to set these registers up between the code in hlsl and in game1.
I recommend doing it like this. It prevents issues like the one you ran into here @willmotil. You can also only set the register for the texture to make sure it resolves correctly for spritebatch (which sets the texture a t0), or other classes that use the texture register.
I only recommend setting the sampler by register when you do not explicitly declare a texture (hlsl implicitly declares a texture for each sampler in the corresponding register → t1 for s1, t2 for s2…). (Note that there’s a bug in MG making this method not work for now, I’ll get this fixed soon). In the other cases MonoGame generates an effect parameter by which you can set textures.
Since you don’t use the register directly for assigning textures in those cases you can let the compiler figure out the registers for you and not set them explicitly in the shader.
You need both a register (because of classes like SpriteBatch) and an effectparameter. In this case when using the register, make sure you set the texture after applying your effectPasses!