Search Unity

How to put this script to work on the Unity5 standard shader?

Discussion in 'General Graphics' started by AlanLadd, Dec 5, 2015.

  1. AlanLadd

    AlanLadd

    Joined:
    Feb 12, 2015
    Posts:
    40
    I have a problem with fade a fairly complex model like a cylinder with hole inside. I want a solid object to fade out. I Use the Standard shader in Unity5 set it to Fade option, then the model looks it´s inside out. Then I found this http://docs.unity3d.com/Manual/SL-CullAndDepth.html
    This script helpt me, but it docent use Standard shader, I need Standard shader for the metal ref, I use this script
    the second example: I want too combine it with a copy of Standard shader script.
    Shader "Transparent/Diffuse ZWrite" {
    Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB) Trans (A)", 2D) = "white" {} }
    SubShader {
    Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
    LOD 200
    // extra pass that renders to depth buffer only
    Pass {
    ZWrite On
    ColorMask 0
    }
    // paste in forward rendering passes from Transparent/Diffuse
    UsePass "Transparent/Diffuse/FORWARD"
    }
    Fallback "Transparent/VertexLit"
    }


    Thanks in advance if anyone can help me with that or point me out!
     
    Last edited: Dec 6, 2015
  2. AlanLadd

    AlanLadd

    Joined:
    Feb 12, 2015
    Posts:
    40
    Does nobody have a solution on this?
     
  3. edredar

    edredar

    Joined:
    Jul 26, 2012
    Posts:
    58
    Hi,
    The code you wrote is not actually a script, this is shader. If you want to use Depth Buffer, you should modify the Standard Shader. You can find Standard Shader source code here:
    http://unity3d.com/get-unity/download/archive
    I didn't work with Standard Shader sources at all, but I presume, if you find the line with "ZWrite Off" and change it to "ZWrite On", this would do a trick. If not, you can buy ShaderForge asset on Asset Store, this is extremely powerful tool for creating shaders. It is really easy to achieve the shader you want there.
    Hope it helps.