Skip to content

Commit c505de6

Browse files
committed
- Rename 'Ghost' to 'ScatteringVolume'
- Revert the Transparency Slider change - Fix 'ExtendedTranslucency::MaterialModel::Disabled' in hlsli
1 parent 9bfe81e commit c505de6

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

features/Extended Translucency/Shaders/ExtendedTranslucency/ExtendedTranslucency.hlsli

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ namespace ExtendedTranslucency
66
static const uint RimLight = 1;
77
static const uint IsotropicFabric = 2;
88
static const uint AnisotropicFabric = 3;
9-
static const uint ScatteringSphere = 4;
10-
static const uint Disabled = 4; // Any value >= 4
9+
static const uint ScatteringVolume = 4;
10+
static const uint Disabled = 5; // Any value >= 5
1111
}
1212

1313
bool IsValidMaterial(uint Material)
@@ -41,12 +41,10 @@ namespace ExtendedTranslucency
4141
float a0 = 1 - sqrt(1.0 - alpha);
4242
return a0 * (length(cross(v, t)) + length(cross(v, b))) / (abs(dot(v, n)) + 0.001) - a0 * a0;
4343
}
44-
45-
float GetViewDependentAlphaScatteringSphere(float alpha, float3 view, float3 normal)
44+
45+
float GetViewDependentAlphaScatteringVolume(float alpha, float3 view, float3 normal)
4646
{
47-
float3 theta = cross(view, normal);
48-
float gamma = sqrt(1 - dot(theta, theta));
49-
return 1.0 - pow(1.0 - alpha, gamma);
47+
return 1.0 - pow(1.0 - alpha, dot(view, normal));
5048
}
5149

5250
float SoftClamp(float alpha, float limit)

package/Shaders/Lighting.hlsl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3205,12 +3205,12 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
32053205

32063206
[branch] if (ExtendedTranslucency::IsValidMaterial(AlphaMaterialModel))
32073207
{
3208-
if (alpha >= 0.0156862754 && alpha < 1.0) {
3208+
if (alpha >= 0.0156862754 && alpha <= 1.0 - 0.0156862754) {
32093209
float originalAlpha = alpha;
32103210
alpha = saturate(alpha * (1.0 - AlphaMaterialReduction));
32113211
[branch] if (AlphaMaterialModel == ExtendedTranslucency::MaterialModel::AnisotropicFabric)
32123212
{
3213-
# if defined(SKINNED) || !defined(MODELSPACENORMALS)
3213+
# if !defined(MODELSPACENORMALS)
32143214
alpha = ExtendedTranslucency::GetViewDependentAlphaFabric2D(alpha, viewDirection, tbnTr);
32153215
# else
32163216
alpha = ExtendedTranslucency::GetViewDependentAlphaFabric1D(alpha, viewDirection, worldNormal.xyz);
@@ -3220,9 +3220,9 @@ PS_OUTPUT main(PS_INPUT input, bool frontFace : SV_IsFrontFace)
32203220
{
32213221
alpha = ExtendedTranslucency::GetViewDependentAlphaFabric1D(alpha, viewDirection, worldNormal.xyz);
32223222
}
3223-
else if (AlphaMaterialModel == ExtendedTranslucency::MaterialModel::ScatteringSphere)
3223+
else if (AlphaMaterialModel == ExtendedTranslucency::MaterialModel::ScatteringVolume)
32243224
{
3225-
alpha = ExtendedTranslucency::GetViewDependentAlphaScatteringSphere(alpha, viewDirection, worldNormal.xyz);
3225+
alpha = ExtendedTranslucency::GetViewDependentAlphaScatteringVolume(alpha, viewDirection, worldNormal.xyz);
32263226
}
32273227
else
32283228
{

src/Features/ExtendedTranslucency.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ void ExtendedTranslucency::DrawSettings()
8989
"1 - Rim Edge",
9090
"2 - Isotropic Fabric, Glass, ...",
9191
"3 - Anisotropic Fabric",
92-
"4 - Ghost",
92+
"4 - Scattering Volume",
9393
};
9494

9595
static constexpr int AlphaModeSize = static_cast<int>(std::size(AlphaModeNames));
@@ -100,12 +100,12 @@ void ExtendedTranslucency::DrawSettings()
100100
}
101101
if (auto _tt = Util::HoverTooltipWrapper()) {
102102
ImGui::Text(
103-
"Anisotropic transluency will make the surface more opaque when you view it parallel to the surface.\n"
104-
" - Disabled: No anisotropic transluency\n"
103+
"Anisotropic transluency will adjust the opacity based on your view angle to the translucent surface.\n"
104+
" - Disabled: No anisotropic transluency, flat alpha.\n"
105105
" - Rim Edge: Naive rim light effect with no physics model, the edge of the geometry is always opaque even its full transparent.\n"
106106
" - Isotropic Fabric: Imaginary fabric weaved from threads in one direction, respect normal map, also works well for layer of glass panels.\n"
107107
" - Anisotropic Fabric: Common fabric weaved from tangent and birnormal direction, ignores normal map.\n"
108-
" - Ghost: A volumn of light scattering or absoring material, it fade the geometry out at its edge instead of strength them like other material.\n");
108+
" - Scattering Volume: A **volumn** (instead of a layer) of light scattering or absoring material, it fade the geometry out at its edge instead of strength them like other material.\n");
109109
}
110110
if (ImGui::Checkbox("Skinned Mesh Only", &SkinnedOnly)) {
111111
changed = true;
@@ -114,7 +114,7 @@ void ExtendedTranslucency::DrawSettings()
114114
ImGui::Text("Control if this effect should only apply to skinned mesh, check this option if your are seeing undesired effect on random objects.");
115115
}
116116

117-
if (ImGui::SliderFloat("Transparency Increase", &settings.AlphaReduction, -1.f, 1.f)) {
117+
if (ImGui::SliderFloat("Transparency Increase", &settings.AlphaReduction, 0, 1.f)) {
118118
changed = true;
119119
}
120120
if (auto _tt = Util::HoverTooltipWrapper()) {
@@ -164,7 +164,7 @@ std::pair<std::string, std::vector<std::string>> ExtendedTranslucency::GetFeatur
164164
return {
165165
"Extended Translucency provides realistic rendering of thin fabric and other translucent materials.\n"
166166
"This feature supports multiple material models for different types of translucent surfaces.",
167-
{ "Multiple translucency material models (rim light, isotropic/anisotropic fabric)",
167+
{ "Multiple translucency material models (rim edge, isotropic/anisotropic fabric, ghost)",
168168
"Realistic fabric translucency with directional light transmission",
169169
"Per-material override support via NIF extra data",
170170
"Configurable transparency and softness controls",

src/Features/ExtendedTranslucency.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ struct ExtendedTranslucency final : Feature
3232
RimLight = 1, // Similar effect like rim light
3333
IsotropicFabric = 2, // 1D fabric model, respect normal map
3434
AnisotropicFabric = 3, // 2D fabric model alone tangent and binormal, ignores normal map
35-
ScatteringSphere = 4, // 2D fabric model alone tangent and binormal, ignores normal map
35+
ScatteringVolume = 4, // Fade out at the edge, models a ball of fog (light decays in exponential on distance)
3636

3737
DescriptorUseDefault = 0, // In ExtraFeatureDescriptor, 0 means 'UseDefault' instead of 'Disabled'
3838
DescriptorDisabled = 7, // In ExtraFeatureDescriptor, value >= 5 means 'Disabled'

0 commit comments

Comments
 (0)