実現したいこと
タイトル通りです、高さによって一部を透過するシェーダーを作ったのですが、非透過部分のみ影が描画さえるようにしたいです。具体的にはStandardシェーダーのCutoutや以下の画像の左側のようにしたいです。
該当のソースコード
cgprogram
1Shader "Custom/PartialTransparency-Height" 2{ 3 Properties 4 { 5 _UpperColor ("Upper Color", Color) = (1,1,1,0) 6 _UnderColor ("Under Color", Color) = (1,1,1,1) 7 _MainTex ("Albedo (RGB)", 2D) = "white" {} 8 _Glossiness ("Smoothness", Range(0,1)) = 0.5 9 _Metallic ("Metallic", Range(0,1)) = 0.0 10 _SeparationHeight ("Separation Height", Float) = 0.0 11 } 12 13 SubShader 14 { 15 Tags { "RenderType"="TransparentCutout" "Queue" = "AlphaTest" } 16 LOD 200 17 18 CGPROGRAM 19 20 #pragma target 3.0 21 #pragma surface surf Standard fullforwardshadows alpha:fade 22 23 sampler2D _MainTex; 24 25 struct Input { 26 float2 uv_MainTex; 27 float3 worldPos; 28 }; 29 30 fixed4 _UpperColor; 31 fixed4 _UnderColor; 32 half _Glossiness; 33 half _Metallic; 34 float _SeparationHeight; 35 36 void surf (Input IN, inout SurfaceOutputStandard o) 37 { 38 fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * lerp(_UnderColor, _UpperColor, step(_SeparationHeight, IN.worldPos.y)); 39 o.Albedo = c.rgb; 40 o.Metallic = _Metallic; 41 o.Smoothness = _Glossiness; 42 o.Alpha = c.a; 43 } 44 ENDCG 45 } 46 Fallback "Transprent/Cutout/Diffuse" 47}
試したこと
http://tsumikiseisaku.com/blog/shader-tutorial-transparent/
このサイトを見て真似してみましたが上手くいきませんでした。
補足情報
Unity2019.1.4f1

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2022/06/06 00:13