Created
December 12, 2015 01:25
-
-
Save whaison/2a61364c4d035133debe 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 "NewUnlitShader02" | |
{ | |
Properties | |
{ | |
_MainTex ("RenderTex", 2D) = "white" {} | |
_DecalATex ("DecalATex", 2D) = "white" {} | |
_DecalBTex ("DecalBTex", 2D) = "white" {} | |
} | |
SubShader | |
{ | |
Tags { "RenderType"="Opaque" } | |
//LOD 100 | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
// make fog work | |
#pragma multi_compile_fog | |
#include "UnityCG.cginc" | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct v2f | |
{ | |
float2 uv : TEXCOORD0; | |
UNITY_FOG_COORDS(1) | |
float4 vertex : SV_POSITION; | |
}; | |
sampler2D _MainTex; | |
float4 _MainTex_ST; | |
//////////////////////////////paint | |
//sampler2D _MainTex; | |
sampler2D _DecalATex; | |
sampler2D _DecalBTex; | |
////////////////////////////////paint | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex); | |
o.uv = TRANSFORM_TEX(v.uv, _MainTex); | |
UNITY_TRANSFER_FOG(o,o.vertex); | |
return o; | |
} | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
// sample the texture | |
fixed4 col = tex2D(_MainTex, i.uv); | |
// apply fog | |
UNITY_APPLY_FOG(i.fogCoord, col); | |
///////////////GLSL | |
float2 resolution=float2(512.0, 512.0); | |
//float2 p =i.uv/resolution; | |
//float2 p =i.uv; | |
float2 p =i.uv/2; | |
/////////////////////////座標を正規化し、0.0 〜 1.0 の範囲に収まるように変換する。 | |
p =float2(-p.x+0.5,-p.y+0.5)/2; | |
p =float2(p.x+0.5,p.y+0.5);///////////sample_05.frag | |
col = fixed4(p.x,p.y, 1.0, 1.0); | |
///////////////GLSL | |
/////////paint | |
float2 uv_Field = float2(p.x,p.y); | |
float3 renderTexCol = tex2D (_MainTex, uv_Field).rrr; | |
float3 decalACol = tex2D (_DecalATex, uv_Field).rgb; | |
float3 decalBCol = tex2D (_DecalBTex, uv_Field).rgb; | |
float3 dA=(decalACol*renderTexCol); | |
float3 dB=(decalBCol*(1-renderTexCol)); | |
float3 albed=dA+dB; | |
col = fixed4(albed.r,albed.g,albed.b,1.0) ; | |
///////paint end | |
return col; | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment