Jump to content

[waterMaterial] Level water up or down


Dad72
 Share

Recommended Posts

I noticed two bug with the waterMaterial.

Place a field at 0, 0, 0 and an object above this field. Then add water some time later. You will see that the terrain is climbing 1.0 on the y axis. It is no longer 0, 0, 0

A second problem is that if you now observe the object, the water drops gently on this PG. On my project, it is the opposite the object is gradually found under water, so the ground goes up very very slowly. You have to wait a minute to fully see the problem.

The water moves up or down and it's very subtle but after a while, a boat can be completely underwater or completely overhead.

https://www.babylonjs-playground.com/#1SLLOJ#434

Link to comment
Share on other sites

image.thumb.png.e75dde9d24fccbef59fab73fc918ed5f.png

 

Then after messing around for a while:

image.thumb.png.37a936416dd5b5ca941886f70c225c6a.pngimage.thumb.png.5fcd7cb96ef7fdf51ecedd8c306d8e18.png

Good catch.

Simple fix I bet.

Another problem I have noticed is reflection problems tword the bottom of the viewpoint when you are close to the water looking out nearly perpendicular.
 It seems to stretch the reflection.

Link to comment
Share on other sites

I can almost guarantee its:
https://github.com/BabylonJS/Babylon.js/blob/master/materialsLibrary/src/water/water.vertex.fx#L129
 

	vec3 p = position;
	float newY = (sin(((p.x / 0.05) + time * waveSpeed)) * waveHeight * windDirection.x * 5.0)
			   + (cos(((p.z / 0.05) +  time * waveSpeed)) * waveHeight * windDirection.y * 5.0);
	p.y += abs(newY);

I would just see if we can nerf out the p.y+=abs(newY) for now if that it will fix it.

https://www.babylonjs-playground.com/#1SLLOJ#435
...Nope that did not seem to fix it...

Hmmm I gotta do some thinking now.

Link to comment
Share on other sites

actually it looks like what I am doing is not replacing the shader, so I bet it would fix it if the changes I made propagated.

That is the only place anywhere on the shader that it manipulates the height so has to be responsible for that glitch.

Perhaps a Parallax Displacement would work better?
http://graphics.cs.brown.edu/games/SteepParallax/index.html

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...