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 zafadadynamic · Oct 24, 2013 at 05:43 PM · shaderstransparencyrenderqueue

Transparency render issue

I understand that this has been asked before but I've done almost everything to get it to work. This might be beyond the scope of my expertise because I barely messed with shaders which I'm saving for last in regards to learning Unity.

Here's the problem as I'm sure you've seen before:

alt text

So there are a lot of solutions out there but none that I understand.

I tried the custom shader solution but I have a feeling that I'm adding the shader code incorrectly. I create a new shader, open the compiled shader, and replace the existing code with the solution code, correct? Or is there somewhere I place the code within the shader code that Unity provides in the shader?

I also tried the 'creating the face at a distance from the main object as part of the object to force render priority' trick but that didn't work.

Then there's renderQueue. I really have no idea how to use that or if it solves this problem.

If any one of these answers is the correct solution, can you say step by step how to fix this seemingly minor problem rather than responding with vague external resources or solutions?

I know that sounds rude but I see this problem as kind of an annoying obstacle that's taking time away from what I should be doing. Sorry, I have really bad OCD and I'd rather not get into writing my own shaders just yet. :)

EDIT: They key is not rendering correctly which is spinning and some of the faces of the key are showing instead of the closer faces. I will need to fade this key out so that's why I'm using the transparent/specular shader. Here are some images...Unity's kind of being a pain right now so I'll need a minute.

alt text

Edit:

I did find something on this thread concerning Zwrite because the guy has the same problem but Zwrite doesn't seem to be in the shader.

http://forum.unity3d.com/threads/41007-Transparent-Diffusr-shader-problem-Done

Commented out Zwrite in the transparent/diffuse shader. Didn't work.

Then I tried this shader:

 Shader "Transparent/VertexLit with Z" {
     Properties {
         _Color ("Main Color", Color) = (1,1,1,1)
         _SpecColor ("Spec Color", Color) = (1,1,1,0)
         _Emission ("Emissive Color", Color) = (0,0,0,0)
         _Shininess ("Shininess", Range (0.1, 1)) = 0.7
         _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
     }
      
     SubShader {
         Tags {"RenderType"="Transparent" "Queue"="Transparent"}
         // Render into depth buffer only
             Pass {
             ColorMask 0
         }
         // Render normally
         Pass {
             ZWrite Off
             Blend SrcAlpha OneMinusSrcAlpha
             ColorMask RGB
             Material {
                 Diffuse [_Color]
                 Ambient [_Color]
                 Shininess [_Shininess]
                 Specular [_SpecColor]
                 Emission [_Emission]
             }
             Lighting On
             SetTexture [_MainTex] {
                 Combine texture * primary DOUBLE, texture * primary
             }
         }
     }
 }

This strangely made the object disappear altogether. Sigh.

untitled.png (259.9 kB)
untitled.png (289.6 kB)
Comment
Add comment · Show 3
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 jonnyhopper · Oct 24, 2013 at 06:07 PM 0
Share

Can you be more specific with what you want to achieve? Not knowing what you're shooting for makes it hard to see the problem.

I'm guessing from the title you want an object to be transparent but it's not working correctly? In the image you've provided, which object?

Have you tried making a new material (Right click in project view, Create/$$anonymous$$aterial ) and then assigning it the Transparent/Diffuse shader?

avatar image zafadadynamic · Oct 24, 2013 at 06:09 PM 0
Share

The key is rendering incorrectly. Sorry, I read what I wrote and afterward realized I left out a few things. Yeah, that key is showing 'holes' in the mesh as it rotates. I'll update with another image. One sec.

avatar image zafadadynamic · Oct 24, 2013 at 06:19 PM 0
Share

@Johnny, yep. I'll try again for good measure.

3 Replies

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

Answer by zafadadynamic · Oct 24, 2013 at 07:48 PM

