OGRE-Next
2.3
Object-Oriented Graphics Rendering Engine
|
Planar Reflections can be used with both Unlit and PBS, but they're setup differently. More...
#include <OgrePlanarReflections.h>
Classes | |
struct | TrackedRenderable |
Public Types | |
enum | CustomParameterBits { UseActiveActor = 0x80 , FlushPending = 0x60 , InactiveActor = 0x40 } |
Public Member Functions | |
PlanarReflections (SceneManager *sceneManager, CompositorManager2 *compositorManager, Real maxDistance, Camera *lockCamera) | |
~PlanarReflections () | |
bool | _isUpdatingRenderablesHlms () const |
void | _notifyRenderableFlushedHlmsDatablock (Renderable *renderable) |
PlanarReflectionActor * | addActor (const PlanarReflectionActor &actor) |
Adds an actor plane that other objects can use as source for reflections if they're close enough to it (and aligned enough to the normal). More... | |
void | addRenderable (const TrackedRenderable &trackedRenderable) |
Once you add a Renderable, we will automatically update its PBS material to use reflection if it's close to any active actor. More... | |
void | beginFrame () |
bool | cameraMatches (const Camera *camera) |
Returns true if the Camera settings (position, orientation, aspect ratio, etc) match with the reflection we have in cache. More... | |
void | destroyActor (PlanarReflectionActor *actor) |
void | destroyAllActors () |
void | fillConstBufferData (TextureGpu *renderTarget, const Camera *camera, const Matrix4 &projectionMatrix, float *RESTRICT_ALIAS passBufferPtr) const |
Fills 'passBufferPtr' with the necessary data for PlanarReflections. More... | |
size_t | getConstBufferSize () const |
Returns the amount of bytes that fillConstBufferData is going to fill. More... | |
uint8 | getMaxActiveActors () const |
uint8 | getMaxNumMipmaps () const |
TextureGpu * | getTexture (uint8 actorIdx) const |
bool | hasActiveActor (const Renderable *renderable) const |
bool | hasFlushPending (const Renderable *renderable) const |
bool | hasPlanarReflections (const Renderable *renderable) const |
void | releaseReservation (PlanarReflectionActor *actor) |
Releases a reservation made with reserve(). More... | |
void | removeRenderable (Renderable *renderable) |
void | reserve (uint8 activeActorSlot, PlanarReflectionActor *actor) |
Reserves a particular slot (i.e. More... | |
void | setMaxActiveActors (uint8 maxActiveActors, IdString workspaceName, bool useAccurateLighting, uint32 width, uint32 height, bool withMipmaps, PixelFormatGpu pixelFormat, bool mipmapMethodCompute) |
Setups how many actors can be active at the same time. More... | |
void | setMaxDistance (Real maxDistance) |
void | update (Camera *camera, Real aspectRatio) |
Planar Reflections can be used with both Unlit and PBS, but they're setup differently.
Unlit is very fast, but also very basic. It's mostly useful for perfect mirrors.
An unlit datablock is tied to a particular Actor (reflection plane). PBS on the other hand, can dynamically assign Renderables to the closest actor that aligns with the Renderable's (predominant) normal, regardless of the pbs datablock it uses. If the actor is close enough but not an exact match, PBS will attempt to project the reflection in an attempt to correct this, however it's an approximation.
If you want perfect reflections, the reflection plane of the actor must match and align exactly the surface being drawn; or rely on a fallback (Local Cubemaps, SSR, etc).
Furthermore, PBS will automatically disable reflections while rendering reflections (but Unlit won't do this, so it's your job to leave it out of rendering i.e. via visibility masks).
Actors are culled against the camera, thus if they're no longer visible Ogre will stop updating those actors, improving performance.
Ogre::PlanarReflections::PlanarReflections | ( | SceneManager * | sceneManager, |
CompositorManager2 * | compositorManager, | ||
Real | maxDistance, | ||
Camera * | lockCamera | ||
) |
sceneManager | |
compositorManager | |
maxActiveActors | |
maxDistance | |
lockCamera |
Ogre::PlanarReflections::~PlanarReflections | ( | ) |
bool Ogre::PlanarReflections::_isUpdatingRenderablesHlms | ( | ) | const |
void Ogre::PlanarReflections::_notifyRenderableFlushedHlmsDatablock | ( | Renderable * | renderable | ) |
PlanarReflectionActor* Ogre::PlanarReflections::addActor | ( | const PlanarReflectionActor & | actor | ) |
Adds an actor plane that other objects can use as source for reflections if they're close enough to it (and aligned enough to the normal).
actor | Actor to use, with some data prefilled (see PlanarReflectionActor::PlanarReflectionActor constructor) |
void Ogre::PlanarReflections::addRenderable | ( | const TrackedRenderable & | trackedRenderable | ) |
Once you add a Renderable, we will automatically update its PBS material to use reflection if it's close to any active actor.
If no active actor is close, we'll disable the reflections for that frame.
trackedRenderable | See TrackedRenderable::TrackedRenderable. |
void Ogre::PlanarReflections::beginFrame | ( | ) |
bool Ogre::PlanarReflections::cameraMatches | ( | const Camera * | camera | ) |
Returns true if the Camera settings (position, orientation, aspect ratio, etc) match with the reflection we have in cache.
void Ogre::PlanarReflections::destroyActor | ( | PlanarReflectionActor * | actor | ) |
void Ogre::PlanarReflections::destroyAllActors | ( | ) |
void Ogre::PlanarReflections::fillConstBufferData | ( | TextureGpu * | renderTarget, |
const Camera * | camera, | ||
const Matrix4 & | projectionMatrix, | ||
float *RESTRICT_ALIAS | passBufferPtr | ||
) | const |
Fills 'passBufferPtr' with the necessary data for PlanarReflections.
size_t Ogre::PlanarReflections::getConstBufferSize | ( | ) | const |
Returns the amount of bytes that fillConstBufferData is going to fill.
|
inline |
|
inline |
TextureGpu* Ogre::PlanarReflections::getTexture | ( | uint8 | actorIdx | ) | const |
bool Ogre::PlanarReflections::hasActiveActor | ( | const Renderable * | renderable | ) | const |
bool Ogre::PlanarReflections::hasFlushPending | ( | const Renderable * | renderable | ) | const |
bool Ogre::PlanarReflections::hasPlanarReflections | ( | const Renderable * | renderable | ) | const |
void Ogre::PlanarReflections::releaseReservation | ( | PlanarReflectionActor * | actor | ) |
Releases a reservation made with reserve().
This is done automatically if you call destroyActor
void Ogre::PlanarReflections::removeRenderable | ( | Renderable * | renderable | ) |
void Ogre::PlanarReflections::reserve | ( | uint8 | activeActorSlot, |
PlanarReflectionActor * | actor | ||
) |
Reserves a particular slot (i.e.
texture) to be used only with a specifc actor. A slot can only be reserved by one actor at a time. If this actor doesn't activate (i.e. it's culled by the camera), the slot won't be used and thus the contents of the texture will remain unchanged.
activeActorSlot | Slot to reserve. Must be in range [0; mMaxActiveActors) |
actor | Actor to link this reservation with. |
void Ogre::PlanarReflections::setMaxActiveActors | ( | uint8 | maxActiveActors, |
IdString | workspaceName, | ||
bool | useAccurateLighting, | ||
uint32 | width, | ||
uint32 | height, | ||
bool | withMipmaps, | ||
PixelFormatGpu | pixelFormat, | ||
bool | mipmapMethodCompute | ||
) |
Setups how many actors can be active at the same time.
You may have many actors (i.e. 1000 actors), but for performance and memory reasons you may only want 1-5 actors at the same time. Actors are dynamically activated based on distance to camera.
maxActiveActors | New max active actors. Can be lower or higher than its previous value. When this value is less or equal than current value, all the next parameters are ignored. When this value is higher than its previous, value, the new active actors will use these parameters; which don't have to necessarily match previous calls (not recommended since we assume the number of mipmaps is the same for all actors. This affects surfaces with roughness > 0). |
workspaceName | Workspace to use for rendering. |
useAccurateLighting | When true, overall scene CPU usage may be higher, but lighting information in the reflections will be accurate. Turning it to false is faster. This is a performance optimization that rarely has a noticeable impact on quality. |
width | Width resolution of the RTT assigned to this reflection plane |
height | Height resolution of the RTT assigned to this reflection plane |
withMipmaps | When true, mipmaps will be created; which are useful for glossy reflections (i.e. roughness close to 1). Set this to false if you only plan on using it for a mirror (which are always a perfect reflection... unless you want to use a roughness map to add scratches & stains to it). |
pixelFormat | Pixel Format of the RTT assigned to this reflection plane |
mipmapMethodCompute | Set to true if the workspace assigned via PlanarReflectionActor::workspaceName will filter the RTT with a compute filter (usually for higher quality). |
void Ogre::PlanarReflections::setMaxDistance | ( | Real | maxDistance | ) |