Skip to content

Instantly share code, notes, and snippets.

@elringus
Created September 8, 2016 09:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elringus/64a3572f851abf1674aed86eeda08c8c to your computer and use it in GitHub Desktop.
Save elringus/64a3572f851abf1674aed86eeda08c8c to your computer and use it in GitHub Desktop.
Shader "BlendModes/Extra/DirectSurfMesh"
{
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 ComputeSurface DirectOnly vertex:ComputeVertex noambient noshadow novertexlights nolightmap nometa
fixed4 _Color;
sampler2D _MainTex;
sampler2D _GrabTexture;
struct Input
{
float2 uv_MainTex;
float4 GrabUV;
};
half4 LightingDirectOnly (SurfaceOutput surfaceOutput, half3 lightDir, half3 viewDir, half atten)
{
half4 color;
color.rgb = surfaceOutput.Albedo;
color.a = surfaceOutput.Alpha;
return color;
}
void ComputeVertex(inout appdata_full vertexInput, out Input vertexOutput)
{
UNITY_INITIALIZE_OUTPUT(Input, vertexOutput);
float4 hpos = mul(UNITY_MATRIX_MVP, vertexInput.vertex);
vertexOutput.GrabUV = ComputeGrabScreenPos(hpos);
}
void ComputeSurface(Input vertexOutput, inout SurfaceOutput surfaceOutput)
{
fixed4 texColor = tex2D(_MainTex, vertexOutput.uv_MainTex) * _Color;
fixed4 grabColor = tex2Dproj(_GrabTexture, UNITY_PROJ_COORD(vertexOutput.GrabUV));
#include "../BlendOps.cginc"
surfaceOutput.Albedo = lerp(grabColor, blendResult.rgb, texColor.a);
}
ENDCG
}
FallBack "Diffuse"
CustomEditor "BmMaterialEditor"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment