|
Hi there, Is it possible to hide objects behind a predefined area of a texture? Let's say, I have a texture with the aerial view of a street with a bridge and I want to have a car drive on the road, under the bridge, then the car needs to be hidden when it's under the bridge. I know, I could render the whole thing again with an alpha (so only the bridge is visible in the second layer) on top of the first layer but is there a better version where i can just determine an area where the car is visible and where not?
(comments are locked)
|
|
Purely FWIW Somian. we've done this sort of thing a number of times, and for the overs I've simply put a small rectangle sitting in space where the bridge would be, and put a little bit of texture on to that (either a small image, or just align the big image). I've never bothered doing one big image for the overs (as you describe) where you just knock-out the non-bridge sections in photoshop. (That's a good idea! - it might be a little inefficient?) As I'm sure you know, none of this "really works" unless it's "really" 3D. To get effective shadows, and so on, and the really effective look of the car going under, you do need the bridge to actually be at least reasonably bridge-shaped (say one up, one flat, and one down at least -- if not "an actual realistic 3D model"). My point is if you really want a really true 3D look, it's one of those disgusting things where you have to "give up and do it properly" from the get go! Horrible, but true. A simple solution of overs and unders won't work. BTW as I'm sure you know, you could just make a trigger area and just turn the car off altogether when it is under the bridge -- obviously though it would then disappear/appear all at once instead of partially as it goes under. Depending on the scale, speed, and feel of the graphics, that may be a good solution, or may not. (It could work well for small avatarish objects, train-logic-type games, say pedestrians popping under a bridge, or other graphicky situations.) I am fairly sure there is no "disappear under here" solution, such as you describe. (Unless you want the car to flip on/off in binary.) You could probably do it using the layers paradigm in Unity and mixing cameras or something, but it would be a huge kludge. A silly approach that comes to mind is using a projector in some way to project the over. I fear the answer here is "on the hard way!" Thanks for your response. I'm on iOS and want to save as much computational time and memory as possible, thus want to avoid rendering the whole background image again, even as it is technically just mesh with 2 polygons because I think i'd need much more memory for rendering another shader, this time with alpha ;) Projectors are heavier than simple planes, I think. The small rectangle is the solution i'm gonna go for, I guess. I can't toggle my object that goes under the bridge because then, it would already be hidden when it's just partially under the bridge and i want it to be cut so I can see part of it :)
Nov 30 '11 at 11:31 AM
Somian
FWIW you will have absolutely no performance problems, whatsoever, using the "small rectangles" approach. Go for it ! My guess is you'll eventually wanna try it with "real 3D bridge models" which will produce far better shadows, etc - but you'll know when you do it.
Nov 30 '11 at 11:39 AM
Fattie
Remember, 'real 3D bridge models', for the purpose of realistic shadows, can be as simple as some primitives leaning against each other. In any case, I think real-time shadows are a bit of a performance hitch for mobile devices in any case...
Nov 30 '11 at 11:52 AM
syclamoth
Real time shadows don't work on mobile anyway :/
Nov 30 '11 at 11:57 AM
Somian
(comments are locked)
|
