kb173 / godot-interactive-water

A water shader for Godot with interactive depth that propagates into waves.
MIT License
18 stars 1 forks source link

Draw colliding objects into the depth mask #3

Open kb173 opened 3 years ago

kb173 commented 3 years ago

An orthogonal camera could be used to render objects which collide with the water surface. By blending its result into the depth mask, we could get realistic waves for any objects which intersects with the surface.

Deriuse commented 2 years ago

Man, I don't know if u ever are going to read this, but just wanted to say that I think this shader of yours is really amazing, don't know nothing about code (am not even an English speaker) but to see this interactive effect in this kind of lets say stylized shader is really amazing, very different to the usual water shaders out there. Truly don't understand why this is so unknown being so amazing. Hope you get the recognition your work deserves. I will be looking forward to your upcoming works. Pd: Am just imagine right now how great would be an anime sort of fight with this shader

kb173 commented 2 years ago

Oh thank you @Deriuse! That's very kind. I also wondered why this type of shader isn't used more commonly; I guess the performance cost is just too high when your game doesn't really need water that realistically reacts to changes on its surface (which most don't :P). But I think it's fascinating how realistic the waves look even though it's just a few very simple physics calculations: each pixel of the water is modeled as a dampled harmonic oscillator connected to neighboring pixels with "springs". Pretty much all of the actual logic is in these 35 lines of code: https://github.com/kb173/godot-interactive-water/blob/main/addons/interactive_water/WaterUpdate.shader#L24 Let me know if you have any questions! Shaders can be intimidating but they're really fun once you get the hang of it.

Deriuse commented 2 years ago

Well, am just going to pretend that I understood your explanation XD. About performance I think it works pretty well, at least I have a piece of chunk of computer and it runs really smooth. The shader is really amazing, but with the other improvements that you mentioned in this and the others issues it would be a master piece. I am convinced that people don't tend to use it because they don't know it exist sadly. Perhaps if you "over polish" it, add those other features and incorporate it into a small project (may be with a character controller that interacts with the water), it would get more visibility. If u want I can send you an animated character I was working on so you can use it ( please forgive my wonderfull use of english 🙏)