S
shadow7692
Guest
I've followed Shaun Spalding's tutorial at youtube[dot]com/watch?v=zWrpHbc6fmc, which basically sets up a one-pixel outline for sprites using shaders. Currently, the outline is black. How do I change this?
I've tried messing with
I've tried messing with
gl_FragColor
but it either messes up the transparency (no longer an outline but a filled in version) or it tints the entire sprite that colour. Below is the code in shOutline.fsh
.
Code:
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
uniform float PixelHeight;
uniform float PixelWidth;
void main()
{
vec2 OffsetX;
OffsetX.x = PixelWidth;
vec2 OffsetY;
OffsetY.y = PixelHeight;
float Alpha = texture2D(gm_BaseTexture, v_vTexcoord).a;
Alpha += ceil(texture2D(gm_BaseTexture, v_vTexcoord + OffsetX).a);
Alpha += ceil(texture2D(gm_BaseTexture, v_vTexcoord - OffsetX).a);
Alpha += ceil(texture2D(gm_BaseTexture, v_vTexcoord + OffsetY).a);
Alpha += ceil(texture2D(gm_BaseTexture, v_vTexcoord - OffsetY).a);
gl_FragColor = v_vColour * texture2D( gm_BaseTexture, v_vTexcoord );
gl_FragColor.a = Alpha;
}
Last edited by a moderator: