I'm completely new to shaders and trying to do something for a game I'm currently working on. I am trying to achieve something like this:
.
I have a simple passthrough shader setup, but I don't know how to remove the exact pixels at the top of the texture. I'm assuming in the fragment shader I need to change the alpha value to 0.0, but how do check if the pixels are at the top? I'm also using libGDX as my game engine which uses OpenGL ES 2.0 by default.
Here is my simple passthrough (vertex) shader:
attribute vec4 a_position;
attribute vec4 a_color;
attribute vec2 a_texCoord0;
uniform mat4 u_projTrans;
varying vec4 v_color;
varying vec2 v_texCoords;
void main() {
v_color = a_color;
v_texCoords = a_texCoord0;
gl_Position = u_projTrans * a_position;
}
Fragment shader:
#ifdef GL_ES
#define PRECISION mediump
precision PRECISION float;
precision PRECISION int;
#else
#define PRECISION
#endif
varying vec4 v_color;
varying vec2 v_texCoords;
uniform sampler2D u_texture;
uniform sampler2D u_other;
void main() {
vec4 color = texture2D(u_texture, v_texCoords);
vec4 other_colors = texture2D(u_other, v_texCoords);
gl_FragColor = other_colors;
}
Thank you for the help :). Been stuck on this for quite some time.
Additional information:
- I am not rendering pixel perfect.
- I need to be able for any side of the texture to make it rough/bumpy (randomly or not).