Skip to content

Commit b7c8d5b

Browse files
committed
Fix last issues with double ambient in KerbalKonstructs, and mismatching asphalt albedo between some KSC statics
1 parent 21130f9 commit b7c8d5b

4 files changed

Lines changed: 28 additions & 11 deletions

File tree

DeferredKSP/Deferred.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
using System;
66
using UnityEngine.SceneManagement;
77

8-
[assembly: AssemblyVersion("1.2.3")]
8+
[assembly: AssemblyVersion("1.2.4")]
99
[assembly: KSPAssemblyDependency("0Harmony", 0, 0)]
1010
[assembly: KSPAssemblyDependency("Shabby", 0, 0)]
1111
namespace Deferred

shaders/DeferredKSPShaders/Assets/Shaders/Replaced shaders/Scenery Shaders/DiffuseKSCGround.shader

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ Shader "KSP/Scenery/Diffuse Ground KSC"
5959

6060
void surf(Input i, inout SurfaceOutputStandard o)
6161
{
62+
_TarmacColor = min(_TarmacColor, float4(0.89.xxx, 1.0)); // hack to equalize mismatching color settings in the KSC
63+
6264
float4 groundColor = tex2D(_TarmacTexture,(i.uv_TarmacTexture));
6365
float blendMask = tex2D(_BlendMaskTexture,(i.uv2_BlendMaskTexture));
6466

shaders/DeferredKSPShaders/Assets/Shaders/Replaced shaders/Scenery Shaders/DiffuseKSCGroundSpecular.shader

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ Shader "KSP/Scenery/Diffuse Ground KSC Specular"
6767

6868
void surf(Input i, inout SurfaceOutputStandard o)
6969
{
70+
_TarmacColor = min(_TarmacColor, float4(0.89.xxx, 1.0)); // hack to equalize mismatching color settings in the KSC
71+
7072
float4 groundColor = tex2D(_TarmacTexture, i.uv_TarmacTexture);
7173
float3 groundNormal = UnpackNormalDXT5nm(tex2D(_TarmacNormal, i.uv_TarmacTexture));
7274
float blendMask = tex2D(_BlendMaskTexture,(i.uv2_BlendMaskTexture));

shaders/DeferredKSPShaders/Assets/Shaders/Replaced shaders/Scenery Shaders/DiffuseMultiply.shader

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -18,18 +18,31 @@
1818

1919
CGPROGRAM
2020
#include "../ReplacementShader.cginc"
21-
#pragma surface surf Standard
21+
#pragma surface surf Standard
2222
#pragma target 3.0
2323

24-
// This shader seems to ignore alpha channel smoothness and _Color property, not sure what's the point
25-
void surf (Input IN, inout SurfaceOutputStandard o)
26-
{
27-
o.Albedo = tex2D(_MainTex, IN.uv_MainTex);
28-
o.Smoothness = 0.5;
29-
o.Normal = float3(0.0,0.0,1.0);
30-
o.Metallic = 0.0;
31-
o.Alpha = 1.0;
32-
}
24+
// This shader seems to ignore alpha channel smoothness and _Color property, not sure what's the point
25+
void surf (Input IN, inout SurfaceOutputStandard o)
26+
{
27+
float4 _TarmacColor = float4(0.89.xxx, 1.0); // hack to equalize mismatching color settings in the KSC
28+
29+
float4 groundColor = tex2D(_MainTex, IN.uv_MainTex) * _TarmacColor;
30+
31+
o.Albedo = groundColor.rgb;
32+
o.Smoothness = 0.25 * sqrt(max(groundColor.a, 0.0000001)); // match shading in DiffuseKSCGroundSpecular
33+
o.Normal = float3(0.0,0.0,1.0);
34+
o.Metallic = 0.0;
35+
o.Alpha = 1.0;
36+
37+
#if UNITY_PASS_DEFERRED
38+
// In deferred rendering do not use the flat ambient because Deferred adds its own ambient as a composite of flat ambient and probe
39+
// Also do not use #pragma skip_variants LIGHTPROBE_SH because it impacts lighting in forward and some elements can still render in
40+
// forward e.g through the VAB scene doors
41+
unity_SHAr = 0.0.xxxx;
42+
unity_SHAg = 0.0.xxxx;
43+
unity_SHAb = 0.0.xxxx;
44+
#endif
45+
}
3346

3447
ENDCG
3548
}

0 commit comments

Comments
 (0)