Add explanations for default constant parameters + define as separate const variables (https://github.com/o3de/o3de/pull/6428#discussion_r776073076, https://github.com/o3de/o3de/pull/6428#discussion_r776072881, https://github.com/o3de/o3de/pull/6428#discussion_r776069391)
Signed-off-by: Santi Paprika <santi.gonzalez.cs@gmail.com>
This commit is contained in:
@@ -75,8 +75,9 @@ float3 GetBackLighting(Surface surface, LightingData lightingData, float3 lightI
|
||||
// Increase angle of influence (angle(N,L) -> angle(N,L) + acos(transmissionNdLBias)) to smooth transition regions
|
||||
float3 E = surface.albedo * saturate(lightingData.transmissionNdLBias + dot(-surface.normal, dirToLight));
|
||||
|
||||
// Transmission distance modulated by hardcoded constant (could be exposed as a weight of scattering distance for transmission)
|
||||
float s = transmissionDistance * 100.0;
|
||||
// Transmission distance modulated by hardcoded constant C (could be exposed as a weight of scattering distance for transmission)
|
||||
const float C = 100.0f;
|
||||
float s = transmissionDistance * C;
|
||||
|
||||
// Use scattering color to weight thin object transmission color
|
||||
const float3 invScattering = rcp(transmissionParams.xyz);
|
||||
|
||||
+9
-2
@@ -135,8 +135,15 @@ void ApplyCapsuleLight(ViewSrg::CapsuleLight light, Surface surface, inout Light
|
||||
float3 closestIntersectionPoint = startPoint + closestT * startToEnd;
|
||||
float3 posToLight = closestIntersectionPoint - surface.position;
|
||||
|
||||
// Tranmission contribution
|
||||
lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), -1.0f, 0.0f);
|
||||
// Transmission contribution
|
||||
// We cannot compute the actual transmission distance so we want to:
|
||||
// - If transmission mode is thick object -> use transmission thickness parameter instead
|
||||
// - If transmission mode is thin object -> ignore back lighting
|
||||
// To detect and apply this behavior in the GetBackLighting function, we need to use a negative transmissionDistance
|
||||
const float transmissionDistance = -1.0f;
|
||||
// If the transmissionDistance is ignored then the attenuation distance (only used on thin objects) does not have any influence
|
||||
const float attenuationDistance = 0.0f;
|
||||
lightingData.translucentBackLighting += GetBackLighting(surface, lightingData, lightIntensity, normalize(posToLight), transmissionDistance, attenuationDistance);
|
||||
|
||||
// Calculate the offset from the nearest point on the reflection vector to the nearest point on the capsule light
|
||||
float3 posToClosestPointAlongReflection = dot(posToLight, reflectionDir) * reflectionDir;
|
||||
|
||||
+3
-1
@@ -20,7 +20,9 @@ void ApplyDirectionalLights(Surface surface, inout LightingData lightingData)
|
||||
float litRatio = 1.0f;
|
||||
float camToSurfDist = distance(ViewSrg::m_worldPosition, surface.position);
|
||||
|
||||
// Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting())
|
||||
// Distance travelled by the light inside the object. If not redefined to a non-negative value, it will take the following behavior:
|
||||
// - If transmission mode is thick object -> use transmission thickness parameter instead
|
||||
// - If transmission mode is thin object -> ignore back lighting
|
||||
float transmissionDistance = -1.0f;
|
||||
|
||||
if (o_enableShadows && shadowIndex < SceneSrg::m_directionalLightCount)
|
||||
|
||||
@@ -77,8 +77,9 @@ void ApplyDiskLight(ViewSrg::DiskLight light, Surface surface, inout LightingDat
|
||||
// shadow
|
||||
float litRatio = 1.0;
|
||||
|
||||
|
||||
// Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting())
|
||||
// Distance travelled by the light inside the object. If not redefined to a non-negative value, it will take the following behavior:
|
||||
// - If transmission mode is thick object -> use transmission thickness parameter instead
|
||||
// - If transmission mode is thin object -> ignore back lighting
|
||||
float transmissionDistance = -1.0f;
|
||||
|
||||
if (o_enableShadows)
|
||||
|
||||
+11
-1
@@ -49,6 +49,16 @@ void AddSampleContribution(
|
||||
float3 intensityRgb = float3(intensity, intensity, intensity);
|
||||
|
||||
diffuseAcc += GetDiffuseLighting(surface, lightingData, intensityRgb, posToLightSampleDir);
|
||||
translucentAcc += GetBackLighting(surface, lightingData, intensityRgb, posToLightSampleDir, -1.0f, 0.0f);
|
||||
|
||||
// Transmission contribution
|
||||
// We cannot compute the actual transmission distance so we want to:
|
||||
// - If transmission mode is thick object -> use transmission thickness parameter instead
|
||||
// - If transmission mode is thin object -> ignore back lighting
|
||||
// To detect and apply this behavior in the GetBackLighting function, we need to use a negative transmissionDistance
|
||||
const float transmissionDistance = -1.0f;
|
||||
// If the transmissionDistance is ignored then the attenuation distance (only used on thin objects) does not have any influence
|
||||
const float attenuationDistance = 0.0f;
|
||||
translucentAcc += GetBackLighting(surface, lightingData, intensityRgb, posToLightSampleDir, transmissionDistance, attenuationDistance);
|
||||
|
||||
specularAcc += GetSpecularLighting(surface, lightingData, intensityRgb, posToLightSampleDir);
|
||||
}
|
||||
|
||||
@@ -85,7 +85,9 @@ void ApplyPointLight(ViewSrg::PointLight light, Surface surface, inout LightingD
|
||||
// shadow
|
||||
float litRatio = 1.0;
|
||||
|
||||
// Distance travelled by the light inside the object. If not redefined, it will take mode-specific null behaviors (see GetBackLighting())
|
||||
// Distance travelled by the light inside the object. If not redefined to a non-negative value, it will take the following behavior:
|
||||
// - If transmission mode is thick object -> use transmission thickness parameter instead
|
||||
// - If transmission mode is thin object -> ignore back lighting
|
||||
float transmissionDistance = -1.0f;
|
||||
|
||||
if (o_enableShadows)
|
||||
|
||||
@@ -148,13 +148,21 @@ void ApplyQuadLight(ViewSrg::QuadLight light, Surface surface, inout LightingDat
|
||||
GetDiffuseLighting(surface, lightingData, intensity, dirToLightCenter)
|
||||
);
|
||||
|
||||
// Transmission contribution
|
||||
// We cannot compute the actual transmission distance so we want to:
|
||||
// - If transmission mode is thick object -> use transmission thickness parameter instead
|
||||
// - If transmission mode is thin object -> ignore back lighting
|
||||
// To detect and apply this behavior in the GetBackLighting function, we need to use a negative transmissionDistance
|
||||
const float transmissionDistance = -1.0f;
|
||||
// If the transmissionDistance is ignored then the attenuation distance (only used on thin objects) does not have any influence
|
||||
const float attenuationDistance = 0.0f;
|
||||
lightingData.translucentBackLighting +=
|
||||
(
|
||||
GetBackLighting(surface, lightingData, intensity, p0, -1.0f, 0.0f) +
|
||||
GetBackLighting(surface, lightingData, intensity, p1, -1.0f, 0.0f) +
|
||||
GetBackLighting(surface, lightingData, intensity, p2, -1.0f, 0.0f) +
|
||||
GetBackLighting(surface, lightingData, intensity, p3, -1.0f, 0.0f) +
|
||||
GetBackLighting(surface, lightingData, intensity, dirToLightCenter, -1.0f, 0.0f)
|
||||
GetBackLighting(surface, lightingData, intensity, p0, transmissionDistance, attenuationDistance) +
|
||||
GetBackLighting(surface, lightingData, intensity, p1, transmissionDistance, attenuationDistance) +
|
||||
GetBackLighting(surface, lightingData, intensity, p2, transmissionDistance, attenuationDistance) +
|
||||
GetBackLighting(surface, lightingData, intensity, p3, transmissionDistance, attenuationDistance) +
|
||||
GetBackLighting(surface, lightingData, intensity, dirToLightCenter, transmissionDistance, attenuationDistance)
|
||||
);
|
||||
|
||||
// Calculate specular by choosing a single representative point on the light's surface based on the reflection ray
|
||||
|
||||
Reference in New Issue
Block a user