Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Haiku-Oezu · Apr 04, 2013 at 09:10 PM · shadertexturemeshtransparency

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

Comment
Add comment · Show 4
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image TimBorquez · Apr 05, 2013 at 08:38 AM 0
Share

lemmie see if i understand this correctly, those windows on the left are transparent, right now the long gray rectangle is going inside of the building on the left so all you can see through the windows is the gray rectangle and what you want is some kind of shader(or something) that will ignore the gray box so looking through the windows would show sky?

I cant really think of a shader that can ignore other geometry like that or some kind of way to delete intersecting geometry like a boolean in a modeling program. But maybe a different solution would be to make your floor a bunch of chunks in a line(being the smallest possible size of sections you can place), then just remove colliding chunks when you place your section(sorry if im totally off base of what youre looking for, it's just a thought)

avatar image Haiku-Oezu · Apr 05, 2013 at 11:25 AM 0
Share

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

avatar image Lockstep · Apr 05, 2013 at 12:27 PM 0
Share

Not sure if there is something for your situation, but there are a couple of shaders available on the wiki. Try the transparent shaders. $$anonymous$$aybe you are lucky.

avatar image Haiku-Oezu · Apr 05, 2013 at 01:18 PM 0
Share

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

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by dorpeleg · Apr 05, 2013 at 06:50 PM

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 :)

Comment
Add comment · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Haiku-Oezu · Apr 05, 2013 at 06:57 PM 0
Share

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 ins$$anonymous$$d of filling the whole floor, should be the best approach.

avatar image dorpeleg · Apr 05, 2013 at 07:09 PM 0
Share

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.

avatar image Haiku-Oezu · Apr 08, 2013 at 12:50 PM 0
Share

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

avatar image dorpeleg · Apr 08, 2013 at 03:45 PM 0
Share

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

avatar image Haiku-Oezu · Apr 08, 2013 at 03:46 PM 0
Share

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!

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

13 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[ problem ] transparent shader !!! 1 Answer

Transparency / depth problem 0 Answers

Triplanar surface shader not responding to Mesh.Colors 0 Answers

How to get a sphere surface with a solid angle through script? 1 Answer

Mesh Clipping / Cross Sections 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges