Last active
August 29, 2015 14:02
-
-
Save sugi-cho/e744b620944869d15257 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 "Custom/BrushTest" { | |
Properties { | |
_MainTex ("Base (RGB)", 2D) = "white" {} | |
_ShapeTex ("brush tex", 2D) = "white" {} | |
_Draw ("draw prop(s,y,size,alpha)",Vector) = (0,0,0,0) | |
} | |
SubShader { | |
Tags { "RenderType"="Opaque" } | |
LOD 200 | |
CGPROGRAM | |
#pragma surface surf Lambert | |
sampler2D _MainTex,_ShapeTex; | |
float4 _Draw; | |
half4 _MainTex_TexelSize; | |
struct Input { | |
float2 uv_MainTex; | |
}; | |
void surf (Input IN, inout SurfaceOutput o) { | |
half2 | |
pos = _Draw.xy, | |
size = _MainTex_TexelSize.xy * _Draw.z; | |
float2 | |
uv = IN.uv_MainTex, | |
uv2 = (uv - (pos - size * 0.5))/size; | |
half intencity = _Draw.a; | |
half4 | |
base = tex2D(_MainTex, uv), | |
draw = tex2D(_ShapeTex, uv2); | |
draw.a *= intencity; | |
o.Emission = lerp(base, draw, draw.a); | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment