@MrKips76 wrote:
Hi, I need to create a single pixel border around my 2d sprites. I don't want to use sprites with the border drawn around them as there are several hundred, plus I'd like the game to be moddable.
I've read through lots of effects examples and managed to get some demos up and running but I'm still nowhere near being able to write my own that create a border. Is this possible with shaders?
I've got this so far based on a GameMaker tutorial, doesn't seem to work though. Intention was to check neighbouring pixels to see if they have an alpha value of 1 and apply that to the current pixel if they do. :
float4 PixelShaderFunction(float4 pos : SV_POSITION, float4 color1 : COLOR0, float2 coords: TEXCOORD0) : COLOR0
{
float2 offsetX = { 1, 0 };
float2 offsetY = { 0, 1 };float alpha = tex2D(s0, coords).a; alpha = max(alpha, tex2D(s0, coords + offsetX).a); alpha = max(alpha, tex2D(s0, coords - offsetX).a); alpha = max(alpha, tex2D(s0, coords + offsetY).a); alpha = max(alpha, tex2D(s0, coords - offsetY).a); float4 color = tex2D(s0, coords); color.a = alpha; return color;
}
Any help with this would be much appreciated.
Posts: 5
Participants: 2