Home Game Development Unity combine multiply shader passess collectively

Unity combine multiply shader passess collectively

0
Unity combine multiply shader passess collectively

[ad_1]

Hi i wish to create a shader with completely different passes, first go 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?

Outline is beneath and Transmission is mixing by Adding and reflections utilizing alpha.

My take a look at shader is :

Shader "Custom/BlendedShader"
{
    Properties
    {
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        _Pass2Color ("Color 2 (RGB)", Color) = (1,1,1,1)
        _Glossiness ("Smoothness", Range(0,1)) = 0.5
        _Metallic ("Metallic", Range(0,1)) = 0.0
    }

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

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

        struct Input
        {
            float2 uv_MainTex;
        };

        half _Glossiness;
        half _Metallic;
        fixed4 _Color;

        void surf (Input 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

        Pass
        {

            Blend 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 : How it appears to be like
B : How I need it’s

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here