Hi there,
if I set two sampler at the top of my HSLS file:
sampler sampler1 = sampler_state { texture = <texture1> ; magfilter = POINT; minfilter = POINT; mipfilter=POINT; AddressU = mirror; AddressV = mirror;}; sampler sampler2 = sampler_state { texture = <texture2> ; magfilter = POINT; minfilter = POINT; mipfilter=POINT; AddressU = mirror; AddressV = mirror;};
and call in pixel shader function
float4 color1 = tex2D(sampler1, uvCoords1);
and later
float4 color2 = tex2D(sampler2, uvCoords2);
color1 get’s the correct values but color2 will be (0,0,0,1) for all uvCoords2. If I switch the defenition of sampler1 and sampler2 around color2 is correct but color1 is (0,0,0,1)
Is there a way to solve this?
EDIT:
I got it! Add a register behind the sampler:
sampler sampler1 : register(s1) = sampler_state { texture = <texture1> ; magfilter = POINT; minfilter = POINT; mipfilter=POINT; AddressU = mirror; AddressV = mirror;}; sampler sampler2 : register(s2) = sampler_state { texture = <texture2> ; magfilter = POINT; minfilter = POINT; mipfilter=POINT; AddressU = mirror; AddressV = mirror;};
but start at s1. s0 seems to be overridden by the texture at the draw call:
spriteBatch.Draw(texture, ...)