2020-05-24 17:46:50 +00:00
|
|
|
Shader "ConformalDecals/Feature/Bumped"
|
2020-05-22 06:38:49 +00:00
|
|
|
{
|
|
|
|
Properties
|
|
|
|
{
|
2020-05-24 23:48:37 +00:00
|
|
|
[Header(Texture Maps)]
|
2020-05-22 06:38:49 +00:00
|
|
|
_Decal("Decal Texture", 2D) = "gray" {}
|
2020-05-25 17:35:32 +00:00
|
|
|
_BumpMap("Decal Bump Map", 2D) = "bump" {}
|
2020-05-22 06:38:49 +00:00
|
|
|
|
|
|
|
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
|
|
|
_Opacity("_Opacity", Range(0,1) ) = 1
|
2020-05-24 23:48:37 +00:00
|
|
|
|
|
|
|
[Header(Effects)]
|
|
|
|
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
|
|
|
[PerRendererData]_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
|
|
|
|
[PerRendererData]_RimColor("_RimColor", Color) = (0,0,0,0)
|
|
|
|
[PerRendererData]_UnderwaterFogFactor ("Underwater Fog Factor", Range(0,1)) = 0
|
2020-05-22 06:38:49 +00:00
|
|
|
}
|
|
|
|
SubShader
|
|
|
|
{
|
2020-05-24 04:52:39 +00:00
|
|
|
Tags { "Queue" = "Geometry+400" }
|
2020-05-22 06:38:49 +00:00
|
|
|
ZWrite Off
|
|
|
|
ZTest LEqual
|
2020-05-24 04:52:39 +00:00
|
|
|
Offset -1, -1
|
2020-05-22 06:38:49 +00:00
|
|
|
|
|
|
|
Pass
|
|
|
|
{
|
|
|
|
Name "FORWARD"
|
|
|
|
Tags { "LightMode" = "ForwardBase" }
|
|
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
|
|
|
|
|
|
|
CGPROGRAM
|
2020-05-24 18:41:09 +00:00
|
|
|
#pragma vertex vert_forward
|
|
|
|
#pragma fragment frag_forward
|
2020-05-22 06:38:49 +00:00
|
|
|
|
2020-05-24 17:46:50 +00:00
|
|
|
#pragma multi_compile_fwdbase nolightmap nodirlightmap nodynlightmap
|
2020-05-22 06:38:49 +00:00
|
|
|
|
2020-05-24 18:41:09 +00:00
|
|
|
sampler2D _Decal;
|
2020-05-25 17:35:32 +00:00
|
|
|
sampler2D _BumpMap;
|
2020-05-25 01:09:03 +00:00
|
|
|
|
|
|
|
float4 _Decal_ST;
|
2020-05-25 17:35:32 +00:00
|
|
|
float4 _BumpMap_ST;
|
2020-05-24 23:48:37 +00:00
|
|
|
|
2020-05-24 18:41:09 +00:00
|
|
|
float _Cutoff;
|
|
|
|
float _Opacity;
|
2020-05-24 23:48:37 +00:00
|
|
|
float _RimFalloff;
|
2020-05-25 01:16:23 +00:00
|
|
|
float4 _RimColor;
|
|
|
|
|
2020-05-25 17:35:32 +00:00
|
|
|
#define DECAL_NORMAL
|
|
|
|
|
2020-05-25 01:16:23 +00:00
|
|
|
#include "UnityCG.cginc"
|
|
|
|
#include "Lighting.cginc"
|
|
|
|
#include "AutoLight.cginc"
|
|
|
|
#include "LightingKSP.cginc"
|
|
|
|
#include "DecalsCommon.cginc"
|
2020-05-24 18:41:09 +00:00
|
|
|
|
|
|
|
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
|
|
|
{
|
2020-05-25 01:16:23 +00:00
|
|
|
float4 color = tex2D(_Decal, IN.uv_decal);
|
2020-05-25 17:35:32 +00:00
|
|
|
float3 normal = UnpackNormal(tex2D(_BumpMap, IN.uv_bump));
|
2020-05-25 01:09:03 +00:00
|
|
|
|
2020-05-24 23:48:37 +00:00
|
|
|
// clip alpha
|
2020-05-24 23:05:29 +00:00
|
|
|
clip(color.a - _Cutoff);
|
2020-05-24 18:41:09 +00:00
|
|
|
|
2020-05-25 01:09:03 +00:00
|
|
|
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
|
|
|
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
|
|
|
|
2020-05-24 23:48:37 +00:00
|
|
|
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
2020-05-24 18:41:09 +00:00
|
|
|
o.Alpha = color.a * _Opacity;
|
2020-05-24 23:48:37 +00:00
|
|
|
o.Emission = emission;
|
2020-05-25 01:09:03 +00:00
|
|
|
o.Normal = normal;
|
2020-05-24 18:41:09 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ENDCG
|
|
|
|
}
|
|
|
|
|
|
|
|
Pass
|
|
|
|
{
|
|
|
|
Name "FORWARD"
|
|
|
|
Tags { "LightMode" = "ForwardAdd" }
|
|
|
|
Blend One One
|
|
|
|
|
|
|
|
CGPROGRAM
|
|
|
|
#pragma vertex vert_forward
|
|
|
|
#pragma fragment frag_forward
|
|
|
|
|
|
|
|
#pragma multi_compile_fwdadd nolightmap nodirlightmap nodynlightmap
|
|
|
|
|
2020-05-22 06:38:49 +00:00
|
|
|
sampler2D _Decal;
|
2020-05-25 17:35:32 +00:00
|
|
|
sampler2D _BumpMap;
|
2020-05-22 06:38:49 +00:00
|
|
|
|
2020-05-25 01:09:03 +00:00
|
|
|
float4 _Decal_ST;
|
2020-05-25 17:35:32 +00:00
|
|
|
float4 _BumpMap_ST;
|
2020-05-25 01:16:23 +00:00
|
|
|
|
2020-05-22 06:38:49 +00:00
|
|
|
float _Cutoff;
|
|
|
|
float _Opacity;
|
2020-05-24 23:48:37 +00:00
|
|
|
float _RimFalloff;
|
2020-05-25 01:16:23 +00:00
|
|
|
float4 _RimColor;
|
|
|
|
|
2020-05-25 17:35:32 +00:00
|
|
|
#define DECAL_NORMAL
|
|
|
|
|
2020-05-25 01:16:23 +00:00
|
|
|
#include "UnityCG.cginc"
|
|
|
|
#include "Lighting.cginc"
|
|
|
|
#include "AutoLight.cginc"
|
|
|
|
#include "LightingKSP.cginc"
|
|
|
|
#include "DecalsCommon.cginc"
|
2020-05-22 06:38:49 +00:00
|
|
|
|
|
|
|
void surf (DecalSurfaceInput IN, inout SurfaceOutput o)
|
|
|
|
{
|
2020-05-25 01:16:23 +00:00
|
|
|
float4 color = tex2D(_Decal, IN.uv_decal);
|
2020-05-25 17:35:32 +00:00
|
|
|
float3 normal = UnpackNormal(tex2D(_BumpMap, IN.uv_bump));
|
2020-05-25 01:09:03 +00:00
|
|
|
|
2020-05-24 23:48:37 +00:00
|
|
|
// clip alpha
|
2020-05-24 23:05:29 +00:00
|
|
|
clip(color.a - _Cutoff);
|
2020-05-22 06:38:49 +00:00
|
|
|
|
2020-05-25 01:09:03 +00:00
|
|
|
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
|
|
|
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
|
|
|
|
2020-05-24 23:48:37 +00:00
|
|
|
o.Albedo = UnderwaterFog(IN.worldPosition, color).rgb;
|
2020-05-24 05:10:27 +00:00
|
|
|
o.Alpha = color.a * _Opacity;
|
2020-05-24 23:48:37 +00:00
|
|
|
o.Emission = emission;
|
2020-05-25 01:09:03 +00:00
|
|
|
o.Normal = normal;
|
2020-05-22 06:38:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ENDCG
|
|
|
|
}
|
|
|
|
|
|
|
|
// shadow casting support
|
|
|
|
UsePass "Legacy Shaders/VertexLit/SHADOWCASTER"
|
|
|
|
}
|
|
|
|
}
|