I am new to shaders and HLSL so bare with me on this one.
I have a 2D tile map in my game and want to create a mini-map, at first I was just copying all the data from one sprite batch to another and rendering it in a smaller camera. This obviously has a performance issue.
So I want to make a mini-map that is composed of coloured pixels depending on what is in that particular cell.
I have a basic shader going at the moment that converts tex coordinates to pixel position but now I need a way to determine what color to set it. My instant decision was to simply pass in a 2d array of colors and grab the color using the x and y coordinate of the pixel, this crashed lol.
Here is what I have so far for the shader:
sampler s0;
// The width and height of the texture being sampled
int width, height;
float4 PixelShaderFunction(float2 coords : TEXCOORD0) : COLOR0
{
float4 color = tex2D(s0, coords);
// Covert the tex coordinates to pixel coordinates
int2 tc = int2(width * coords.x, height * coords.y);
// Here I need to do some sort of check or something?
return color;
}
technique Technique1
{
pass Pass1
{
PixelShader = compile ps_2_0 PixelShaderFunction();
}
}
How can I pass the color data to the pixel shader so it knows what color to set each pixel? I already know how to pass data but not sure how I can represent that data to pass it.
My map is every changing and units are moving around constantly, so the data will be passed in almost every frame.