From b3a8f1fa55d4938a5d410f37d3460f6bad71a781 Mon Sep 17 00:00:00 2001 From: Lionel Bischof Date: Thu, 22 Mar 2018 21:26:44 +0100 Subject: [PATCH] Saturation separate for Aircraft/Cockpit --- OpenShade/MainWindow.xaml.cs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/OpenShade/MainWindow.xaml.cs b/OpenShade/MainWindow.xaml.cs index 2010104..cef2482 100644 --- a/OpenShade/MainWindow.xaml.cs +++ b/OpenShade/MainWindow.xaml.cs @@ -1202,7 +1202,15 @@ private void ApplyPreset(object sender, RoutedEventArgs e) #endif {finalText}"); - generalText = generalText.AddBefore(ref success, "// Apply IR if active", "if ((cb_mObjectType == (uint)0) || (cb_mObjectType == (uint)19))\r\n {\r\n cColor.rgb = saturate(lerp(dot(cColor.rgb, float3(0.299f, 0.587f, 0.114f)), cColor.rgb, " + tweak.parameters[4].value.ToString() + "));\r\n }\r\n"); + generalText = generalText.AddBefore(ref success, "// Apply IR if active", $@"if ((cb_mObjectType == (uint)0) || (cb_mObjectType == (uint)19)) +{{ + #if defined(PS_NEEDS_TANSPACE) + cColor.rgb = saturate(lerp(dot(cColor.rgb, float3(0.299f, 0.587f, 0.114f)), cColor.rgb, {tweak.parameters[4].value})); + #else + cColor.rgb = saturate(lerp(dot(cColor.rgb, float3(0.299f, 0.587f, 0.114f)), cColor.rgb, 1)); + #endif +}} +"); break; } @@ -1251,6 +1259,8 @@ private void ApplyPreset(object sender, RoutedEventArgs e) Tweak aircraft = tweaks.First(p => p.name == "Aircraft lighting and saturation"); if (aircraft.isEnabled) { generalText = generalText.ReplaceFirst(ref success, replaceText, $"DirectionalLightingTweak(vNormalWS, shadowContrib, { tweak.parameters[0].value}, { tweak.parameters[1].value}, { tweak.parameters[2].value}, { tweak.parameters[3].value}, directionalDiffuse);"); + + generalText = generalText.ReplaceFirst(ref success, "cColor.rgb = saturate(lerp(dot(cColor.rgb, float3(0.299f, 0.587f, 0.114f)), cColor.rgb, 1));", $"cColor.rgb = saturate(lerp(dot(cColor.rgb, float3(0.299f, 0.587f, 0.114f)), cColor.rgb, {tweak.parameters[4].value}));"); } else { // 1st - VC/interior @@ -1266,7 +1276,16 @@ private void ApplyPreset(object sender, RoutedEventArgs e) #endif {finalText}"); - generalText = generalText.AddBefore(ref success, "// Apply IR if active", "if ((cb_mObjectType == (uint)0) || (cb_mObjectType == (uint)19))\r\n {\r\n cColor.rgb = saturate(lerp(dot(cColor.rgb, float3(0.299f, 0.587f, 0.114f)), cColor.rgb, " + tweak.parameters[4].value.ToString() + "));\r\n }\r\n"); + generalText = generalText.AddBefore(ref success, "// Apply IR if active", $@"if ((cb_mObjectType == (uint)0) || (cb_mObjectType == (uint)19)) +{{ + #if !defined(PS_NEEDS_TANSPACE) + cColor.rgb = saturate(lerp(dot(cColor.rgb, float3(0.299f, 0.587f, 0.114f)), cColor.rgb, {tweak.parameters[4].value})); + #else + cColor.rgb = saturate(lerp(dot(cColor.rgb, float3(0.299f, 0.587f, 0.114f)), cColor.rgb, 1)); + #endif +}} +"); + } break;