Last active
May 8, 2017 10:54
-
-
Save elringus/7790892b9608e8a30180b7b8f70707f0 to your computer and use it in GitHub Desktop.
Surf mesh blend mode shader with shadows
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 "BlendModes/MeshDefault/Grab" | |
{ | |
Properties | |
{ | |
_Color("Tint Color", Color) = (1,1,1,1) | |
_MainTex("Base (RGB)", 2D) = "white" {} | |
} | |
SubShader | |
{ | |
Tags { "Queue" = "AlphaTest" "IgnoreProjector" = "True" } | |
LOD 200 | |
GrabPass { } | |
CGPROGRAM | |
#include "UnityCG.cginc" | |
#include "../BlendModes.cginc" | |
#pragma target 3.0 | |
#pragma multi_compile BmDarken BmMultiply BmColorBurn BmLinearBurn BmDarkerColor BmLighten BmScreen BmColorDodge BmLinearDodge BmLighterColor BmOverlay BmSoftLight BmHardLight BmVividLight BmLinearLight BmPinLight BmHardMix BmDifference BmExclusion BmSubtract BmDivide BmHue BmSaturation BmColor BmLuminosity | |
#pragma surface surf Lambert vertex:vert | |
fixed4 _Color; | |
sampler2D _MainTex; | |
sampler2D _GrabTexture; | |
struct Input | |
{ | |
float2 uv_MainTex; | |
float4 grabUV; | |
}; | |
void vert(inout appdata_full v, out Input o) | |
{ | |
UNITY_INITIALIZE_OUTPUT(Input, o); | |
float4 hpos = mul(UNITY_MATRIX_MVP, v.vertex); | |
o.grabUV = ComputeGrabScreenPos(hpos); | |
} | |
void surf(Input IN, inout SurfaceOutput o) | |
{ | |
fixed4 texColor = tex2D(_MainTex, IN.uv_MainTex) * _Color; | |
fixed4 grabColor = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(IN.grabUV)); | |
#include "../BlendOps.cginc" | |
o.Albedo = blendResult.rgb; | |
} | |
ENDCG | |
} | |
FallBack "Diffuse" | |
CustomEditor "BmMaterialEditor" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment