Le Slo
Member
Hello,
I've been playing around with shaders for the first time and I got an unexpected result of what I was trying to do. The tiles of my tileset get colored differently:
As you can see some of the looks darker than others, and the shader I made had no relationship with the tiles (I think), I was trying to darken the corners. I put you another picture of the screen when the shader isn't applying only to the tiles layer:
And here the code of the shader, clumpsy but it kind of does what I want.
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec2 coord=v_vTexcoord;
vec4 newColor=v_vColour * texture2D( gm_BaseTexture, coord );
newColor.r-=-0.2+max(abs(-coord.x+0.5),abs(-coord.y+0.5));
newColor.g-=-0.2+max(abs(-coord.x+0.5),abs(-coord.y+0.5));
newColor.b-=-0.2+max(abs(-coord.x+0.5),abs(-coord.y+0.5));
newColor.a=newColor.a;
gl_FragColor = newColor;
}
Do you know if this is normal? I'm missing something of the code? Or maybe an option of the graphics? Or even maybe the way I did the tileset was wrong?
I've been playing around with shaders for the first time and I got an unexpected result of what I was trying to do. The tiles of my tileset get colored differently:
As you can see some of the looks darker than others, and the shader I made had no relationship with the tiles (I think), I was trying to darken the corners. I put you another picture of the screen when the shader isn't applying only to the tiles layer:
And here the code of the shader, clumpsy but it kind of does what I want.
//
// Simple passthrough fragment shader
//
varying vec2 v_vTexcoord;
varying vec4 v_vColour;
void main()
{
vec2 coord=v_vTexcoord;
vec4 newColor=v_vColour * texture2D( gm_BaseTexture, coord );
newColor.r-=-0.2+max(abs(-coord.x+0.5),abs(-coord.y+0.5));
newColor.g-=-0.2+max(abs(-coord.x+0.5),abs(-coord.y+0.5));
newColor.b-=-0.2+max(abs(-coord.x+0.5),abs(-coord.y+0.5));
newColor.a=newColor.a;
gl_FragColor = newColor;
}
Do you know if this is normal? I'm missing something of the code? Or maybe an option of the graphics? Or even maybe the way I did the tileset was wrong?