• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!
  • Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Question - Code Different color tiles with shader

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:
upload_2017-6-20_19-18-48.png

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:
upload_2017-6-20_19-21-17.png

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?
 
Top