Created
September 7, 2018 04:14
-
-
Save TheStoneBook/693de17af000dc50a4a7fa116ca4ddad 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 "Unlit/Reversible" | |
{ | |
Properties | |
{ | |
_MainTexA ("TextureA", 2D) = "white" {} | |
_MainTexB ("TextureB", 2D) = "white" {} | |
} | |
SubShader | |
{ | |
Tags { "RenderType"="Opaque" } | |
LOD 100 | |
Cull off//カリング処理をOFFに。 | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct v2f | |
{ | |
float2 uv : TEXCOORD0; | |
float4 vertex : SV_POSITION; | |
}; | |
sampler2D _MainTexA; | |
sampler2D _MainTexB; | |
float4 _MainTex_ST; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.vertex = UnityObjectToClipPos(v.vertex); | |
o.uv = v.uv; | |
return o; | |
} | |
fixed4 frag (v2f i, fixed facing : VFACE) : SV_Target | |
{ | |
return (facing > 0) ? tex2D(_MainTexA, i.uv) : tex2D(_MainTexB, i.uv); | |
//facing>0の時は表、facing<=0の時は裏 | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment