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 /
This question was closed Jul 01, 2014 at 06:03 PM by tanoshimi for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by QuestionAsker · Jul 01, 2014 at 05:36 PM · shaderissueglitchtransparent

Multiple transparency shaders yields a massive Unity glitch.

alt text

Well the title just about says it. I have a material for the roof and another for the walls. When i switch it from Transparent/Diffuse to Diffuse, the issue goes away but i need to be able to edit the transparency through a script so the Transparency diffuse is necessary.

Is there any way to fix this?

Viewing from underneath the fixes the roof. The issue appears to only happen when 2 transparent/diffuses overlap.

alt text

untitled.png (317.0 kB)
untitled.png (230.4 kB)
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 tanoshimi · Jul 01, 2014 at 05:39 PM 0
Share

It's hard to see from your pictures what exactly the problem is, but the fact that you said "viewing from underneath fixes the problem" makes me think this might be related to the normals of your surfaces - is the roof a plane?

avatar image deltamish · Jul 01, 2014 at 05:41 PM 0
Share

may be you are using single plane for walls and roof right

avatar image QuestionAsker · Jul 01, 2014 at 05:43 PM 0
Share

No it has multiple faces. I recalculated the normals in blender, and if I change the shader to a regular diffuse the problem goes away. The pictures are trying to show how the object seems to dissapear only when you view one over the other.

avatar image QuestionAsker · Jul 01, 2014 at 05:45 PM 0
Share

single plane for walls, multiple for roof.

avatar image deltamish · Jul 01, 2014 at 05:49 PM 0
Share

Hmm thats strange cause the shader are independent of each other they only consider inco$$anonymous$$g light and texture

Could you upload the 3d model once so that we could have a closer lOok at the problem

and you said two diffuse layers overlap right does the smae happen with other shaders as well

and which render mode are you running

Show more comments

1 Reply

  • Sort: 
avatar image
2
Best Answer

Answer by tanoshimi · Jul 01, 2014 at 06:02 PM

The built-in transparent shaders do not write to the depth buffer. Since the transparent queue is not sorted, the draw order of overlapping transparent objects is therefore somewhat arbitrary, as any objects sent to the GPU later will be rendered over the top of previous objects, even if they actually lie behind them.

If you really need to use transparent shaders (it's a bit unclear why) and want to maintain depth, you can add ZWrite On to the shader - although note that this will cause your apparently "transparent" objects to occlude objects that lie behind them (which is why it's generally turned off).

Try creating a new shader as follows and assigning it to the material on your objects:

 Shader "Transparent/Diffuse ZWrite" {
 Properties {
     _Color ("Main Colour", Color) = (1,1,1,1)
     _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
 }
 SubShader {
     Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
     LOD 200
 
     // Initial pass renders to depth buffer only
     Pass {
         ZWrite On
         ColorMask 0
     }
 
     // Now use regular forward rendering passes from Transparent/Diffuse
     UsePass "Transparent/Diffuse/FORWARD"
 }
 Fallback "Transparent/VertexLit"
 }




 
Comment
Add comment · Show 3 · 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 QuestionAsker · Jul 01, 2014 at 06:07 PM 0
Share

Ill test this out, because if it works it is far better than what I have now! Ill edit when im done

avatar image QuestionAsker · Jul 01, 2014 at 06:13 PM 0
Share

AHHH THAT DID IT!!! Thank you so much!!!

avatar image deltamish · Jul 01, 2014 at 06:19 PM 0
Share

Way to go @tanoshimi Nice job

Follow this Question

Answers Answers and Comments

22 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 avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Semitransparent shader issue. How can I fix it? 0 Answers

Shader - Transparent Shows Through 1 Answer

Blender to Unity glitch? 3 Answers

Transparent Diffuse issues 1 Answer

A node in a childnode? 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