Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
13
Help us understand the problem. What are the problem?

More than 5 years have passed since last update.

@beinteractive

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

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 をお好みで指定すればアルファが変えられます
  • 他の部分はお好みで (上の例はテクスチャから色を取ってくる設定)
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
13
Help us understand the problem. What are the problem?