Hello,
I’m working on a project where we will have a number of boats on an ocean. At the moment i’m trying to find a way to have the boats sit in the ocean but not have the ocean be visible as it is coming through the bottom of the boats.
I’ve implemented a way to do this by multiple pass rendering to different textures and composite them for the final render image.
This is the approach:
Create 3 cameras in identical locations, a Main, a Non-Ocean, and a Mask. Depending on the camera that is being used, swap materials on the objects during OnWillRenderObject, with the following logic:
Non-Ocean camera renders the scene without the ocean, to capture the bottom of the boats that may be covered by water.
Mask renders a white circle around the area that includes the inside of the boat, and the ocean and background as black everywhere else, creating a black and white image mask. This mask can be covered by waves in front of the boat, but will cover any waves poking through the bottom of the boat.
in the final OnRenderImage for the main camera, a shader is used to consider the mask as alpha channel to lerp pixels from the non-ocean view overlaying them with the full scene view, effectively “revealing” the bottoms of the boats that were covered by waves.
See the screenshots for an example of what I’m talking about. The first is a shot of the problem, the second of the solution with the render textures (mask, No-Ocen) shown at the top left
The problem is when using RenderTextures is that they don’t support Anti Aliasing, so the inside of the boat is alias when everything else in the scene is not. My question is if there is a different approach to take, or if it’s possible to render the scene twice and composite together them without using RenderTextures?
Or am I missing a different approach to the problem entirely?
Thanks!

