使用しているShaderにNormalMapを追加した(Unity3D))

Unityの以下のshadercodeにnormalmapを追加することは可能でしょうか?
こんにちは。一週間前にshaderを学び始めた初心者です。
すりガラスのような宝石のシェーダを作りたいのですが、様々ブログを参考にしてもオブジェクトが赤紫になってしまい、
上手くいきません。

参考にしたURL

https://docs.unity3d.com/ja/2021.2/Manual/SL-VertexFragmentShaderExamples.html
https://blog.applibot.co.jp/2017/10/10/tutorial-for-unity-3d-6/
https://3dcg-school.pro/unity-shader-normal-map/

現在のコード

Shader "Custom/GemGlassShader" { Properties { _MainTex ("Albedo (RGB)", 2D ) = "white" {} _Color ("Color" , Color ) = (1, 1, 1, 1) _Metallic ("Metallic" , Range(0, 1)) = 0.0 _SmoothMin ("Smooth Min" , Range(0, 1)) = 0.0 _SmoothMax ("Smooth Max" , Range(0, 1)) = 1.0 } SubShader { Tags { "Queue" = "Geometry" "RenderType" = "Opaque" "Queue" = "Transparent" } CGPROGRAM #pragma target 3.0 #pragma surface surf Standard fullforwardshadows alpha:blend sampler2D _MainTex; fixed4 _Color; half _Metallic; half _SmoothMin; half _SmoothMax; struct Input { float3 worldNormal; float3 viewDir; float2 uv_MainTex; }; void surf (Input IN, inout SurfaceOutputStandard o) { fixed4 mainTex = tex2D(_MainTex, IN.uv_MainTex); float _DielectricSpecular_Out = 0.040; o.Albedo = fixed4(4, 0, 2, 1); o.Metallic = _Metallic; o.Smoothness = _SmoothMax; float alpha = 1 - (abs(dot(IN.viewDir, IN.worldNormal))); o.Alpha = alpha*1.9f; } ENDCG } FallBack "Diffuse" }

コメントを投稿

0 コメント