![]() |
VR-Forces Developer's Guide
|
A class responsible for rendering decal projectors for a camera context.
Decal projector components are registered with this renderer. The renderer does not own the components and the components should be unregistered when no longer in use.
The basic rendering algorithm is as follows: This renderer creates a unit cube geometry that is used as a render proxy for the bounds of decal primitives. If the camera is inside the decal projection bounds, then cull face is reversed for the cube so that the inside of the cube is rendered. The unit cube is rendered and in the vertex shader the cube is expanded to the actual bounds of the decal projector space. The decal primitives are sent to the fragment shader in a uniform buffer. The fragment shader reads the scene depth buffer and computes the viewspace position from the depth. The depth viewspace position is then transformed to the decal projector space. It is first clipped against the projector bounds. If it's inside the bounds, then for triangles rendering, the position is checked to see if it's in any triangle and if so, then the decal frament is rendered. For line rendering, the nearest line distance is computed and if the distance is within the line width, then the decal fragment is rendered.
This class creates a specific set of shaders used for drawing the primitives. This base class renderer handles triangle primitives. There is a derived class DtDecalProjectorLineRenderer that overides a few items in order to handle line primitives.

Classes | |
| struct | DrawItemInfo |
| struct | StippleKey |
Public Member Functions | |
| virtual | ~DtDecalProjectorRenderer () |
| DtDecalProjectorRenderer ()=delete | |
| DtDecalProjectorRenderer (const DtDecalProjectorRenderer &other)=delete | |
| DtDecalProjectorRenderer & | operator= (const DtDecalProjectorRenderer &other)=delete |
| virtual void | releaseResources () |
| virtual void | releaseShaderResources () |
| virtual DtCoordinateSystem * | findCoordinateSystem () |
| virtual const unsigned int | maxDrawPassPoints () const |
| virtual const unsigned int | topologyPointCount () const |
| virtual bool | cull (const DtDecalProjectorRendererDrawSettings &drawSettings) |
| virtual void | draw (const DtDecalProjectorRendererDrawSettings &drawSettings) |
| virtual DtDecalProjectorComponent * | createComponent () |
| virtual void | registerComponent (DtDecalProjectorComponent *component) |
| virtual void | unregisterComponent (DtDecalProjectorComponent *component) |
| virtual size_t | registeredComponentCount () const |
Protected Types | |
| typedef std::map< std::string, unsigned int > | TextureMap |
| typedef std::map< StippleKey, unsigned int > | StippleMap |
Protected Member Functions | |
| DtDecalProjectorRenderer (DtDe &de) | |
| virtual bool | initializeShaders () |
| virtual void | initializeBox () |
| virtual int | evaluateAabbVsSphere (const DtVector3< double > &boxCenter, const DtVector3< double > &boxExtent, const DtVector3< double > &sphereCenter, const double sphereRadius) const |
| virtual bool | isCameraOutsideBox (const DtVector3< double > &camPos, const float camFrustum[6], const DtVector3< double > &boxPos, const DtMatrix4< float > &boxRot, const DtVector3< float > &boxOffset, const DtVector3< float > &boxSize) const |
| virtual unsigned int | setStipple (const unsigned int stipplePattern[32], DtOverlayResourceProvider *resourceProvider, unsigned int lastSetTextureId) |
| virtual unsigned int | setTexture (DtTextureInterface *textureId, DtOverlayResourceProvider *resourceProvider, unsigned int lastSetTextureId) |
| virtual unsigned int | computeStipplePatternSortId (const unsigned int pattern[32]) |
| virtual void | slot_coordinateSystemChanged () |
| virtual void | slot_reloadShaders () |
Static Protected Member Functions | |
| static bool | theSortByMaterial (const DrawItemInfo &arg0, const DrawItemInfo &arg1) |
Static Protected Attributes | |
| static const unsigned int | thePointsMax = 192 |
Private Attributes | |
| friend | DtDecalProjectorRendererCreator |
|
protected |
|
protected |
This is a map that contains stipple pattern id's used with draw items for faster material sorting. The id's are only used for sorting.
|
virtual |
|
delete |
Default Constructor not implemented.
|
delete |
Copy Constructor not implemented - Copy not allowed.
|
protected |
Protected CTOR Create using DtDecalProjectorRendererCreator.
|
delete |
Assignment Operator not implemented - Assignment not allowed.
|
virtual |
Release all rendering resources.
|
virtual |
Release shader specific rendering resources.
|
virtual |
Returns the cloned coordinate system.
Returns the maximum supported points per draw pass.
Returns the number of points per primitive. For example a triangle = 3, a line = 2.
Reimplemented in makVrv::DtDecalProjectorLineRenderer.
|
virtual |
Culls all decals. Returns true if there is anything to draw.
|
virtual |
Draws all decals.
|
virtual |
Creates and returns a component that is compatible with this system. The component will register itself with this system on creation. The component will un-register itself with this system on destruction. The system does not own the component. The caller of this createComponent() method will own the component and should destroy it when done with it.
|
virtual |
Registers the given component with this system. The system does not own the component. The system will perform operations on the component while it is registered.
|
virtual |
Un-Registers the given component with this system. The system does not own the component.
|
virtual |
Returns the number of registered components.
|
protectedvirtual |
Loads and creates shaders for the program.
|
protectedvirtual |
Initializes a unit cube box used to render a proxy box. The box is scaled inside of the vertex shader to be the size of the decal clipping box.
|
protectedvirtual |
Tests for an intersection betweenan axis-align bounding box and a sphere. Returns 1 if the sphere is outside of the box. Returns -1 if the sphere is inside of the box. Returns 0 if the sphere is intersecting with the box.
|
protectedvirtual |
Tests whether the camera is outside of the given box. Accounts for the near clip of the camera.
|
protectedvirtual |
Gets the stipple pattern texture from the resource provider. Sets the stipple pattern texture as the current texture. Returns the texture id that was set (0 if error).
| stipplePattern | The pattern for the resource provider |
| resourceProvider | The resource provider to get the texture from |
| lastSetTextureId | The last texture id that was set (used to prevent state change) |
|
protectedvirtual |
Creates a texture from the given texture interface handle if needed. The texture interface handle comes from the 2D overlay system and therefore needs duplicated for 3D so mip-maps can be generated and mip-map sampling can be used. Sets the texture as the current texture. Returns the texture id that was set (0 if error).
| textureId | The texture handle for the resource provider |
| resourceProvider | The resource provider to get the texture from |
| lastSetTextureId | The last texture id that was set (used to prevent state change) |
|
protectedvirtual |
Computes and returns a sorting id unique to the given stipple pattern. This is used for sorting draw items by material.
|
protectedvirtual |
slot for when the coordinate system changes
|
protectedvirtual |
slot to handle shader reloading
|
staticprotected |
sort function used for sorting draw items by material
|
private |
This is the maximum number of primitive points that the fragment shader can support. If the shader is changed, then this value needs to change. It's in both the triangle and line fragment shaders.
|
protected |
|
protected |
local clone of the system wide coordinate system. for thread safety.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |