OpenGL 4, problems following tutorial (Parallax)

The tutorial points to deprecated GLSL calls, I have issues following its example, any help would be greatly appreciated (

From the tutorial:


attribute vec3 tangent; 
attribute vec3 binormal; 
uniform vec3 CAMERA_POSITION; 
varying vec3 eyeVec; 
void main() 
 gl_Position = ftransform(); 
 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; 
 mat3 TBNMatrix = mat3(tangent, binormal, gl_Normal); 
 eyeVec *= TBNMatrix; 


uniform sampler2D basetex; 
uniform sampler2D heightMap; 
uniform vec2 scaleBias; 
varying vec3 eyeVec; 
void main() 
 float height = texture2D(heightMap, gl_TexCoord[0].st).r; 
 //Our heightmap only has one color channel. 
 float v = height * scaleBias.r - scaleBias.g; 
 vec3 eye = normalize(eyeVec); 
 vec2 newCoords = texCoord + (eye.xy * v); 
 vec3 rgb = texture2D(basetex, newCoords).rgb; 
 gl_FragColor = vec4(rgb, 1.0); 

My Vertex:

layout( location = 0 ) in vec3 VertexPosition;
layout( location = 1 ) in vec3 VertexNormal;
layout( location = 2 ) in vec2 VertexTexCoord;
layout( location = 3 ) in vec3 VertexTangent;

out vec3 Position;
out vec3 Tangent;
out vec3 Normal;
out vec2 TexCoord;

uniform float TexTile;
uniform vec3 gEyeWorldPos;

out vec3 EyeVec; 

uniform mat4 M;
uniform mat4 V;
uniform mat4 P;

void main() {

gl_Position = (P*V*M) * vec4(VertexPosition,1.0);

Normal =  (M * vec4(VertexNormal, 0.0)).xyz;
Tangent =  (M * vec4(VertexTangent, 0.0)).xyz;
Position = (M * vec4(VertexPosition, 1.0)).xyz;
TexCoord = VertexTexCoord * TexTile;

vec3 Bitangent = cross(Tangent, Normal);
mat3 TBN = mat3(Tangent, Bitangent, Normal);
EyeVec = gEyeWorldPos -;
EyeVec *= TBN;

My Fragment:

… same in as out from vertex

void main()

	float height = texture2D(gNormalMap,; 
	//Our heightmap only has one color channel. 
	float v = height * 0.04 - 0.02; 
	vec3 eye = normalize(EyeVec); 
	vec2 newCoords = TexCoord + (eye.xy * v); 

	TangentData = normalize(Tangent); = texture(gColorMap, newCoords).xyz;
	ColorNormalData = texture(gNormalMap, newCoords).xyz;
	ColorPropData.r = 5.0f; //intBitsToFloat(5);

Results show some elevation where expected, but allot of noise etc. I also used the same or similar normal(height) texture and diffuse as what demonstrated in the tutorial, so something is wrong around TBN I think, but not sure…

 eyeVec *= TBNMatrix;

I see the example has this line but I was wondering if it should be

 eyeVec = TBNMatrix * eyeVec;

also you can look at this example

Hello, normal mapping is something I already support. Parallax, relief mapping etc generate superior results

Here is a slightly different version

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