# GLSL - 2 Water related problems (screenshot)

## Recommended Posts

Firstly, here's the screen grab. The main problem is with transformed objects. When drawing the scene, fog is applied correctly in the frag shader (computing it myself based upon camera distance). The problem arises with translated and rotated scene objects. The fog is applied as if the object was at the origin. I'm obtaining the vertex in the vert shader as follows:

cullvertex	= 	gl_Vertex;


In the frag shader, i'm just computing the fog as a scalar value between a given falloff distance against the distance between the camera and the fragment. What's going on? Any help would be greatly appreciated.

##### Share on other sites
I'm not sure exactly what you're doing since you've only posted one line of shader code, but shouldn't you be multiplying gl_vertex by the modelview matrix?

##### Share on other sites
I've tried multuplying it by the mv matrix, but then the fog, which should be green below 0 in the y axis, and grey above changes dependant upon the where the box is in relation to the middle of the screen.

I think it has something to do with the way the sahder handles translation and rotation.

## Create an account

Register a new account

• ## Partner Spotlight

• ### Forum Statistics

• Total Topics
627660
• Total Posts
2978489

• 10
• 12
• 22
• 13
• 33