Sign in to follow this  
Adaline

Toubles wqith basic shaders in GLSL

Recommended Posts

Hello everyone !

I have a strange problem with basic shaders in GLSL that struggles me, using OpenGL ES 2.0 on Android. (Main program is in Java)

 

Here's the vertex shader :

attribute vec4 position;
attribute vec2 iTexCoord;
attribute vec4 iColor;
attribute float iAngle;

uniform mat4 vpMatrix;

varying vec2 oTexCoord;
varying vec4 oColor;
varying float oAngle;

void main() {
    oTexCoord = iTexCoord;
    oColor = iColor;
    oAngle = iAngle;
    gl_Position = vpMatrix * position;
}

And here's the fragment shader

precision mediump float;

varying vec2 oTexCoord;
varying vec4 oColor;
varying float oAngle;

uniform sampler2D sampler;

void main() {
	gl_FragColor = texture2D(sampler, oTexCoord / 4.0 + vec2(0.0, 0.8)) * oColor;
}

Whatever I do, gl_FragColor is always sampled from oTexCoord. Even if my rule of 3 is designed to sample a normal map in the last row of the color map. (All is in a regular sprite sheet).

I'm really new to GLSL(even if I used HLSL before), so this should be a dumb question.

Thanks.

:rolleyes:

Edited by Tournicoti

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this