zoukankan      html  css  js  c++  java
  • 扣绿幕Shader(可自选颜色)

    Shader "Custom/ChromaKey" {
    
        Properties {
            _MainTex ("Base (RGB)", 2D) = "white" {}
            _thresh ("Threshold", Range (0, 16)) = 0.8
            _slope ("Slope", Range (0, 1)) = 0.2
            _keyingColor ("Key Colour", Color) = (1,1,1,1)
        }
        
        SubShader {
            Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
            LOD 100
            
            Lighting Off
            ZWrite Off
            AlphaTest Off
            Blend SrcAlpha OneMinusSrcAlpha 
            
            Pass {
                CGPROGRAM
                    #pragma vertex vert_img
                    #pragma fragment frag
                    #pragma fragmentoption ARB_precision_hint_fastest
    
                    sampler2D _MainTex;
                    float3 _keyingColor;
                    float _thresh; // 0.8
                    float _slope; // 0.2
    
                    #include "UnityCG.cginc"
    
                   float4 frag(v2f_img i) : COLOR{
                  float3 input_color = tex2D(_MainTex,i.uv).rgb;
                  float d = abs(length(abs(_keyingColor.rgb - input_color.rgb)));
                  float edge0 = _thresh*(1 - _slope);
                  float alpha = smoothstep(edge0,_thresh,d);
                  return float4(input_color,alpha);
                  
                
                  } 
                  
                ENDCG
            }
        } 
        
         FallBack "Unlit/Texture"
    }
  • 相关阅读:
    160809207刘兆轩
    技术报告
    homework160809207刘兆轩
    施润行160809301(9)
    施润行160809301(8)
    施润行160809301(7)
    施润行160809301(6)
    施润行160809301(5)
    施润行160809301(作业4)
    施润行160809301(作业3)
  • 原文地址:https://www.cnblogs.com/leesymbol/p/8042070.html
Copyright © 2011-2022 走看看