- Home /
How would you cull a water intersecting a ship when viewing inside?
I don't really know how to explain it, im going to post a pic for illustration. If im going to use a plane, the water then would go through the ship's inside. How would I hide it? 
Answer by ina · Dec 21, 2010 at 09:19 AM
Try using a DepthMask shader.
even more misc. knowledge: learned about depthmasks in http://bit.ly/arsdklecture where they created the Penelope canyons on a table AR ImageTarget printout! ;)
I'll have to check that out once I get a little bit more free time on my hands. :) Working day has begun.
Im not able to access my project right now but just apply the shader on the water? and that's it? :)
Answer by Statement · Dec 21, 2010 at 09:21 AM
At first glance it looks like an easy problem, but it becomes harder once you start to appreciate it. I guess I have come up with three approaches that doesn't involve changing the mesh runtime.
You could draw the water first and then clear Z buffer before rendering the ship. This won't look good if you're viewing the ship from outside. Maybe you could switch to clearing Z buffer only if you're looking from the interior of the ship to reduce this effect.
You could perhaps draw the interior of the ship first using scissoring (if that is available in Unity, I don't know) to clip the sea rendering. Finally you could apply the boat. In fact I see now at my final touches to my answer that ina already posted a DepthMask shader that seems to achieve this.
You could use render to texture to render the inside of the ship through a portal. This is probably somewhat more complex and I am not entirely sure how to go about it best. Basically you'd have the inside of the ship modeled somewhere else and have another camera mimic the main camera to render the insides and apply the resulting texture to the boats main surface plane. Think of it like a mirror, but not really a mirror. More of a portal.
Your answer
Follow this Question
Related Questions
Hide water 1 Answer
Reduce FPS Overhead using Unity3D Pro Daylight Water 1 Answer
ship trail on water 1 Answer
Can't stand on the boat(but it already have collider) 1 Answer
How do i make floating ship ? 0 Answers