After debugging that, I set to work on attempting to implement this shader/script into a project of my own, but I have a behavior that I am entirely unsure how to address or investigate. It looks like the objects that I place in the WaveSources Layer appear in the very center of the texture at a very very small size and strangely I have waves coming from uniform spots across the plane…
And as I typed that out I realized that he camera must have it’s clear color set to #00000000 to fix that problem. Still, removing the terrain and relying on only a few rock for ripple result in a very small representation of the ripples in the center of the plane:
I’ve tried adjusting the Orthographic height of the Water Camera, adjusting both the land width and wave width, texture size, placement of objects, UV tiling, and I think I’ve run out of ideas. Any insight on this project, or how this might be overcome would be incredibly appreciated!
Fresh morning eyes revealed that the updateWater() function was actually setting the camera’s orthoHeight and position, meaning basically any of the changes I made with the camera were overwritten.
Now I’m getting a pretty good result that will be tweaked in the future. I decided to see if the shader could be updated, especially considering that I saw that the script registers an app level event to update the water to dirty the layer. I noticed that the event isn’t called anywhere in the script, so I’m guessing it was meant to be updatable. Firing the event produces a Trying to bind current color buffer as a texture error:
Ok, so I managed to get a couple of minutes to take a look at this. While I did update the shader to survive the changes in 1.62+, it seems like there were changes in 1.63+ that are causing the shader in this thread to fail. (There are two shaders running in this project, the one in this thread, and another custom one I made called voronoiWater)
Here is the error that is being generated by the water shader:
Shaders are definitely not my specialty, so it will take me awhile to debug and throw things at the wall until it works, but I looked back at the PR’s for 1.63.0 which does break the water shader and I highly suspect that this has something to do with it:
but @mvaligursky would have WAY information than I would. Sorry I couldn’t be more helpful, but hopefully this information points you or someone else in the right direction faster than I can get to it.
and then added the following to the onUpdateShader()function being sent to the renderer:
result.pass = self.layer.shaderPass;
This ensured that the appropriate shaderPass was created and then provided to the material for processing.
While this cleared the errors, it seems like the change altered the way that the waves were being generated, so I updated water.glsl to look a bit closer to how it was and adjusted my settings. Your mileage may vary, and it may take more tinkering with the shader itself to make everything work for your use-case.
I made all of the changes to the same project shared previously. I will keep it up for others to look at. Please feel free to fork it. I hope this is helpful and that the shaders work for you!