Using libGdx and writing shaders without hardcoding
Bevilacqua opened this issue · 0 comments
Bevilacqua commented
I tried to get it to work but it doesn't display at all. There are no compile errors.
Vertex
uniform mat4 u_progTrans;
//SpriteBatch input
attribute vec4 Position;
attribute vec2 TexCoord;
attribute vec4 Color;
//Fragment output (varying)
varying vec2 vTexCoord;
varying vec4 vColor;
//Main
void main() {
vColor = Color;
vTexCoord = TexCoord;
gl_Position = u_progTrans * Position;
}
Fragment
#ifdef GL_ES
#define LOWP lowp
precision mediump float;
#else
#define LOWP
#endif
//Texture
uniform sampler2D u_texture;
//Input form vertex (varying)
varying vec2 vTexCoord;
varying LOWP vec4 vColor;
//Main
void main() {
//Sample the texture
vec4 texColor = texture2D(u_texture, vTexCoord);
//Color modification
texColor.rgb = 1.0 - texColor.rgb;
//Output
gl_FragColor = texColor * vColor;
}