Last active
December 12, 2015 01:26
-
-
Save whaison/ae71aeded1db075b476e to your computer and use it in GitHub Desktop.
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 "SelectDecalMap3" { | |
Properties { | |
_MainTex ("RenderTex", 2D) = "white" {} | |
_GrandTex ("_GrandTex", 2D) = "white" {} | |
_DecalATex ("_DecalATex", 2D) = "white" {} | |
_DecalBTex ("_DecalBTex", 2D) = "white" {} | |
_DecalCTex ("_DecalCTex", 2D) = "white" {} | |
} | |
SubShader { | |
Tags { "RenderType" = "Opaque" } | |
CGPROGRAM | |
#pragma surface surf Lambert | |
struct Input { | |
float3 worldPos; | |
float2 uv_MainTex; | |
}; | |
sampler2D _MainTex; | |
sampler2D _GrandTex; | |
sampler2D _DecalATex; | |
sampler2D _DecalBTex; | |
sampler2D _DecalCTex; | |
void surf (Input In, inout SurfaceOutput o) { | |
float3 tmp = (In.worldPos + float3(5,0,5)) * 0.1f;// 位置をUV空間に フィールドが原点配置10x10のため | |
float2 uv_Field = float2(tmp.x,tmp.z); | |
float3 renderTexColG = tex2D (_MainTex, uv_Field).rrr; | |
float3 renderTexColA = tex2D (_MainTex, uv_Field).rrr; | |
float3 renderTexColB = tex2D (_MainTex, uv_Field).ggg; | |
float3 renderTexColC = tex2D (_MainTex, uv_Field).bbb; | |
float3 decalGCol = tex2D (_GrandTex, In.uv_MainTex).rgb; | |
float3 decalACol = tex2D (_DecalATex, In.uv_MainTex).rgb; | |
float3 decalBCol = tex2D (_DecalBTex, In.uv_MainTex).rgb; | |
float3 decalCCol = tex2D (_DecalCTex, In.uv_MainTex).rgb; | |
float3 dG=(decalGCol*(1-renderTexColG));//(decalACol*renderTexColG); | |
float3 dA=(decalACol*renderTexColA); | |
float3 dB=(decalACol*renderTexColB); | |
float3 dC=(decalACol*renderTexColC); //(decalGCol*(1-renderTexColG)); | |
o.Albedo =(dA+dB+dC)/3+dG; | |
//o.Albedo =(decalACol*renderTexColA) + (decalGCol*(1-renderTexColG)); | |
} | |
ENDCG | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment