Godot Version
3.5.3.mono
Question
The original idea was to create a piece of 2D water that player could step in, and there is depth involved, which means the player could be half submerged into the water, and there should also be some reflection for the body that is above the water. And maybe some other stuff could go in like grass half submerged.
I think the drawing order would be something like terrain>objects(including player)>transparent objects>postprocess
Then my thought goes like: Oh, why not generate a height map, just make every object provide a height map and render them into a seperate texture, then apply a shader on the water to calculate which pixel is beneath water using the height map and passthrough those are above. Then the same map could be used to calculate reflection and the edge foam thing as well. What an excellent idea!
Then I finds out that I have no clue on how to render a height map in parallel to the actual color texture. Which requires rendering the same object using two different texture separately.
I also thought about other ideas, like: maybe let the the player detect water objects and get a color from it then apply on itself, which could also be a bit tricky, if draw the water before player it still creates the illusion of submerging, but the water must be perfectly still otherwise it will be obvious the submerged part is above water, or if draw water after player the water does not know if the pixel belongs to an object above water and the whole thing would be beneath water.
I mean…are those even the right way to do it? Maybe I’m going too far on a wrong direction?