Monday, October 17, 2022
HomeGame DevelopmentUnity combine multiply shader passess collectively

Unity combine multiply shader passess collectively


Hello i wish to create a shader with completely different passes, first move has transmission second one has reflection, GI and PBR utilizing surf and third one is define round utilizing unlit.

How am i able to mix my completely different passes along with a weight?

Define is beneath and Transmission is mixing by Including and reflections utilizing alpha.

My check shader is :

Shader "Customized/MixedShader"
{
    Properties
    {
        _Color ("Coloration", Coloration) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Pass2Color ("Coloration 2 (RGB)", Coloration) = (1,1,1,1)
        _Glossiness ("Smoothness", Vary(0,1)) = 0.5
        _Metallic ("Metallic", Vary(0,1)) = 0.0
    }

    SubShader
    {
        Tags { "RenderType"="Opaque" }
        LOD 200

        CGPROGRAM
        #pragma floor surf Customary fullforwardshadows decal:mix keepalpha
        #pragma goal 3.0
    
        sampler2D _MainTex;

        struct Enter
        {
            float2 uv_MainTex;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;

        void surf (Enter IN, inout SurfaceOutputStandard o)
        {
            fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
            o.Albedo = c.rgb;
            o.Metallic = _Metallic;
            o.Smoothness = _Glossiness;
            o.Alpha = 1.0f;
        }
        ENDCG

        Cross
        {

            Mix SrcAlpha DstAlpha

            CGPROGRAM
            #pragma vertex vert
            #pragma fragment frag
            // make fog work
            #pragma multi_compile_fog

            #embrace "UnityCG.cginc"

            struct appdata
            {
                float4 vertex : POSITION;
                float2 uv : TEXCOORD0;
            };

            struct v2f
            {
                float2 uv : TEXCOORD0;
                UNITY_FOG_COORDS(1)
                float4 vertex : SV_POSITION;
            };

            sampler2D _MainTex;
            float4 _MainTex_ST;
            float4 _Pass2Color;

            v2f vert (appdata v)
            {
                v2f o;
                o.vertex = UnityObjectToClipPos(v.vertex * 1.05);
                o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                UNITY_TRANSFER_FOG(o,o.vertex);
                return o;
            }

            fixed4 frag (v2f i) : SV_Target
            {
                // pattern the feel
                fixed4 col = tex2D(_MainTex, i.uv);
                // apply fog
                UNITY_APPLY_FOG(i.fogCoord, col);
                return _Pass2Color;
            }
            ENDCG
        }
    }
    FallBack "Diffuse"
}

enter image description here
A : The way it seems
B : How I would like or not it’s

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments