WATER SIMULATION in Godot 4

preview_player
Показать описание
4:14 Missing step:

Here's how I ported my water ripple simulation shader from Unity to Godot.

Resources used:

Github:

Scripts:
Рекомендации по теме
Комментарии
Автор

Hello again!
The repo has now been updated to work in version 4.1.

The changes I made are as follows:
Added a second viewport to act as a buffer, this removed the error spam but doesn't fix the core issue.
Set MaxFPS in the render settings to 60. Unlocked FPS caused the shader to update so fats you could barely see the ripples.

I'm going to investigate fixing the effect without capping framerate, but for now the effect works again.

crigz
Автор

Wow man you're amazing!
Literally just imported into 4.3 and runs perfectly. Tutorials like this give so much inspiration for the community and I look forward to messing around with this one!
Shader coding = actual wizardry _change my mind._

jamesodonnell
Автор

This is probably the best 11 minute course on Godot shaders period.

mb
Автор

I made some water ripple effects in Godot before, but this is just outright better. Using a viewport texture in a shader inside the same viewport is nice trick.

Galomortalbr
Автор

Me: *Struggles with basic things*
Crigz: Yeah sure, let's put a fucking water simulation in there.

demian
Автор

Hey all! I've just updated the github project to get it working with 4.0 RC 5.

The changes required were all in the Visual Shader, essentially the manual calculation of depth from the DEPTH_TEXTURE is no longer needed as there's now a node that does it for you! the expression node only calculates the murkiness via beer's law now.

crigz
Автор

I would love to see this improved upon with realistic caustics and making waves! Very cool tutorial, makes me want to use godot myself.

btarg
Автор

Really great tutorial ❤ thoroughly explained, thank you! In 4.0 there is Skala SceneDepth node I added in my PR but I suppose if you wanted to add Beers Law to it, you had to write that Expression node

flamelizard
Автор

Nice tutorial, I would suggest adding caustics to really sell the effect! Since you have the wave texture it shouldn't be hard to project them on the bottom of the pool (I guess?) Anyway, thanks a lot. I look forward to more videos like this!

pcaires
Автор

I filed it for Godot 4 for my 2D needs. It works perfectly.Thank you.

sugarfree
Автор

Wow. Probably the best water I've seen. 💐

kiyasuihito
Автор

Wow.. amazing tutorial.. thank you so much! You're the best 😁

lehisluguer
Автор

amazing as always, you are the best bro. very well done and informative

chrisnevermorebotha
Автор

and how to make a larger capture size, when the camera increases in size, the texture in the viewport decreases very much and there is no simulation

ganzagame
Автор

best water simulation video in Godot 4.
Awesome video Sir!

pietraderdetective
Автор

One bonus point coming to my mind – haven't tried it, so not sure how good it would look: One might be able to use the waves texture together with a light to add light caustics and/or shadows for the waves to everything under the water, too. Might be an interesting attempt to improve the effect even further.

Smaxx
Автор

Some notes:
The issue connecting your sampler inputs to your shader is not a bug, it's a limitation of Vulkan, and the fact that you can bypass the check by assigning the connection in code *is* a bug, which has since been fixed in later versions of Godot. The correct way to fix this is to create a second viewport to act as a buffer. Plug the simulation image into the new viewport, plug the viewport output into the simulation. (What exactly goes on inside the buffer viewport is left as an exercise to the reader, I used a do-nothing shader that just draws whatever sampler2D it receives.)

You may, as I did, find yourself in a frustrating situation where the shader output only appears in a tiny corner of the viewport. To fix this, go to the your ColorRect, in the Layout controls, and set "Anchors Preset" from "Top Left" to "Full Rect."

I was able to get the shader itself working, and it looks nice, but I can't get whats' in the viewport to draw onto the surface of the water. Inside the editor, it works fine, but the moment I tell Godot to run the scene, all I get is a blank purple sheet. I went ahead and plugged in the vertex shader as well, and that doesn't produce any ripples either. I'm not sure what the issue is there.

ClokworkGremlin
Автор

I made a water simulation where you can fully interact with it in 2D I tried 3D but its too process intensive for more than a few particles and I used the PhysicsServer in both. This however is something I'd definitely use🤩

Chevifier
Автор

could this shader be better improved by adding foam to the ripples themselves?
oh would i be possible to add some sort of caustics or shadows for the water
right now, 11:00 theres only the shadow of the capsule spinning

RenderingUser
Автор

Errors evry frame : draw_list_bind_uniform_set: Attempted to use the same texture in framebuffer attachment and a uniform (set: 1, binding: 1), this is not allowed.

yura