I’m having a problem when applied shader to TMX tiled map.
It won’t display the tiled map. But I also use the same shader for the sprite but it works fine.
Is there something wrong with my shader cause I’m very new to the shader.
This is a basic shader, It will darken the texture.
#if OPENGL
#define SV_POSITION POSITION
#define VS_SHADERMODEL vs_3_0
#define PS_SHADERMODEL ps_3_0
#else
#define VS_SHADERMODEL vs_4_0_level_9_1
#define PS_SHADERMODEL ps_4_0_level_9_1
#endif
texture SpriteTexture;
sampler s0;
float ambient;
sampler2D SpriteTextureSampler = sampler_state
{
Texture = <SpriteTexture>;
};
struct VertexShaderOutput
{
float4 Position : SV_POSITION;
float4 Color : COLOR0;
float2 TextureCoordinates : TEXCOORD0;
};
float4 MainPS(VertexShaderOutput input) : COLOR
{
float4 color = tex2D(s0, input.TextureCoordinates);
color.r = color.r * ambient;
color.g = color.g * ambient;
color.b = color.b * ambient;
return color;
}
technique SpriteDrawing
{
pass P0
{
PixelShader = compile PS_SHADERMODEL MainPS();
}
};
This is how I render Tiled map with shader.
mapRenderer.Draw(SceneManager.allScene[sceneController.ChoosingScene].map, cam.GetViewMatrix(), null, TestEffect);