Removing unused softening boundary width controls
Signed-off-by: mrieggeramzn <mriegger@amazon.com>
This commit is contained in:
-76
@@ -10,7 +10,6 @@
|
||||
|
||||
#include <scenesrg.srgi>
|
||||
#include <viewsrg.srgi>
|
||||
#include "JitterTablePcf.azsli"
|
||||
#include "Shadow.azsli"
|
||||
#include "ShadowmapAtlasLib.azsli"
|
||||
#include "BicubicPcfFilters.azsli"
|
||||
@@ -82,12 +81,6 @@ class DirectionalLightShadow
|
||||
// result.y == true if the given coordinate is in shadow.
|
||||
bool2 IsShadowed(float3 shadowCoord, uint indexOfCascade);
|
||||
|
||||
// This checks if the point is shadowed or not for the given center coordinate and jitter.
|
||||
bool IsShadowedWithJitter(
|
||||
float3 jitterUnit,
|
||||
float jitterDepthDiffBase,
|
||||
uint jitterIndex);
|
||||
|
||||
// This outputs visibility ratio (from 0.0 to 1.0) of the given coordinate
|
||||
// from the light origin without filtering.
|
||||
float GetVisibilityFromLightNoFilter();
|
||||
@@ -189,75 +182,6 @@ bool2 DirectionalLightShadow::IsShadowed(float3 shadowCoord, uint indexOfCascade
|
||||
return bool2(false, false);
|
||||
}
|
||||
|
||||
bool DirectionalLightShadow::IsShadowedWithJitter(
|
||||
float3 jitterUnit,
|
||||
float jitterDepthDiffBase,
|
||||
uint jitterIndex)
|
||||
{
|
||||
const uint cascadeCount = ViewSrg::m_directionalLightShadows[m_lightIndex].m_cascadeCount;
|
||||
const float4x4 worldToLightViewMatrices[ViewSrg::MaxCascadeCount] =
|
||||
ViewSrg::m_directionalLightShadows[m_lightIndex].m_worldToLightViewMatrices;
|
||||
const float4x4 lightViewToShadowmapMatrices[ViewSrg::MaxCascadeCount] =
|
||||
ViewSrg::m_directionalLightShadows[m_lightIndex].m_lightViewToShadowmapMatrices;
|
||||
const float boundaryScale =
|
||||
ViewSrg::m_directionalLightShadows[m_lightIndex].m_boundaryScale;
|
||||
|
||||
const float2 jitterXY = g_jitterTablePcf[jitterIndex];
|
||||
|
||||
// jitterLightView is the jittering diff vector from the lighted point on the surface
|
||||
// in the light view space. It is remarked as "v_J" in the comment
|
||||
// named "Calculate depth adjusting diff for jittered samples"
|
||||
// just before the function GetJitterUnitVectorDepthDiffBase.
|
||||
const float4 jitterLightView = float4(jitterXY, 0., 0.) * boundaryScale;
|
||||
|
||||
// It checks the jittered point is lit or shadowed from the detailed cascade
|
||||
// to the less detailed one.
|
||||
for (uint indexOfCascade = 0; indexOfCascade < cascadeCount; ++indexOfCascade)
|
||||
{
|
||||
// jitterShadowmap is the jittering diff vector in the shadowmap space.
|
||||
const float4 jitterShadowmap = mul(lightViewToShadowmapMatrices[indexOfCascade], jitterLightView);
|
||||
|
||||
// Calculation of the jittering for Z-coordinate (light direction) is required
|
||||
// to check lit/shadowed for the jittered point.
|
||||
// jitterDepthDiff is the Z-coordinate of the jittering diff vector
|
||||
// in the shadowmap space.
|
||||
float jitterDepthDiff = 0.;
|
||||
|
||||
// jitterDepthDiffBase is "1/tan(theta)" in the comment.
|
||||
if (jitterDepthDiffBase != 0.)
|
||||
{
|
||||
// jitterUnitLightView is the unit vector in the light view space
|
||||
// noted as "v_M" in the comment.
|
||||
const float3 jitterUnitLightView =
|
||||
normalize(mul(worldToLightViewMatrices[indexOfCascade], float4(jitterUnit, 0.)).xyz);
|
||||
const float lightViewToShadowmapZScale = -lightViewToShadowmapMatrices[indexOfCascade]._m22;
|
||||
// jitterDepthDiff is the "d" in the note, and it is calculated by
|
||||
// d = (v_J . v_M) / tan(theta)
|
||||
// in the light view space. Furthermore it have to be converted
|
||||
// to the light clip space, which can be done by lightViewToShadowmapZScale.
|
||||
jitterDepthDiff =
|
||||
dot(jitterLightView.xyz, jitterUnitLightView) * jitterDepthDiffBase *
|
||||
lightViewToShadowmapZScale;
|
||||
}
|
||||
// jitteredCoord is the coordinate of the jittered point in the shadowmap space.
|
||||
const float3 jitteredCoord =
|
||||
m_shadowCoords[indexOfCascade] + float3(jitterShadowmap.xy, jitterDepthDiff);
|
||||
// Check for the jittered point is lit or shadowed.
|
||||
const bool2 checkedShadowed = IsShadowed(
|
||||
jitteredCoord,
|
||||
indexOfCascade);
|
||||
// If check is done, return the lit/shadowed flag.
|
||||
// Otherwise make it pend to the next cascade.
|
||||
if (checkedShadowed.x)
|
||||
{
|
||||
m_debugInfo.m_cascadeIndex = indexOfCascade;
|
||||
return checkedShadowed.y;
|
||||
}
|
||||
}
|
||||
m_debugInfo.m_cascadeIndex = cascadeCount;
|
||||
return false;
|
||||
}
|
||||
|
||||
float DirectionalLightShadow::GetVisibilityFromLightNoFilter()
|
||||
{
|
||||
const uint cascadeCount = ViewSrg::m_directionalLightShadows[m_lightIndex].m_cascadeCount;
|
||||
|
||||
@@ -1,185 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) Contributors to the Open 3D Engine Project.
|
||||
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
||||
*
|
||||
*/
|
||||
|
||||
/*
|
||||
The following is the output of
|
||||
$ python3 pcf_jitter_table.py 6 g_jitterTablePcf 0
|
||||
where pcf_jitter_table.py has the following contents.
|
||||
|
||||
@code
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import random
|
||||
import sys
|
||||
import math
|
||||
|
||||
|
||||
""" Returns if a point in the range
|
||||
[radius_min, radius_sup)*[angle_min, angle_sup)
|
||||
is contained in the tuple polar coordinates.
|
||||
"""
|
||||
def is_point_include(radius_min, radius_sup, angle_min, angle_sup, polars):
|
||||
for polar in polars:
|
||||
if (radius_min <= polar[0] and polar[0] < radius_sup and
|
||||
angle_min <= polar[1] and polar[1] < angle_sup):
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
""" Insert a randomly generated polar coordianted point in each
|
||||
range [r0, r1)*[a0, a1) if there has not been such a point
|
||||
in tuple coords yet, where [0, 1)*[0, 2pi) is divided
|
||||
into the rad_count*agl_count ranges.
|
||||
"""
|
||||
def add_jitter_coords(radius_count, angle_count, polars):
|
||||
radius_base = 1.0 / math.sqrt(radius_count)
|
||||
for radius_index in range(radius_count):
|
||||
# range of radius
|
||||
radius_min = math.sqrt(radius_index) * radius_base
|
||||
radius_sup = math.sqrt(radius_index + 1) * radius_base
|
||||
|
||||
# randomize angle order
|
||||
random_state = random.getstate()
|
||||
angle_indices = list(range(angle_count))
|
||||
random.shuffle(angle_indices)
|
||||
random.setstate(random_state)
|
||||
|
||||
for angle_index in angle_indices:
|
||||
# range of angle
|
||||
angle_min = 2 * math.pi * angle_index / angle_count
|
||||
angle_sup = 2 * math.pi * (angle_index + 1) / angle_count
|
||||
|
||||
# if no point in the radius/angle range, add a new point
|
||||
if not is_point_include(radius_min, radius_sup,
|
||||
angle_min, angle_sup,
|
||||
polars):
|
||||
radius = radius_min + (radius_sup - radius_min) * random.random()
|
||||
angle = angle_min + (angle_sup - angle_min) * random.random()
|
||||
polars += [[radius, angle]]
|
||||
|
||||
|
||||
""" Return a formatted string readable as an array of
|
||||
orthogonal coordinated points which are in inside of the unit disk.
|
||||
"""
|
||||
def conv_array_string(polars):
|
||||
result = "{\n"
|
||||
for [radius, angle] in polars:
|
||||
x = radius * math.cos(angle)
|
||||
y = radius * math.sin(angle)
|
||||
result += str.format(" float2({: 1.20e}, {: 1.20e}),\n", x, y)
|
||||
result = result.rstrip(",\n") + "\n};\n"
|
||||
return result
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
rad_size = 1
|
||||
ang_size = 1
|
||||
|
||||
if len(sys.argv) > 3:
|
||||
random_seed = int(sys.argv[3])
|
||||
else:
|
||||
random_seed = 0
|
||||
|
||||
if len(sys.argv) > 2:
|
||||
array_name = sys.argv[2]
|
||||
else:
|
||||
array_name = False
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
len_log = int(sys.argv[1])
|
||||
else:
|
||||
print(" usage: {} array_len_log2 [array_file_name] [random_seed]".format(__file__))
|
||||
print(" array_len_log2 = 2 -> array length = 4")
|
||||
print(" array_len_log2 = 6 -> array length = 64")
|
||||
sys.exit()
|
||||
|
||||
random.seed(random_seed)
|
||||
coords = []
|
||||
add_jitter_coords(rad_size, ang_size, coords)
|
||||
for index in range(len_log):
|
||||
if index % 2 == 0:
|
||||
rad_size *= 2
|
||||
else:
|
||||
ang_size *= 2
|
||||
add_jitter_coords(rad_size, ang_size, coords)
|
||||
|
||||
if array_name:
|
||||
print(str.format("static const float2 {}[{}] =", array_name, len(coords)))
|
||||
print(conv_array_string(coords))
|
||||
|
||||
@endcode
|
||||
*/
|
||||
#pragma once
|
||||
|
||||
static const float2 g_jitterTablePcf[64] =
|
||||
{
|
||||
float2( 4.21857815578105532772e-02, -8.43367430701083664601e-01),
|
||||
float2(-1.66526814909220763350e-02, 2.96922406531470617352e-01),
|
||||
float2(-1.06374665780382349212e-01, -3.45521852905696924552e-01),
|
||||
float2( 5.42648241814168375008e-01, 7.63475573328278533936e-01),
|
||||
float2(-1.55045122122251910479e-01, 5.78282315712970729216e-01),
|
||||
float2( 1.01310018770242576264e-02, -6.88001749851880561870e-01),
|
||||
float2(-5.41276603451248283783e-01, 5.21888233660957712168e-01),
|
||||
float2(-6.69885071867917680777e-01, -6.72019666097878665134e-01),
|
||||
float2( 1.22985029409499718039e-02, 4.54706838949524849713e-01),
|
||||
float2( 4.00334354168925599105e-01, -6.20112671104014120949e-02),
|
||||
float2( 2.32326155804074424571e-01, 5.14183027524470093184e-01),
|
||||
float2(-3.26788693165450228051e-01, -6.03339478694129849323e-01),
|
||||
float2( 7.72374386126136736053e-01, 1.23204314299169448432e-01),
|
||||
float2(-4.45379212004159807936e-01, -6.35591042627205338178e-01),
|
||||
float2( 9.86986293787213919693e-01, -5.18195017297516449806e-02),
|
||||
float2(-9.09197225477999193544e-01, 1.95281945570711268356e-01),
|
||||
float2( 8.78123785413316704229e-02, -2.77671865082058690055e-02),
|
||||
float2( 1.93947312440399088906e-01, 4.27852204081567363825e-03),
|
||||
float2(-2.06133675819526185347e-01, -1.49183652412411493771e-01),
|
||||
float2(-4.11351098583102647854e-01, 2.36214692717993696158e-01),
|
||||
float2( 3.50058750095615767162e-01, -3.57193658067260721989e-01),
|
||||
float2(-5.54174780014121681759e-01, -2.23361040823672196698e-01),
|
||||
float2(-6.29913348094886860196e-01, 1.29962593232600148729e-01),
|
||||
float2( 3.96119563669521335125e-01, 4.90495219155295036906e-01),
|
||||
float2( 7.26077464944819728210e-01, -3.70531027878536270426e-02),
|
||||
float2(-5.50726266551596621568e-01, 6.48997654184258587762e-01),
|
||||
float2(-6.98067624269093189859e-01, -3.83843898992943299842e-01),
|
||||
float2( 8.72900706885875177221e-02, 8.24287559846993866941e-01),
|
||||
float2( 6.65413234189638491678e-01, -5.66029707430476647367e-01),
|
||||
float2(-5.97071574457786802270e-01, -6.93417220711863180327e-01),
|
||||
float2( 6.09778569514949131403e-01, 6.92279483269558570946e-01),
|
||||
float2(-8.10051800827623957879e-01, 5.82366304247235455627e-01),
|
||||
float2(-8.77200948157437071506e-02, -1.88326609190753474499e-01),
|
||||
float2( 9.79306884403889771340e-02, 1.86693151785678163046e-01),
|
||||
float2( 4.60071424048798319206e-02, -1.98255149016034859510e-01),
|
||||
float2(-5.37585860722621794450e-02, 3.99205315590760584366e-02),
|
||||
float2( 2.18621803321778829243e-01, -3.85632280444686503795e-01),
|
||||
float2(-2.98409571230789372187e-02, 4.22286693608096730390e-01),
|
||||
float2( 3.58654757584850270025e-01, 2.95175871390239985548e-01),
|
||||
float2(-3.85631921979480485341e-01, -3.00322047091407640096e-01),
|
||||
float2( 4.49800763439369810648e-01, 3.98492182500493397068e-01),
|
||||
float2(-4.97878650048238891035e-01, 2.57984038389083569776e-01),
|
||||
float2(-3.12055242602567339816e-01, -4.88013525550807125697e-01),
|
||||
float2( 5.87078632117718268724e-01, -6.97256834327608099322e-02),
|
||||
float2( 6.23692403999373534695e-01, 3.11519734097943645779e-01),
|
||||
float2( 6.64426445690903810792e-01, -2.27661844509491811950e-01),
|
||||
float2(-3.24662942872471160793e-01, 5.68939932480760024447e-01),
|
||||
float2(-5.31263995010459511015e-01, -4.66108719959298256619e-01),
|
||||
float2( 5.10323549430644951563e-01, 5.81027848262460677731e-01),
|
||||
float2( 2.82695533021593392586e-01, -7.03582425015577883620e-01),
|
||||
float2(-5.98419541732174709026e-01, -4.68015982003612274198e-01),
|
||||
float2(-3.95281650646674975746e-01, 6.10614720709622194050e-01),
|
||||
float2( 7.87454411900813555647e-01, 1.37726315874787758053e-01),
|
||||
float2(-7.36310249594224086600e-01, 4.25723821775386646049e-01),
|
||||
float2( 6.48232481978769037312e-01, -5.53108138515975955585e-01),
|
||||
float2(-1.88558544306507869237e-01, -7.79120748356531223067e-01),
|
||||
float2(-3.78614630625567993860e-01, 7.82366459873827913007e-01),
|
||||
float2(-8.48582606942172357201e-01, -3.78504015913022351381e-01),
|
||||
float2( 1.91472859899175090748e-02, -9.13050020447597532325e-01),
|
||||
float2( 8.08826910050883585157e-01, 4.17202663034078935489e-01),
|
||||
float2(-9.27062588380768493046e-01, -2.94160352051227980130e-01),
|
||||
float2( 6.67882607007592055126e-01, -6.88642020601400450808e-01),
|
||||
float2(-1.59349274307943010454e-02, 9.37629353656756814317e-01),
|
||||
float2( 9.86975590293644233775e-01, 1.44401793964158337014e-01)
|
||||
};
|
||||
@@ -13,7 +13,6 @@
|
||||
#include <Atom/Features/Shadow/ShadowmapAtlasLib.azsli>
|
||||
#include <Atom/RPI/Math.azsli>
|
||||
#include "BicubicPcfFilters.azsli"
|
||||
#include "JitterTablePcf.azsli"
|
||||
#include "Shadow.azsli"
|
||||
|
||||
// ProjectedShadow calculates shadowed area projected from a light.
|
||||
@@ -44,11 +43,6 @@ class ProjectedShadow
|
||||
float GetThickness();
|
||||
|
||||
bool IsShadowed(float3 shadowPosition);
|
||||
bool IsShadowedWithJitter(
|
||||
float3 jitterUnitX,
|
||||
float3 jitterUnitY,
|
||||
float jitterDepthDiffBase,
|
||||
uint jitterIndex);
|
||||
void SetShadowPosition();
|
||||
float3 GetAtlasPosition(float2 texturePosition);
|
||||
static float UnprojectDepth(uint shadowIndex, float depthBufferValue);
|
||||
@@ -321,35 +315,6 @@ bool ProjectedShadow::IsShadowed(float3 shadowPosition)
|
||||
return false;
|
||||
}
|
||||
|
||||
bool ProjectedShadow::IsShadowedWithJitter(
|
||||
float3 jitterUnitX,
|
||||
float3 jitterUnitY,
|
||||
float jitterDepthDiffBase,
|
||||
uint jitterIndex)
|
||||
{
|
||||
ViewSrg::ProjectedShadow shadow = ViewSrg::m_projectedShadows[m_shadowIndex];
|
||||
const float4x4 depthBiasMatrix = shadow.m_depthBiasMatrix;
|
||||
const float boundaryScale = shadow.m_boundaryScale;
|
||||
|
||||
const float2 jitterXY = g_jitterTablePcf[jitterIndex];
|
||||
|
||||
const float dist = distance(m_worldPosition, m_viewPosition);
|
||||
const float boundaryRadius = dist * tan(boundaryScale);
|
||||
// jitterWorldXY is the jittering diff vector from the lighted point on the surface
|
||||
// in the world space. It is remarked as "v_J" in the comment
|
||||
// named "Calculate depth adjusting diff for jittered samples"
|
||||
// just before the function GetJitterUnitVectorDepthDiffBase.
|
||||
const float3 jitterWorldXY = jitterUnitX * (jitterXY.x * boundaryRadius) + jitterUnitY * (jitterXY.y * boundaryRadius);
|
||||
// The adjusting diff of depth ("d" in the comment) is calculated by
|
||||
// jitterXY.y * boundaryRadius * jitterDepthDiffBase.
|
||||
const float3 jitterWorldZ = m_lightDirection * (jitterXY.y * boundaryRadius * jitterDepthDiffBase);
|
||||
|
||||
const float3 jitteredWorldPosition = m_worldPosition + jitterWorldXY + jitterWorldZ;
|
||||
const float4 jitteredShadowmapHomogeneous = mul(depthBiasMatrix, float4(jitteredWorldPosition, 1));
|
||||
|
||||
return IsShadowed(jitteredShadowmapHomogeneous.xyz / jitteredShadowmapHomogeneous.w);
|
||||
}
|
||||
|
||||
void ProjectedShadow::SetShadowPosition()
|
||||
{
|
||||
const float4x4 depthBiasMatrix = ViewSrg::m_projectedShadows[m_shadowIndex].m_depthBiasMatrix;
|
||||
|
||||
@@ -23,14 +23,11 @@ struct FilterParameter
|
||||
uint m_isEnabled;
|
||||
uint2 m_shadowmapOriginInSlice;
|
||||
uint m_shadowmapSize;
|
||||
uint m_parameterOffset;
|
||||
uint m_parameterCount;
|
||||
float m_lightDistanceOfCameraViewFrustum;
|
||||
float m_n_f_n; // n / (f - n)
|
||||
float m_n_f; // n - f
|
||||
float m_f; // f
|
||||
// where n: nearDepth, f: farDepth.
|
||||
float2 m_padding; // explicit padding
|
||||
};
|
||||
|
||||
class Shadow
|
||||
|
||||
@@ -22,14 +22,11 @@ partial ShaderResourceGroup ViewSrg
|
||||
uint m_isEnabled;
|
||||
uint2 m_shadowmapOriginInSlice;
|
||||
uint m_shadowmapSize;
|
||||
uint m_parameterOffset;
|
||||
uint m_parameterCount;
|
||||
float m_lightDistanceOfCameraViewFrustum;
|
||||
float m_n_f_n; // n / (f - n)
|
||||
float m_n_f; // n - f
|
||||
float m_f; // f
|
||||
// where n: nearDepth, f: farDepth.
|
||||
float2 m_padding; // explicit padding
|
||||
};
|
||||
|
||||
// Simple Point Lights
|
||||
|
||||
@@ -286,7 +286,6 @@ set(FILES
|
||||
ShaderLib/Atom/Features/ScreenSpace/ScreenSpaceUtil.azsli
|
||||
ShaderLib/Atom/Features/Shadow/BicubicPcfFilters.azsli
|
||||
ShaderLib/Atom/Features/Shadow/DirectionalLightShadow.azsli
|
||||
ShaderLib/Atom/Features/Shadow/JitterTablePcf.azsli
|
||||
ShaderLib/Atom/Features/Shadow/ProjectedShadow.azsli
|
||||
ShaderLib/Atom/Features/Shadow/Shadow.azsli
|
||||
ShaderLib/Atom/Features/Shadow/ShadowmapAtlasLib.azsli
|
||||
|
||||
-6
@@ -154,12 +154,6 @@ namespace AZ
|
||||
//! @param count Sample Count for filtering (up to 64)
|
||||
virtual void SetFilteringSampleCount(LightHandle handle, uint16_t count) = 0;
|
||||
|
||||
//! This specifies the width of boundary between shadowed area and lit area.
|
||||
//! @param handle the light handle.
|
||||
//! @param width Boundary width. The shadow is gradually changed the degree of shadowed.
|
||||
//! If width == 0, softening edge is disabled. Units are in meters.
|
||||
virtual void SetShadowBoundaryWidth(LightHandle handle, float boundaryWidth) = 0;
|
||||
|
||||
//! Sets whether the directional shadowmap should use receiver plane bias.
|
||||
//! This attempts to reduce shadow acne when using large pcf filters.
|
||||
virtual void SetShadowReceiverPlaneBiasEnabled(LightHandle handle, bool enable) = 0;
|
||||
|
||||
-2
@@ -90,8 +90,6 @@ namespace AZ
|
||||
virtual void SetShadowmapMaxResolution(LightHandle handle, ShadowmapSize shadowmapSize) = 0;
|
||||
//! Specifies filter method of shadows.
|
||||
virtual void SetShadowFilterMethod(LightHandle handle, ShadowFilterMethod method) = 0;
|
||||
//! Specifies the width of boundary between shadowed area and lit area in radians. The degree ofshadowed gradually changes on the boundary. 0 disables softening.
|
||||
virtual void SetSofteningBoundaryWidthAngle(LightHandle handle, float boundaryWidthRadians) = 0;
|
||||
//! Sets sample count for filtering of shadow boundary (up to 64)
|
||||
virtual void SetFilteringSampleCount(LightHandle handle, uint16_t count) = 0;
|
||||
//! Sets the Esm exponent to use. Higher values produce a steeper falloff in the border areas between light and shadow.
|
||||
|
||||
-3
@@ -70,9 +70,6 @@ namespace AZ
|
||||
virtual void SetShadowBias(LightHandle handle, float bias) = 0;
|
||||
//! Specifies filter method of shadows.
|
||||
virtual void SetShadowFilterMethod(LightHandle handle, ShadowFilterMethod method) = 0;
|
||||
//! Specifies the width of boundary between shadowed area and lit area in radians. The degree ofshadowed gradually changes on
|
||||
//! the boundary. 0 disables softening.
|
||||
virtual void SetSofteningBoundaryWidthAngle(LightHandle handle, float boundaryWidthRadians) = 0;
|
||||
//! Sets sample count for filtering of shadow boundary (up to 64)
|
||||
virtual void SetFilteringSampleCount(LightHandle handle, uint16_t count) = 0;
|
||||
//! Sets the Esm exponent to use. Higher values produce a steeper falloff in the border areas between light and shadow.
|
||||
|
||||
@@ -42,7 +42,6 @@ namespace AZ
|
||||
// [GFX TODO][ATOM-2408] Make the max number of cascade modifiable at runtime.
|
||||
static constexpr uint16_t MaxNumberOfCascades = 4;
|
||||
static constexpr uint16_t MaxPcfSamplingCount = 64;
|
||||
static constexpr float MaxSofteningBoundaryWidth = 0.1f;
|
||||
} // namespace Shadow
|
||||
|
||||
} // namespace Render
|
||||
|
||||
-2
@@ -54,8 +54,6 @@ namespace AZ::Render
|
||||
virtual void SetShadowBias(ShadowId id, float bias) = 0;
|
||||
//! Sets the shadow filter method
|
||||
virtual void SetShadowFilterMethod(ShadowId id, ShadowFilterMethod method) = 0;
|
||||
//! Sets the width of boundary between shadowed area and lit area.
|
||||
virtual void SetSofteningBoundaryWidthAngle(ShadowId id, float boundaryWidthRadians) = 0;
|
||||
//! Sets the sample count for filtering of the shadow boundary, max 64.
|
||||
virtual void SetFilteringSampleCount(ShadowId id, uint16_t count) = 0;
|
||||
//! Sets all of the shadow properites in one call
|
||||
|
||||
+2
-68
@@ -584,15 +584,6 @@ namespace AZ
|
||||
m_shadowBufferNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void DirectionalLightFeatureProcessor::SetShadowBoundaryWidth(LightHandle handle, float boundaryWidth)
|
||||
{
|
||||
for (auto& it : m_shadowData)
|
||||
{
|
||||
it.second.GetData(handle.GetIndex()).m_boundaryScale = boundaryWidth / 2.f;
|
||||
}
|
||||
m_shadowBufferNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void DirectionalLightFeatureProcessor::SetShadowReceiverPlaneBiasEnabled(LightHandle handle, bool enable)
|
||||
{
|
||||
m_shadowProperties.GetData(handle.GetIndex()).m_isReceiverPlaneBiasEnabled = enable;
|
||||
@@ -1116,50 +1107,13 @@ namespace AZ
|
||||
for (const auto& passIt : m_esmShadowmapsPasses)
|
||||
{
|
||||
const RPI::View* cameraView = passIt.second.front()->GetRenderPipeline()->GetDefaultView().get();
|
||||
UpdateStandardDeviations(handle, cameraView);
|
||||
UpdateFilterOffsetsCounts(handle, cameraView);
|
||||
UpdateFilterEnabled(handle, cameraView);
|
||||
UpdateShadowmapPositionInAtlas(handle, cameraView);
|
||||
SetFilterParameterToPass(handle, cameraView);
|
||||
}
|
||||
}
|
||||
|
||||
void DirectionalLightFeatureProcessor::UpdateStandardDeviations(LightHandle handle, const RPI::View* cameraView)
|
||||
{
|
||||
if (handle != m_shadowingLightHandle)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
const DirectionalLightShadowData& data = m_shadowData.at(cameraView).GetData(handle.GetIndex());
|
||||
const ShadowProperty& property = m_shadowProperties.GetData(handle.GetIndex());
|
||||
AZStd::fixed_vector<float, Shadow::MaxNumberOfCascades> standardDeviations;
|
||||
for (size_t cascadeIndex = 0; cascadeIndex < property.m_segments.at(cameraView).size(); ++cascadeIndex)
|
||||
{
|
||||
const Aabb& aabb = property.m_segments.at(cameraView)[cascadeIndex].m_aabb;
|
||||
const float aabbDiameter = AZStd::GetMax(
|
||||
aabb.GetMax().GetX() - aabb.GetMin().GetX(),
|
||||
aabb.GetMax().GetZ() - aabb.GetMin().GetZ());
|
||||
float standardDeviation = 0.f;
|
||||
if (aabbDiameter > 0.f)
|
||||
{
|
||||
const float boundaryWidth = data.m_boundaryScale * 2.f;
|
||||
const float ratioToAabbWidth = boundaryWidth / aabbDiameter;
|
||||
const float widthInPixels = ratioToAabbWidth * data.m_shadowmapSize;
|
||||
standardDeviation = widthInPixels / (2 * GaussianMathFilter::ReliableSectionFactor);
|
||||
}
|
||||
standardDeviations.push_back(standardDeviation);
|
||||
}
|
||||
|
||||
for (const RPI::RenderPipelineId& pipelineId : m_renderPipelineIdsForPersistentView.at(cameraView))
|
||||
{
|
||||
for (EsmShadowmapsPass* esmPass : m_esmShadowmapsPasses.at(pipelineId))
|
||||
{
|
||||
esmPass->SetFilterParameters(standardDeviations);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DirectionalLightFeatureProcessor::UpdateFilterOffsetsCounts(LightHandle handle, const RPI::View* cameraView)
|
||||
void DirectionalLightFeatureProcessor::UpdateFilterEnabled(LightHandle handle, const RPI::View* cameraView)
|
||||
{
|
||||
if (handle != m_shadowingLightHandle)
|
||||
{
|
||||
@@ -1170,29 +1124,11 @@ namespace AZ
|
||||
if (shadowData.m_shadowFilterMethod == aznumeric_cast<uint32_t>(ShadowFilterMethod::Esm) ||
|
||||
(shadowData.m_shadowFilterMethod == aznumeric_cast<uint32_t>(ShadowFilterMethod::EsmPcf)))
|
||||
{
|
||||
// Get array of filter counts for the camera view.
|
||||
const RPI::RenderPipelineId& pipelineId = m_renderPipelineIdsForPersistentView.at(cameraView).front();
|
||||
AZ_Assert(!m_esmShadowmapsPasses.at(pipelineId).empty(), "Cannot find a EsmShadowmapsPass.");
|
||||
const AZStd::array_view<uint32_t> filterCounts = m_esmShadowmapsPasses.at(pipelineId).front()->GetFilterCounts();
|
||||
AZ_Assert(filterCounts.size() == GetCascadeCount(handle), "FilterCounts differs with cascade count.");
|
||||
|
||||
// Create array of filter offsets
|
||||
AZStd::vector<uint32_t> filterOffsets;
|
||||
filterOffsets.reserve(filterCounts.size());
|
||||
uint32_t filterOffset = 0;
|
||||
for (const uint32_t count : filterCounts)
|
||||
{
|
||||
filterOffsets.push_back(filterOffset);
|
||||
filterOffset += count;
|
||||
}
|
||||
|
||||
// Write filter offsets and filter counts to ESM data
|
||||
for (uint16_t index = 0; index < GetCascadeCount(handle); ++index)
|
||||
{
|
||||
EsmShadowmapsPass::FilterParameter& filterParameter = m_esmParameterData.at(cameraView).GetData(index);
|
||||
filterParameter.m_isEnabled = true;
|
||||
filterParameter.m_parameterOffset = filterOffsets[index];
|
||||
filterParameter.m_parameterCount = filterCounts[index];
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1202,8 +1138,6 @@ namespace AZ
|
||||
{
|
||||
EsmShadowmapsPass::FilterParameter& filterParameter = m_esmParameterData.at(cameraView).GetData(index);
|
||||
filterParameter.m_isEnabled = false;
|
||||
filterParameter.m_parameterOffset = 0;
|
||||
filterParameter.m_parameterCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -217,7 +217,6 @@ namespace AZ
|
||||
void SetDebugFlags(LightHandle handle, DebugDrawFlags flags) override;
|
||||
void SetShadowFilterMethod(LightHandle handle, ShadowFilterMethod method) override;
|
||||
void SetFilteringSampleCount(LightHandle handle, uint16_t count) override;
|
||||
void SetShadowBoundaryWidth(LightHandle handle, float boundaryWidth) override;
|
||||
void SetShadowReceiverPlaneBiasEnabled(LightHandle handle, bool enable) override;
|
||||
|
||||
const Data::Instance<RPI::Buffer> GetLightBuffer() const;
|
||||
@@ -278,10 +277,8 @@ namespace AZ
|
||||
|
||||
//! This updates the parameter of Gaussian filter used in ESM.
|
||||
void UpdateFilterParameters(LightHandle handle);
|
||||
//! This updates standard deviations for each cascade.
|
||||
void UpdateStandardDeviations(LightHandle handle, const RPI::View* cameraView);
|
||||
//! This updates filter offset and size for each cascade.
|
||||
void UpdateFilterOffsetsCounts(LightHandle handle, const RPI::View* cameraView);
|
||||
//! This updates if the filter is enabled.
|
||||
void UpdateFilterEnabled(LightHandle handle, const RPI::View* cameraView);
|
||||
//! This updates shadowmap position(origin and size) in the atlas for each cascade.
|
||||
void UpdateShadowmapPositionInAtlas(LightHandle handle, const RPI::View* cameraView);
|
||||
//! This set filter parameters to passes which execute filtering.
|
||||
|
||||
@@ -322,11 +322,6 @@ namespace AZ
|
||||
{
|
||||
SetShadowSetting(handle, &ProjectedShadowFeatureProcessor::SetShadowFilterMethod, method);
|
||||
}
|
||||
|
||||
void DiskLightFeatureProcessor::SetSofteningBoundaryWidthAngle(LightHandle handle, float boundaryWidthRadians)
|
||||
{
|
||||
SetShadowSetting(handle, &ProjectedShadowFeatureProcessor::SetSofteningBoundaryWidthAngle, boundaryWidthRadians);
|
||||
}
|
||||
|
||||
void DiskLightFeatureProcessor::SetFilteringSampleCount(LightHandle handle, uint16_t count)
|
||||
{
|
||||
|
||||
@@ -53,7 +53,6 @@ namespace AZ
|
||||
void SetShadowBias(LightHandle handle, float bias) override;
|
||||
void SetShadowmapMaxResolution(LightHandle handle, ShadowmapSize shadowmapSize) override;
|
||||
void SetShadowFilterMethod(LightHandle handle, ShadowFilterMethod method) override;
|
||||
void SetSofteningBoundaryWidthAngle(LightHandle handle, float boundaryWidthRadians) override;
|
||||
void SetFilteringSampleCount(LightHandle handle, uint16_t count) override;
|
||||
void SetEsmExponent(LightHandle handle, float esmExponent) override;
|
||||
|
||||
|
||||
@@ -42,28 +42,6 @@ namespace AZ
|
||||
return m_lightTypeName;
|
||||
}
|
||||
|
||||
void EsmShadowmapsPass::SetFilterParameters(const AZStd::array_view<float>& standardDeviations)
|
||||
{
|
||||
// Set descriptor for Gaussian filters for given set of standard deviations.
|
||||
MathFilterDescriptor descriptor;
|
||||
descriptor.m_kind = MathFilterKind::Gaussian;
|
||||
descriptor.m_gaussians.reserve(standardDeviations.size());
|
||||
for (const float standardDeviation : standardDeviations)
|
||||
{
|
||||
descriptor.m_gaussians.emplace_back(GaussianFilterDescriptor{ standardDeviation });
|
||||
}
|
||||
|
||||
// Set filter paramter buffer along with element counts for each filter.
|
||||
MathFilter::BufferWithElementCounts bufferCounts = MathFilter::FindOrCreateFilterBuffer(descriptor);
|
||||
m_filterTableBuffer = bufferCounts.first;
|
||||
m_filterCounts = AZStd::move(bufferCounts.second);
|
||||
}
|
||||
|
||||
AZStd::array_view<uint32_t> EsmShadowmapsPass::GetFilterCounts() const
|
||||
{
|
||||
return m_filterCounts;
|
||||
}
|
||||
|
||||
void EsmShadowmapsPass::SetShadowmapIndexTableBuffer(const Data::Instance<RPI::Buffer>& tableBuffer)
|
||||
{
|
||||
m_shadowmapIndexTableBuffer = tableBuffer;
|
||||
|
||||
@@ -50,14 +50,11 @@ namespace AZ
|
||||
uint32_t m_isEnabled = false;
|
||||
AZStd::array<uint32_t, 2> m_shadowmapOriginInSlice = { {0, 0 } }; // shadowmap origin in the slice of the atlas.
|
||||
uint32_t m_shadowmapSize = static_cast<uint32_t>(ShadowmapSize::None); // width and height of shadowmap.
|
||||
uint32_t m_parameterOffset; // offset of the filter parameter.
|
||||
uint32_t m_parameterCount; // element count of the filter parameter.
|
||||
float m_lightDistanceOfCameraViewFrustum = 0.f;
|
||||
float m_n_f_n = 0.f; // n / (f - n)
|
||||
float m_n_f = 0.f; // n - f
|
||||
float m_f = 0.f; // f
|
||||
// where n: nearDepth, f: farDepth.
|
||||
AZStd::array<float, 2> m_padding = {{0.f, 0.f}}; // explicit padding
|
||||
};
|
||||
|
||||
virtual ~EsmShadowmapsPass() = default;
|
||||
@@ -65,13 +62,6 @@ namespace AZ
|
||||
|
||||
const Name& GetLightTypeName() const;
|
||||
|
||||
//! This sets the standard deviations of the Gaussian filter
|
||||
//! for each cascade.
|
||||
void SetFilterParameters(const AZStd::array_view<float>& standardDeviations);
|
||||
|
||||
//! This returns element count of filters.
|
||||
AZStd::array_view<uint32_t> GetFilterCounts() const;
|
||||
|
||||
//! This sets the buffer of the table which enable to get shadowmap index
|
||||
//! from the coordinate in the atlas.
|
||||
//! Note that shadowmpa index is shader light index for a spot light
|
||||
|
||||
@@ -292,11 +292,6 @@ namespace AZ
|
||||
SetShadowSetting(handle, &ProjectedShadowFeatureProcessor::SetShadowFilterMethod, method);
|
||||
}
|
||||
|
||||
void PointLightFeatureProcessor::SetSofteningBoundaryWidthAngle(LightHandle handle, float boundaryWidthRadians)
|
||||
{
|
||||
SetShadowSetting(handle, &ProjectedShadowFeatureProcessor::SetSofteningBoundaryWidthAngle, boundaryWidthRadians);
|
||||
}
|
||||
|
||||
void PointLightFeatureProcessor::SetFilteringSampleCount(LightHandle handle, uint16_t count)
|
||||
{
|
||||
SetShadowSetting(handle, &ProjectedShadowFeatureProcessor::SetFilteringSampleCount, count);
|
||||
|
||||
@@ -50,7 +50,6 @@ namespace AZ
|
||||
void SetShadowBias(LightHandle handle, float bias) override;
|
||||
void SetShadowmapMaxResolution(LightHandle handle, ShadowmapSize shadowmapSize) override;
|
||||
void SetShadowFilterMethod(LightHandle handle, ShadowFilterMethod method) override;
|
||||
void SetSofteningBoundaryWidthAngle(LightHandle handle, float boundaryWidthRadians) override;
|
||||
void SetFilteringSampleCount(LightHandle handle, uint16_t count) override;
|
||||
void SetEsmExponent(LightHandle handle, float esmExponent) override;
|
||||
void SetPointData(LightHandle handle, const PointLightData& data) override;
|
||||
|
||||
@@ -186,17 +186,6 @@ namespace AZ::Render
|
||||
m_filterParameterNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void ProjectedShadowFeatureProcessor::SetSofteningBoundaryWidthAngle(ShadowId id, float boundaryWidthRadians)
|
||||
{
|
||||
AZ_Assert(id.IsValid(), "Invalid ShadowId passed to ProjectedShadowFeatureProcessor::SetShadowBoundaryWidthAngle().");
|
||||
|
||||
ShadowData& shadowData = m_shadowData.GetElement<ShadowDataIndex>(id.GetIndex());
|
||||
shadowData.m_boundaryScale = boundaryWidthRadians / 2.0f;
|
||||
|
||||
m_shadowmapPassNeedsUpdate = true;
|
||||
m_filterParameterNeedsUpdate = true;
|
||||
}
|
||||
|
||||
void ProjectedShadowFeatureProcessor::SetFilteringSampleCount(ShadowId id, uint16_t count)
|
||||
{
|
||||
AZ_Assert(id.IsValid(), "Invalid ShadowId passed to ProjectedShadowFeatureProcessor::SetFilteringSampleCount().");
|
||||
@@ -368,14 +357,13 @@ namespace AZ::Render
|
||||
{
|
||||
if (m_filterParameterNeedsUpdate)
|
||||
{
|
||||
UpdateStandardDeviations();
|
||||
UpdateFilterOffsetsCounts();
|
||||
UpdateEsmPassEnabled();
|
||||
SetFilterParameterToPass();
|
||||
m_filterParameterNeedsUpdate = false;
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectedShadowFeatureProcessor::UpdateStandardDeviations()
|
||||
void ProjectedShadowFeatureProcessor::UpdateEsmPassEnabled()
|
||||
{
|
||||
if (m_esmShadowmapsPasses.empty())
|
||||
{
|
||||
@@ -383,24 +371,7 @@ namespace AZ::Render
|
||||
return;
|
||||
}
|
||||
|
||||
AZStd::vector<float> standardDeviations(m_shadowProperties.GetDataCount());
|
||||
|
||||
for (uint32_t i = 0; i < m_shadowProperties.GetDataCount(); ++i)
|
||||
{
|
||||
ShadowProperty& shadowProperty = m_shadowProperties.GetDataVector().at(i);
|
||||
const ShadowData& shadow = m_shadowData.GetElement<ShadowDataIndex>(shadowProperty.m_shadowId.GetIndex());
|
||||
if (!FilterMethodIsEsm(shadow))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const FilterParameter& filter = m_shadowData.GetElement<FilterParamIndex>(shadowProperty.m_shadowId.GetIndex());
|
||||
const float boundaryWidthAngle = shadow.m_boundaryScale * 2.0f;
|
||||
const float fieldOfView = GetMax(shadowProperty.m_desc.m_fieldOfViewYRadians, MinimumFieldOfView);
|
||||
const float ratioToEntireWidth = boundaryWidthAngle / fieldOfView;
|
||||
const float widthInPixels = ratioToEntireWidth * filter.m_shadowmapSize;
|
||||
standardDeviations.at(i) = widthInPixels / (2.0f * GaussianMathFilter::ReliableSectionFactor);
|
||||
}
|
||||
if (standardDeviations.empty())
|
||||
if (m_shadowProperties.GetDataCount() == 0)
|
||||
{
|
||||
for (EsmShadowmapsPass* esmPass : m_esmShadowmapsPasses)
|
||||
{
|
||||
@@ -411,50 +382,6 @@ namespace AZ::Render
|
||||
for (EsmShadowmapsPass* esmPass : m_esmShadowmapsPasses)
|
||||
{
|
||||
esmPass->SetEnabledComputation(true);
|
||||
esmPass->SetFilterParameters(standardDeviations);
|
||||
}
|
||||
}
|
||||
|
||||
void ProjectedShadowFeatureProcessor::UpdateFilterOffsetsCounts()
|
||||
{
|
||||
if (m_esmShadowmapsPasses.empty())
|
||||
{
|
||||
AZ_Error("ProjectedShadowFeatureProcessor", false, "Cannot find a required pass.");
|
||||
return;
|
||||
}
|
||||
|
||||
// Get array of filter counts for the camera view.
|
||||
const AZStd::array_view<uint32_t> filterCounts = m_esmShadowmapsPasses.front()->GetFilterCounts();
|
||||
|
||||
// Create array of filter offsets.
|
||||
AZStd::vector<uint32_t> filterOffsets;
|
||||
filterOffsets.reserve(filterCounts.size());
|
||||
uint32_t filterOffset = 0;
|
||||
for (const uint32_t count : filterCounts)
|
||||
{
|
||||
filterOffsets.push_back(filterOffset);
|
||||
filterOffset += count;
|
||||
}
|
||||
|
||||
auto& shadowProperties = m_shadowProperties.GetDataVector();
|
||||
for (uint32_t i = 0; i < shadowProperties.size(); ++i)
|
||||
{
|
||||
ShadowProperty& shadowProperty = shadowProperties.at(i);
|
||||
const ShadowId shadowId = shadowProperty.m_shadowId;
|
||||
ShadowData& shadowData = m_shadowData.GetElement<ShadowDataIndex>(shadowId.GetIndex());
|
||||
FilterParameter& filterData = m_shadowData.GetElement<FilterParamIndex>(shadowId.GetIndex());
|
||||
|
||||
if (FilterMethodIsEsm(shadowData))
|
||||
{
|
||||
filterData.m_parameterOffset = filterOffsets[i];
|
||||
filterData.m_parameterCount = filterCounts[i];
|
||||
}
|
||||
else
|
||||
{
|
||||
// If filter is not required, reset offsets and counts of filter in ESM data.
|
||||
filterData.m_parameterOffset = 0;
|
||||
filterData.m_parameterCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ namespace AZ::Render
|
||||
void SetShadowmapMaxResolution(ShadowId id, ShadowmapSize size) override;
|
||||
void SetShadowBias(ShadowId id, float bias) override;
|
||||
void SetShadowFilterMethod(ShadowId id, ShadowFilterMethod method) override;
|
||||
void SetSofteningBoundaryWidthAngle(ShadowId id, float boundaryWidthRadians) override;
|
||||
void SetFilteringSampleCount(ShadowId id, uint16_t count) override;
|
||||
void SetShadowProperties(ShadowId id, const ProjectedShadowDescriptor& descriptor) override;
|
||||
const ProjectedShadowDescriptor& GetShadowProperties(ShadowId id) override;
|
||||
@@ -101,8 +100,7 @@ namespace AZ::Render
|
||||
|
||||
//! Functions to update the parameter of Gaussian filter used in ESM.
|
||||
void UpdateFilterParameters();
|
||||
void UpdateStandardDeviations();
|
||||
void UpdateFilterOffsetsCounts();
|
||||
void UpdateEsmPassEnabled();
|
||||
void SetFilterParameterToPass();
|
||||
bool FilterMethodIsEsm(const ShadowData& shadowData) const;
|
||||
|
||||
|
||||
-7
@@ -120,13 +120,6 @@ namespace AZ
|
||||
//! Sets the filter method of shadows.
|
||||
virtual void SetShadowFilterMethod(ShadowFilterMethod method) = 0;
|
||||
|
||||
//! Gets the width of softening boundary between shadowed area and lit area in degrees.
|
||||
virtual float GetSofteningBoundaryWidthAngle() const = 0;
|
||||
|
||||
//! Sets the width of softening boundary between shadowed area and lit area in degrees.
|
||||
//! 0 disables softening.
|
||||
virtual void SetSofteningBoundaryWidthAngle(float degrees) = 0;
|
||||
|
||||
//! Gets the sample count for filtering of the shadow boundary.
|
||||
virtual uint32_t GetFilteringSampleCount() const = 0;
|
||||
|
||||
|
||||
-1
@@ -59,7 +59,6 @@ namespace AZ
|
||||
float m_bias = 0.1f;
|
||||
ShadowmapSize m_shadowmapMaxSize = ShadowmapSize::Size256;
|
||||
ShadowFilterMethod m_shadowFilterMethod = ShadowFilterMethod::None;
|
||||
float m_boundaryWidthInDegrees = 0.25f;
|
||||
uint16_t m_filteringSampleCount = 12;
|
||||
float m_esmExponent = 87.0f;
|
||||
|
||||
|
||||
-9
@@ -153,15 +153,6 @@ namespace AZ
|
||||
//! @param method filter method.
|
||||
virtual void SetShadowFilterMethod(ShadowFilterMethod method) = 0;
|
||||
|
||||
//! This gets the width of boundary between shadowed area and lit area.
|
||||
//! @return Boundary width. The shadow is gradually changed the degree of shadowed.
|
||||
virtual float GetSofteningBoundaryWidth() const = 0;
|
||||
|
||||
//! This specifies the width of boundary between shadowed area and lit area.
|
||||
//! @param width Boundary width. The shadow is gradually changed the degree of shadowed.
|
||||
//! If width == 0, softening edge is disabled. Units are in meters.
|
||||
virtual void SetSofteningBoundaryWidth(float width) = 0;
|
||||
|
||||
//! This gets the sample count for filtering of the shadow boundary.
|
||||
//! @return Sample Count for filtering (up to 64)
|
||||
virtual uint32_t GetFilteringSampleCount() const = 0;
|
||||
|
||||
-4
@@ -101,10 +101,6 @@ namespace AZ
|
||||
//! Method of shadow's filtering.
|
||||
ShadowFilterMethod m_shadowFilterMethod = ShadowFilterMethod::None;
|
||||
|
||||
//! Width of the boundary between shadowed area and lit one.
|
||||
//! If this is 0, edge softening is disabled. Units are in meters.
|
||||
float m_boundaryWidth = 0.03f; // 3cm
|
||||
|
||||
//! Sample Count for filtering (from 4 to 64)
|
||||
//! It is used only when the pixel is predicted as on the boundary.
|
||||
uint16_t m_filteringSampleCount = 32;
|
||||
|
||||
-1
@@ -36,7 +36,6 @@ namespace AZ
|
||||
->Field("Shadow Bias", &AreaLightComponentConfig::m_bias)
|
||||
->Field("Shadowmap Max Size", &AreaLightComponentConfig::m_shadowmapMaxSize)
|
||||
->Field("Shadow Filter Method", &AreaLightComponentConfig::m_shadowFilterMethod)
|
||||
->Field("Softening Boundary Width", &AreaLightComponentConfig::m_boundaryWidthInDegrees)
|
||||
->Field("Filtering Sample Count", &AreaLightComponentConfig::m_filteringSampleCount)
|
||||
->Field("Esm Exponent", &AreaLightComponentConfig::m_esmExponent)
|
||||
;
|
||||
|
||||
-18
@@ -74,8 +74,6 @@ namespace AZ::Render
|
||||
->Event("SetShadowmapMaxSize", &AreaLightRequestBus::Events::SetShadowmapMaxSize)
|
||||
->Event("GetShadowFilterMethod", &AreaLightRequestBus::Events::GetShadowFilterMethod)
|
||||
->Event("SetShadowFilterMethod", &AreaLightRequestBus::Events::SetShadowFilterMethod)
|
||||
->Event("GetSofteningBoundaryWidthAngle", &AreaLightRequestBus::Events::GetSofteningBoundaryWidthAngle)
|
||||
->Event("SetSofteningBoundaryWidthAngle", &AreaLightRequestBus::Events::SetSofteningBoundaryWidthAngle)
|
||||
->Event("GetFilteringSampleCount", &AreaLightRequestBus::Events::GetFilteringSampleCount)
|
||||
->Event("SetFilteringSampleCount", &AreaLightRequestBus::Events::SetFilteringSampleCount)
|
||||
->Event("GetEsmExponent", &AreaLightRequestBus::Events::GetEsmExponent)
|
||||
@@ -95,7 +93,6 @@ namespace AZ::Render
|
||||
->VirtualProperty("ShadowBias", "GetShadowBias", "SetShadowBias")
|
||||
->VirtualProperty("ShadowmapMaxSize", "GetShadowmapMaxSize", "SetShadowmapMaxSize")
|
||||
->VirtualProperty("ShadowFilterMethod", "GetShadowFilterMethod", "SetShadowFilterMethod")
|
||||
->VirtualProperty("SofteningBoundaryWidthAngle", "GetSofteningBoundaryWidthAngle", "SetSofteningBoundaryWidthAngle")
|
||||
->VirtualProperty("FilteringSampleCount", "GetFilteringSampleCount", "SetFilteringSampleCount")
|
||||
->VirtualProperty("EsmExponent", "GetEsmExponent", "SetEsmExponent");
|
||||
;
|
||||
@@ -307,7 +304,6 @@ namespace AZ::Render
|
||||
m_lightShapeDelegate->SetShadowBias(m_configuration.m_bias);
|
||||
m_lightShapeDelegate->SetShadowmapMaxSize(m_configuration.m_shadowmapMaxSize);
|
||||
m_lightShapeDelegate->SetShadowFilterMethod(m_configuration.m_shadowFilterMethod);
|
||||
m_lightShapeDelegate->SetSofteningBoundaryWidthAngle(m_configuration.m_boundaryWidthInDegrees);
|
||||
m_lightShapeDelegate->SetFilteringSampleCount(m_configuration.m_filteringSampleCount);
|
||||
m_lightShapeDelegate->SetEsmExponent(m_configuration.m_esmExponent);
|
||||
}
|
||||
@@ -506,20 +502,6 @@ namespace AZ::Render
|
||||
}
|
||||
}
|
||||
|
||||
float AreaLightComponentController::GetSofteningBoundaryWidthAngle() const
|
||||
{
|
||||
return m_configuration.m_boundaryWidthInDegrees;
|
||||
}
|
||||
|
||||
void AreaLightComponentController::SetSofteningBoundaryWidthAngle(float width)
|
||||
{
|
||||
m_configuration.m_boundaryWidthInDegrees = width;
|
||||
if (m_lightShapeDelegate)
|
||||
{
|
||||
m_lightShapeDelegate->SetSofteningBoundaryWidthAngle(width);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t AreaLightComponentController::GetFilteringSampleCount() const
|
||||
{
|
||||
return m_configuration.m_filteringSampleCount;
|
||||
|
||||
-2
@@ -82,8 +82,6 @@ namespace AZ
|
||||
void SetShadowmapMaxSize(ShadowmapSize size) override;
|
||||
ShadowFilterMethod GetShadowFilterMethod() const override;
|
||||
void SetShadowFilterMethod(ShadowFilterMethod method) override;
|
||||
float GetSofteningBoundaryWidthAngle() const override;
|
||||
void SetSofteningBoundaryWidthAngle(float width) override;
|
||||
uint32_t GetFilteringSampleCount() const override;
|
||||
void SetFilteringSampleCount(uint32_t count) override;
|
||||
float GetEsmExponent() const override;
|
||||
|
||||
-1
@@ -37,7 +37,6 @@ namespace AZ
|
||||
->Field("IsCascadeCorrectionEnabled", &DirectionalLightComponentConfig::m_isCascadeCorrectionEnabled)
|
||||
->Field("IsDebugColoringEnabled", &DirectionalLightComponentConfig::m_isDebugColoringEnabled)
|
||||
->Field("ShadowFilterMethod", &DirectionalLightComponentConfig::m_shadowFilterMethod)
|
||||
->Field("SofteningBoundaryWidth", &DirectionalLightComponentConfig::m_boundaryWidth)
|
||||
->Field("PcfFilteringSampleCount", &DirectionalLightComponentConfig::m_filteringSampleCount)
|
||||
->Field("ShadowReceiverPlaneBiasEnabled", &DirectionalLightComponentConfig::m_receiverPlaneBiasEnabled);
|
||||
}
|
||||
|
||||
-19
@@ -80,8 +80,6 @@ namespace AZ
|
||||
->Event("SetDebugColoringEnabled", &DirectionalLightRequestBus::Events::SetDebugColoringEnabled)
|
||||
->Event("GetShadowFilterMethod", &DirectionalLightRequestBus::Events::GetShadowFilterMethod)
|
||||
->Event("SetShadowFilterMethod", &DirectionalLightRequestBus::Events::SetShadowFilterMethod)
|
||||
->Event("GetSofteningBoundaryWidth", &DirectionalLightRequestBus::Events::GetSofteningBoundaryWidth)
|
||||
->Event("SetSofteningBoundaryWidth", &DirectionalLightRequestBus::Events::SetSofteningBoundaryWidth)
|
||||
->Event("GetFilteringSampleCount", &DirectionalLightRequestBus::Events::GetFilteringSampleCount)
|
||||
->Event("SetFilteringSampleCount", &DirectionalLightRequestBus::Events::SetFilteringSampleCount)
|
||||
->Event("GetShadowReceiverPlaneBiasEnabled", &DirectionalLightRequestBus::Events::GetShadowReceiverPlaneBiasEnabled)
|
||||
@@ -99,7 +97,6 @@ namespace AZ
|
||||
->VirtualProperty("ViewFrustumCorrectionEnabled", "GetViewFrustumCorrectionEnabled", "SetViewFrustumCorrectionEnabled")
|
||||
->VirtualProperty("DebugColoringEnabled", "GetDebugColoringEnabled", "SetDebugColoringEnabled")
|
||||
->VirtualProperty("ShadowFilterMethod", "GetShadowFilterMethod", "SetShadowFilterMethod")
|
||||
->VirtualProperty("SofteningBoundaryWidth", "GetSofteningBoundaryWidth", "SetSofteningBoundaryWidth")
|
||||
->VirtualProperty("FilteringSampleCount", "GetFilteringSampleCount", "SetFilteringSampleCount")
|
||||
->VirtualProperty("ShadowReceiverPlaneBiasEnabled", "GetShadowReceiverPlaneBiasEnabled", "SetShadowReceiverPlaneBiasEnabled");
|
||||
;
|
||||
@@ -404,21 +401,6 @@ namespace AZ
|
||||
}
|
||||
}
|
||||
|
||||
float DirectionalLightComponentController::GetSofteningBoundaryWidth() const
|
||||
{
|
||||
return m_configuration.m_boundaryWidth;
|
||||
}
|
||||
|
||||
void DirectionalLightComponentController::SetSofteningBoundaryWidth(float width)
|
||||
{
|
||||
width = GetMin(Shadow::MaxSofteningBoundaryWidth, GetMax(0.f, width));
|
||||
m_configuration.m_boundaryWidth = width;
|
||||
if (m_featureProcessor)
|
||||
{
|
||||
m_featureProcessor->SetShadowBoundaryWidth(m_lightHandle, width);
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t DirectionalLightComponentController::GetFilteringSampleCount() const
|
||||
{
|
||||
return aznumeric_cast<uint32_t>(m_configuration.m_filteringSampleCount);
|
||||
@@ -517,7 +499,6 @@ namespace AZ
|
||||
SetViewFrustumCorrectionEnabled(m_configuration.m_isCascadeCorrectionEnabled);
|
||||
SetDebugColoringEnabled(m_configuration.m_isDebugColoringEnabled);
|
||||
SetShadowFilterMethod(m_configuration.m_shadowFilterMethod);
|
||||
SetSofteningBoundaryWidth(m_configuration.m_boundaryWidth);
|
||||
SetFilteringSampleCount(m_configuration.m_filteringSampleCount);
|
||||
SetShadowReceiverPlaneBiasEnabled(m_configuration.m_receiverPlaneBiasEnabled);
|
||||
|
||||
|
||||
-2
@@ -76,8 +76,6 @@ namespace AZ
|
||||
void SetDebugColoringEnabled(bool enabled) override;
|
||||
ShadowFilterMethod GetShadowFilterMethod() const override;
|
||||
void SetShadowFilterMethod(ShadowFilterMethod method) override;
|
||||
float GetSofteningBoundaryWidth() const override;
|
||||
void SetSofteningBoundaryWidth(float width) override;
|
||||
uint32_t GetFilteringSampleCount() const override;
|
||||
void SetFilteringSampleCount(uint32_t count) override;
|
||||
bool GetShadowReceiverPlaneBiasEnabled() const override;
|
||||
|
||||
@@ -147,14 +147,6 @@ namespace AZ::Render
|
||||
}
|
||||
}
|
||||
|
||||
void DiskLightDelegate::SetSofteningBoundaryWidthAngle(float widthInDegrees)
|
||||
{
|
||||
if (GetShadowsEnabled() && GetLightHandle().IsValid())
|
||||
{
|
||||
GetFeatureProcessor()->SetSofteningBoundaryWidthAngle(GetLightHandle(), DegToRad(widthInDegrees));
|
||||
}
|
||||
}
|
||||
|
||||
void DiskLightDelegate::SetFilteringSampleCount(uint32_t count)
|
||||
{
|
||||
if (GetShadowsEnabled() && GetLightHandle().IsValid())
|
||||
|
||||
@@ -44,7 +44,6 @@ namespace AZ
|
||||
void SetShadowBias(float bias) override;
|
||||
void SetShadowmapMaxSize(ShadowmapSize size) override;
|
||||
void SetShadowFilterMethod(ShadowFilterMethod method) override;
|
||||
void SetSofteningBoundaryWidthAngle(float widthInDegrees) override;
|
||||
void SetFilteringSampleCount(uint32_t count) override;
|
||||
void SetEsmExponent(float exponent) override;
|
||||
|
||||
|
||||
-9
@@ -154,15 +154,6 @@ namespace AZ
|
||||
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::AttributesAndValues)
|
||||
->Attribute(Edit::Attributes::Visibility, &AreaLightComponentConfig::SupportsShadows)
|
||||
->Attribute(Edit::Attributes::ReadOnly, &AreaLightComponentConfig::ShadowsDisabled)
|
||||
->DataElement(Edit::UIHandlers::Slider, &AreaLightComponentConfig::m_boundaryWidthInDegrees, "Softening boundary width",
|
||||
"Width of the boundary between shadowed area and lit one. "
|
||||
"Units are in degrees. "
|
||||
"If this is 0, softening edge is disabled.")
|
||||
->Attribute(Edit::Attributes::Min, 0.f)
|
||||
->Attribute(Edit::Attributes::Max, 1.f)
|
||||
->Attribute(Edit::Attributes::Suffix, " deg")
|
||||
->Attribute(Edit::Attributes::Visibility, &AreaLightComponentConfig::SupportsShadows)
|
||||
->Attribute(Edit::Attributes::ReadOnly, &AreaLightComponentConfig::IsEsmDisabled)
|
||||
->DataElement(Edit::UIHandlers::Slider, &AreaLightComponentConfig::m_filteringSampleCount, "Filtering sample count",
|
||||
"This is only used when the pixel is predicted to be on the boundary. Specific to PCF and ESM+PCF.")
|
||||
->Attribute(Edit::Attributes::Min, 4)
|
||||
|
||||
-9
@@ -133,15 +133,6 @@ namespace AZ
|
||||
->EnumAttribute(ShadowFilterMethod::Esm, "ESM")
|
||||
->EnumAttribute(ShadowFilterMethod::EsmPcf, "ESM+PCF")
|
||||
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
|
||||
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_boundaryWidth, "Softening boundary width",
|
||||
"Width of the boundary between shadowed area and lit one. "
|
||||
"Units are in meters. "
|
||||
"If this is 0, softening edge is disabled.")
|
||||
->Attribute(Edit::Attributes::Min, 0.f)
|
||||
->Attribute(Edit::Attributes::Max, 0.1f)
|
||||
->Attribute(Edit::Attributes::Suffix, " m")
|
||||
->Attribute(Edit::Attributes::ChangeNotify, Edit::PropertyRefreshLevels::ValuesOnly)
|
||||
->Attribute(Edit::Attributes::ReadOnly, &DirectionalLightComponentConfig::IsEsmDisabled)
|
||||
->DataElement(Edit::UIHandlers::Slider, &DirectionalLightComponentConfig::m_filteringSampleCount, "Filtering sample count",
|
||||
"This is used only when the pixel is predicted as on the boundary. "
|
||||
"Specific to PCF and ESM+PCF.")
|
||||
|
||||
@@ -56,7 +56,6 @@ namespace AZ
|
||||
void SetShadowBias([[maybe_unused]] float bias) override {};
|
||||
void SetShadowmapMaxSize([[maybe_unused]] ShadowmapSize size) override {};
|
||||
void SetShadowFilterMethod([[maybe_unused]] ShadowFilterMethod method) override {};
|
||||
void SetSofteningBoundaryWidthAngle([[maybe_unused]] float widthInDegrees) override {};
|
||||
void SetFilteringSampleCount([[maybe_unused]] uint32_t count) override {};
|
||||
void SetEsmExponent([[maybe_unused]] float esmExponent) override{};
|
||||
|
||||
|
||||
@@ -75,8 +75,6 @@ namespace AZ
|
||||
virtual void SetShadowmapMaxSize(ShadowmapSize size) = 0;
|
||||
//! Sets the filter method for the shadow
|
||||
virtual void SetShadowFilterMethod(ShadowFilterMethod method) = 0;
|
||||
//! Sets the width of boundary between shadowed area and lit area in degrees.
|
||||
virtual void SetSofteningBoundaryWidthAngle(float widthInDegrees) = 0;
|
||||
//! Sets the sample count for filtering of the shadow boundary, max 64.
|
||||
virtual void SetFilteringSampleCount(uint32_t count) = 0;
|
||||
//! Sets the Esm exponent to use. Higher values produce a steeper falloff between light and shadow.
|
||||
|
||||
@@ -92,14 +92,6 @@ namespace AZ::Render
|
||||
}
|
||||
}
|
||||
|
||||
void SphereLightDelegate::SetSofteningBoundaryWidthAngle(float widthInDegrees)
|
||||
{
|
||||
if (GetShadowsEnabled() && GetLightHandle().IsValid())
|
||||
{
|
||||
GetFeatureProcessor()->SetSofteningBoundaryWidthAngle(GetLightHandle(), DegToRad(widthInDegrees));
|
||||
}
|
||||
}
|
||||
|
||||
void SphereLightDelegate::SetFilteringSampleCount(uint32_t count)
|
||||
{
|
||||
if (GetShadowsEnabled() && GetLightHandle().IsValid())
|
||||
|
||||
@@ -34,7 +34,6 @@ namespace AZ
|
||||
void SetShadowBias(float bias) override;
|
||||
void SetShadowmapMaxSize(ShadowmapSize size) override;
|
||||
void SetShadowFilterMethod(ShadowFilterMethod method) override;
|
||||
void SetSofteningBoundaryWidthAngle(float widthInDegrees) override;
|
||||
void SetFilteringSampleCount(uint32_t count) override;
|
||||
void SetEsmExponent(float esmExponent) override;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user