-
Notifications
You must be signed in to change notification settings - Fork 96
/
SpecularBumpTransparent.shader
89 lines (70 loc) · 2.05 KB
/
SpecularBumpTransparent.shader
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
Shader "KSP/Bumped Specular (Transparent)"
{
Properties
{
_MainTex("_MainTex (RGB spec(A))", 2D) = "white" {}
_BumpMap("_BumpMap", 2D) = "bump" {}
_MainColor ("Main Color", Color) = (1,1,1,1)
_Shininess ("Shininess", Range (0.03, 1)) = 0.078125
_Opacity("_Opacity", Range(0,1) ) = 1
_Fresnel("Fresnel", Range(0,10)) = 0
[MaterialToggle] _FresnelInvert("Invert Fresnel", Float) = 0
_RimFalloff("_RimFalloff", Range(0.01,5) ) = 0.1
_RimColor("_RimColor", Color) = (0,0,0,0)
_TemperatureColor("_TemperatureColor", Color) = (0,0,0,0)
_BurnColor ("Burn Color", Color) = (1,1,1,1)
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
Pass
{
ZWrite On
ColorMask 0
}
//ZWrite On
ZTest LEqual
Blend SrcAlpha OneMinusSrcAlpha
CGPROGRAM
#include "LightingKSP.cginc"
#pragma surface surf BlinnPhongSmooth alpha:fade
#pragma target 3.0
half _Shininess;
sampler2D _MainTex;
sampler2D _BumpMap;
float4 _MainColor;
float _Opacity;
float _RimFalloff;
float4 _RimColor;
float4 _TemperatureColor;
float4 _BurnColor;
float _Fresnel;
float _FresnelInvert;
float _Brightness;
struct Input
{
float2 uv_MainTex;
float2 uv_BumpMap;
float2 uv_Emissive;
float3 viewDir;
};
void surf (Input IN, inout SurfaceOutput o)
{
float4 color = tex2D(_MainTex,(IN.uv_MainTex)) * _MainColor * _BurnColor;
float3 normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), normal));
float3 fresnel = (_FresnelInvert + (pow(1 - rim, _Fresnel))) * (1 - _FresnelInvert + 1 - (pow(1 - rim, _Fresnel)));
float3 emission = (_RimColor.rgb * pow(rim, _RimFalloff)) * _RimColor.a;
emission += _TemperatureColor.rgb * _TemperatureColor.a;
o.Albedo = color.rgb;
o.Emission = emission;
o.Gloss = color.a;
o.Specular = _Shininess;
o.Normal = normal;
o.Emission *= _Opacity;
o.Alpha = _Opacity * color.a * fresnel;
}
ENDCG
}
Fallback "Standard"
}