Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 andrewsolis · Aug 09, 2017 at 09:29 PM · shader3drenderingobjecttransparent shader

set gameobject in front of all others and don't have own faces appear in front of each other

Hello,

I am trying to create a shader that when I attach it to the object, the object will always appear in front of any other object. I copied the standard shader that unity has and modified it a bit so that ZWrite and Cull are OFF and ZTest is set to Always. You can view the changes below and also the entire shader file here which is the entire standard shader Unity uses, plus my changes:

 Shader "CustomShader"
 {
     Properties{...}
     ....
     SubShader
     {
         Tags{....}
         Cull Off
         ZTest Always
         ZWrite Off
     }
     ....
     SubShader
     {
         Tags{....}
         Cull Off
         ZTest Always
         ZWrite Off
     }

It works for the most part, however I am getting a weird issue where the faces are all appearing in front of each other. Here is an example where the camera is placed inside a sphere which has a texture attached to it. There is a gameobject in the scene that is a house which I've attached my shader to. The house appears to be in front of sphere all the time, however you notice that the faces of the houses are in front of each other. You can have a view of the issue through the link provided below.

shader_issue

I found a post on the answers forum here that has an answer that says to add the code below to avoid this issue:

  SubShader {
      Cull Off
      Pass{
          ZTest Greater
      }
      Pass{
          ZTest Less
      }
      Pass{
          ZTest Always
      }

However adding this still did not resolve this issue. Any help would be greatly appreciated, and if there is anything else I can better explain please let me know!

Thanks.

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by · Aug 09, 2017 at 09:39 PM

Changing the render queue to a higher value in the material is not an option?

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 · Aug 09, 2017 at 09:47 PM 0
Share

If not, this is a simple shader that i made in amplify that does what you want

 Shader "New AmplifyShader"
 {
     Properties
     {
         [HideInInspector] __dirty( "", Int ) = 1
         _Color("Color", Color) = (0,0,0,0)
         _Smoothness("Smoothness", Range( 0 , 1)) = 0
         _$$anonymous$$etalic("$$anonymous$$etalic", Range( 0 , 1)) = 0
     }
 
     SubShader
     {
         Tags{ "RenderType" = "Opaque"  "Queue" = "Geometry+0" }
         Cull Back
         ZTest Always
         CGPROGRA$$anonymous$$
         #pragma target 3.0
         #pragma surface surf Standard keepalpha addshadow fullforwardshadows 
         struct Input
         {
             fixed filler;
         };
 
         uniform float4 _Color;
         uniform float _$$anonymous$$etalic;
         uniform float _Smoothness;
 
         void surf( Input i , inout SurfaceOutputStandard o )
         {
             o.Albedo = _Color.rgb;
             o.$$anonymous$$etallic = _$$anonymous$$etalic;
             o.Smoothness = _Smoothness;
             o.Alpha = 1;
         }
 
         ENDCG
     }
     Fallback "Diffuse"
     CustomEditor "ASE$$anonymous$$aterialInspector"
 }
avatar image andrewsolis · Aug 09, 2017 at 09:54 PM 0
Share

I tried using the shader you provided, and it looks like it occluded some things successfully, but it looks like you can still see some objects.

http://imgur.com/a/1$$anonymous$$R$$anonymous$$e

I just copied and pasted the shader into a new one and set that as the shader for the object. Is that all I would need to do?

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

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

Related Questions

Pixelart camera shader 2 Answers

Particles visible through everything! :( 1 Answer

Is particular object visible 1 Answer

How would I fix this DrawMeshInstancedIndirect and Translucent object problem? 0 Answers

Image effect shader not running 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