Shader Talk

Recommended Posts

So what you could do then is you need to have the GPU generate a heightmap texture using the same displacement algo that you are using.

Change the shader from using your displacement algo to sampling the heightmap texture, and then you can cat rays from the sphere to the plane to establish the UV position.  Convert the UV position into a pxl location, then identify the value of that pixel on the heightmap and transform the sphere accordingly.

then you can also add a variable in your heightmap generator pass that can account for the sphere's impression into the water as well.

Hope that makes sense?  You will have to use a rtt.

Just looked at the source for and it looks like thats what he is doing.  Using the GPU to generate the heightmap and then 'ping-ponging' it to simulate the water,  Look up my GPU game of life simulation and it will show you how to set up the 'ping-pong' buffer setup.  He is also raymarching the caustics I think.

Share this post

Link to post
Share on other sites
8 minutes ago, Nabroski said:


their was an example the BabylonJs dude walking in a terrain. Based on Raypicking. That would work i think. But i can't find the playground anymore ... 

That was all CPU if I'm not mistaken.

Share this post

Link to post
Share on other sites

I think this is gonna be my long term personal project.No, i think on BabylonJS side it would be best to work with a geometry shader.  I really don't know why khronos decided to skip that one. 
This guy claims to have a working implementation:

  • So one possibility could be:
    • displace on the GPU
    • send the information as texture
    • read the information from a texture buffer
    • apply to a babylonjs mesh
    • make collisions 

Yeah, let''s implement the hole missing WebGL stuff, sounds like fun.  Also remands me of Transform feedback,  just without the f e e d b a c k. Should be faster then read/write texture accesses. Pulling the data, without re - sending it, i actually don't no if this works. but i will give it a try at the weekend. 





@NasimiAsl If you have something interesting feel free to share. :)




Share this post

Link to post
Share on other sites

i would like to help, but i don't understand (as always) the problem. Can you rephrase. If i change the #renderCanvas an click rerun the jsEditor you scene looks good. So w a t do you mean with same size ?

Share this post

Link to post
Share on other sites

i just you more on the save side (also project dependent) when you set the Vec2 to ViewportSize not canvas.width see here:


now the thing is the vUV goes from 0 to 1. So you need ( as you allready figured out) a conversation.


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

  • Recently Browsing   0 members

    No registered users viewing this page.