LoginSignup
13
13

More than 5 years have passed since last update.

Unity 半透明描画するサーフェースシェーダー

Posted at
TransparentSurface.shader
Shader "Custom/TransparentSurface" {
    Properties {
        _MainTex ("Base (RGB)", 2D) = "white" {}
    }
    SubShader {
        Tags {
            "Queue" = "Transparent"
            "RenderType" = "Transparent"
        }
        CGPROGRAM
        #pragma surface surf Lambert alpha

        sampler2D _MainTex;

        struct Input {
        float2 uv_MainTex;
        };

        void surf(Input IN, inout SurfaceOutput o) {
            half4 c = tex2D(_MainTex, IN.uv_MainTex);
            o.Albedo = c.rgb;
            o.Alpha  = 0.25;
        }
        ENDCG
    }
}

ポイント:

  • "Queue" = "Transparent" を指定
  • "RenderType" = "Transparent" を指定
  • #pragma surface の指定に alpha を追加 (忘れやすい)
  • SurfaceOutputAlpha をお好みで指定すればアルファが変えられます
  • 他の部分はお好みで (上の例はテクスチャから色を取ってくる設定)
13
13
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
13