![]() |
OGRE-Next
4.0.0unstable
Object-Oriented Graphics Rendering Engine
|
#include <OgreVctLighting.h>
Public Member Functions | |
VctLighting (IdType id, VctVoxelizerSourceBase *voxelizer, bool bAnisotropic) | |
~VctLighting () override | |
void | addCascade (VctLighting *cascade) |
Used by VctCascadedVoxelizer. More... | |
void | fillConstBufferData (const Matrix4 &viewMatrix, float *RESTRICT_ALIAS passBufferPtr) const |
bool | getAllowMultipleBounces () const |
float | getBakingMultiplier () const |
const HlmsSamplerblock * | getBindTrilinearSamplerblock () |
size_t | getConstBufferSize () const |
float | getCurrentBakingMultiplier () const |
If you've set setBakingMultiplier but haven't yet called VctLighting::update with autoMultiplier = false, this function returns the baking multiplier that is currently in use (beware of floating point accuracy differences) More... | |
bool | getDebugVisualizationMode () const |
TextureGpu ** | getLightVoxelTextures () |
TextureGpu ** | getLightVoxelTextures (const size_t cascadeIdx) |
size_t | getNumCascades () const |
uint32 | getNumVoxelTextures () const |
const VctVoxelizerSourceBase * | getVoxelizer () const |
bool | isAnisotropic () const |
bool | needsAmbientHemisphere () const |
void | notifyTextureChanged (TextureGpu *texture, TextureGpuListener::Reason reason, void *extraData) override |
Called when a TextureGpu changed in a way that affects how it is displayed: More... | |
void | reserveExtraCascades (size_t numExtraCascades) |
Used by VctCascadedVoxelizer. More... | |
void | resetTexturesFromBuildRelative () |
When VctImageVoxelizer::buildRelative is called; voxelizer's textures (albedo, normal, emissive) may be swapped for a copy. More... | |
void | setAllowMultipleBounces (bool bAllowMultipleBounces) |
This function allows VctLighting::update to pass numBounces > 0 as argument. More... | |
void | setAmbient (const ColourValue &upperHemisphere, const ColourValue &lowerHemisphere) |
Extremely similar version of SceneManager::setAmbientLight In fact the hemisphereDir parameter is shared and set in SceneManager::setAmbientLight. More... | |
void | setAnisotropic (bool bAnisotropic) |
Toggles anisotropic mips. More... | |
void | setBakingMultiplier (float bakingMult) |
Sets baking multiplier for HDR rendering. More... | |
void | setDebugVisualization (bool bShow, SceneManager *sceneManager) |
bool | shouldEnableSpecularSdfQuality () const |
bool | shouldStayLoaded (TextureGpu *texture) override |
Return true if this TextureGpu should likely stay loaded or else graphical changes could occur. More... | |
void | update (SceneManager *sceneManager, uint32 numBounces, float thinWallCounter=1.0f, bool autoMultiplier=true, float rayMarchStepScale=1.0f, uint32 lightMask=0xffffffff) |
![]() | |
IdObject (IdType id) | |
We don't call generateNewId() here, to prevent objects in the stack (i.e. More... | |
IdType | getId () const |
Get the unique id of this object. More... | |
bool | operator() (const IdObject &left, const IdObject &right) |
bool | operator() (const IdObject *left, const IdObject *right) |
![]() | |
virtual | ~TextureGpuListener () |
Public Attributes | |
float | mMultiplier |
Sets the intensity/brightness of the GI. More... | |
float | mSpecularSdfQuality |
When roughness is close to 0.02, specular cone tracing becomes path tracing. More... | |
Static Public Attributes | |
static const uint16 | msDistanceThresholdCustomParam |
Additional Inherited Members | |
![]() | |
enum | Reason { Unknown , FromStorageToSysRam , FromSysRamToStorage , GainedResidency , LostResidency , PoolTextureSlotChanged , ResidentToSysRamSync , MetadataCacheOutOfDate , ExceptionThrown , FsaaSettingAlteredByApi , ReadyForRendering , Deleted } |
Ogre::VctLighting::VctLighting | ( | IdType | id, |
VctVoxelizerSourceBase * | voxelizer, | ||
bool | bAnisotropic | ||
) |
|
override |
void Ogre::VctLighting::addCascade | ( | VctLighting * | cascade | ) |
Used by VctCascadedVoxelizer.
By having extra cascade info, we can calculate multiple bounces with extra info
void Ogre::VctLighting::fillConstBufferData | ( | const Matrix4 & | viewMatrix, |
float *RESTRICT_ALIAS | passBufferPtr | ||
) | const |
bool Ogre::VctLighting::getAllowMultipleBounces | ( | ) | const |
|
inline |
|
inline |
size_t Ogre::VctLighting::getConstBufferSize | ( | ) | const |
|
inline |
If you've set setBakingMultiplier but haven't yet called VctLighting::update with autoMultiplier = false, this function returns the baking multiplier that is currently in use (beware of floating point accuracy differences)
bool Ogre::VctLighting::getDebugVisualizationMode | ( | ) | const |
|
inline |
TextureGpu** Ogre::VctLighting::getLightVoxelTextures | ( | const size_t | cascadeIdx | ) |
|
inline |
References Ogre::FastArray< T >::size().
|
inline |
|
inline |
|
inline |
bool Ogre::VctLighting::needsAmbientHemisphere | ( | ) | const |
|
overridevirtual |
Called when a TextureGpu changed in a way that affects how it is displayed:
Implements Ogre::TextureGpuListener.
void Ogre::VctLighting::reserveExtraCascades | ( | size_t | numExtraCascades | ) |
Used by VctCascadedVoxelizer.
By having extra cascade info, we can calculate multiple bounces with extra info
This function calls mExtraCascades.reserve
void Ogre::VctLighting::resetTexturesFromBuildRelative | ( | ) |
When VctImageVoxelizer::buildRelative is called; voxelizer's textures (albedo, normal, emissive) may be swapped for a copy.
This function notifies us that buildRelative to update some of our references
void Ogre::VctLighting::setAllowMultipleBounces | ( | bool | bAllowMultipleBounces | ) |
This function allows VctLighting::update to pass numBounces > 0 as argument.
Note however, that multiple bounces requires creating another RGBA32_UNORM texture of the same resolution as the voxel texture.
This can cause increase memory consumption.
However remember to call setAllowMultipleBounces( true ) before calling update() again with numBounces > 0.
bAllowMultipleBounces | True to allow multiple bounces, and consume more memory. False to no longer allow multiple bounces, and release memory. |
void Ogre::VctLighting::setAmbient | ( | const ColourValue & | upperHemisphere, |
const ColourValue & | lowerHemisphere | ||
) |
Extremely similar version of SceneManager::setAmbientLight In fact the hemisphereDir parameter is shared and set in SceneManager::setAmbientLight.
Setting upperHemisphere = lowerHemisphere can cause shader recompilations.
These values are used when cone tracing reaches the end of the probe without hitting anything, which usually means the sky must be visible.
upperHemisphere | upperHemisphere should be set to the sky colour, which is usually set to a value much brighter than the ambient light (i.e. use the clear colour instead of the ambient colour) |
lowerHemisphere | lowerHemisphere should be set to the ground colour |
void Ogre::VctLighting::setAnisotropic | ( | bool | bAnisotropic | ) |
Toggles anisotropic mips.
Anisotropic mips provide much higher quality and generally lower light leaking. However it costs a bit more performance, and increases memory consumption.
Normally regular mipmaps of 3D textures increase memory consumption by 1/7 Anisotropic mipmaps of 3D textures increase memory consumption by 6/7
void Ogre::VctLighting::setBakingMultiplier | ( | float | bakingMult | ) |
Sets baking multiplier for HDR rendering.
Internally the lighting data is stored in RGBA8_UNORM_sRGB, which is not enough for HDR. More precise formats would allow for native HDR, however it's memory cost and bandwidth could be prohibtive.
Hence bakingMult is used to bring down the lighting data to usable levels without saturation (however beware areas with very low lighting conditions may round to 0).
During rendering, we use 1.0 / bakingMult to bring back the values its original range.
For LDR rendering, you probably would want to set this value to 1.0.
This function is different from VctLighting::mMultiplier. That variable controls the GI strength/brightness. This function only controls precision and accuracy.
bakingMult | Value to multiply against GI lighting during baking. Use values >= 1 when all your lights are too dim, but could saturate quickly if that's not the case |
Values <= 1 make when your lights are very bright, but can cause low light to become 0 (too dark)
Changes to this value take effect after calling VctLighting::update and autoMultiplier must be set to false
void Ogre::VctLighting::setDebugVisualization | ( | bool | bShow, |
SceneManager * | sceneManager | ||
) |
bool Ogre::VctLighting::shouldEnableSpecularSdfQuality | ( | ) | const |
|
inlineoverridevirtual |
Return true if this TextureGpu should likely stay loaded or else graphical changes could occur.
Return false if it is certainly safe to unload.
Reimplemented from Ogre::TextureGpuListener.
void Ogre::VctLighting::update | ( | SceneManager * | sceneManager, |
uint32 | numBounces, | ||
float | thinWallCounter = 1.0f , |
||
bool | autoMultiplier = true , |
||
float | rayMarchStepScale = 1.0f , |
||
uint32 | lightMask = 0xffffffff |
||
) |
sceneManager | |
numBounces | Number of GI bounces. This value must be 0 if getAllowMultipleBounces() == false |
thinWallCounter | Shadows are calculated by raymarching towards the light source. However sometimes the ray 'may go through' a wall due to how bilinear interpolation works. |
Bilinear interpolation can produce nicer soft shaddows, but it can also cause this light leaking from behind a wall.
Increase this value (e.g. to 2.0f) to fight light leaking. This should generally (over-)darken the scene
Lower values will lighten the scene and allow more light leaking
Note that thinWallCounter can not fight all sources of light leaking, thus increasing it to ridiculous high values may not yield any benefit.
autoMultiplier | Whether we should calculate the ideal multiplier based on lights on scene. See VctLighting::setMultiplier |
rayMarchStepScale | Scale for the ray march step size. A value < 1.0f makes little sense and will trigger an assert. |
Bigger values means the shadow raymarching during light injection pass is faster, but may cause glitches if too high (areas that are supposed to be shadowed won't be shadowed)
lightMask |
float Ogre::VctLighting::mMultiplier |
Sets the intensity/brightness of the GI.
e.g. to make the GI 2x brighter, set it to 2.0 To make the GI darker, set it to 0.5
Default value is 1.0
Valid range is (0; inf)
|
static |
float Ogre::VctLighting::mSpecularSdfQuality |
When roughness is close to 0.02, specular cone tracing becomes path tracing.
This is very slow. However we can greatly speed it up by skipping gaps of empty voxels.
We use the alpha (opacity) component of the higher mips to approximate the SDF (Signed Distance Field) and thus know how much to skip. This is theoretically wrong, but not very wrong because the mips are very close to its true SDF representation thus in it works practice.
Some of these formulas have been empirically tuned to match a good performance/quality ratio
Once the roughness is higher, this formula starts hurting quality (produces noticeable artifacts) and thus we disable it.
This formula has tweakable parameters to leverage performance vs quality
Recommended range is [0; 1] where 1 is high quality and 0 is high performance (artifacts may appear).
However you can go outside that range.
PUBLIC VARIABLE. This variable can be altered directly. Changes are reflected immediately.