Skip to content

Commit

Permalink
style: 🎨 apply clang-format changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ArcEarth authored and github-actions[bot] committed Oct 27, 2024
1 parent 62888ef commit c84f52b
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 43 deletions.
Original file line number Diff line number Diff line change
@@ -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
Expand Down
20 changes: 10 additions & 10 deletions package/Shaders/Lighting.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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 {
Expand All @@ -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;

Expand Down
39 changes: 16 additions & 23 deletions src/Features/ExtendedTranslucency.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ NLOHMANN_DEFINE_TYPE_NON_INTRUSIVE_WITH_DEFAULT(
ExtendedTranslucency::MaterialParams,
AlphaMode,
AlphaReduction,
AlphaSoftness
);
AlphaSoftness);

const RE::BSFixedString ExtendedTranslucency::NiExtraDataName = "AnisotropicAlphaMaterial";

Expand Down Expand Up @@ -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);
//}
}
}
Expand Down Expand Up @@ -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()) {
Expand All @@ -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);
}

Expand All @@ -146,8 +141,7 @@ void ExtendedTranslucency::DrawSettings()
void ExtendedTranslucency::LoadSettings(json& o_json)
{
settings = o_json;
if (materialDefaultCB)
{
if (materialDefaultCB) {
materialDefaultCB->Update(settings);
}
}
Expand All @@ -160,8 +154,7 @@ void ExtendedTranslucency::SaveSettings(json& o_json)
void ExtendedTranslucency::RestoreDefaultSettings()
{
settings = {};
if (materialDefaultCB)
{
if (materialDefaultCB) {
materialDefaultCB->Update(settings);
}
}
12 changes: 6 additions & 6 deletions src/Features/ExtendedTranslucency.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once

#include "../Feature.h"
#include "../Buffer.h"
#include "../Feature.h"

struct ExtendedTranslucency final : Feature
{
Expand All @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit c84f52b

Please sign in to comment.