mirror of
https://github.com/drewcassidy/KSP-Conformal-Decals.git
synced 2024-09-01 18:23:54 +00:00
Backside shader
This commit is contained in:
parent
f95a8d909c
commit
6a25472d9c
81
Assets/Shaders/DecalBack.shader
Normal file
81
Assets/Shaders/DecalBack.shader
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
Shader "ConformalDecals/Decal Back"
|
||||||
|
{
|
||||||
|
Properties
|
||||||
|
{
|
||||||
|
[Header(Texture Maps)]
|
||||||
|
_MainTex("Main Tex (RGB spec(A))", 2D) = "gray" {}
|
||||||
|
_BumpMap("Normal Map", 2D) = "bump" {}
|
||||||
|
_Color ("Color", Color) = (1,1,1,1)
|
||||||
|
|
||||||
|
_RowOffset("Row Offset", Range (0, 1)) = 0.5
|
||||||
|
|
||||||
|
[Header(Specularity)]
|
||||||
|
_SpecColor ("_SpecColor", Color) = (0.5, 0.5, 0.5, 1)
|
||||||
|
_Shininess ("Shininess", Range (0.03, 10)) = 0.4
|
||||||
|
|
||||||
|
[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
|
||||||
|
}
|
||||||
|
|
||||||
|
SubShader
|
||||||
|
{
|
||||||
|
Tags { "RenderType"="Opaque" }
|
||||||
|
ZWrite On
|
||||||
|
ZTest LEqual
|
||||||
|
|
||||||
|
CGPROGRAM
|
||||||
|
|
||||||
|
#include "LightingKSP.cginc"
|
||||||
|
#pragma surface surf BlinnPhongSmooth
|
||||||
|
#pragma target 3.0
|
||||||
|
|
||||||
|
sampler2D _MainTex;
|
||||||
|
sampler2D _BumpMap;
|
||||||
|
|
||||||
|
half _RowOffset;
|
||||||
|
|
||||||
|
half _Shininess;
|
||||||
|
|
||||||
|
float _Opacity;
|
||||||
|
float _RimFalloff;
|
||||||
|
float4 _RimColor;
|
||||||
|
|
||||||
|
struct Input
|
||||||
|
{
|
||||||
|
float2 uv_MainTex;
|
||||||
|
float2 uv_BumpMap;
|
||||||
|
float3 viewDir;
|
||||||
|
float3 worldPos;
|
||||||
|
};
|
||||||
|
|
||||||
|
void surf (Input IN, inout SurfaceOutput o)
|
||||||
|
{
|
||||||
|
float2 uv_MainTex = IN.uv_MainTex;
|
||||||
|
float2 uv_BumpMap = IN.uv_BumpMap;
|
||||||
|
|
||||||
|
fixed row = floor(uv_MainTex.y);
|
||||||
|
uv_MainTex.x += row * _RowOffset;
|
||||||
|
|
||||||
|
float4 color = _Color * tex2D(_MainTex,(uv_MainTex));
|
||||||
|
float3 normal = UnpackNormal(tex2D(_BumpMap, uv_BumpMap));
|
||||||
|
|
||||||
|
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
|
||||||
|
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
|
||||||
|
|
||||||
|
float4 fog = UnderwaterFog(IN.worldPos, color);
|
||||||
|
|
||||||
|
o.Albedo = fog.rgb;
|
||||||
|
o.Emission = emission;
|
||||||
|
o.Gloss = color.a;
|
||||||
|
o.Specular = _Shininess;
|
||||||
|
o.Normal = normal;
|
||||||
|
o.Emission *= _Opacity * fog.a;
|
||||||
|
o.Alpha = _Opacity * fog.a;
|
||||||
|
}
|
||||||
|
ENDCG
|
||||||
|
}
|
||||||
|
Fallback "Standard"
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user