My Monogame HLSL shaders only successfully sample one texture (besides the screen). Any additional textures I try to sample end up with the same texture data as the screen.
I've found people with similar issues as me, such as this thread. However, I'm unsure of what they've done to remedy the problem. Any solutions I've seen in other threads don't work.
C#
Lighting.Parameters["NightTexture"].SetValue(night);
Lighting.Parameters["SunsetTexture"].SetValue(sunset);
HLSL
float4x4 World;
float4x4 View;
float4x4 Projection;
Texture2D NightTexture;
sampler2D NightSampler = sampler_state
{
Texture = <NightTexture>;
};
Texture2D SunsetTexture;
sampler2D SunsetSampler = sampler_state
{
Texture = <SunsetTexture>;
};
sampler TextureSampler : register(s0);
float4 main(float4 position : SV_Position, float4 color : COLOR0, float2
texCoord : TEXCOORD0) : COLOR0
{
// Different Grading
float4 day = tex2D(TextureSampler, texCoord);
float4 night = tex2D(NightSampler, texCoord);
float4 sunset = tex2D(SunsetSampler, texCoord);
float4 col = lerp(day, night, .5);
col = lerp(sunset, col, .5);
return col;
}
technique Technique1
{
pass Pass1
{
PixelShader = compile ps_5_0 main();
}
}
Note: The code is abbreviated to show the issue. When executed, the SunsetTexture and TextureSampler both have correct data, but the NightTexture copies the TextureSampler's data.
Any ideas how to fix this?