Is it possible to read a value from Absolute World Position?

Good day, everyone!
Currently I’m working on water shader and I’ve stuck with question about reading from Absolute World Position aligned texture. First of all, let me show you a simple setup for my material.

Here is a base setup for my water shader:

After a few tweaks with parameters here is how it looks in editor:
2

I want to know at some specific point (for example, at pivot point) how far vertices are ‘pushed’ at current time. Is it possible to do?

Can you just use world pos - world pos (excluding offset) to find the delta?

This would also mean you wouldn’t need to do your transform or vertex ops on the pixel shader either. Just do your position offsets, then find the delta between those two to always direction/magnitude of offset in pixel shader.

Does this help?

3 Likes

Great idea, thank you! But unfortunately, not in my case.
I want to get that delta into Blueprint / Code and work with it. As far as I know I can’t set that delta inside the material to read if from somewhere else.

oh no, there will be no way to do that. It’s all just GPU based and no way for CPU access there as you’d be interested in per-vertex info, right?

That type of thing, and particularly if its what I think it is? - would require a compute shader.

1 Like

Thank you for answer!

I wanted this workaround to simulate buoyancy on water waves. I looked into community based Ocean Water shader and I think I get an idea how they do a byouancy. In that project they using Gerstner Waves and calculate them in shader AND code separately (but Time synchronized in Play mode so, for visuals there are no difference).

There are no workarounds for simulating this with scrolling by UV texture, so I gave up on this and just faked buoyancy with PID Controller. Looks not so accuarate, but not bad after all.

P.S. Yeah, I know, stones can’t swim like this :grin:

1 Like

Not sure if it helps but here I describe how we did read the height of a height-map based in the world position on the object: https://youtu.be/aYZEmaQUrAo?t=10m38s

a material solution i’ve used for buoyancy before is to have your wave height control in a material function and just use the same data to drive the vertex offset of the water plane and the floating objects. Just add a little bit of extra bounce for the floating objects (and maybe a bit of rotation) and it should work. just make sure to use the object position for the floating object and world position for the water waves so your solid objects look solid still.

Something like that. Obviously you can add more variation to this using Vertex Colours to offset the various floating objects etc. and refine the water motion to be more than just a Sin wave, but a purely material approach is certainly possible.

3 Likes

Great speech, thank you!

Great idea, thank you very much! I’m using similar technique for splashes on water