Jump to content

Shader Talk


Pryme8
 Share

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 http://madebyevan.com/webgl-water/ 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.

Link to comment
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: https://acko.net/blog/yak-shading/.

  • 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. 

 

53572598.jpg

 

 

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

 

 

 

Link to comment
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:

 https://computergraphics.stackexchange.com/a/5725/5950

UkCmZw3ukQ.png

now the thing is the vUV goes from 0 to 1. So you need ( as you allready figured out) a conversation.
https://www.babylonjs-playground.com/#UUQJGM#7

 

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...