Here's the shader that worked to my surprise because I tried this yesterday and there was no change:

 Shader "Transparent/VertexLit with Z" {
     Properties {
         _Color ("Main Color", Color) = (1,1,1,1)
         _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
     }
      
     SubShader {
         Tags {"RenderType"="Transparent" "Queue"="Transparent"}
         // Render into depth buffer only
         Pass {
             ColorMask 0
         }
         // Render normally
         Pass {
             ZWrite Off
             Blend SrcAlpha OneMinusSrcAlpha
             ColorMask RGB
             Material {
                 Diffuse [_Color]
                 Ambient [_Color]
             }
             Lighting On
             SetTexture [_MainTex] {
                 Combine texture * primary DOUBLE, texture * primary
             } 
         }
     }
 }
 

And probably all I had to do was add Zwrite Off instead of just commenting it out in the transparent/diffuse shader.

Anyway, it's not polite for me to accept my own answer like last time so I'll pick someone. Here's what the final product should look like:

alt text

It's amazing how different the result is. I was going to use @Griffo 's method yesterday but I'm just way too stubborn for compromises, lol.


untitled.png (271.3 kB)
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 Owen-Reynolds · Oct 25, 2013 at 12:17 AM 0
Share

You can accept your own answer. The whole point is for other people with the same Q to see it later.

I think the problem was you were seeing the bright back-face of the key (hard to tell w/o being able to move it around.) Seems like backface-culling would also have solved it. Or just not having it lit from behind.

avatar image zafadadynamic · Oct 25, 2013 at 03:09 AM 0
Share

If you think it'd clarify the answer for people more, I can take a video, reprodeuce the problem, and see if backface cull would repair it too. That's just CULL OFF in the shader, right?

avatar image Owen-Reynolds · Oct 25, 2013 at 05:31 AM 0
Share

First result in "unity shader cull" says/shows how to use it. also has the shader you're using.

I'm wondering if you don't have extra, doubled faces. That's the only reason their robot looks odd.

avatar image
1

Answer by Owen-Reynolds · Oct 24, 2013 at 06:22 PM

Those missing faces in the key probably means it was modelled with some flipped normals. In other words, the key is the problem, not your part.

You could turn off backface culling in the shader, but better to fix the key (lots of places here about flipped normals, missing faces ... , but might be better to look at a site for the program you made the key with.) If someone else made it, the mere words "some flipped normals" are all you have to tell them.

Also, you didn't write you did this, but in the Material for the key, switch to the new shader (whatever name you put in the very top of the new shader code, that should appear in the shader dropdown) (but if you fix the key, you won't need a new shader.)

Comment
Add comment · Show 2 · 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 zafadadynamic · Oct 24, 2013 at 06:25 PM 0
Share

Ya know, I was wondering if it was a flipped normal problem so I'll flip them in $$anonymous$$ax to see what happens. This problem only exists with the transparent shader.

I'll also make sure I did what you said about the material.

avatar image zafadadynamic · Oct 24, 2013 at 06:39 PM 0
Share

Okay, that was a no-go. The faces are all unified and facing the correct direction. Even went through the normals individually. I have the shader labeled 'test shader' which is selected. I may have even used the wrong code. I'll keep looking around and update the problem.

avatar image
0

Answer by jonnyhopper · Oct 24, 2013 at 06:35 PM

If it's not flipped normals then it might be a sort order problem - bet it goes away if you turn it back to a non-transparent shader?

Comment
Add comment · Show 2 · 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 zafadadynamic · Oct 24, 2013 at 06:53 PM 0
Share

That is correct. I need the transparent shader so I can gradually fade out the alpha channel.

avatar image Griffo · Oct 24, 2013 at 06:57 PM 0
Share

I use a normal shader then just before I fade out the game object I swap the shade to transparent in run time and fade it out, and it's not noticeable ..

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

18 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

Related Questions

Why does the 3D Text shader show specular at certain angles? 2 Answers

Prefab's High poly mesh VS lower poly transparency cutout 2 Answers

Shader Constants - Lighting Params require Queue=Geometry? 1 Answer

I have transparent shader, but after quad with it material all objects with not default sorting layer are unvisible 0 Answers

PBR shader is too transparent 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