Open noidexe opened 9 months ago
Seconding this, would be great.
I've been trying to port this myself; I've had the same console spam mentioned above and I have an issue with the color mixing.
The former is discussed here. To quote clayjohn:
Using the root Viewport as a texture to draw a Sprite in the root Viewport is not supported and cannot be supported. The error is correct, but not very helpful for end-users.
The vector map parameter is configured as a TextureRect inside of a SubViewport, with the texture set as said SubViewport, so there's probably a better way to achieve this in Godot 4.
The color mixing causes this weird banding effect.
Narrowing things down, it seems to come from this part of the fragment function:
// NORMAL APPLIED TO DEPTH AND READ FROM BUFFER AGAIN (DISTORTED Z-DEPTH)
depth = texture(depth_texture, SCREEN_UV + ((normal_output.xy - vec2(0.5, 0.5)) * clamp(depth * 0.2, 0.0, 0.1) )).r;
depth = depth * 2.0 - 1.0;
depth = PROJECTION_MATRIX[3][2] / (depth + PROJECTION_MATRIX[2][2]); // Camera Z Depth to World Space Z
depth = depth + VERTEX.z;
Commenting out the last line removes the banding, but I'm unsure how to actually fix this.
I've made a repo of my progress here if anyone wants to check it out. Not much of a shader coder at all, but I hope it helps!
@soldiersorrowful Will you continue your work on the port? I would very much appreciate it as my own efforts have borne little fruit.
@soldiersorrowful Will you continue your work on the port? I would very much appreciate it as my own efforts have borne little fruit.
Haven't touched it much and honestly don't really plan to unless someone asks or helps with it, sorry! Just wanted to share what little information for possible fixes there could be; again, not much of a shader coder.
The banding is caused by the 'water color' gradient on the waterplane object. If you change it from left to right orientation to top to bottom, the banding is gone and SSS works. I haven't figured out how to fix the errors though, but it has something to do with the vector_map_buffer that is both read and written to (I believe it's the wind/flowmap).
[edit] The errors stop spamming when you toggle the 'image' visibility. The flow stops then aswell but that's to be expected :-)
The banding is caused by the 'water color' gradient on the waterplane object. If you change it from left to right orientation to top to bottom, the banding is gone and SSS works. I haven't figured out how to fix the errors though, but it has something to do with the vector_map_buffer that is both read and written to (I believe it's the wind/flowmap).
[edit] The errors stop spamming when you toggle the 'image' visibility. The flow stops then aswell but that's to be expected :-)
Regarding the continuous thrown error: the problem is the same, as is mentioned here:
https://github.com/inkusgames/godot4_shader_viewport_example
As you mentioned, it shouldn't be read from and written to. It needs to be separated.
Btw, if you look at the surface a bit closer, do you all also notice the vibration or turbulence? Does anybody know why that is happening?
Regarding the "gradient bands", I am not completely sure, if the gradient is needed. I just changed it to a constant value. In this case I made it a bit more blue: \
\ I still have a problem with the continuous error message regarding the SubViewport. How can the "write" and the "read" be separated in this case, as is mentioned in: https://github.com/inkusgames/godot4_shader_viewport_example
The banding is caused by the 'water color' gradient on the waterplane object. If you change it from left to right orientation to top to bottom, the banding is gone and SSS works. I haven't figured out how to fix the errors though, but it has something to do with the vector_map_buffer that is both read and written to (I believe it's the wind/flowmap). [edit] The errors stop spamming when you toggle the 'image' visibility. The flow stops then aswell but that's to be expected :-)
Regarding the continuous thrown error: the problem is the same, as is mentioned here:
https://github.com/inkusgames/godot4_shader_viewport_example
As you mentioned, it shouldn't be read from and written to. It needs to be separated.
Btw, if you look at the surface a bit closer, do you all also notice the vibration or turbulence? Does anybody know why that is happening?
I did notice that, not sure why this happens but I think it’s because of the mesh subdivides and rounding of the verices moving them
The banding is caused by the 'water color' gradient on the waterplane object. If you change it from left to right orientation to top to bottom, the banding is gone and SSS works. I haven't figured out how to fix the errors though, but it has something to do with the vector_map_buffer that is both read and written to (I believe it's the wind/flowmap). [edit] The errors stop spamming when you toggle the 'image' visibility. The flow stops then aswell but that's to be expected :-)
Regarding the continuous thrown error: the problem is the same, as is mentioned here: https://github.com/inkusgames/godot4_shader_viewport_example As you mentioned, it shouldn't be read from and written to. It needs to be separated. Btw, if you look at the surface a bit closer, do you all also notice the vibration or turbulence? Does anybody know why that is happening?
I did notice that, not sure why this happens but I think it’s because of the mesh subdivides and rounding of the verices moving them
I don't think it happens, because of the mesh subdivides. If you go to the corners of the mesh, where it has less subdivision, you can still notice the vibration. I tested my assumption by subdividing the waterplane in blender even more and importing it into the Godot project. The vibration was still there.
P.S.: @Platinguin are you still using your old shaders? Have you updated them, so it can run with Godot 4.x?
The vibration can be reduced a bit by setting the shader parameter "Gerstner Speed 2" in "MeshInstance3D" to (0,0), so it is basically switched off.
That is what I currently have. It runs with Godot 4.3-beta2 (I attached the original audio):
It really is a shame, that such a wonderful shader cannot be used in its original glory anymore. I even tried to use the original project by @Platinguin with older versions of Godot, so I understand the code better by playing around with it, but it only shows pixel noise, when I run the project...
@soldiersorrowful if you have any improvements, please let us know 🙂.
Any chance of having this working on Godot 4?
I tried going to the first couple errors and got this:
with the console spamming
Attempted to use the same texture in framebuffer attachment and a uniform (set: 3, binding: 0), this is not allowed