Support Forum       G3D Web Page     
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | Static Protected Attributes | List of all members
G3D::DDGIVolume Class Reference

A volume of space within which irradiance queries at arbitrary points are supported using a grid of DDGI probes. More...

Inherits G3D::ReferenceCountedObject.

Public Types

enum  ProbeStates {
  OFF = 0,
  ASLEEP = 1,
  JUST_WOKE = 2,
  AWAKE = 3,
  JUST_VIGILANT = 4,
  VIGILANT = 5,
  UNINITIALIZED = 6
}
 

Public Member Functions

bool cameraLocked ()
 
void computeProbeOffsetsAndFlags (RenderDevice *rd, const shared_ptr< Texture > &rayHitLocations, const int offset, const int raysPerProbe, bool adjustOffsets=true)
 
void debugDrawProbeLabels (float probeVisualizationRadius) const
 
void debugRenderProbeVisualization (RenderDevice *rd, const shared_ptr< Camera > &camera, const bool visualizeDepth, const float probeVisualizationRadius)
 
bool encloseScene ()
 Should the bounds of the probes go around the geo or to the edge of the geo? More...
 
void gatherTracingProbes (const Array< ProbeStates > &states)
 
int guiIrradianceFormatIndex ()
 
int guiVisibilityFormatIndex ()
 
bool hasTracingProbes ()
 
void init (const String &name, const DDGIVolumeSpecification &spec, const Point3 &cameraPos=Point3(0, 0, 0))
 
const ImageFormatirradianceFormat ()
 
const int irradianceOctSideLength ()
 
const shared_ptr< Texture > & irradianceTexture ()
 
Vector4int8mapSleepingProbesBuffer (bool forWriting=false)
 
bool notifyOfCameraPosition (const Point3 &cameraWSPosition)
 
void notifyOfDynamicObjects (const Array< AABox > &currentBoxArray, const Array< Vector3 > &velocityArray)
 
void onGlobalLightChange ()
 Switch to low hysteresis for a few frames. More...
 
void onLargeObjectChange ()
 
void onSmallLightChange ()
 
int probeCount () const
 
const Vector3int32probeCounts () const
 
const shared_ptr< Texture > & probeOffsetTexture ()
 
bool probeSleeping ()
 
virtual const Matrix3randomOrientation ()
 
const shared_ptr< GLPixelTransferBuffer > & rayBlockIndexOffsetBuffer ()
 
virtual void resizeIfNeeded ()
 
void setCameraLocked (bool b)
 
void setDepthOctSideLength (int sideLengthSize, RenderDevice *rd)
 
void setEncloseScene (bool b)
 
void setFirstFrame (bool b)
 
void setGuiIrradianceFormatIndex (int index)
 
void setGuiVisibilityFormatIndex (int index)
 
void setIrradianceOctSideLength (int sideLengthSize, RenderDevice *rd)
 
void setProbeSleeping (bool b)
 
void setRandomOrientation (const Matrix3 &orientation)
 
void setShaderArgs (UniformTable &args, const String &prefix)
 
int skippedProbes ()
 
DDGIVolumeSpecificationspecification ()
 
void unmapSleepingProbesBuffer ()
 
virtual void updateAllProbeTypes (RenderDevice *rd, const Array< shared_ptr< Surface >> &surfaceArray, const shared_ptr< Texture > &rayHitLocations, const shared_ptr< Texture > &rayHitRadiance, const int offset, const int raysPerProbe)
 Update both irradiance and depth using newly sampled rays. More...
 
void updateIrradianceTexture (const shared_ptr< Texture > &newTexture)
 
void updateIrradianceTexture (const shared_ptr< GLPixelTransferBuffer > &pbo)
 
void updateProbeOffsetTexture (const shared_ptr< Texture > &newTexture)
 
void updateProbeOffsetTexture (const shared_ptr< GLPixelTransferBuffer > &pbo)
 
void updateVisibilityTexture (const shared_ptr< Texture > &newTexture)
 
void updateVisibilityTexture (const shared_ptr< GLPixelTransferBuffer > &pbo)
 
const int visibilityOctSideLength ()
 
const shared_ptr< Texture > & visibilityTexture ()
 

Static Public Member Functions

static shared_ptr< DDGIVolumecreate (const String &name, const DDGIVolumeSpecification &spec, const Point3 &cameraPos)
 
static void loadGeometry (const String &filename, float scale, Color3 faceColor, AttributeArray &vertexArray, IndexStream &indexStream)
 
static const Texture::EncodingnormalEncoding ()
 
static void setVisualizeDebugColors (bool b)
 
static const bool visualizeDebugColors ()
 

Protected Member Functions

Point3int32 probeIndexToGridIndex (int index) const
 
Point3 probeIndexToPosition (int index) const
 
void setProbeStatesToUninitialized ()
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 

Protected Attributes

shared_ptr< GLPixelTransferBufferm_conservativeAABoundsPBO
 
int m_debugProbeVisualizationColorsIndex
 
bool m_firstFrame = true
 If true, set hysteresis to zero and force all probes to re-render. More...
 
int m_guiIrradianceFormatIndex = 3
 
bool m_guiProbeFormatChanged
 
int m_guiVisibilityFormatIndex = 2
 
shared_ptr< Texturem_irradianceTexture
 Irradiance encoded with a high gamma curve. More...
 
int m_lowIrradianceHysteresisFrames = 0
 When lighting changes dramatically, we drop the hysteresis to 50% of the typical value for a few frames. More...
 
int m_lowVisibilityHysteresisFrames = 0
 
float m_maxDistance = 4.0f
 Maximum distance that can be written to a probe. More...
 
String m_name
 
Vector3int32 m_phaseOffset = Vector3int32(0, 0, 0)
 
Point3 m_probeGridOrigin
 
shared_ptr< Texturem_probeOffsetTexture
 
bool m_probeSleeping
 
Vector3 m_probeSpacing
 
Matrix3 m_randomOrientation
 Stored so that we can use the same random orientation for each of many calls that recompute the ray direction. More...
 
shared_ptr< GLPixelTransferBufferm_rayBlockIndexOffset
 1D mapping from probe indices to ray block indices in the compressed ray buffers. More...
 
int m_reducedIrradianceHysteresisFrames = 0
 
int m_skippedProbes = 0
 
shared_ptr< GLPixelTransferBufferm_sleepingProbesBuffer
 
DDGIVolumeSpecification m_specification
 
Vector3int32 m_uninitializedPlane = Vector3int32(0, 0, 0)
 
shared_ptr< Texturem_visibilityTexture
 R = mean distance, G = mean distance^2. More...
 

Static Protected Attributes

static const Array< Color3s_debugProbeVisualizationColors
 
static int s_debugProbeVisualizationColorsIndex
 
static IndexStream s_debugProbeVisualizationIndexStream
 
static AttributeArray s_debugProbeVisualizationVertexArray
 
static const Array< const ImageFormat * > s_guiDepthFormats
 
static const Array< const ImageFormat * > s_guiIrradianceFormats
 
static shared_ptr< GFonts_guiLabelFont
 
static bool s_visualizeDebugColors
 

Detailed Description

A volume of space within which irradiance queries at arbitrary points are supported using a grid of DDGI probes.

A single DDGIVolume may cover the entire scene and use multiple update cascades within it.

If there are parts of your scene with very different geometric density or dimensions, you can have multiple DDGIVolumes.

Member Enumeration Documentation

◆ ProbeStates

Enumerator
OFF 
ASLEEP 
JUST_WOKE 
AWAKE 
JUST_VIGILANT 
VIGILANT 
UNINITIALIZED 

Member Function Documentation

◆ cameraLocked()

bool G3D::DDGIVolume::cameraLocked ( )
inline

◆ computeProbeOffsetsAndFlags()

void G3D::DDGIVolume::computeProbeOffsetsAndFlags ( RenderDevice rd,
const shared_ptr< Texture > &  rayHitLocations,
const int  offset,
const int  raysPerProbe,
bool  adjustOffsets = true 
)

◆ create()

static shared_ptr<DDGIVolume> G3D::DDGIVolume::create ( const String name,
const DDGIVolumeSpecification spec,
const Point3 cameraPos 
)
static

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ debugDrawProbeLabels()

void G3D::DDGIVolume::debugDrawProbeLabels ( float  probeVisualizationRadius) const

◆ debugRenderProbeVisualization()

void G3D::DDGIVolume::debugRenderProbeVisualization ( RenderDevice rd,
const shared_ptr< Camera > &  camera,
const bool  visualizeDepth,
const float  probeVisualizationRadius 
)

◆ encloseScene()

bool G3D::DDGIVolume::encloseScene ( )
inline

Should the bounds of the probes go around the geo or to the edge of the geo?

◆ gatherTracingProbes()

void G3D::DDGIVolume::gatherTracingProbes ( const Array< ProbeStates > &  states)

◆ guiIrradianceFormatIndex()

int G3D::DDGIVolume::guiIrradianceFormatIndex ( )
inline

◆ guiVisibilityFormatIndex()

int G3D::DDGIVolume::guiVisibilityFormatIndex ( )
inline

◆ hasTracingProbes()

bool G3D::DDGIVolume::hasTracingProbes ( )
inline

◆ init()

void G3D::DDGIVolume::init ( const String name,
const DDGIVolumeSpecification spec,
const Point3 cameraPos = Point3(0, 0, 0) 
)

◆ irradianceFormat()

const ImageFormat* G3D::DDGIVolume::irradianceFormat ( )
inline

◆ irradianceOctSideLength()

const int G3D::DDGIVolume::irradianceOctSideLength ( )
inline

◆ irradianceTexture()

const shared_ptr<Texture>& G3D::DDGIVolume::irradianceTexture ( )
inline

◆ loadGeometry()

static void G3D::DDGIVolume::loadGeometry ( const String filename,
float  scale,
Color3  faceColor,
AttributeArray vertexArray,
IndexStream indexStream 
)
static

◆ mapSleepingProbesBuffer()

Vector4int8* G3D::DDGIVolume::mapSleepingProbesBuffer ( bool  forWriting = false)

◆ normalEncoding()

static const Texture::Encoding& G3D::DDGIVolume::normalEncoding ( )
inlinestatic

◆ notifyOfCameraPosition()

bool G3D::DDGIVolume::notifyOfCameraPosition ( const Point3 cameraWSPosition)

◆ notifyOfDynamicObjects()

void G3D::DDGIVolume::notifyOfDynamicObjects ( const Array< AABox > &  currentBoxArray,
const Array< Vector3 > &  velocityArray 
)

◆ onGlobalLightChange()

void G3D::DDGIVolume::onGlobalLightChange ( )
inline

Switch to low hysteresis for a few frames.

Referenced by onLargeObjectChange().

◆ onLargeObjectChange()

void G3D::DDGIVolume::onLargeObjectChange ( )
inline

◆ onSmallLightChange()

void G3D::DDGIVolume::onSmallLightChange ( )
inline

◆ probeCount()

int G3D::DDGIVolume::probeCount ( ) const
inline

Referenced by hasTracingProbes().

◆ probeCounts()

const Vector3int32& G3D::DDGIVolume::probeCounts ( ) const
inline

◆ probeIndexToGridIndex()

Point3int32 G3D::DDGIVolume::probeIndexToGridIndex ( int  index) const
protected

◆ probeIndexToPosition()

Point3 G3D::DDGIVolume::probeIndexToPosition ( int  index) const
protected

◆ probeOffsetTexture()

const shared_ptr<Texture>& G3D::DDGIVolume::probeOffsetTexture ( )
inline

◆ probeSleeping()

bool G3D::DDGIVolume::probeSleeping ( )
inline

◆ randomOrientation()

virtual const Matrix3& G3D::DDGIVolume::randomOrientation ( )
inlinevirtual

◆ rayBlockIndexOffsetBuffer()

const shared_ptr<GLPixelTransferBuffer>& G3D::DDGIVolume::rayBlockIndexOffsetBuffer ( )
inline

◆ resizeIfNeeded()

virtual void G3D::DDGIVolume::resizeIfNeeded ( )
virtual

◆ setCameraLocked()

void G3D::DDGIVolume::setCameraLocked ( bool  b)
inline

◆ setDepthOctSideLength()

void G3D::DDGIVolume::setDepthOctSideLength ( int  sideLengthSize,
RenderDevice rd 
)
inline

◆ setEncloseScene()

void G3D::DDGIVolume::setEncloseScene ( bool  b)
inline

◆ setFirstFrame()

void G3D::DDGIVolume::setFirstFrame ( bool  b)
inline

◆ setGuiIrradianceFormatIndex()

void G3D::DDGIVolume::setGuiIrradianceFormatIndex ( int  index)
inline

◆ setGuiVisibilityFormatIndex()

void G3D::DDGIVolume::setGuiVisibilityFormatIndex ( int  index)
inline

◆ setIrradianceOctSideLength()

