GLSL varrying declaration?!

How to declare varying fragment shader input using version 1.3/1.4

Is it compatible with shader 1.2?

Thanks.

Use “in” keyword instead of varying keyword in fragment shader.

And this works for GLSL 1.2?

No. GLSL 1.20 is deprecated in OpenGL 3.0 context. You will need two versions of shaders (maybe some preprocessor magic can help).

It looks like it doesn’t work :/. Look at the following very simple shader (just output transformed normal that I write into a texture) :

VERTEX :

// GLSL 1.30
#version 130

uniform mat3x3 NormalMatrix;
in vec3 Normal;

noperspective out vec3 TransformedNormal;

void main ()
{
	TransformedNormal = NormalMatrix * Normal;
}

And the fragment shader :

noperspective in vec3 TransformedNormal;
out vec4 NormalPassTexture;

void main()
{
	NormalPassTexture = vec4 (normalize (TransformedNormal), 1.0);
}

I have the following error :
ERROR: Symbol TransformedNormal is defined with 2 different types in vertex and fragment shaders.

Is this normal ? It works well if I write “out” in the fragment shader instead of in, but it’s not logical at all to me.

EDIT : when I compile in GLSL 1.2, the previous code workds… Notice that I have a 3870 HD card with Catalyst 9.3 so it should support OpenGL 3.1 :/.

Or maybe it doesn’t compile because I’m using a software to try my shaders (Shader Maker).

Try adding #version 130 also to fragment shader.

I don’t know how Shader Maker compiles shaders. But I guess you should do it in OpenGL 3.0/3.1 context. I don’t know what should happen in 2.1 context (error?)

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.