OGRE: Ogre::PccPerPixelGridPlacement Class Reference

| OGRE 2.2.4 Object-Oriented Graphics Rendering Engine

Public Member Functions | List of all members
Ogre::PccPerPixelGridPlacement Class Reference

Placing multiple PCC probes by hand can be difficult and even error prone. More...

`#include <OgrePccPerPixelGridPlacement.h>`

Inheritance diagram for Ogre::PccPerPixelGridPlacement:
[legend]

## Public Member Functions
| PccPerPixelGridPlacement ()
| ~PccPerPixelGridPlacement ()
void | buildEnd (void)
| 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 (void) const
uint32 | getMaxNumProbes () const
| Returns numProbes[0] * numProbes[1] * numProbes[2]. More...
const uint32 * | getNumProbes (void) const
const Vector3 & | getOverlap (void) const
ParallaxCorrectedCubemapAuto * | getParallaxCorrectedCubemap ()
const Vector3 & | getSnapDeviationError (void) const
const Vector3 & | getSnapSidesDeviationErrorMax (void) const
const Vector3 & | getSnapSidesDeviationErrorMin (void) const
virtual void | preCopyRenderTargetToCubemap (TextureGpu *renderTarget, uint32 cubemapArrayIdx)
| 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...

## Detailed Description

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.

Remarks
  The ParallaxCorrectedCubemapAuto pointer is externally owned and must be provided via PccPerPixelGridPlacement::setParallaxCorrectedCubemapAuto, before calling build.

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

## Constructor & Destructor Documentation

## ◆ PccPerPixelGridPlacement()

Ogre::PccPerPixelGridPlacement::PccPerPixelGridPlacement | ( |  | ) |

## ◆ ~PccPerPixelGridPlacement()

Ogre::PccPerPixelGridPlacement::~PccPerPixelGridPlacement | ( |  | ) |

## Member Function Documentation

## ◆ buildEnd()

void Ogre::PccPerPixelGridPlacement::buildEnd | ( | void |  | ) |

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.

See PccPerPixelGridPlacement::buildStart

## ◆ buildStart()

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

Parameters

  resolution | Cubemap resolution. Beware you can easily run out of memory!
  camera |
  pixelFormat |
  camNear |
  camFar |

## ◆ getFullRegion()

const Aabb& Ogre::PccPerPixelGridPlacement::getFullRegion | ( | void |  | ) | const
| inline

## ◆ getMaxNumProbes()

uint32 Ogre::PccPerPixelGridPlacement::getMaxNumProbes | ( |  | ) | const

Returns numProbes[0] * numProbes[1] * numProbes[2].

## ◆ getNumProbes()

const uint32* Ogre::PccPerPixelGridPlacement::getNumProbes | ( | void |  | ) | const
| inline

## ◆ getOverlap()

const Vector3& Ogre::PccPerPixelGridPlacement::getOverlap | ( | void |  | ) | const
| inline

## ◆ getParallaxCorrectedCubemap()

ParallaxCorrectedCubemapAuto* Ogre::PccPerPixelGridPlacement::getParallaxCorrectedCubemap | ( |  | ) |
| inline

## ◆ getSnapDeviationError()

const Vector3& Ogre::PccPerPixelGridPlacement::getSnapDeviationError | ( | void |  | ) | const
| inline

## ◆ getSnapSidesDeviationErrorMax()

const Vector3& Ogre::PccPerPixelGridPlacement::getSnapSidesDeviationErrorMax | ( | void |  | ) | const

## ◆ getSnapSidesDeviationErrorMin()

const Vector3& Ogre::PccPerPixelGridPlacement::getSnapSidesDeviationErrorMin | ( | void |  | ) | const

## ◆ preCopyRenderTargetToCubemap()

virtual void Ogre::PccPerPixelGridPlacement::preCopyRenderTargetToCubemap | ( | TextureGpu * | renderTarget,
|  | uint32 | cubemapArrayIdx
| ) |  |
| virtual

ParallaxCorrectedCubemapAutoListener overloads.

Reimplemented from Ogre::ParallaxCorrectedCubemapAutoListener.

## ◆ setFullRegion()

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.

Parameters

  fullRegion |

## ◆ setNumProbes()

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]

Parameters

  numProbes |

## ◆ setOverlap()

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).

Parameters

  overlap | Valid range: (0; inf) Default: 1.5

## ◆ setParallaxCorrectedCubemapAuto()

void Ogre::PccPerPixelGridPlacement::setParallaxCorrectedCubemapAuto | ( | ParallaxCorrectedCubemapAuto * | pcc | ) |

## ◆ setSnapDeviationError()

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.

See also
  PccPerPixelGridPlacement::snapToFullRegion

Parameters

  relativeError | Valid range: [0; inf) Use a very large value to always snap 0 to disable snapping in this axis

## ◆ setSnapSides()

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:

max
-----------
| A | B | C |
| D | E | F |
| G | H | I |
-----------
min

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.

Remarks
  Why shouldn't always snap? Consider a room with a hallway, or a non-rectangular room with column:

// Room with a hallway:
-----------------------
| A | B | C ___________|
| D | E | F |
| G | H | I |
-----------
// Non-rectangular with a column:
-------
| A | B |___
| D | E | F |
| G | H | I |
-----------

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)

Parameters

  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

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

- OgrePccPerPixelGridPlacement.h

Ogre::max
const float & max(const float &a, const float &b)
Definition: OgreCommon.h:1117
Ogre::min
const float & min(const float &a, const float &b)
Definition: OgreCommon.h:1112