void G3D::DDGIVolume::setIrradianceOctSideLength ( int  sideLengthSize,
RenderDevice rd 
)
inline

◆ setProbeSleeping()

void G3D::DDGIVolume::setProbeSleeping ( bool  b)
inline

◆ setProbeStatesToUninitialized()

void G3D::DDGIVolume::setProbeStatesToUninitialized ( )
protected

◆ setRandomOrientation()

void G3D::DDGIVolume::setRandomOrientation ( const Matrix3 orientation)
inline

◆ setShaderArgs()

void G3D::DDGIVolume::setShaderArgs ( UniformTable args,
const String prefix 
)

◆ setVisualizeDebugColors()

static void G3D::DDGIVolume::setVisualizeDebugColors ( bool  b)
inlinestatic

◆ skippedProbes()

int G3D::DDGIVolume::skippedProbes ( )
inline

◆ specification()

DDGIVolumeSpecification& G3D::DDGIVolume::specification ( )
inline

◆ unmapSleepingProbesBuffer()

void G3D::DDGIVolume::unmapSleepingProbesBuffer ( )

◆ updateAllProbeTypes()

virtual void G3D::DDGIVolume::updateAllProbeTypes ( RenderDevice rd,
const Array< shared_ptr< Surface >> &  surfaceArray,
const shared_ptr< Texture > &  rayHitLocations,
const shared_ptr< Texture > &  rayHitRadiance,
const int  offset,
const int  raysPerProbe 
)
virtual

Update both irradiance and depth using newly sampled rays.

Optional offset within the ray textures for multiple volumes. For now, this offset is equal to the number of probes in the first volume: the texture dimensions are:

w = max(ddgiVolumePrimary.raysPerProbe, ddgiVolumeSecondary.raysPerProbe); h = ddgiVolumePrimary.numProbes + ddgiVolumeSecondary.numProbes;

Lot's of unused texture space in the common case where both volumes cast a different number of rays/probe. However, we'll clean this up by compacting the smaller buffer to have multiple probes on one row.

◆ updateIrradianceTexture() [1/2]

void G3D::DDGIVolume::updateIrradianceTexture ( const shared_ptr< Texture > &  newTexture)

◆ updateIrradianceTexture() [2/2]

void G3D::DDGIVolume::updateIrradianceTexture ( const shared_ptr< GLPixelTransferBuffer > &  pbo)

◆ updateProbeOffsetTexture() [1/2]

void G3D::DDGIVolume::updateProbeOffsetTexture ( const shared_ptr< Texture > &  newTexture)

◆ updateProbeOffsetTexture() [2/2]

void G3D::DDGIVolume::updateProbeOffsetTexture ( const shared_ptr< GLPixelTransferBuffer > &  pbo)

◆ updateVisibilityTexture() [1/2]

void G3D::DDGIVolume::updateVisibilityTexture ( const shared_ptr< Texture > &  newTexture)

◆ updateVisibilityTexture() [2/2]

void G3D::DDGIVolume::updateVisibilityTexture ( const shared_ptr< GLPixelTransferBuffer > &  pbo)

◆ visibilityOctSideLength()

const int G3D::DDGIVolume::visibilityOctSideLength ( )
inline

◆ visibilityTexture()

const shared_ptr<Texture>& G3D::DDGIVolume::visibilityTexture ( )
inline

◆ visualizeDebugColors()

static const bool G3D::DDGIVolume::visualizeDebugColors ( )
inlinestatic

Member Data Documentation

◆ m_conservativeAABoundsPBO

shared_ptr<GLPixelTransferBuffer> G3D::DDGIVolume::m_conservativeAABoundsPBO
protected

◆ m_debugProbeVisualizationColorsIndex

int G3D::DDGIVolume::m_debugProbeVisualizationColorsIndex
protected

◆ m_firstFrame

bool G3D::DDGIVolume::m_firstFrame = true
protected

If true, set hysteresis to zero and force all probes to re-render.

Used for when parameters change.

Referenced by setFirstFrame().

◆ m_guiIrradianceFormatIndex

int G3D::DDGIVolume::m_guiIrradianceFormatIndex = 3
protected

◆ m_guiProbeFormatChanged

bool G3D::DDGIVolume::m_guiProbeFormatChanged
protected

◆ m_guiVisibilityFormatIndex

int G3D::DDGIVolume::m_guiVisibilityFormatIndex = 2
protected

◆ m_irradianceTexture

shared_ptr<Texture> G3D::DDGIVolume::m_irradianceTexture
protected

Irradiance encoded with a high gamma curve.

Referenced by irradianceTexture().

◆ m_lowIrradianceHysteresisFrames

int G3D::DDGIVolume::m_lowIrradianceHysteresisFrames = 0
protected

When lighting changes dramatically, we drop the hysteresis to 50% of the typical value for a few frames.

Referenced by onGlobalLightChange().

◆ m_lowVisibilityHysteresisFrames

int G3D::DDGIVolume::m_lowVisibilityHysteresisFrames = 0
protected

Referenced by onLargeObjectChange().

◆ m_maxDistance

float G3D::DDGIVolume::m_maxDistance = 4.0f
protected

Maximum distance that can be written to a probe.

◆ m_name

String G3D::DDGIVolume::m_name
protected

◆ m_phaseOffset

Vector3int32 G3D::DDGIVolume::m_phaseOffset = Vector3int32(0, 0, 0)
protected

◆ m_probeGridOrigin

Point3 G3D::DDGIVolume::m_probeGridOrigin
protected

◆ m_probeOffsetTexture

shared_ptr<Texture> G3D::DDGIVolume::m_probeOffsetTexture
protected

Referenced by probeOffsetTexture().

◆ m_probeSleeping

bool G3D::DDGIVolume::m_probeSleeping
protected

Referenced by probeSleeping(), and setProbeSleeping().

◆ m_probeSpacing

Vector3 G3D::DDGIVolume::m_probeSpacing
protected

◆ m_randomOrientation

Matrix3 G3D::DDGIVolume::m_randomOrientation
protected

Stored so that we can use the same random orientation for each of many calls that recompute the ray direction.

Referenced by randomOrientation(), and setRandomOrientation().

◆ m_rayBlockIndexOffset

shared_ptr<GLPixelTransferBuffer> G3D::DDGIVolume::m_rayBlockIndexOffset
protected

1D mapping from probe indices to ray block indices in the compressed ray buffers.

Referenced by rayBlockIndexOffsetBuffer().

◆ m_reducedIrradianceHysteresisFrames

int G3D::DDGIVolume::m_reducedIrradianceHysteresisFrames = 0
protected

Referenced by onSmallLightChange().

◆ m_skippedProbes

int G3D::DDGIVolume::m_skippedProbes = 0
protected

Referenced by hasTracingProbes(), and skippedProbes().

◆ m_sleepingProbesBuffer

shared_ptr<GLPixelTransferBuffer> G3D::DDGIVolume::m_sleepingProbesBuffer
protected

◆ m_specification

DDGIVolumeSpecification G3D::DDGIVolume::m_specification
protected

◆ m_uninitializedPlane

Vector3int32 G3D::DDGIVolume::m_uninitializedPlane = Vector3int32(0, 0, 0)
protected

◆ m_visibilityTexture

shared_ptr<Texture> G3D::DDGIVolume::m_visibilityTexture
protected

R = mean distance, G = mean distance^2.

Referenced by visibilityTexture().

◆ s_debugProbeVisualizationColors

const Array<Color3> G3D::DDGIVolume::s_debugProbeVisualizationColors
staticprotected

◆ s_debugProbeVisualizationColorsIndex

int G3D::DDGIVolume::s_debugProbeVisualizationColorsIndex
staticprotected

◆ s_debugProbeVisualizationIndexStream

IndexStream G3D::DDGIVolume::s_debugProbeVisualizationIndexStream
staticprotected

◆ s_debugProbeVisualizationVertexArray

AttributeArray G3D::DDGIVolume::s_debugProbeVisualizationVertexArray
staticprotected

◆ s_guiDepthFormats

const Array<const ImageFormat*> G3D::DDGIVolume::s_guiDepthFormats
staticprotected

◆ s_guiIrradianceFormats

const Array<const ImageFormat*> G3D::DDGIVolume::s_guiIrradianceFormats
staticprotected

Referenced by irradianceFormat().

◆ s_guiLabelFont

shared_ptr<GFont> G3D::DDGIVolume::s_guiLabelFont
staticprotected

◆ s_visualizeDebugColors

bool G3D::DDGIVolume::s_visualizeDebugColors
staticprotected

documentation generated on Wed Nov 24 2021 08:01:54 using doxygen 1.8.15