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-06-17 23:41:55 +00:00
|
|
|
_Decal("Decal Texture", 2D) = "gray" {}
|
|
|
|
_DecalBumpMap("Decal Bump Map", 2D) = "bump" {}
|
|
|
|
|
|
|
|
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.5
|
|
|
|
_DecalOpacity("Opacity", Range(0,1) ) = 1
|
|
|
|
_Background("Background Color", Color) = (0.9,0.9,0.9,0.7)
|
|
|
|
|
2020-06-06 04:26:57 +00:00
|
|
|
[Enum(UnityEngine.Rendering.CullMode)] _Cull ("Cull", int) = 2
|
|
|
|
[Toggle(DECAL_PREVIEW)] _Preview ("Preview", int) = 0
|
2020-06-17 23:41:55 +00:00
|
|
|
|
|
|
|
[Header(Effects)]
|
|
|
|
[PerRendererData]_Opacity("_Opacity", Range(0,1) ) = 1
|
|
|
|
[PerRendererData]_Color("_Color", Color) = (1,1,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-06-01 01:25:29 +00:00
|
|
|
Tags { "Queue" = "Geometry+100" }
|
2020-06-04 07:12:09 +00:00
|
|
|
Cull [_Cull]
|
|
|
|
Ztest LEqual
|
|
|
|
|
2020-05-22 06:38:49 +00:00
|
|
|
Pass
|
|
|
|
{
|
|
|
|
Name "FORWARD"
|
2020-06-17 23:41:55 +00:00
|
|
|
Tags { "LightMode" = "ForwardBase" }
|
|
|
|
Blend SrcAlpha OneMinusSrcAlpha
|
2020-05-22 06:38:49 +00:00
|
|
|
|
|
|
|
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-06-04 07:12:09 +00:00
|
|
|
#pragma multi_compile DECAL_PROJECT DECAL_PREVIEW
|
2020-05-22 06:38:49 +00:00
|
|
|
|
2020-05-24 18:41:09 +00:00
|
|
|
sampler2D _Decal;
|
2020-06-04 07:12:09 +00:00
|
|
|
sampler2D _DecalBumpMap;
|
2020-05-25 01:09:03 +00:00
|
|
|
|
|
|
|
float4 _Decal_ST;
|
2020-06-04 07:12:09 +00:00
|
|
|
float4 _DecalBumpMap_ST;
|
|
|
|
|
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-06-10 04:13:36 +00:00
|
|
|
float3 normal = UnpackNormalDXT5nm(tex2D(_DecalBumpMap, IN.uv_bump));
|
2020-05-25 01:09:03 +00:00
|
|
|
|
2020-06-12 05:02:13 +00:00
|
|
|
decalClipAlpha(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-06-04 07:12:09 +00:00
|
|
|
o.Alpha = color.a * _DecalOpacity;
|
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"
|
2020-06-17 23:41:55 +00:00
|
|
|
Tags { "LightMode" = "ForwardAdd" }
|
|
|
|
Blend One One
|
2020-05-24 18:41:09 +00:00
|
|
|
|
|
|
|
CGPROGRAM
|
|
|
|
#pragma vertex vert_forward
|
|
|
|
#pragma fragment frag_forward
|
|
|
|
|
|
|
|
#pragma multi_compile_fwdadd nolightmap nodirlightmap nodynlightmap
|
2020-06-04 07:12:09 +00:00
|
|
|
#pragma multi_compile DECAL_PROJECT DECAL_PREVIEW
|
2020-05-24 18:41:09 +00:00
|
|
|
|
2020-05-22 06:38:49 +00:00
|
|
|
sampler2D _Decal;
|
2020-06-04 07:12:09 +00:00
|
|
|
sampler2D _DecalBumpMap;
|
2020-05-22 06:38:49 +00:00
|
|
|
|
2020-05-25 01:09:03 +00:00
|
|
|
float4 _Decal_ST;
|
2020-06-04 07:12:09 +00:00
|
|
|
float4 _DecalBumpMap_ST;
|
2020-05-25 01:16:23 +00:00
|
|
|
|
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-06-04 07:12:09 +00:00
|
|
|
float3 normal = UnpackNormal(tex2D(_DecalBumpMap, IN.uv_bump));
|
2020-05-25 01:09:03 +00:00
|
|
|
|
2020-06-12 05:02:13 +00:00
|
|
|
decalClipAlpha(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-06-04 07:12:09 +00:00
|
|
|
o.Alpha = color.a * _DecalOpacity;
|
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"
|
|
|
|
}
|
2020-06-17 23:41:55 +00:00
|
|
|
}
|