Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3754234
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:30:49+00:00 2026-05-19T09:30:49+00:00

My Parallax mapping gives wrong results. I don’t know what can be wrong. The

  • 0

My Parallax mapping gives wrong results. I don’t know what can be wrong.

alt text

alt text

The “shadow” is in the wrong place.

Light is pointing from the viewer and goes towards the cube.
Shader program (based on dhpoware.com):

[vert]
     varying vec3 lightDir;            
     varying vec3 viewDir;
     attribute vec4 tangent;
     void main() 
     { 
     gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
     gl_TexCoord[0] = gl_MultiTexCoord0;
     vec3 vertexPos = vec3(gl_ModelViewMatrix * gl_Vertex);
     vec3 n = normalize(gl_NormalMatrix * gl_Normal);
     vec3 t = normalize(gl_NormalMatrix * tangent.xyz);
     vec3 b = cross(n, t) * tangent.w;
     mat3 tbnMatrix = mat3(t.x, b.x, n.x,
                           t.y, b.y, n.y,
                           t.z, b.z, n.z);
     lightDir = (gl_LightSource[0].position.xyz - vertexPos) / 1000.0;
     lightDir = tbnMatrix * lightDir;
     viewDir = -vertexPos;
     viewDir = tbnMatrix * viewDir;
     } 

    [frag]
     varying vec3 lightDir;            
     varying vec3 viewDir;
     uniform sampler2D diffuseMap;
     uniform sampler2D normalMap;
     uniform sampler2D heightMap;
     uniform float scale;
     uniform float bias;
     void main() 
     { 
     vec3 v = normalize(viewDir);
     vec2 TexCoord = gl_TexCoord[0].st;
    {
     float height = texture2D(heightMap, gl_TexCoord[0].st).r;
     height = height * scale + bias;
     TexCoord = gl_TexCoord[0].st + (height * v.xy); 
    }
     vec3 l = lightDir;
     float atten = max(0.0, 1.0 - dot(l, l));
     l = normalize(l);
     vec3 n = normalize(texture2D(normalMap, TexCoord).rgb * 2.0 - 1.0);
     vec3 h = normalize(l + v);
     float nDotL = max(0.0, dot(n, l));
     float nDotH = max(0.0, dot(n, h));
     float power = (nDotL == 0.0) ? 0.0 : pow(nDotH, gl_FrontMaterial.shininess);
     vec4 ambient = gl_FrontLightProduct[0].ambient * atten;
     vec4 diffuse = gl_FrontLightProduct[0].diffuse * nDotL * atten;
     vec4 specular = gl_FrontLightProduct[0].specular * power * atten;
     vec4 color = gl_FrontLightModelProduct.sceneColor + ambient + diffuse + specular;color *= texture2D(diffuseMap,TexCoord);
     gl_FragColor = color ;
     } 

log from cube content (tangents included, the fourth component is handedness):

------------------------------------------------------------------------------------------------------------------
VecContainer<Vertex> vertices = 

size: 36
space: 36
{
-4.000000, -4.000000, -4.000000, 
-4.000000, 4.000000, -4.000000, 
4.000000, 4.000000, -4.000000, 
4.000000, 4.000000, -4.000000, 
4.000000, -4.000000, -4.000000, 
-4.000000, -4.000000, -4.000000, 
-4.000000, -4.000000, -4.000000, 
4.000000, -4.000000, -4.000000, 
4.000000, -4.000000, 4.000000, 
4.000000, -4.000000, 4.000000, 
-4.000000, -4.000000, 4.000000, 
-4.000000, -4.000000, -4.000000, 
-4.000000, -4.000000, -4.000000, 
-4.000000, -4.000000, 4.000000, 
-4.000000, 4.000000, 4.000000, 
-4.000000, 4.000000, 4.000000, 
-4.000000, 4.000000, -4.000000, 
-4.000000, -4.000000, -4.000000, 
4.000000, -4.000000, -4.000000, 
4.000000, 4.000000, -4.000000, 
4.000000, 4.000000, 4.000000, 
4.000000, 4.000000, 4.000000, 
4.000000, -4.000000, 4.000000, 
4.000000, -4.000000, -4.000000, 
-4.000000, 4.000000, -4.000000, 
-4.000000, 4.000000, 4.000000, 
4.000000, 4.000000, 4.000000, 
4.000000, 4.000000, 4.000000, 
4.000000, 4.000000, -4.000000, 
-4.000000, 4.000000, -4.000000, 
-4.000000, -4.000000, 4.000000, 
4.000000, -4.000000, 4.000000, 
4.000000, 4.000000, 4.000000, 
4.000000, 4.000000, 4.000000, 
-4.000000, 4.000000, 4.000000, 
-4.000000, -4.000000, 4.000000, 

}

------------------------------------------------------------------------------------------------------------------
VecContainer<Vertex> texcoords = 

size: 36
space: 36
{
0.000000, 0.000000, 
0.000000, 1.000000, 
1.000000, 1.000000, 
1.000000, 1.000000, 
1.000000, 0.000000, 
0.000000, 0.000000, 
0.000000, 0.000000, 
1.000000, 0.000000, 
1.000000, 1.000000, 
1.000000, 1.000000, 
0.000000, 1.000000, 
0.000000, 0.000000, 
0.000000, 0.000000, 
1.000000, 0.000000, 
1.000000, 1.000000, 
1.000000, 1.000000, 
0.000000, 1.000000, 
0.000000, 0.000000, 
1.000000, 0.000000, 
1.000000, 1.000000, 
0.000000, 1.000000, 
0.000000, 1.000000, 
0.000000, 0.000000, 
1.000000, 0.000000, 
0.000000, 1.000000, 
0.000000, 0.000000, 
1.000000, 0.000000, 
1.000000, 0.000000, 
1.000000, 1.000000, 
0.000000, 1.000000, 
0.000000, 0.000000, 
1.000000, 0.000000, 
1.000000, 1.000000, 
1.000000, 1.000000, 
0.000000, 1.000000, 
0.000000, 0.000000, 

}

------------------------------------------------------------------------------------------------------------------
VecContainer<Vertex> normals = 

size: 36
space: 36
{
0.000000, 0.000000, -1.000000, 
0.000000, 0.000000, -1.000000, 
0.000000, 0.000000, -1.000000, 
0.000000, 0.000000, -1.000000, 
0.000000, 0.000000, -1.000000, 
0.000000, 0.000000, -1.000000, 
0.000000, -1.000000, 0.000000, 
0.000000, -1.000000, 0.000000, 
0.000000, -1.000000, 0.000000, 
0.000000, -1.000000, 0.000000, 
0.000000, -1.000000, 0.000000, 
0.000000, -1.000000, 0.000000, 
-1.000000, 0.000000, 0.000000, 
-1.000000, 0.000000, 0.000000, 
-1.000000, 0.000000, 0.000000, 
-1.000000, 0.000000, 0.000000, 
-1.000000, 0.000000, 0.000000, 
-1.000000, 0.000000, 0.000000, 
1.000000, 0.000000, 0.000000, 
1.000000, 0.000000, 0.000000, 
1.000000, 0.000000, 0.000000, 
1.000000, 0.000000, 0.000000, 
1.000000, 0.000000, 0.000000, 
1.000000, 0.000000, 0.000000, 
0.000000, 1.000000, 0.000000, 
0.000000, 1.000000, 0.000000, 
0.000000, 1.000000, 0.000000, 
0.000000, 1.000000, 0.000000, 
0.000000, 1.000000, 0.000000, 
0.000000, 1.000000, 0.000000, 
0.000000, 0.000000, 1.000000, 
0.000000, 0.000000, 1.000000, 
0.000000, 0.000000, 1.000000, 
0.000000, 0.000000, 1.000000, 
0.000000, 0.000000, 1.000000, 
0.000000, 0.000000, 1.000000, 

}

------------------------------------------------------------------------------------------------------------------
VecContainer<tangent>* tangents = 

size: 36
space: 36
{
1.000000, -0.000000, 0.000000, 1.000000, 
1.000000, -0.000000, 0.000000, 1.000000, 
1.000000, -0.000000, 0.000000, 1.000000, 
1.000000, -0.000000, 0.000000, 1.000000, 
1.000000, -0.000000, 0.000000, 1.000000, 
1.000000, -0.000000, 0.000000, 1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
0.000000, 0.000000, 1.000000, -1.000000, 
0.000000, 0.000000, 1.000000, -1.000000, 
0.000000, 0.000000, 1.000000, -1.000000, 
0.000000, 0.000000, 1.000000, -1.000000, 
0.000000, 0.000000, 1.000000, -1.000000, 
0.000000, 0.000000, 1.000000, -1.000000, 
0.000000, 0.000000, -1.000000, -1.000000, 
0.000000, 0.000000, -1.000000, -1.000000, 
0.000000, 0.000000, -1.000000, -1.000000, 
0.000000, 0.000000, -1.000000, -1.000000, 
0.000000, 0.000000, -1.000000, -1.000000, 
0.000000, 0.000000, -1.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, 0.000000, -1.000000, 
1.000000, 0.000000, -0.000000, -1.000000, 
1.000000, 0.000000, -0.000000, -1.000000, 
1.000000, 0.000000, -0.000000, -1.000000 

}

------------------------------------------------------------------------------------------------------------------
VecContainer<GLuint> indices = 

size: 12
space: 12
{
3, 4, 5, 
6, 7, 8, 
9, 10, 11, 
12, 13, 14, 
15, 16, 17, 
18, 19, 20, 
21, 22, 23, 
24, 25, 26, 
27, 28, 29, 
30, 31, 32, 
33, 34, 35, 
0, 1, 2 

}

What could cause this problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T09:30:50+00:00Added an answer on May 19, 2026 at 9:30 am

    As in your previous question, I think you still have the same issue. You forget a minus somewhere, or perhaps performed a cross product in the wrong order.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to make a navigation inline list. You can find it here: http://www.luukratief-design.nl/dump/parallax/para.html
I am developing a game in VB6 (plz don't ask me why :) ).
I'm developing a form in WPF with the technique of Parallax Scrolling and I
I am looking to setup a multi-layer parallax scrolling background for a game application
I have got a css problem. http://www.luukratief-design.nl/dump/parallax/index.html I cant get this page to align
I have 4 textures used in a multi-pass effect with the color map at
I've got basically a 2d game on the iPhone and I'm trying to set
I started off programming in Basic on the ZX81 , then BASICA , GW-BASIC
I am adding layer objects to the stage with a depth value. I have
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd> <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Davey Whitney</title> <link

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.