Jump to content
  • Advertisement
Sign in to follow this  
Kaptein

Underwater / above

This topic is 1491 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

So, I have experimented with different solutions.

I'm having problems getting a functional transition between entering into water. You can see the terrain for a small amount of time.

To combat this, I am using pixel perfect testing in the renderer (since it interpolates the camera position, and implements some bobbing).

I have also made the water rendering phase cull FRONT the same frame and after you enter into water, vs BACK when outside water.

This will work, since my in-water effect is post-processed. At least, that's what I hoped. It doesn't work completely. There is ~1 frame where you can still see half the terrain, kind of like tearing.

 

Any ideas?

 

Edit: It turns out it's simply the znear plane causing me problems.

How do you solve that?

 

Edit2: I wish I could flip-flop the "plane," if it even was a plane. If it was an actual plane, I could render the water sligthly higher up after entering into it.

 

I just checked if (player.x, player.y - camera.getZNear(), player.z) was inside water, and if he was, move the player instantly down ZNear.

It works, but only if entering water up/down, which is the majority of cases anyways.

Edited by Kaptein

Share this post


Link to post
Share on other sites
Advertisement

Is this really a problem? Real cameras exhibit this behaviour too - the lens has non-zero area, so you can see both above and below the surface of the water as you enter it.
 

Regard the classical "tropical destination" photograph:

half.jpg?itok=1WDlWwvQ

Share this post


Link to post
Share on other sites

I suppose so, the problem is just my postprocess shader which is a fullscreen water effect.

I'd have to calculate where on near-plane that player is underwater, instead of just switching shader.

Share this post


Link to post
Share on other sites

in your under water screen shader, can you read the shaded pixel depth information? If yes you could then untransform projected x,y,z to  world space and check the pixel y axis value, in case your water plane is an axis aligned plane. Then you will shade only pixels whose untrunsformed y position is less than water plane y.

 

I feel there are many other hacks though.

 

 

Share this post


Link to post
Share on other sites

in your under water screen shader, can you read the shaded pixel depth information? If yes you could then untransform projected x,y,z to  world space and check the pixel y axis value, in case your water plane is an axis aligned plane. Then you will shade only pixels whose untrunsformed y position is less than water plane y.

 

I feel there are many other hacks though.

 

Yep, but it's unfortunately not a plane.

I feel like I will keep my "solution", as at least it works "decently" in the most common scenario.

Edited by Kaptein

Share this post


Link to post
Share on other sites

Stencil is no option? This (want to process only part of the screen, no trivial analytic solution like a plane test) sounds like it's just made for stencil.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!