[GLSL] Trying to recalculate pixel transform by GLSL. (Cannot find tutorial back)

Hey Derivative community,

I decided to turn one of my old projects into a sort a generative sea visual. The old project was based on a tutorial I can no longer find back. In the tutorial were instructions on how to write the GLSL for it, with explanation on how it works.

The GLSL takes a plane and transforms the topology such that it looks like waves. I wish to take a point on that plane and calculate the height and possibly slope of that point of the plane. How do I calculate the height of a single point as modified by the glsl?

I’ll share the initial result of the tutorial. Maybe someone can recognize it.

WaveSphere.toe (6.2 KB) (The GLSL plane is what I am using for the new project, the sphere is gone)

Thank you for reading!

Baas

Hi @Baas,

theoretically the TOP called “displacement” is the height if height is defined as an offset in y from the original grid position?

Otherwise you could also output the worldSpacePos or ProjectionSpacePos as color and render that in a extra buffer.

Completely depends though what you mean with height.

cheers
Markus

Hey Markus,

Thank you for the reply! I now realise that height can mean a whole lot of different things in a project like this. So instead I’ll share the file I had been working in a little bit. There is a dot drawn on the grid that is influenced by the GLSL and there is a cube with which I unsuccessfully tried to follow the visual height on the Y axis in 3D space. It comes close, but if I were to present the cube as a boat, it would not seem to really float.

Boats at sea.3.toe (12.4 KB) (2025 version of TD)

Does this clear it up better?

Have a great time,
Bas

Hi @Baas

this is a good case where you would want to move to POPs.

With POPs, you can keep data as attributes and work with them before actually applying any transformations.

My approach would be to combine the slope and the displacement texture into a single TOP using the Reorder TOP. This can then used in a Lookup Texture POP to retrieve those values and store them in a attribute. As the grid would not be deformed yet, we can make use of a single point and a Ray POP to retrieve this attribute (specify it under the Hit Point Attr Scope) and now with a Math Combine POP after the Ray POP calculate the rotation from the slope values and set the position to the retrieved height.
This single point we can now use to copy a box onto using the calculated rotation to apply to the box as well.

I think the rotation is approximately right… maybe you want to check if it should be done differently…

cheers
Markus
Boats at sea.4.toe (10.2 KB)

Hi @Baas

just realized that the Slope TOP is not necessary as the Ray POP can return the Hit Normal, meaning if we have the normals calculated for the transformed grid, we can just fetch those directly.
Simplifies the network a bit as we can just use the Ray Hit Normal attribute together with the Copy POP’s Template Rotate To Vector feature.

cheers
Markus
Boats at sea.7.toe (9.9 KB)

Thank you so much Markus! I’ll be studying your returned project file for a little while as POPs are still very new to me. However, I can already say this has helped me a lot!

May more questions regarding this POP approach to the project come about, would it be okay to reply them to you?

mega cheers

Bas