Open 3D Engine Atom Gem API Reference 23.10.0
O3DE is an open-source, fully-featured, high-fidelity, modular 3D engine for building games and simulations, available to every industry.
AZ::Render::ShadowmapAtlas Class Referencefinal

#include <ShadowmapAtlas.h>

Classes

struct  Origin
 
struct  ShadowmapIndexNode
 

Public Member Functions

void Initialize ()
 This initializes the packing of shadowmap sizes.
 
void SetShadowmapSize (size_t index, ShadowmapSize size)
 
void Finalize ()
 
uint16_t GetArraySliceCount () const
 
ShadowmapSize GetBaseShadowmapSize () const
 
Origin GetOrigin (size_t index) const
 
Data::Instance< RPI::BufferCreateShadowmapIndexTableBuffer (const AZStd::string &bufferName) const
 
const AZStd::vector< ShadowmapIndexNode > & GetShadowmapIndexTable () const
 

Detailed Description

A shadowmap atlas is a single image array which contains shadowmaps with different sizes. This ShadowmapAtlas class determines the location of each shadowmap. This class also offers ShadowmapIndexTable, by which a compute shader can determine the corresponding shadowmap index from a coordinate (x, y, z) in the image array resource.

Member Function Documentation

◆ CreateShadowmapIndexTableBuffer()

Data::Instance< RPI::Buffer > AZ::Render::ShadowmapAtlas::CreateShadowmapIndexTableBuffer ( const AZStd::string &  bufferName) const

This returns a buffer by which a shader finds the shadowmap index in the atlas.

Parameters
bufferNamename of the buffer
Returns
buffer which a computer shader look up for the shadowmap index.

The buffer contains a table ShadowmapIndexTable which consists of "subtables." A subtable is an array of ShadowmapIndexNodes, and corresponds to a shadowmap Location. A ShadowmapIndexNode offers either the offset to another subtable or ths shadowmap index. So a subtable offers the offsets of the sub-subtable and shadowmap indices for direct children Location of the corresponding Location. We call the subtable for Locaion [] (the empty array) by "root subtable." The size of the root subtable equals to the array slice count of the image resource which the atlas occupies. The size of a non-root subtable (i.e., subtable for non-empty Location) is LocationIndexNum, i.e., 4. If m_nextTableOffset != 0, then m_nextTableOffset means the corresponding subtable's offset from the beginning of the buffer. If m_nextTableOffset == 0, then m_shadowmapIndex is the required shadowmap index.

For example, we assume baseShadowmapSize = 2048 light #0 uses Location [0], #1 does [1,0], and #2 does [1,1]. Then the resulting array "table" of T has size 6 and would be like below:

(root subtable, i.e., subtable for Location []) table[0] : m_nextTableOffset == 0, and m_shadowmapIndex == 0 the Location of the shadowmap is [0]. table[1] : m_nextTableOffset == 2 which indicate slice #1 is shared by multiple shadowmaps and the next subtable begin with offset 2.

(subtalble for Location [1]) table[2 + 0] : m_nextTableOffset == 0 and m_shadowmapIndex == 1 the Location of the shadowmap is [1, 0]. table[2 + 1] : m_nextTableOffset == 0 and m_shadowmapIndex == 2 the Location of the shadowmap is [1, 1]. table[4], table[5] : not used. For the way to extract shadowmap specific parameter, refer ShadowmapAtlasLib.azsli.

◆ Finalize()

void AZ::Render::ShadowmapAtlas::Finalize ( )

This decides shadowmap locations in the atlas. As we describe below (above of definition of Location), a location is encoded in a finite sequence of non-negative integers. This determines the locations from the largest shadowmaps to smaller ones, and the locations of the same size are occupied in the lexicographical order, e.g., [0,1,1] is occupied before [0,1,2].

◆ GetArraySliceCount()

uint16_t AZ::Render::ShadowmapAtlas::GetArraySliceCount ( ) const

This returns array slice count of the atlas. This has to be called after execution of Finalize().

Returns
array slice count of the atlas.

◆ GetBaseShadowmapSize()

ShadowmapSize AZ::Render::ShadowmapAtlas::GetBaseShadowmapSize ( ) const

This returns image size of the atlas. This has to be called after execution of Finalize().

Returns
image size of the atlas.

◆ GetOrigin()

Origin AZ::Render::ShadowmapAtlas::GetOrigin ( size_t  index) const

This returns shadowmap origin in the atlas. This has to be called after execution of Finalize().

Parameters
indexshadowmap index.
Returns
shadowmap origin in the atlas.

◆ SetShadowmapSize()

void AZ::Render::ShadowmapAtlas::SetShadowmapSize ( size_t  index,
ShadowmapSize  size 
)

This sets shadowmap size.

Parameters
indexlight index of shadowmap.
sizeshadowmap size (width/height).

The documentation for this class was generated from the following file: