Sign in to follow this  
Kaptein

Underwater / above

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

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this