Last active
January 19, 2019 18:47
-
-
Save TheStoneBook/e26cf6d871d9d85bec4631ed8d156fa4 to your computer and use it in GitHub Desktop.
【Unity】バンプマッピング【Shader】
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/BumpMapping" { | |
Properties { | |
_Color ("Color", Color) = (1,1,1,1) | |
_MainTex("MainTexture", 2D) = "white" {} | |
_BumpMap("NormalMap", 2D) = "white" {} | |
_BumpScale("NormalScale", Range(0,1)) = 0.5 | |
_Glossiness ("Smoothness", Range(0,1)) = 0.5 | |
_Metallic ("Metallic", Range(0,1)) = 0.0 | |
} | |
SubShader { | |
Tags { "RenderType"="Opaque" } | |
LOD 200 | |
CGPROGRAM | |
#pragma surface surf Standard fullforwardshadows | |
#pragma target 3.0 | |
fixed4 _Color; | |
sampler2D _MainTex; | |
sampler2D _BumpMap; | |
half _BumpScale; | |
half _Glossiness; | |
half _Metallic; | |
struct Input { | |
float2 uv_MainTex; | |
}; | |
void surf (Input IN, inout SurfaceOutputStandard o) { | |
fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color; | |
o.Albedo = c.rgb; | |
o.Metallic = _Metallic; | |
o.Smoothness = _Glossiness; | |
o.Alpha = c.a; | |
//BumpMapping | |
fixed4 n = tex2D (_BumpMap, IN.uv_MainTex); | |
o.Normal = UnpackScaleNormal(n, _BumpScale); | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment