Support Forum       G3D Web Page     
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Protected Types | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
G3D::UniversalSurface Class Reference

An optimized implementation G3D::Surface for G3D::Shader / G3D::UniversalMaterial classes. More...

Inherits G3D::Surface.

Classes

class  CPUGeom
 
class  GPUGeom
 A GPU mesh utility class that works with G3D::UniversalSurface. More...
 

Public Member Functions

virtual bool canBeFullyRepresentedInGBuffer (const GBuffer::Specification &specification) const override
 Can this particular instance of this type of Surface be fully described in a G3D::GBuffer using the given specification? More...
 
virtual bool canChange () const
 Returns true if this surface should be included in static data structures because it is from an object that never changes. More...
 
virtual bool canRenderIntoSVO () const override
 
virtual CPUGeomcpuGeom ()
 
virtual const CPUGeomcpuGeom () const
 
const shared_ptr< Entity > & entity () const
 The Entity that created this surface. More...
 
virtual CoordinateFrame frame (bool previous=false) const
 
virtual void getCoordinateFrame (CoordinateFrame &c, bool previous=false) const override
 
virtual void getObjectSpaceBoundingBox (AABox &, bool previous=false) const override
 May be infinite. More...
 
virtual void getObjectSpaceBoundingSphere (Sphere &, bool previous=false) const override
 May be infinite. More...
 
virtual void getObjectSpaceGeometry (Array< int > &index, Array< Point3 > &vertex, Array< Vector3 > &normal, Array< Vector4 > &packedTangent, Array< Point2 > &texCoord, bool previous=false) const override
 Clears the arrays and appends indexed triangle list information. More...
 
virtual void getTrisHomogeneous (const Array< shared_ptr< Surface > > &surfaceArray, CPUVertexArray &cpuVertexArray, Array< Tri > &triArray, bool computePrevPosition=false) const override
 Creates and appends Tris and CPUVertexArray::Vertices onto the parameter arrays using the cpuGeom's of the surfaces in surfaceArray. More...
 
shared_ptr< GPUGeom > & gpuGeom ()
 
const shared_ptr< GPUGeom > & gpuGeom () const
 
virtual bool hasNonRefractiveTransmission () const
 Has transmission that can't be modeled in the opaque pass (since refraction is modeled by painting the surface via screen-space refraction by UniversalSurface) More...
 
virtual bool hasRefractiveTransmission () const
 
virtual bool hasTransmission () const override
 If true, this object transmits light, potentially refracting it and filtering the background with color or diffusion. More...
 
const MeshAlg::GeometryinternalGeometry () const
 For use by classes that pose objects on the CPU and need a place to store the geometry. More...
 
MeshAlg::GeometryinternalGeometry ()
 
virtual bool isSkybox () const
 
virtual RealTime lastChangeTime () const
 Wall-clock time at which the source of this surface changed in some way, e.g., that might require recomputing a shadow map or spatial data structure. More...
 
const shared_ptr< UniversalMaterial > & material () const
 
const shared_ptr< Model > & model () const
 The Model that created this surface. More...
 
virtual String name () const override
 Name of the underlying model or part for debugging purposes. More...
 
int numInstances () const
 
bool preferLowResolutionTransparency () const
 
virtual void render (RenderDevice *rd, const LightingEnvironment &environment, RenderPassType passType) const override
 Forward-render all illumination terms for each element of surfaceArray, which must all be of the same most-derived type as this. More...
 
virtual void renderDepthOnlyHomogeneous (RenderDevice *rd, const Array< shared_ptr< Surface > > &surfaceArray, const shared_ptr< Texture > &depthPeelTexture, const float minZSeparation, TransparencyTestMode transparencyTestMode, const Color3 &transmissionWeight) const override
 Use the current RenderDevice::cullFace. More...
 
virtual void renderHomogeneous (RenderDevice *rd, const Array< shared_ptr< Surface > > &surfaceArray, const LightingEnvironment &lightingEnvironment, RenderPassType passType) const
 Render a set of surfaces from the same most-derived class type. More...
 
virtual void renderIntoGBufferHomogeneous (RenderDevice *rd, const Array< shared_ptr< Surface > > &surfaceArray, const shared_ptr< GBuffer > &gbuffer, const shared_ptr< Texture > &depthPeelTexture, const float minZSeparation, const LightingEnvironment &lightingEnvironment) const override
 
Render all instances of surfaceArray to the currently-bound Framebuffer using the fields and mapping dictated by specification. More...
 
virtual void renderIntoSVOHomogeneous (RenderDevice *rd, Array< shared_ptr< Surface > > &surfaceArray, const shared_ptr< SVO > &svo, const CFrame &previousCameraFrame) const override
 
RenderMask renderMask () const
 
virtual void renderWireframeHomogeneous (RenderDevice *rd, const Array< shared_ptr< Surface > > &surfaceArray, const Color4 &color, bool previous) const override
 Rendering a set of surfaces in wireframe, using the current blending mode. More...
 
uint64 rigidBodyID () const
 An identifier that, if nonzero, is unique for a combination of geometry and material. More...
 
void setShaderArgs (Args &args, bool useStructFormat=false) const
 Bind material and geometry arguments, including setting args.numInstances() More...
 
virtual void setStorage (ImageStorage newStorage) override
 
virtual TransparencyType transparencyType () const override
 What type of transparency (= alpha and transmission) does this surface have? More...
 

Static Public Member Functions

static void bindDepthPeelArgs (Args &args, RenderDevice *rd, const shared_ptr< Texture > &depthPeelTexture, const float minZSeparation)
 
static shared_ptr< UniversalSurfacecreate (const String &name, const CFrame &frame, const CFrame &previousFrame, const shared_ptr< UniversalMaterial > &material, const shared_ptr< GPUGeom > &gpuGeom, const CPUGeom &cpuGeom=CPUGeom(), const shared_ptr< ReferenceCountedObject > &source=nullptr, const ExpressiveLightScatteringProperties &expressiveProperties=ExpressiveLightScatteringProperties(), const shared_ptr< Model > &model=nullptr, const shared_ptr< Entity > &entity=nullptr, const shared_ptr< UniformTable > &uniformTable=nullptr, int numInstances=1)
 
static void cull (const CoordinateFrame &cameraFrame, const class Projection &cameraProjection, const class Rect2D &viewport, const Array< shared_ptr< Surface > > &allSurfaces, Array< shared_ptr< Surface > > &outSurfaces, bool previous=false)
 Computes the array of surfaces that can be seen by camera. More...
 
static void cull (const CoordinateFrame &cameraFrame, const class Projection &cameraProjection, const class Rect2D &viewport, Array< shared_ptr< Surface > > &allSurfaces, bool previous=false)
 Culls surfaces in place. More...
 
static void extract (Array< shared_ptr< Surface > > &all, Array< shared_ptr< Surface > > &super)
 Called by Surface. More...
 
static void getBoxBounds (const Array< shared_ptr< Surface >> &surfaceArray, AABox &bounds, bool previous=false, bool &anyInfinite=ignoreBool, bool onlyShadowCasters=false)
 Computes the world-space bounding box of an array of Surfaces of any type. More...
 
static void getSphereBounds (const Array< shared_ptr< Surface > > &surfaceArray, Sphere &bounds, bool previous=false, bool &anyInfinite=ignoreBool, bool onlyShadowCasters=false)
 Computes the world-space bounding sphere of an array of Surfaces of any type. More...
 
static void getTris (const Array< shared_ptr< Surface > > &surfaceArray, CPUVertexArray &cpuVertexArray, Array< Tri > &triArray, bool computePrevPosition=false)
 Returns a CPUVertexArray and an Array<Tri> generated from the surfaces in surfaceArray, with everything transformed to world space First separates surfaceArray by derived type and then calls getTrisHomogenous. More...
 
static void operator delete (void *p)
 
static void * operator new (size_t size)
 Allocates with System::malloc to avoid the performance overhead of creating lots of small heap objects using ::malloc. More...
 
static void renderDepthOnly (RenderDevice *rd, const Array< shared_ptr< Surface > > &surfaceArray, CullFace cull, const shared_ptr< Texture > &depthPeelTexture=nullptr, const float minZSeparation=0.0f, TransparencyTestMode transparencyTestMode=TransparencyTestMode::REJECT_TRANSPARENCY, const Color3 &transmissionWeight=Color3::white()/3.0f)
 Render geometry only (no shading), and ignore color (but do perform alpha testing). More...
 
static void renderIntoGBuffer (RenderDevice *rd, const Array< shared_ptr< Surface > > &sortedVisible, const shared_ptr< GBuffer > &gbuffer, const shared_ptr< Texture > &depthPeelTexture=shared_ptr< Texture >(), const float minZSeparation=0.0f, const LightingEnvironment &lightingEnvironment=LightingEnvironment())
 Renders front-to-back to a GBuffer using current stencil and depth operations. More...
 
static void renderIntoSVO (RenderDevice *rd, Array< shared_ptr< Surface > > &visible, const shared_ptr< SVO > &svo, const CoordinateFrame &previousCameraFrame=CoordinateFrame())
 
static void renderWireframe (RenderDevice *rd, const Array< shared_ptr< Surface > > &surfaceArray, const Color4 &color=Color3::black(), bool previous=false)
 Utility function for rendering a set of surfaces in wireframe using the current blending mode. More...
 
static void setStorage (const Array< shared_ptr< Surface >> &surfaceArray, ImageStorage newStorage)
 Set the storage on all Materials in the array. More...
 
static void sortBackToFront (Array< shared_ptr< Surface > > &surfaces, const Vector3 &wsLookVector)
 
static void sortFrontToBack (Array< shared_ptr< UniversalSurface > > &a, const Vector3 &v)
 
static void sortFrontToBack (Array< shared_ptr< Surface > > &surfaces, const Vector3 &wsLookVector)
 Divides the inModels into a front-to-back sorted array of opaque models and a back-to-front sorted array of potentially transparent models. More...
 

Public Attributes

const ExpressiveLightScatteringProperties expressiveLightScatteringProperties
 

Static Public Attributes

static float debugSubmitFraction
 For debugging only. More...
 
static uint64 debugTrianglesSubmitted
 For debugging only. More...
 

Protected Types

enum  DepthPassType {
  FIXED_FUNCTION_NO_ALPHA,
  FIXED_FUNCTION_ALPHA,
  PARALLAX_AND_ALPHA
}
 Used in renderDepthOnlyHomogeneous to store the last pass type. More...
 

Protected Member Functions

 UniversalSurface (const String &name, const CoordinateFrame &frame, const CoordinateFrame &previousFrame, const shared_ptr< UniversalMaterial > &material, const shared_ptr< GPUGeom > &gpuGeom, const CPUGeom &cpuGeom, const shared_ptr< ReferenceCountedObject > &source, const ExpressiveLightScatteringProperties &expressive, const shared_ptr< class Model > &model, const shared_ptr< class Entity > &entity, const shared_ptr< class UniformTable > &uniformTable, int numInstances)
 
virtual bool anyUnblended () const
 Returns true if there are potentially any opaque samples on this surface. More...
 
void bindScreenSpaceTexture (Args &args, const LightingEnvironment &lightingEnvironment, RenderDevice *rd, const Vector2int16 colorGuardBandSize, const Vector2int16 depthGuardBandSize) const
 
void launchForwardShader (Args &args) const
 Launch the bone or non-bone shader as needed. More...
 
void modulateBackgroundByTransmission (RenderDevice *rd) const
 Using the current cull face, modulate the background by the transmission, if there is any transmission. More...
 
virtual bool requiresBlending () const
 Does this surface require blending for some samples? More...
 

Static Protected Member Functions

template<class T , class ... ArgTypes>
static shared_ptr< T > createShared (ArgTypes &&... args)
 Like std::make_shared, but works for protected constructors. More...
 
static void cull (const CoordinateFrame &cameraFrame, const class Projection &cameraProjection, const class Rect2D &viewport, Array< shared_ptr< Surface > > &allSurfaces, Array< shared_ptr< Surface > > &outSurfaces, bool previous, bool inPlace)
 
static void depthRenderHelper (RenderDevice *rd, Args &args, const shared_ptr< UniversalSurface > &surface, const String &profilerHint, const shared_ptr< Texture > &previousDepthBuffer, const float minZSeparation, const Color3 &transmissionWeight, const shared_ptr< Shader > &depthShader, const shared_ptr< Shader > &depthPeelShader, const CullFace cull)
 Abstracts some common code for batch rendering mode from renderDepthOnlyHomogeneous. More...
 

Protected Attributes

CPUGeom m_cpuGeom
 
shared_ptr< class Entitym_entity
 
CoordinateFrame m_frame
 Object to world space transformation. More...
 
shared_ptr< GPUGeomm_gpuGeom
 
MeshAlg::Geometry m_internalGeometry
 For use by classes that want the m_cpuGeom to point at geometry that is deallocated with the surface. More...
 
bool m_isLight
 
shared_ptr< UniversalMaterialm_material
 
shared_ptr< class Modelm_model
 
String m_name
 
int m_numInstances
 
bool m_preferLowResolutionTransparency
 Hint for renderers to use low resolution rendering. More...
 
CoordinateFrame m_previousFrame
 Object to world transformation from the previous time step. More...
 
String m_profilerHint
 A string used in indentifing profiler events. More...
 
uint64 m_rigidBodyID = 0
 
shared_ptr< ReferenceCountedObjectm_source
 
shared_ptr< UniformTablem_uniformTable
 

Detailed Description

An optimized implementation G3D::Surface for G3D::Shader / G3D::UniversalMaterial classes.

Used by G3D::ArticulatedModel, G3D::MD2Model, G3D::MD3Model

Member Enumeration Documentation

◆ DepthPassType

Used in renderDepthOnlyHomogeneous to store the last pass type.

Alpha testing turns of depth-only optimizations on GPUs, so we need to avoid using alpha testing when unneccessary. When a surface is both parallax mapped and has alpha, we need a shader to render the depth pass. Otherwise the depth pass renders the flat version of the surface, which leads to background color bleeding in around the edges where the surface is perturbed .

Enumerator
FIXED_FUNCTION_NO_ALPHA 
FIXED_FUNCTION_ALPHA 
PARALLAX_AND_ALPHA 

Constructor & Destructor Documentation

◆ UniversalSurface()

G3D::UniversalSurface::UniversalSurface ( const String name,
const CoordinateFrame frame,
const CoordinateFrame previousFrame,
const shared_ptr< UniversalMaterial > &  material,
const shared_ptr< GPUGeom > &  gpuGeom,
const CPUGeom cpuGeom,
const shared_ptr< ReferenceCountedObject > &  source,
const ExpressiveLightScatteringProperties expressive,
const shared_ptr< class Model > &  model,
const shared_ptr< class Entity > &  entity,
const shared_ptr< class UniformTable > &  uniformTable,
int  numInstances 
)
protected

Member Function Documentation

◆ anyUnblended()

virtual bool G3D::UniversalSurface::anyUnblended ( ) const
protectedvirtual

Returns true if there are potentially any opaque samples on this surface.

Used to optimize out whole surfaces from rendering during RenderPassType::OPAQUE passes.

This can conservatively always return true at a performance loss.

Used by the default transparencyType()

See also
requiresBlending, canBeFullyRepresentedInGBuffer, AlphaFilter, hasTransmission

◆ bindDepthPeelArgs()

static void G3D::UniversalSurface::bindDepthPeelArgs ( Args args,
RenderDevice rd,
const shared_ptr< Texture > &  depthPeelTexture,
const float  minZSeparation 
)
static

◆ bindScreenSpaceTexture()

void G3D::UniversalSurface::bindScreenSpaceTexture ( Args args,
const LightingEnvironment lightingEnvironment,
RenderDevice rd,
const Vector2int16  colorGuardBandSize,
const Vector2int16  depthGuardBandSize 
) const
protected

◆ canBeFullyRepresentedInGBuffer()

virtual bool G3D::UniversalSurface::canBeFullyRepresentedInGBuffer ( const GBuffer::Specification specification) const
overridevirtual

Can this particular instance of this type of Surface be fully described in a G3D::GBuffer using the given specification?

Often set to false for Surfaces with fractional alpha values, transmission, special back-to-front rendering needs, that require more dynamic range in the emissive channel, or that simply lack a renderIntoGBufferHomogeneous implementation.

Surfaces that return false for canBeFullyRepresentedInGBuffer may still implement renderIntoGBufferHomogeneous for the parts of their surfaces that are representable, and doing so will improve the quality of AmbientOcclusion and post-processing techniques like MotionBlur and DepthOfField.

See also
anyUnblended, requiresBlending

Implements G3D::Surface.

◆ canChange()

virtual bool G3D::Surface::canChange ( ) const
virtualinherited

Returns true if this surface should be included in static data structures because it is from an object that never changes.

The default implementation tests whether the surface comes from an Entity and that Entity::canChange.

See also
Entity::canChange
lastChangeTime

◆ canRenderIntoSVO()

virtual bool G3D::UniversalSurface::canRenderIntoSVO ( ) const
inlineoverridevirtual

Reimplemented from G3D::Surface.

◆ cpuGeom() [1/2]

virtual CPUGeom& G3D::UniversalSurface::cpuGeom ( )
inlinevirtual

◆ cpuGeom() [2/2]

virtual const CPUGeom& G3D::UniversalSurface::cpuGeom ( ) const
inlinevirtual

◆ create()

static shared_ptr<UniversalSurface> G3D::UniversalSurface::create ( const String name,
const CFrame frame,
const CFrame previousFrame,
const shared_ptr< UniversalMaterial > &  material,
const shared_ptr< GPUGeom > &  gpuGeom,
const CPUGeom cpuGeom = CPUGeom(),
const shared_ptr< ReferenceCountedObject > &  source = nullptr,
const ExpressiveLightScatteringProperties expressiveProperties = ExpressiveLightScatteringProperties(),
const shared_ptr< Model > &  model = nullptr,
const shared_ptr< Entity > &  entity = nullptr,
const shared_ptr< UniformTable > &  uniformTable = nullptr,
int  numInstances = 1 
)
static
Parameters
sourceAn object to hold a strong pointer to to prevent it from being garbage collected. This is useful because m_cpuGeom often contains pointers into an object that may not be held by anything else. Note that any shared_ptr will automatically upcast to this type.

◆ createShared()

template<class T , class ... ArgTypes>
static shared_ptr<T> G3D::ReferenceCountedObject::createShared ( ArgTypes &&...  args)
inlinestaticprotectedinherited

Like std::make_shared, but works for protected constructors.

Call as createShared<myclass>.

◆ cull() [1/3]

static void G3D::Surface::cull ( const CoordinateFrame cameraFrame,
const class Projection cameraProjection,
const class Rect2D viewport,
Array< shared_ptr< Surface > > &  allSurfaces,
Array< shared_ptr< Surface > > &  outSurfaces,
bool  previous,
bool  inPlace 
)
staticprotectedinherited

Referenced by G3D::Surface::cull().

◆ cull() [2/3]

static void G3D::Surface::cull ( const CoordinateFrame cameraFrame,
const class Projection cameraProjection,
const class Rect2D viewport,
const Array< shared_ptr< Surface > > &  allSurfaces,
Array< shared_ptr< Surface > > &  outSurfaces,
bool  previous = false 
)
inlinestaticinherited

Computes the array of surfaces that can be seen by camera.

Preserves order.

◆ cull() [3/3]

static void G3D::Surface::cull ( const CoordinateFrame cameraFrame,
const class Projection cameraProjection,
const class Rect2D viewport,
Array< shared_ptr< Surface > > &  allSurfaces,
bool  previous = false 
)
inlinestaticinherited

Culls surfaces in place.

◆ depthRenderHelper()

static void G3D::UniversalSurface::depthRenderHelper ( RenderDevice rd,
Args args,
const shared_ptr< UniversalSurface > &  surface,
const String profilerHint,
const shared_ptr< Texture > &  previousDepthBuffer,
const float  minZSeparation,
const Color3 transmissionWeight,
const shared_ptr< Shader > &  depthShader,
const shared_ptr< Shader > &  depthPeelShader,
const CullFace  cull 
)
staticprotected

Abstracts some common code for batch rendering mode from renderDepthOnlyHomogeneous.

◆ entity()

const shared_ptr<Entity>& G3D::Surface::entity ( ) const
inlineinherited

The Entity that created this surface.

May be nullptr

Referenced by G3D::ParticleSurface::create(), and G3D::ParticleSurface::ParticleSurface().

◆ extract()

static void G3D::UniversalSurface::extract ( Array< shared_ptr< Surface > > &  all,
Array< shared_ptr< Surface > > &  super 
)
static

Called by Surface.

Removes the SuperSurfaces from array all and appends them to the super array.

◆ frame()

virtual CoordinateFrame G3D::Surface::frame ( bool  previous = false) const
inlinevirtualinherited

◆ getBoxBounds()

static void G3D::Surface::getBoxBounds ( const Array< shared_ptr< Surface >> &  surfaceArray,
AABox bounds,
bool  previous = false,
bool &  anyInfinite = ignoreBool,
bool  onlyShadowCasters = false 
)
staticinherited

Computes the world-space bounding box of an array of Surfaces of any type.

Ignores infinite bounding boxes.

Parameters
anyInfiniteSet to true if any bounding box in surfaceArray was infinite. Not modified otherwise.
onlyShadowCastersIf true, only get the bounds of shadow casting surfaces.

◆ getCoordinateFrame()

virtual void G3D::UniversalSurface::getCoordinateFrame ( CoordinateFrame c,
bool  previous = false 
) const
overridevirtual

Reimplemented from G3D::Surface.

◆ getObjectSpaceBoundingBox()

virtual void G3D::UniversalSurface::getObjectSpaceBoundingBox ( AABox box,
bool  previous = false 
) const
overridevirtual

May be infinite.

Implements G3D::Surface.

◆ getObjectSpaceBoundingSphere()

virtual void G3D::UniversalSurface::getObjectSpaceBoundingSphere ( Sphere sphere,
bool  previous = false 
) const
overridevirtual

May be infinite.

Implements G3D::Surface.

◆ getObjectSpaceGeometry()

virtual void G3D::UniversalSurface::getObjectSpaceGeometry ( Array< int > &  index,
Array< Point3 > &  vertex,
Array< Vector3 > &  normal,
Array< Vector4 > &  packedTangent,
Array< Point2 > &  texCoord,
bool  previous = false 
) const
overridevirtual

Clears the arrays and appends indexed triangle list information.

Many subclasses will ignore previous because they only use that for rigid-body transformations and can be represented by the current geometry and moving coordinate frame. However, it is possible to include skinning or keyframe information in a Surface and respond to timeOffset.

Not required to be implemented.

Reimplemented from G3D::Surface.

◆ getSphereBounds()

static void G3D::Surface::getSphereBounds ( const Array< shared_ptr< Surface > > &  surfaceArray,
Sphere bounds,
bool  previous = false,
bool &  anyInfinite = ignoreBool,
bool  onlyShadowCasters = false 
)
staticinherited

Computes the world-space bounding sphere of an array of Surfaces of any type.

Ignores infinite bounding boxes.

Parameters
anyInfiniteSet to true if any bounding box in surfaceArray was infinite. Not modified otherwise.
onlyShadowCastersIf true, only get the bounds of shadow casting surfaces.

◆ getTris()

static void G3D::Surface::getTris ( const Array< shared_ptr< Surface > > &  surfaceArray,
CPUVertexArray cpuVertexArray,
Array< Tri > &  triArray,
bool  computePrevPosition = false 
)
staticinherited

Returns a CPUVertexArray and an Array<Tri> generated from the surfaces in surfaceArray, with everything transformed to world space First separates surfaceArray by derived type and then calls getTrisHomogenous.

◆ getTrisHomogeneous()

virtual void G3D::UniversalSurface::getTrisHomogeneous ( const Array< shared_ptr< Surface > > &  surfaceArray,
CPUVertexArray cpuVertexArray,
Array< Tri > &  triArray,
bool  computePrevPosition = false 
) const
overridevirtual

Creates and appends Tris and CPUVertexArray::Vertices onto the parameter arrays using the cpuGeom's of the surfaces in surfaceArray.

Invoking this with elements of surfaceArray that are not of the same most-derived type as this will result in an error.

This function maintains a table of already used cpuGeoms, so that we don't need to duplicate things unneccessarily.

Reimplemented from G3D::Surface.

◆ gpuGeom() [1/2]

shared_ptr<GPUGeom>& G3D::UniversalSurface::gpuGeom ( )
inline

◆ gpuGeom() [2/2]

const shared_ptr<GPUGeom>& G3D::UniversalSurface::gpuGeom ( ) const
inline

◆ hasNonRefractiveTransmission()

virtual bool G3D::UniversalSurface::hasNonRefractiveTransmission ( ) const
virtual

Has transmission that can't be modeled in the opaque pass (since refraction is modeled by painting the surface via screen-space refraction by UniversalSurface)

◆ hasRefractiveTransmission()

virtual bool G3D::UniversalSurface::hasRefractiveTransmission ( ) const
virtual

◆ hasTransmission()

virtual bool G3D::UniversalSurface::hasTransmission ( ) const
overridevirtual

If true, this object transmits light, potentially refracting it and filtering the background with color or diffusion.

This says nothing about whether it has partial coverage.

The default implementation returns false.

Reimplemented from G3D::Surface.

◆ internalGeometry() [1/2]

const MeshAlg::Geometry& G3D::UniversalSurface::internalGeometry ( ) const
inline

For use by classes that pose objects on the CPU and need a place to store the geometry.

See MD2Model::pose implementation for an example of how to use this.

◆ internalGeometry() [2/2]

MeshAlg::Geometry& G3D::UniversalSurface::internalGeometry ( )
inline

◆ isSkybox()

virtual bool G3D::Surface::isSkybox ( ) const
inlinevirtualinherited

Reimplemented in G3D::SkyboxSurface.

◆ lastChangeTime()

virtual RealTime G3D::Surface::lastChangeTime ( ) const
virtualinherited

Wall-clock time at which the source of this surface changed in some way, e.g., that might require recomputing a shadow map or spatial data structure.

The default implementation returns the Entity's last change time if it is not null or System::time() otherwise, indicating that the surface is always out of date.

See also
canChange

◆ launchForwardShader()

void G3D::UniversalSurface::launchForwardShader ( Args args) const
protected

Launch the bone or non-bone shader as needed.

Called from render() and renderNonRefractiveTransparency()

◆ material()

const shared_ptr<UniversalMaterial>& G3D::UniversalSurface::material ( ) const
inline

◆ model()

const shared_ptr<Model>& G3D::Surface::model ( ) const
inlineinherited

The Model that created this surface.

May be nullptr

◆ modulateBackgroundByTransmission()

void G3D::UniversalSurface::modulateBackgroundByTransmission ( RenderDevice rd) const
protected

Using the current cull face, modulate the background by the transmission, if there is any transmission.

Also darkens based on coverage. Called from render() for RenderPassType::MULTIPASS_BLENDED_SAMPLES.

◆ name()

virtual String G3D::UniversalSurface::name ( ) const
overridevirtual

Name of the underlying model or part for debugging purposes.

Reimplemented from G3D::Surface.

◆ numInstances()

int G3D::UniversalSurface::numInstances ( ) const
inline

◆ operator delete()

static void G3D::UniversalSurface::operator delete ( void *  p)
inlinestatic

◆ operator new()

static void* G3D::UniversalSurface::operator new ( size_t  size)
inlinestatic

Allocates with System::malloc to avoid the performance overhead of creating lots of small heap objects using ::malloc.

◆ preferLowResolutionTransparency()

bool G3D::Surface::preferLowResolutionTransparency ( ) const
inlineinherited

◆ render()

virtual void G3D::UniversalSurface::render ( RenderDevice rd,
const LightingEnvironment environment,
RenderPassType  passTypen 
) const
overridevirtual

Forward-render all illumination terms for each element of surfaceArray, which must all be of the same most-derived type as this.

Implementations must obey the semantics of the current stencil, viewport, clipping, and depth tests.

Parameters
environmentWorld-space, screen-space, and light-space data needed for illumination.

Use the writePixel() function defined by the Framebuffer for generating output. when passType == RenderPassType::SINGLE_PASS_UNORDERED_BLENDED_SAMPLES.

Implements G3D::Surface.

◆ renderDepthOnly()

static void G3D::Surface::renderDepthOnly ( RenderDevice rd,
const Array< shared_ptr< Surface > > &  surfaceArray,
CullFace  cull,
const shared_ptr< Texture > &  depthPeelTexture = nullptr,
const float  minZSeparation = 0.0f,
TransparencyTestMode  transparencyTestMode = TransparencyTestMode::REJECT_TRANSPARENCY,
const Color3 transmissionWeight = Color3::white()/3.0f 
)
staticinherited

Render geometry only (no shading), and ignore color (but do perform alpha testing).

Render only back or front faces (two-sided surfaces render no matter what).

Does not sort or cull based on the view frustum of the camera like other batch rendering routines–sort before invoking if you want that.

Used for z prepass and shadow mapping.

◆ renderDepthOnlyHomogeneous()

virtual void G3D::UniversalSurface::renderDepthOnlyHomogeneous ( RenderDevice rd,
const Array< shared_ptr< Surface > > &  surfaceArray,
const shared_ptr< Texture > &  depthPeelTexture,
const float  depthPeelEpsilon,
TransparencyTestMode  transparencyTestMode,
const Color3 transmissionWeight 
) const
overridevirtual

Use the current RenderDevice::cullFace.

Assume that surfaceArray is sorted back to front, so render in reverse order for optimal early-z test behavior.

Parameters
transparencyTestModenet coverage testing mode applied after the alphaFilter's processing.
transmissionWeightHow wavelength-varying transmission elements (for shadow map rendering: lightPower/dot(lightPower, vec3(1,1,1)))
See also
renderDepthOnly

Reimplemented from G3D::Surface.

◆ renderHomogeneous()

virtual void G3D::Surface::renderHomogeneous ( RenderDevice rd,
const Array< shared_ptr< Surface > > &  surfaceArray,
const LightingEnvironment lightingEnvironment,
RenderPassType  passType 
) const
virtualinherited

Render a set of surfaces from the same most-derived class type.

The default implementation calls render() on each surface.

Parameters
surfaceArrayPre-sorted from back to front and culled to the current camera. Invoking this method with elements of surfaceArray that are not of the same most-derived type as this will result in an error.

Reimplemented in G3D::HeightfieldModel::Tile, G3D::ParticleSurface, and G3D::TextSurface.

◆ renderIntoGBuffer()

static void G3D::Surface::renderIntoGBuffer ( RenderDevice rd,
const Array< shared_ptr< Surface > > &  sortedVisible,
const shared_ptr< GBuffer > &  gbuffer,
const shared_ptr< Texture > &  depthPeelTexture = shared_ptr< Texture >(),
const float  minZSeparation = 0.0f,
const LightingEnvironment lightingEnvironment = LightingEnvironment() 
)
staticinherited

Renders front-to-back to a GBuffer using current stencil and depth operations.

Parameters
sortedVisibleSurfaces that are visible to the camera (i.e., already culled) and sorted from back to front.
previousCameraFrameUsed for rendering GBuffer::CS_POSITION_CHANGE frames.

If depthPeelTexture is not null, then use it and minZSeparation to perform a depth peel. This will result in the depth buffer representing the closest geometry at least minZSeparation behind the geometry in depthPeelTexture.

Parameters
lightingEnvironmentProvided even though this method is primarily used for deferred shading to allow objects with partly pre-computed lighting to complete their shading and write directly to the emissive buffer.
See also
cull, sortBackToFront

◆ renderIntoGBufferHomogeneous()

virtual void G3D::UniversalSurface::renderIntoGBufferHomogeneous ( RenderDevice rd,
const Array< shared_ptr< Surface > > &  surfaceArray,
const shared_ptr< GBuffer > &  gbuffer,
const shared_ptr< Texture > &  depthPeelTexture,
const float  minZSeparation,
const LightingEnvironment lighting 
) const
overridevirtual


Render all instances of surfaceArray to the currently-bound Framebuffer using the fields and mapping dictated by specification.

This is also used for depth-only (e.g., z-prepass) rendering.

Invoking this with elements of surfaceArray that are not of the same most-derived type as this will result in an error.

If depthPeelTexture is not null, then use it and minZSeparation to perform a depth peel. This will result in the GBuffer representing the closest geometry at least minZSeparation behind the geometry in depthPeelTexture.

Parameters
previousCameraFrameUsed for rendering GBuffer::CS_POSITION_CHANGE frames.
See also
renderIntoGBuffer

Reimplemented from G3D::Surface.

◆ renderIntoSVO()

static void G3D::Surface::renderIntoSVO ( RenderDevice rd,
Array< shared_ptr< Surface > > &  visible,
const shared_ptr< SVO > &  svo,
const CoordinateFrame previousCameraFrame = CoordinateFrame() 
)
staticinherited

◆ renderIntoSVOHomogeneous()

virtual void G3D::UniversalSurface::renderIntoSVOHomogeneous ( RenderDevice rd,
Array< shared_ptr< Surface > > &  surfaceArray,
const shared_ptr< SVO > &  svo,
const CFrame previousCameraFrame 
) const
overridevirtual

Reimplemented from G3D::Surface.

◆ renderMask()

RenderMask G3D::Surface::renderMask ( ) const
inherited

◆ renderWireframe()

static void G3D::Surface::renderWireframe ( RenderDevice rd,
const Array< shared_ptr< Surface > > &  surfaceArray,
const Color4 color = Color3::black(),
bool  previous = false 
)
staticinherited

Utility function for rendering a set of surfaces in wireframe using the current blending mode.

Parameters
previousIf true, the caller should set the RenderDevice camera transformation to the previous one.

◆ renderWireframeHomogeneous()

virtual void G3D::UniversalSurface::renderWireframeHomogeneous ( RenderDevice rd,
const Array< shared_ptr< Surface > > &  surfaceArray,
const Color4 color,
bool  previous 
) const
overridevirtual

Rendering a set of surfaces in wireframe, using the current blending mode.

This is primarily used for debugging.

Invoking this with elements of surfaceArray that are not of the same most-derived type as this will result in an error.

If depthPeelTexture is not null, then use it and minZSeparation to perform a depth peel. This will result in the depth buffer representing the closest geometry at least minZSeparation behind the geometry in depthPeelTexture.

Parameters
previousIf true, the caller should set the RenderDevice camera transformation to the previous one. This is provided for debugging previous frame data.
See also
renderWireframe

Implements G3D::Surface.

◆ requiresBlending()

virtual bool G3D::UniversalSurface::requiresBlending ( ) const
protectedvirtual

Does this surface require blending for some samples?

