Make transparency ignore meshes inside?

Hello everyone, I’m currently working a 2.5D building game where players can place different kinds of structures inside a building to build it floor by floor.
Whenever something is built the game places another “building” behind it called the floor, this is necessary so that when a building is removed the story above isn’t floating in the air but has some kind of support underneath; the floor is always moved and stretched around by the game so that it always matches the space used by the buildings.

Right now all the buildings are just cubes stretched out in different rectangular shapes with a single texture applied to them, it has worked well enough up until now.
However, when I wanted to introduce a structure that has glass windows you can see through I noticed I can’t actually see through them at all. I thought I got the material’s transparency or the texture settings wrong but it turns out I’m simply seeing the floor through the windows.

The situation is basically as follows
alt text

That long grey thing is the floor, it is positioned almost exactly as a building, it’s just slightly thinner so the textures don’t overlap, in other words it’s actually “inside” the cube mesh representing the building.

The problem here of course is that the front face has those see-through windows that let you see the floor, when they should let you see the sky behind instead.

I’m not sure how to get out of this predicament; the most obvious solution would be to not make the floor go through buildings at all, but that would make it much more complicated, the floor would need to be split and merged constantly when buildings are added or removed.
It would be much simpler if I could tweak my mesh or the material so that the transparency acts as expected, or some other solution I’m not seeing right now… does anyone know how to achieve the desired effect?

Thanks in advance

I forgot to mention, the game camera actually faces straight on so the left sides are irrelevant, what should happen is what you said but with the front face (the large lit one). I was thinking of scrapping this "single stretching floor" approach and just have smaller floors to fill the gaps between buildings myself but I was concerns about the performance impact of having so many little GameObjects scattered around

Not sure if there is something for your situation, but there are a couple of shaders available on the [wiki][1]. Try the transparent shaders. Maybe you are lucky. [1]: http://wiki.unity3d.com/index.php/Shaders

Tried all the Unity 3.x shaders that might apply but unfortunately none of them seem to help

1 Answer

1

I only see 3 options for this:

1.Make it so the floors split (like you said, it might hurt performance).

2.Find some why to use render texture to display the sky behind(might be even worse for performance).

3.Just draw “sky” in your texture, it won’t be real-time moving sky but will give best performance.

Looks like your making something like SimTower, should be cool in 3D :slight_smile:

Yeah, that's the plan actually! I think I'll give number 1 a shot, maybe rig a script to fill the floors with 1x1 tiles to simulate a worst case scenario... hopefully since the floors don't really do anything other than stay there they won't have a noticeable impact on performance. Either that or make them stretch just to fill gaps instead of filling the whole floor, should be the best approach.

It seems all your meshes are boxes, so that is good for performance. If you could make a really smart code that will stretch when needed and split when needed, then it should help performance.

Apparently filling with tiny boxes is not a good idea, I made a test with 100 floors and it outright killed performance. Looks like I'll have to go for the stretching gap fill approach after all

Like I said, try to make a smart code that will stretch when needed and split when needed, then it should help performance.

Yeah, working on the split/merge thing now, hopefully it will be good enough to handle a big building AND all the simulation going on at the same time!