Skip to content

Commit 81645c2

Browse files
authored
Added RimLight and OcclusionStrength
1 parent 6fbc201 commit 81645c2

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

Assets/KSP2UnityTools/Shaders/KSP2/Parts/Paintable.shader

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ Shader "KSP2/Parts/Paintable"
4646
struct Input
4747
{
4848
float2 uv_MainTex;
49+
float3 viewDir;
4950
};
5051

5152
fixed4 _Color;
@@ -59,6 +60,7 @@ Shader "KSP2/Parts/Paintable"
5960
sampler2D _BumpMap;
6061

6162
sampler2D _OcclusionMap;
63+
half _OcclusionStrength;
6264
sampler2D _EmissionMap;
6365
fixed4 _EmissionColor;
6466

@@ -68,6 +70,9 @@ Shader "KSP2/Parts/Paintable"
6870
float _PaintGlossMapScale;
6971
bool _SmoothnessOverride;
7072

73+
fixed4 _RimColor;
74+
float _RimFalloff;
75+
7176

7277
// Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
7378
// See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
@@ -97,9 +102,13 @@ Shader "KSP2/Parts/Paintable"
97102
o.Albedo = c;
98103
o.Metallic = MetallicValue.a;
99104
o.Smoothness = _Metallic * _GlossMapScale;
100-
o.Emission = tex2D(_EmissionMap, IN.uv_MainTex) * _EmissionColor;
101-
o.Occlusion = tex2D(_OcclusionMap, IN.uv_MainTex);
102105
o.Normal = UnpackNormal (tex2D(_BumpMap, IN.uv_MainTex));
106+
o.Occlusion = tex2D(_OcclusionMap, IN.uv_MainTex);
107+
o.Occlusion = o.Occlusion * _OcclusionStrength;
108+
109+
half rim = 1.0 - saturate(dot (normalize(IN.viewDir), o.Normal));
110+
o.Emission = tex2D(_EmissionMap, IN.uv_MainTex) * _EmissionColor + (_RimColor.rgb * pow (rim, _RimFalloff));
111+
103112
}
104113
ENDCG
105114
}

0 commit comments

Comments
 (0)