Surfaces with non-refractive transmission or AlphaFilter::BLEND should return true. A surface must return true if any sample within it requires blending, even if large areas are opaque.

Surfaces with refractive transmission but full coverage do not require blending because they write the refracted image themselves.

AlphaFilter::BINARY and AlphaFilter::COVERAGE_MASK surfaces that are not transmissive do not require blending.

See also
anyUnblended, canBeFullyRepresentedInGBuffer, hasTransmission

◆ rigidBodyID()

uint64 G3D::Surface::rigidBodyID ( ) const
inlineinherited

An identifier that, if nonzero, is unique for a combination of geometry and material.

This allows high-level data structures such as G3D::TriTreeBase to identify corresponding Surfaces between frames that have moved but not otherwise changed and avoid rebuilding the data structure.

◆ setShaderArgs()

void G3D::UniversalSurface::setShaderArgs ( Args args,
bool  useStructFormat = false 
) const

Bind material and geometry arguments, including setting args.numInstances()

◆ setStorage() [1/2]

virtual void G3D::UniversalSurface::setStorage ( ImageStorage  newStorage)
overridevirtual

Implements G3D::Surface.

◆ setStorage() [2/2]

static void G3D::Surface::setStorage ( const Array< shared_ptr< Surface >> &  surfaceArray,
ImageStorage  newStorage 
)
staticinherited

Set the storage on all Materials in the array.

◆ sortBackToFront()

static void G3D::Surface::sortBackToFront ( Array< shared_ptr< Surface > > &  surfaces,
const Vector3 wsLookVector 
)
inlinestaticinherited

◆ sortFrontToBack() [1/2]

static void G3D::UniversalSurface::sortFrontToBack ( Array< shared_ptr< UniversalSurface > > &  a,
const Vector3 v 
)
static

◆ sortFrontToBack() [2/2]

static void G3D::Surface::sortFrontToBack ( Array< shared_ptr< Surface > > &  surfaces,
const Vector3 wsLookVector 
)
staticinherited

Divides the inModels into a front-to-back sorted array of opaque models and a back-to-front sorted array of potentially transparent models.

Any data originally in the output arrays is cleared.

Parameters
wsLookVectorSort axis; usually the -Z axis of the camera.

Referenced by G3D::Surface::sortBackToFront().

◆ transparencyType()

virtual TransparencyType G3D::UniversalSurface::transparencyType ( ) const
overridevirtual

What type of transparency (= alpha and transmission) does this surface have?

Implements G3D::Surface.

Member Data Documentation

◆ debugSubmitFraction

float G3D::UniversalSurface::debugSubmitFraction
static

For debugging only.

◆ debugTrianglesSubmitted

uint64 G3D::UniversalSurface::debugTrianglesSubmitted
static

For debugging only.

◆ expressiveLightScatteringProperties

const ExpressiveLightScatteringProperties G3D::Surface::expressiveLightScatteringProperties
inherited

◆ m_cpuGeom

CPUGeom G3D::UniversalSurface::m_cpuGeom
protected

Referenced by cpuGeom().

◆ m_entity

shared_ptr<class Entity> G3D::Surface::m_entity
protectedinherited

◆ m_frame

CoordinateFrame G3D::UniversalSurface::m_frame
protected

Object to world space transformation.

◆ m_gpuGeom

shared_ptr<GPUGeom> G3D::UniversalSurface::m_gpuGeom
protected

Referenced by gpuGeom().

◆ m_internalGeometry

MeshAlg::Geometry G3D::UniversalSurface::m_internalGeometry
protected

For use by classes that want the m_cpuGeom to point at geometry that is deallocated with the surface.

Referenced by internalGeometry().

◆ m_isLight

bool G3D::UniversalSurface::m_isLight
protected

◆ m_material

shared_ptr<UniversalMaterial> G3D::UniversalSurface::m_material
protected

Referenced by material().

◆ m_model

shared_ptr<class Model> G3D::Surface::m_model
protectedinherited

Referenced by G3D::Surface::model().

◆ m_name

String G3D::UniversalSurface::m_name
protected

◆ m_numInstances

int G3D::UniversalSurface::m_numInstances
protected

Referenced by numInstances().

◆ m_preferLowResolutionTransparency

bool G3D::Surface::m_preferLowResolutionTransparency
protectedinherited

Hint for renderers to use low resolution rendering.

Referenced by G3D::FogVolumeSurface::FogVolumeSurface(), and G3D::Surface::preferLowResolutionTransparency().

◆ m_previousFrame

CoordinateFrame G3D::UniversalSurface::m_previousFrame
protected

Object to world transformation from the previous time step.

◆ m_profilerHint

String G3D::UniversalSurface::m_profilerHint
protected

A string used in indentifing profiler events.

◆ m_rigidBodyID

uint64 G3D::Surface::m_rigidBodyID = 0
protectedinherited

◆ m_source

shared_ptr<ReferenceCountedObject> G3D::UniversalSurface::m_source
protected

◆ m_uniformTable

shared_ptr<UniformTable> G3D::UniversalSurface::m_uniformTable
protected

documentation generated on Wed Nov 24 2021 08:02:01 using doxygen 1.8.15