Game Development Community

Mirrors and boats

by Daniel Buckmaster · in Torque 3D Professional · 01/27/2012 (6:18 am) · 6 replies

I've been thinking about boats and the tricky problem of level geometry penetrating water surfaces. I just remembered something from the days of TGE which might help the situation. Interior objects used to have surfaces that could be designated as mirrors, which resulted, sensibly, in those surfaces rendering reflections of the world. This worked using some sort of portal process that actually seemed to re-render the scene from the mirror's point of view. The important bit was, objects could tell when a particular render call was for a reflection or for a 'real' render. So you could modify rendering for objects that were being reflected. I don't have any examples of when this was used, but I've often thought it would make for great little details, like vampires not reflecting.

Could the same approach not be applied to water inside a boat? If the space inside a boat was covered by a plane that initiated the same sort of 'reflect' render pass, then water objects could be set to not render on these passes. The geometry visible through the plane would be rendered, but without any visible water.

The trouble, of course, comes when you get down below this water-clipping plane. I guess for many situations you could just disable water rendering entirely while inside a given volume; the parts of a boat that are likely to suffer from water penetration are probably down low enough not to be able to see the water outside the boat anyway. Collision is another wrinkle, but I daresay it'd be an easier one to deal with.

I'm probably going to give this a try, if I can figure out how on earth the old mirror objects used to work - and how I could perform the same view transform in T3D. I'm a novice to graphics programming; wish me luck ;P.

EDIT: So okay, I think the particular term I'm looking for is 'transform portal'. Although technically this water-clipping object doesn't need to be a transform portal; all it needs to do is render the scene with some additional logic. A transform portal would just be a good example of what I need done; i.e., rendering a separate pass onto a plane.
And hey, if I/we figure out transform portals, they could be used for nifty effects - like the Portal gun.

About the author

Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!


#1
01/28/2012 (12:32 am)
wasnt there something for wheeledVehicles that would prevent rendering things like groundCover when they penetrated the vehicle?

couldnt that be modified to prevent water that penetrates the vehicle from rendering too?
#2
01/28/2012 (1:49 am)
@deep

Not sure if that will work because the GC are made of individual partials and waterblock has no parts to hide unless the water block could be broken down on the mesh level.
#3
01/28/2012 (6:11 am)
I've never seen anything like that in the engine! But it sounds fantastic so I hope I wasn't just missing out this whole time :P. But Rene has said elsewhere that modifying the water objects to actually cut out a hole in them would be difficult due to the way they're rendered.
#4
01/28/2012 (6:14 am)
I think that you're on to a loser with hiding water ...

I think Groundcover had a fade variable for close distance to prevent it rendering inside a car near the camera - which might be what Deep is thinking of.
#5
01/28/2012 (3:49 pm)
I've been trying to get a updated build of the terrain geometry occluder working(I'm not that great with shaders yet). That's pretty well into the ballpark of what you want though.
What I suggested in a different thread would be integrating the occluder functionality into the zone system, so you could take arbitrarily shaped convex shapes, convert into an occluder, and set what object types it occludes. So make and mount a convex the shape of your boat, and then turn it into an occluder with the water field set. This cuts any water that would render in the occluder, and would double-action as a trigger so while in it you don't get affected by being partially submerged.

This would work for terrain, water or danged-near anything. Imagine a gun that you shoot a portal and it lets you walk through solid walls to the other side :P
It'd be a real handy feature, and I've been messing with getting it updated off and on, but I haven't played with torque's render code since tgea, so I'm ever-so-slightly out of my element at the moment until i brush up.
If someone got that resource updated with the above elements though, I think we'd have a winner.
#6
01/28/2012 (5:23 pm)
@Jeff,
That is a good idea!