Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using libGdx and writing shaders without hardcoding #4

Open
Bevilacqua opened this issue Jul 25, 2013 · 0 comments
Open

Using libGdx and writing shaders without hardcoding #4

Bevilacqua opened this issue Jul 25, 2013 · 0 comments

Comments

@Bevilacqua
Copy link

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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant