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 emreCanbazoglu · Jan 18, 2012 at 12:49 PM · shaderalphatransparent

Object not effected by transparent object in front

Hi,

I am trying to put a game object behind a transparent layer but I dont't want it to be effected by the alpha channel of the transparent layer. Using a second camera isn't a solution for my problem. Is there a way to do it with shaders or some other way?

Comment
Add comment · Show 6
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 Kryptos · Jan 18, 2012 at 01:09 PM 0
Share

Not sure to understand what you mean.

avatar image emreCanbazoglu · Jan 18, 2012 at 02:26 PM 0
Share

think of 2 transparent layers. One is infront of the other one. The layer which is behind shouldn't be affected by the layer which is in front. The texture which is behind should be seen as itself.

avatar image mehowe7 · Jan 18, 2012 at 03:18 PM 0
Share

so you are wanting to have a transparent layer in front of a coloured object, but do not want the colour of the behind object to be affected?

avatar image Kryptos · Jan 18, 2012 at 03:38 PM 0
Share

Well that does not make any sense. What is the point of having a transparent layer if you don't want it to affect anything?

Are you referring to alpha blending problems where a transparent layer completely masks another object because alpha blended layers are not z-sorted?

avatar image emreCanbazoglu · Jan 18, 2012 at 03:52 PM 0
Share

No, I surely want my transparent layer to affect other layers. But - I do not want some of my layers to be effected from the transparent layer, but I also don't want those layers to be in front.

That's all.

Show more comments

1 Reply

· Add your reply
  • Sort: 
avatar image
1

Answer by Wolfram · Jan 18, 2012 at 03:35 PM

If the object in the back uses non-transparent shaders, increase its render queue by 1001 (by modifying the shader code, or by adding a script containing this line: )

 renderer.material.shader.renderQueue += 1001;

If the object in the back uses a transparent shader, you can achieve the same effect by just increasing the renderQueue be 1, but the look will only be the same if your back object's alpha is 1. For smaller alphas (i.e., if the object is actually (semi-)transparent, instead of merely using a transparent shader), the solution is not so simple I guess. You might be able to modify the shader to use a different blend function.

The renderQueue approach works because transparent shaders do not write to the zBuffer. So if you make sure your object renders after your transparent front object, it will overwrite its frame buffer values. Opaque geometry is rendered with a render queue value 1000 lower than transparent geometry, so you need to add at least 1001 to make it render later.

Comment
Add comment · Show 1 · 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 emreCanbazoglu · Jan 18, 2012 at 03:49 PM 0
Share

Unfortunately renderQueue isn't a proper solution for me. There are more than two layers. What I want to do is for example; we have layers A, B, C. Let's say A is the transparent layer which is closest to the camera. B shouldn't be effected by Layer A. Layer B and layer C should be z-sorted. Finally, layer C should be effected by Layer B. I know it sounds complicated but I don't know another way to explain it

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

7 People are following this question.

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

Related Questions

shader for tree leaves + lightmap 1 Answer

Transparent Vertex Shader Error 1 Answer

How can I add alpha-channel to this shader? 2 Answers

Mobile Diffuse Shader with transparent support and Lightmap support 0 Answers

Opaque to Transparent animation effect on a textured object (Lerpz)? 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