Ocean shader directly into texture without baking?

Hi all!

I was wondering about the following.

The ocean modifier is, in my understanding, nothing more but a displacement modifier combined with a type of normal texture generated in the modifier. The parameters in the ocean modifier generates the texture, and then the object on which it is applied is displaced.

To generate an infinite ocean that doesn’t repeat itself, you’d now have to 1)Bake two or three oceans with different sizes; 2) Bake it for every frame; 3) Bake the foam as well; 4) Generate a shader that all loads this data and combines it to one nice smooth ocean; 5) apply a subdivision modifier to the ocean object and set it to adaptive subsampling

Steps 1-3 take an insane amount of data for a somewhat nice looking ocean and has to be redone for every project…

Since the ocean modifier generates the textures itself, would it not be possible to directly load the texture in the shader? This would safe an insane amount of data as know the displacement texture is only generated when the frame is rendered. Also, this would have the added benefit of getting a higher resolution foam on a lower resolution displacement texture (it’s okay if the displacement isn’t insanely detailed, if the foam isn’t though you can easily tell).

So, is this possible?

Well… what do you think…

Only this one looks kind of neat:

But that would require using open shading language and programming this (quite elaborative)
Will look a bit further too.

But no way to program it directly? The ocean modifier looks so realistic, because the it uses actual wave spectra as we measure them in real-life. It also generates a texture, so it must be possible to use as direct input…?

The modifier is generating textures but as an addition to geometry displacement in viewport.
The interest of a displacement in viewport is to set an interaction with other objects.

Generally, an ocean is not rendered alone. It is rendered with characters : boats, submarines and swimmers, one giant wave (higher than the others).
And those objects are deforming the displacement.
So, the idea of using a modifier is that other modifiers will be added after it, in modifier stack.

Ocean modifier is an old modifier made for 2.4x series, more than a decade ago.
Nowadays, that would make sense to create a texture node usable by geometry nodes and shaders.

Feature request next version?

Just an empiric method. i’ m not a scientist at all. but here is my vision as a guy coming from a fisherman family in the western part of france:

Lets build a wave displacement shader.
assuming we have got a 15 meter boat on a 400*400 meter ocean.
due to the huge scale… we gonna scale the plane to avoid impossible values in shader editor.
we gonna use object coordinate system for mapping then the procedural shader “wave” will have a scale inheritance from it.
Ocean is maid of crossing waves of different “size” moving at different speed regarding the flux force.
Let’s call that under waves and over it there is some wind effect.
we gonna focus first on “houle” (under waves)


with that we gonna make a group to be able to mix displacement vectors to add more than one wave direction.

To be continued…

ocean_test

5 Likes

It’s essential that you model and share your family’s fishing boat now :grin:

1 Like

To avoid resource consuming displacement with cycle for nothing, let’s reproduce the big wave’s shader in geometry node. By this, we’ ll be also able to stick the boat over the ocean surface.
you can notice that the wave’s scale is very strong. the boat cannot fish, it’s too dangerous. the captain decide to navigate “à la cape”.
so we must play with the noise scale to avoid everybody’s death onboard.

then again, we create a group to duplicate and orientate more waves.

ocean_GN_01

Next we ll get ride off the big wave’s displacement in the shader and focus on the wind effect over the surface.

to be continued…

5 Likes

Cool to follow your progress, @skuax
Looking forward to your folow-ups.

1 Like

I’d rather thought of a challenge of Geometry Nodes lovers.
As you can see, @skuax started.

But there are a lot of settings in Ocean modifier.
Depth of ocean and smallest wave setting are there, because generated waves don’t have same size.
Choppiness of wave, speed of wind and spectrum can make them more or less frightening.
And Foam is generated only on a part of waves.
That are a lot of variations that is making it more realistic.

So, if several Geometry Nodes experts give it a try, they could determine what is currently missing in Geometry Nodes to reproduce modifier.
That way, developers would have to spend time and to figure it out.
They would have minimal work to port it to Geometry Nodes.

If pattern generated by Ocean modifier was available as a 4D procedural texture in Geometry Nodes, and if another node was created for such specific displacement, user would not have to set-up several dozen of nodes.
I am wondering if a kind special displacement node could be created to generate landscapes and oceans, too.

3 Likes

Amazing work!! Very cool to be able to get this far with geometry nodes / shader nodes.

Some addition of wave theory to make it more realistic. These are all so-called “first-order” Navier-Stokes waves: basically a normal sine function. When water gets more shallow (the depth parameter) or when the waves get longer (swell, less steep → steepness parameter), some harmonics will come into play, creating second-order and sometimes even third and fourth order waves. This will make them steeper as well.

Water Waves 2014 | A blog on the water waves programme at the Newton Institute in summer 2014, Managing Editor: T Bridges, Editorial Advisory Board: M Groves, P Milewski, D Nicholls | Page 8

You can see that effect in this picture of very nice swell waves:

Not sure though about when and how to add foam… Foam is usually only generated when the wind has a force of approx ~5/6 bft, so above ~10 m/s.

2 Likes

One small question: can geometry nodes be used in combination with adaptive subsampling?

I guess I’ll try first :stuck_out_tongue:

Okay so that’s not possible (making it a bit difficult for infinite oceans). So let my try this in terms of just shader nodes.

First question: why are the waves in the wave texture not linear? Why are they skewed? How can we get them linear?

The mesh is displaced in 3 values X Y Z if you use a vector displacement.
To tweak it use a vector map range node.
MapRangeWave

It will be useful later to push the wave crest a little bit more in the wind direction for example

1 Like

I’m on my journey on the ocean.
I’ll try to incorporate the maximum stuff i can inside.
i don’t really know where i’ m going. But i 'll try to do my best to incorporate as much thing as possible without making it to heavy…
I use Eevee to tweak the animation and roughly put shading etc…
then after… i ll switch to cycle…
there is a lot to do, and any advises like yours and from the others ll be welcome.

Wave_Progress

4 Likes

The foam could be generated by getting the wave’s height with a mask. and can be also used for particle generation.

I also tried to put something together, but then in shader nodes.

Seems like I have a nice base:

With the group:

Group input has wave length in terms of blender units (1m, so 100 as input is 100m wavelenght). Wave height is wave height, etc. You can include a factor for second order and third order harmonics (0.5 and 0.25 by default)

Thing though is, to make a proper realistic sea, you’d have to multiply waves on top of eachother in a bunch of different directions, probably like 10-20 times, the more the better.

Actual oceans make use of a so-called “wave spectrum”: a summation of many smaller sinuses. That’s what gets the nice random look.

3 SEA STATE PARAMETERS AND ENGINEERING WAVE SPECTRA

Then for animation, the waves also have different speeds, depending on there wavelength. This is what you also see in real life: wave catching up on eachother, suddenly splitting up, etc.

image

All of this can be programmed in geometry nodes / shader nodes of course, but it will take a lot of nodes. This all is implemented in the ocean modifier by default.

3 Likes

Another interesting approach at OceanNodes I see.

How does this look?

3 Likes

Okay so I added 15 of those wave shaders including the propagation speed with a bunch of different directions into a shader.

How does this look? It took about 20 seconds per frame to render.

Any recommendations for improvements?

I’ll share it later once it’s finished.

8 Likes

Any suggestions for foam?

Just adding a white layer on values for z above certain threshold is downright ugly :stuck_out_tongue:

1 Like