From c84f52beae59c18c3c00d75b100b6b738f170714 Mon Sep 17 00:00:00 2001 From: ArcEarth Date: Sun, 27 Oct 2024 07:05:09 +0000 Subject: [PATCH] =?UTF-8?q?style:=20=F0=9F=8E=A8=20apply=20clang-format=20?= =?UTF-8?q?changes?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ExtendedTranslucency.hlsli | 8 ++-- package/Shaders/Lighting.hlsl | 20 +++++----- src/Features/ExtendedTranslucency.cpp | 39 ++++++++----------- src/Features/ExtendedTranslucency.h | 12 +++--- 4 files changed, 36 insertions(+), 43 deletions(-) diff --git a/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli b/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli index e5449dcea..df821a806 100644 --- a/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli +++ b/features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli @@ -1,9 +1,9 @@ cbuffer ExtendedTranslucencyPerGeometry : register(b7) { - uint AnisotropicAlphaFlags; - float AnisotropicAlphaReduction; - float AnisotropicAlphaSoftness; - float AnisotropicAlphaStrength; + uint AnisotropicAlphaFlags; + float AnisotropicAlphaReduction; + float AnisotropicAlphaSoftness; + float AnisotropicAlphaStrength; }; namespace ExtendedTransclucency diff --git a/package/Shaders/Lighting.hlsl b/package/Shaders/Lighting.hlsl index ede5f5cdc..51b20f61c 100644 --- a/package/Shaders/Lighting.hlsl +++ b/package/Shaders/Lighting.hlsl @@ -401,12 +401,12 @@ struct PS_OUTPUT #else struct PS_OUTPUT { - float4 Diffuse : SV_Target0; - float4 MotionVectors : SV_Target1; - float4 ScreenSpaceNormals : SV_Target2; -#if defined(SNOW) + float4 Diffuse : SV_Target0; + float4 MotionVectors : SV_Target1; + float4 ScreenSpaceNormals : SV_Target2; +# if defined(SNOW) float4 Parameters : SV_Target3; -#endif +# endif }; #endif @@ -2607,17 +2607,17 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace } # endif // DO_ALPHA_TEST -# if defined(EXTENDED_TRANSLUCENCY) && !(defined(SKIN) || defined(HAIR) || defined(EYE) || defined(TREE_ANIM) || defined(LODOBJECTSHD) || defined(LODOBJECTS)) +# if defined(EXTENDED_TRANSLUCENCY) && !(defined(SKIN) || defined(HAIR) || defined(EYE) || defined(TREE_ANIM) || defined(LODOBJECTSHD) || defined(LODOBJECTS)) if (AnisotropicAlphaFlags > 0) { if (alpha >= 0.0156862754 && alpha < 1.0) { float originalAlpha = alpha; alpha = alpha * (1.0 - AnisotropicAlphaReduction); if (AnisotropicAlphaFlags == 3) { -#if defined(SKINNED) || !defined(MODELSPACENORMALS) +# if defined(SKINNED) || !defined(MODELSPACENORMALS) alpha = ExtendedTransclucency::GetViewDependentAlphaFabric2D(alpha, viewDirection, tbnTr); -# else +# else alpha = ExtendedTransclucency::GetViewDependentAlphaFabric1D(alpha, viewDirection, modelNormal.xyz); -# endif +# endif } else if (AnisotropicAlphaFlags == 2) { alpha = ExtendedTransclucency::GetViewDependentAlphaFabric1D(alpha, viewDirection, modelNormal.xyz); } else { @@ -2627,7 +2627,7 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace alpha = lerp(alpha, originalAlpha, AnisotropicAlphaStrength); } } -#endif // EXTENDED_TRANSLUCENCY +# endif // EXTENDED_TRANSLUCENCY psout.Diffuse.w = alpha; diff --git a/src/Features/ExtendedTranslucency.cpp b/src/Features/ExtendedTranslucency.cpp index 6182733c9..5fc382172 100644 --- a/src/Features/ExtendedTranslucency.cpp +++ b/src/Features/ExtendedTranslucency.cpp @@ -6,8 +6,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT( ExtendedTranslucency::MaterialParams, AlphaMode, AlphaReduction, - AlphaSoftness -); + AlphaSoftness); const RE::BSFixedString ExtendedTranslucency::NiExtraDataName = "AnisotropicAlphaMaterial"; @@ -54,9 +53,9 @@ void ExtendedTranslucency::BSLightingShader_SetupGeometry(RE::BSRenderPass* pass } else { //if (!isDefaultCB) //{ - //isDefaultCB = true; - buffers[0] = materialDefaultCB->CB(); - context->PSSetConstantBuffers(materialCBIndex, 1, buffers); + //isDefaultCB = true; + buffers[0] = materialDefaultCB->CB(); + context->PSSetConstantBuffers(materialCBIndex, 1, buffers); //} } } @@ -96,29 +95,26 @@ void ExtendedTranslucency::DrawSettings() }; bool changed = false; - if (ImGui::Combo("Default Material Model", (int*)&settings.AlphaMode, AlphaModeNames, 4)) - { + if (ImGui::Combo("Default Material Model", (int*)&settings.AlphaMode, AlphaModeNames, 4)) { changed = true; } if (auto _tt = Util::HoverTooltipWrapper()) { - ImGui::Text("Anisotropic transluency will make the surface more opaque when you view it parallel to the surface.\n" - " - Disabled: No anisotropic transluency\n" - " - Rim Light: Naive rim light effect\n" - " - Isotropic Fabric: Imaginary fabric weaved from threads in one direction, respect normal map.\n" - " - Anisotropic Fabric: Common fabric weaved from tangent and birnormal direction, ignores normal map.\n" - ); + ImGui::Text( + "Anisotropic transluency will make the surface more opaque when you view it parallel to the surface.\n" + " - Disabled: No anisotropic transluency\n" + " - Rim Light: Naive rim light effect\n" + " - Isotropic Fabric: Imaginary fabric weaved from threads in one direction, respect normal map.\n" + " - Anisotropic Fabric: Common fabric weaved from tangent and birnormal direction, ignores normal map.\n"); } - if (ImGui::SliderFloat("Default Material Transparency Increase", &settings.AlphaReduction, 0.f, 1.f)) - { + if (ImGui::SliderFloat("Default Material Transparency Increase", &settings.AlphaReduction, 0.f, 1.f)) { changed = true; } if (auto _tt = Util::HoverTooltipWrapper()) { ImGui::Text("Anisotropic transluency will make the material more opaque on average, which could be different from the intent, reduce the alpha to counter this effect and increase the dynamic range of the output."); } - if (ImGui::SliderFloat("Softness", &settings.AlphaSoftness, 0.0f, 1.0f)) - { + if (ImGui::SliderFloat("Softness", &settings.AlphaSoftness, 0.0f, 1.0f)) { changed = true; } if (auto _tt = Util::HoverTooltipWrapper()) { @@ -132,8 +128,7 @@ void ExtendedTranslucency::DrawSettings() ImGui::Text("Control the blend weight of the effect applied to the final result."); } - if (changed && materialDefaultCB) - { + if (changed && materialDefaultCB) { materialDefaultCB->Update(settings); } @@ -146,8 +141,7 @@ void ExtendedTranslucency::DrawSettings() void ExtendedTranslucency::LoadSettings(json& o_json) { settings = o_json; - if (materialDefaultCB) - { + if (materialDefaultCB) { materialDefaultCB->Update(settings); } } @@ -160,8 +154,7 @@ void ExtendedTranslucency::SaveSettings(json& o_json) void ExtendedTranslucency::RestoreDefaultSettings() { settings = {}; - if (materialDefaultCB) - { + if (materialDefaultCB) { materialDefaultCB->Update(settings); } } \ No newline at end of file diff --git a/src/Features/ExtendedTranslucency.h b/src/Features/ExtendedTranslucency.h index 2f37b722d..14e113f79 100644 --- a/src/Features/ExtendedTranslucency.h +++ b/src/Features/ExtendedTranslucency.h @@ -1,7 +1,7 @@ #pragma once -#include "../Feature.h" #include "../Buffer.h" +#include "../Feature.h" struct ExtendedTranslucency final : Feature { @@ -10,7 +10,7 @@ struct ExtendedTranslucency final : Feature virtual inline std::string GetName() override { return "Extended Translucency"; } virtual inline std::string GetShortName() override { return "ExtendedTranslucency"; } virtual inline std::string_view GetShaderDefineName() override { return "EXTENDED_TRANSLUCENCY"; } - virtual bool HasShaderDefine(RE::BSShader::Type shaderType) override { return RE::BSShader::Type::Lighting == shaderType;}; + virtual bool HasShaderDefine(RE::BSShader::Type shaderType) override { return RE::BSShader::Type::Lighting == shaderType; }; virtual void SetupResources() override; virtual void PostPostLoad() override; virtual void DrawSettings() override; @@ -34,10 +34,10 @@ struct ExtendedTranslucency final : Feature struct alignas(16) MaterialParams { - uint32_t AlphaMode = std::to_underlying(MaterialModel::Default); - float AlphaReduction = 0.15f; - float AlphaSoftness = 0.f; - float AlphaStrength = 0.f; + uint32_t AlphaMode = std::to_underlying(MaterialModel::Default); + float AlphaReduction = 0.15f; + float AlphaSoftness = 0.f; + float AlphaStrength = 0.f; }; MaterialParams settings;