Underwater / above

Started by
4 comments, last by Norman Barrows 9 years, 10 months ago

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.

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

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

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.

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.

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.

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.

see if you can find out how skyrim does it. the water transitions are quite good.

Norm Barrows

Rockland Software Productions

"Building PC games since 1989"

rocklandsoftware.net

PLAY CAVEMAN NOW!

http://rocklandsoftware.net/beta.php

This topic is closed to new replies.

Advertisement