Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Underwater / above


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 Kaptein   Prime Members   -  Reputation: 2174

Like
0Likes
Like

Posted 15 June 2014 - 11:57 AM

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, 15 June 2014 - 12:11 PM.


Sponsor:

#2 swiftcoder   Senior Moderators   -  Reputation: 10231

Like
0Likes
Like

Posted 15 June 2014 - 05:30 PM

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 - Software Engineer @Amazon - [swiftcoding]


#3 Kaptein   Prime Members   -  Reputation: 2174

Like
0Likes
Like

Posted 15 June 2014 - 05:52 PM

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.



#4 JohnnyCode   Members   -  Reputation: 261

Like
0Likes
Like

Posted 16 June 2014 - 09:42 AM

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.

 

 



#5 Kaptein   Prime Members   -  Reputation: 2174

Like
0Likes
Like

Posted 16 June 2014 - 06:11 PM

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, 16 June 2014 - 06:12 PM.


#6 samoth   Crossbones+   -  Reputation: 4912

Like
0Likes
Like

Posted 17 June 2014 - 07:36 AM

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.



#7 Norman Barrows   Crossbones+   -  Reputation: 2204

Like
0Likes
Like

Posted 17 June 2014 - 09:52 AM

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 1988"

 

rocklandsoftware.net

 





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS