![]() |
OGRE-Next
4.0.0unstable
Object-Oriented Graphics Rendering Engine
|
Placing multiple PCC probes by hand can be difficult and even error prone. More...
#include <OgrePccPerPixelGridPlacement.h>
Public Member Functions | |
PccPerPixelGridPlacement () | |
~PccPerPixelGridPlacement () override | |
void | buildEnd () |
Finishes placing all probes and renders to them again, this time with the modified auto-generated shape sizes. More... | |
void | buildStart (uint32 resolution, Camera *camera, PixelFormatGpu pixelFormat=PFG_RGBA8_UNORM_SRGB, float camNear=0.5f, float camFar=500.0f) |
Issues GPU commands to render into all probes and obtain depth from it. More... | |
const Aabb & | getFullRegion () const |
uint32 | getMaxNumProbes () const |
Returns numProbes[0] * numProbes[1] * numProbes[2]. More... | |
const uint32 * | getNumProbes () const |
const Vector3 & | getOverlap () const |
ParallaxCorrectedCubemapAuto * | getParallaxCorrectedCubemap () |
const Vector3 & | getSnapDeviationError () const |
const Vector3 & | getSnapSidesDeviationErrorMax () const |
const Vector3 & | getSnapSidesDeviationErrorMin () const |
void | preCopyRenderTargetToCubemap (TextureGpu *renderTarget, uint32 cubemapArrayIdx) override |
ParallaxCorrectedCubemapAutoListener overloads. More... | |
void | setFullRegion (const Aabb &fullRegion) |
PccPerPixelGridPlacement needs, as guidance, the maximum region it will be occupying. More... | |
void | setNumProbes (uint32 numProbes[3]) |
Sets the number of probes in each axis. More... | |
void | setOverlap (const Vector3 &overlap) |
PccPerPixelGridPlacement will subdivide in mNumProbes[i] probes along each axis, creating a 3D grid. More... | |
void | setParallaxCorrectedCubemapAuto (ParallaxCorrectedCubemapAuto *pcc) |
void | setSnapDeviationError (const Vector3 &relativeError) |
When the probes have a different size than what they should have, but they're almost the same as mFullRegion (they can be different due to precision issues, small objects being on camera); it may be desirable to make them "snap" back to mFullRegion; particularly to avoid artifacts (missing reflections). More... | |
void | setSnapSides (const Vector3 &snapSidesDeviationErrorMin, const Vector3 &snapSidesDeviationErrorMax) |
Very similar to PccPerPixelGridPlacement::setSnapDeviationError but more specific; thus allowing for much bigger error margins to fix glitches without causing major distortions. More... | |
![]() | |
virtual | ~ParallaxCorrectedCubemapAutoListener () |
Placing multiple PCC probes by hand can be difficult and even error prone.
This class aims at helping developers and artists by automatically finding ideal probe shape sizes that adjust to underlying geometry in the scene by only providing the overall enclosing AABB of the scene that needs to be covered by PCC.
Note that once probes have been rendered and their shapes set, you can safely destroy this PccPerPixelGridPlacement instance; and even modify or remove probes you don't like or that feel excessive.
The compositor from which ParallaxCorrectedCubemapAuto is based on MUST have the depth compressed in the alpha channel.
See samples on how they use PccDepthCompressor and see Media/2.0/scripts/Compositors/LocalCubemaps.compositor
See Samples/2.0/ApiUsage/PccPerPixelGridPlacement for usage
Ogre::PccPerPixelGridPlacement::PccPerPixelGridPlacement | ( | ) |
|
override |
void Ogre::PccPerPixelGridPlacement::buildEnd | ( | ) |
Finishes placing all probes and renders to them again, this time with the modified auto-generated shape sizes.
Must be called after buildStart. This function reads from GPU memory, thus we must wait for our GPU commands issued in buildStart to finish. If you have something else to do, you may want to insert your code between those buildStart and buildEnd calls in order to maximize CPU/GPU parallelism.
void Ogre::PccPerPixelGridPlacement::buildStart | ( | uint32 | resolution, |
Camera * | camera, | ||
PixelFormatGpu | pixelFormat = PFG_RGBA8_UNORM_SRGB , |
||
float | camNear = 0.5f , |
||
float | camFar = 500.0f |
||
) |
Issues GPU commands to render into all probes and obtain depth from it.
See PccPerPixelGridPlacement::buildEnd
resolution | Cubemap resolution. Beware you can easily run out of memory! |
camera | |
pixelFormat | |
camNear | |
camFar |
|
inline |
uint32 Ogre::PccPerPixelGridPlacement::getMaxNumProbes | ( | ) | const |
Returns numProbes[0] * numProbes[1] * numProbes[2].
|
inline |
|
inline |
|
inline |
|
inline |
const Vector3& Ogre::PccPerPixelGridPlacement::getSnapSidesDeviationErrorMax | ( | ) | const |
const Vector3& Ogre::PccPerPixelGridPlacement::getSnapSidesDeviationErrorMin | ( | ) | const |
|
overridevirtual |
ParallaxCorrectedCubemapAutoListener overloads.
Reimplemented from Ogre::ParallaxCorrectedCubemapAutoListener.
void Ogre::PccPerPixelGridPlacement::setFullRegion | ( | const Aabb & | fullRegion | ) |
PccPerPixelGridPlacement needs, as guidance, the maximum region it will be occupying.
It could be a room, a house. We will then distribute the probes homegeneously then analyze average depth, and try to match the shape of the probes to match the visible geometry from the probe's perspective.
fullRegion |
void Ogre::PccPerPixelGridPlacement::setNumProbes | ( | uint32 | numProbes[3] | ) |
Sets the number of probes in each axis.
Thus the total number of probes will be numProbes[0] * numProbes[1] * numProbes[2]
numProbes |
void Ogre::PccPerPixelGridPlacement::setOverlap | ( | const Vector3 & | overlap | ) |
PccPerPixelGridPlacement will subdivide in mNumProbes[i] probes along each axis, creating a 3D grid.
Overlap is disabled with a value of 1.0
Without overlap, there will be harsh outlines at the borders between the probes. Adding some overlap allows a smooth blending between them.
Higher overlap results in smoother blending, but also makes each probe's area coverage bigger, which reduces runtime performance.
Vaules lower than 1.0 make the areas smaller, leaving gaps between each probe. This often is undesired unless it's a building with clearly separated rooms at homogeneous distances (which is often unnatural).
overlap | Valid range: (0; inf) Default: 1.5 |
void Ogre::PccPerPixelGridPlacement::setParallaxCorrectedCubemapAuto | ( | ParallaxCorrectedCubemapAuto * | pcc | ) |
void Ogre::PccPerPixelGridPlacement::setSnapDeviationError | ( | const Vector3 & | relativeError | ) |
When the probes have a different size than what they should have, but they're almost the same as mFullRegion (they can be different due to precision issues, small objects being on camera); it may be desirable to make them "snap" back to mFullRegion; particularly to avoid artifacts (missing reflections).
If the distance between the new shape and the mFullRegion is smaller than relativeError (in %) then we snap the shape's bound back to mFullRegion. For more info, see snapToFullRegion.
relativeError | Valid range: [0; inf) Use a very large value to always snap 0 to disable snapping in this axis |
void Ogre::PccPerPixelGridPlacement::setSnapSides | ( | const Vector3 & | snapSidesDeviationErrorMin, |
const Vector3 & | snapSidesDeviationErrorMax | ||
) |
Very similar to PccPerPixelGridPlacement::setSnapDeviationError but more specific; thus allowing for much bigger error margins to fix glitches without causing major distortions.
If a wall is outside the probe's shape, it won't have reflections. It may be quite common that if setFullRegion() defines a rectangular room, then the produced shapes may end up smaller than the room; thus the walls, ceiling and floor won't have reflections.
Thus this setting allows to defining relative errors for probes that are in the corners.
In a 2D version, if the layout is like the following:
Then G will be snapped against the left corner if the distance to this corner is <= snapSidesDeviationErrorMin.x (in percentage) and A will also snapped against the bottom corner using snapSidesDeviationErrorMin.y
While C will snapped against the right corner using snapSidesDeviationErrorMax.x and against the top corner using snapSidesDeviationErrorMax.y
B will only be snapped against the top corner using snapSidesDeviationErrorMax.y
Likewise, E won't be snapped because it's not in any corner or edge.
In these cases, we don't want C to snap, because the reflections when using C's probe will look unnecessarily distorted. Thus we only want to snap if the error is small enough, else it should be safe to assume there is no wall at that location.
It's not always easy. If the probe is too big and the hallway/column is halfway through the probe, then we could only fix this by hand by an artist, or by adding more probes (which can consume significantly more resources)
snapSidesDeviationErrorMin | Valid range: [0; inf) Use a very large value to always snap 0 to disable snapping against this corner |
snapSidesDeviationErrorMax | Valid range: [0; inf) Use a very large value to always snap 0 to disable snapping against this corner |