1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

簡易輪郭シェーダー

Last updated at Posted at 2022-11-22

モデルに輪郭をつける場合、
もっぱらイメージベース+深度で行いますが、
モバイルではイメージベースの処理や
深度バッファが使用できないことがまだまだあります。
そんなときは、昔ながらの拡大&反転法線を使った
輪郭描画が便利です。

oldStyleEdgeDetect.shader
Shader "Custom/oldStyleEdgeDetect" {
    Properties {
      _Color ("MainColor", Color) = (1,1,1,1)
      _Amount ("Edge Width", Range(1,2)) = 1.1
    }
    SubShader {
      Tags { "RenderType" = "Opaque" "Queue" = "Geometry-10"}
      Pass{
        Cull Front
        ZWrite Off
      }
      CGPROGRAM
      #pragma surface surf Lambert vertex:vert alpha

      struct Input {
          float4 screenPos;
      };
      
      float _Amount;
      float4 _Color;
      sampler2D _MainTex;
      
      void vert (inout appdata_full v) {
          v.vertex.xyz *= _Amount;
      }
      void surf (Input IN, inout SurfaceOutput o) {
          o.Emission = _Color.rgb;
          o.Alpha = _Color.a;
      }
      ENDCG
    } 
    Fallback "Unlit"
}

「それなりの輪郭」がまた懐かしい感じでいいですね。
image.png

1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?