STTrife

08-11-2014, 07:20 AM

Hi there,

In my project I started out with transforming positions and normals into world-coordinates, but I was recently suggested to just use eye-space instead. Now I run into the following difficulty:

In the world, everything under z=0 is underwater. In the case that a fragment is underwater, and the camera is above water, I apply the underwater effect, then then semi-transparant surface of the water, and than the fog effect for above water (the surface of the water is drawn in a separate buffer and I use deferred rendering for this)

To do this I need to know which part of the ray (from camera/eye to the fragment) is underwater and which part is above water (see picture). In world space I could solve this easily with my high school math, but in eye-space this seems more difficult.

I know you can find the intersection of a line and a plane with solving equations, but i don't know the equation for the plane (z=0 in world-space) in eye space, and I'm not sure if this is best way to go anyway. Basically I would like to know which part of the ray is underwater, and which part is above water... (not only the lengths, but I would like to know for both the fragment and the camera coordinates if they are underwater or not)

Can anyone advise me on this? thanks!

In my project I started out with transforming positions and normals into world-coordinates, but I was recently suggested to just use eye-space instead. Now I run into the following difficulty:

In the world, everything under z=0 is underwater. In the case that a fragment is underwater, and the camera is above water, I apply the underwater effect, then then semi-transparant surface of the water, and than the fog effect for above water (the surface of the water is drawn in a separate buffer and I use deferred rendering for this)

To do this I need to know which part of the ray (from camera/eye to the fragment) is underwater and which part is above water (see picture). In world space I could solve this easily with my high school math, but in eye-space this seems more difficult.

I know you can find the intersection of a line and a plane with solving equations, but i don't know the equation for the plane (z=0 in world-space) in eye space, and I'm not sure if this is best way to go anyway. Basically I would like to know which part of the ray is underwater, and which part is above water... (not only the lengths, but I would like to know for both the fragment and the camera coordinates if they are underwater or not)

Can anyone advise me on this? thanks!