Class TSceneRenderingAttributes

Unit

Declaration

type TSceneRenderingAttributes = class(TRenderingAttributes)

Description

No description available, ancestor TRenderingAttributes description follows

Various properties that control rendering done with TGLRenderer.

They are collected here, in a class separate from TGLRenderer, because various things (like TCastleScene and TCastlePrecalculatedAnimation) wrap TGLRenderer instances and hide it, but still they want to allow user to change these attributes.

Hierarchy

Overview

Fields

Public internal const DefaultBlendingSourceFactor = bsSrcAlpha;
Public internal const DefaultBlendingDestinationFactor = bdOneMinusSrcAlpha;
Public internal const DefaultBlendingSort = bs3D;
Public internal const DefaultWireframeColor: TVector3Single = (0, 0, 0);
Public internal const DefaultSolidWireframeScale = 1;
Public internal const DefaultSolidWireframeBias = 1;
Public internal const DefaultSilhouetteScale = 5;
Public internal const DefaultSilhouetteBias = 5;
Public var OnCreate: TRenderingAttributesEvent; static;

Methods

Protected procedure ReleaseCachedResources; override;
Protected procedure SetBlending(const Value: boolean); virtual;
Protected procedure SetBlendingSourceFactor(const Value: TBlendingSourceFactor); virtual;
Protected procedure SetBlendingDestinationFactor(const Value: TBlendingDestinationFactor); virtual;
Protected procedure SetBlendingSort(const Value: TBlendingSort); virtual;
Protected procedure SetControlBlending(const Value: boolean); virtual;
Protected procedure SetUseOcclusionQuery(const Value: boolean); virtual;
Protected procedure SetShaders(const Value: TShadersRendering); override;
Public constructor Create; override;
Public destructor Destroy; override;
Public procedure Assign(Source: TPersistent); override;

Properties

Public property Blending: boolean read FBlending write SetBlending default true;
Public property BlendingSourceFactor: TBlendingSourceFactor read FBlendingSourceFactor write SetBlendingSourceFactor default DefaultBlendingSourceFactor;
Public property BlendingDestinationFactor: TBlendingDestinationFactor read FBlendingDestinationFactor write SetBlendingDestinationFactor default DefaultBlendingDestinationFactor;
Public property BlendingSort: TBlendingSort read FBlendingSort write SetBlendingSort default DefaultBlendingSort;
Public property ControlBlending: boolean read FControlBlending write SetControlBlending default true;
Public property WireframeEffect: TWireframeEffect read FWireframeEffect write FWireframeEffect default weNormal;
Public property SolidWireframeScale: Single read FSolidWireframeScale write FSolidWireframeScale default DefaultSolidWireframeScale;
Public property SolidWireframeBias: Single read FSolidWireframeBias write FSolidWireframeBias default DefaultSolidWireframeBias;
Public property SilhouetteScale: Single read FSilhouetteScale write FSilhouetteScale default DefaultSilhouetteScale;
Public property SilhouetteBias: Single read FSilhouetteBias write FSilhouetteBias default DefaultSilhouetteBias;
Public property WireframeColor: TVector3Single read FWireframeColor write FWireframeColor;
Public property UseOcclusionQuery: boolean read FUseOcclusionQuery write SetUseOcclusionQuery default false;
Public property UseHierarchicalOcclusionQuery: boolean read FUseHierarchicalOcclusionQuery write FUseHierarchicalOcclusionQuery default false;
Public property DebugHierOcclusionQueryResults: boolean read FDebugHierOcclusionQueryResults write FDebugHierOcclusionQueryResults default false;

Description

Fields

Public internal const DefaultBlendingSourceFactor = bsSrcAlpha;
 
Public internal const DefaultBlendingDestinationFactor = bdOneMinusSrcAlpha;

Default value of Attributes.BlendingDestinationFactor. See TSceneRenderingAttributes.BlendingDestinationFactor.

Using bdOneMinusSrcAlpha is the standard value for 3D graphic stuff, often producing best results. However, it causes troubles when multiple transparent shapes are visible on the same screen pixel. For closed convex 3D objects, using backface culling (solid = TRUE for geometry) helps. For multiple transparent shapes, sorting the transparent shapes helps, see TSceneRenderingAttributes.BlendingSort. Sometimes, no solution works for all camera angles.

Another disadvantage of bdOneMinusSrcAlpha may be that the color of opaque shapes disappears too quickly from resulting image (since bdOneMinusSrcAlpha scales it down). So the image may be darker than you like.

You can instead consider using bdOne, that doesn't require sorting and never has problems with multiple transparent shapes. On the other hand, it only adds to the color, often making too bright results.

Public internal const DefaultBlendingSort = bs3D;

Default value of TSceneRenderingAttributes.BlendingSort.

Public internal const DefaultWireframeColor: TVector3Single = (0, 0, 0);
 
Public internal const DefaultSolidWireframeScale = 1;
 
Public internal const DefaultSolidWireframeBias = 1;
 
Public internal const DefaultSilhouetteScale = 5;
 
Public internal const DefaultSilhouetteBias = 5;
 
Public var OnCreate: TRenderingAttributesEvent; static;

Adjust attributes of all loaded resources.

Methods

Protected procedure ReleaseCachedResources; override;
 
Protected procedure SetBlending(const Value: boolean); virtual;
 
Protected procedure SetBlendingSourceFactor(const Value: TBlendingSourceFactor); virtual;
 
Protected procedure SetBlendingDestinationFactor(const Value: TBlendingDestinationFactor); virtual;
 
Protected procedure SetBlendingSort(const Value: TBlendingSort); virtual;
 
Protected procedure SetControlBlending(const Value: boolean); virtual;
 
Protected procedure SetUseOcclusionQuery(const Value: boolean); virtual;
 
Protected procedure SetShaders(const Value: TShadersRendering); override;
 
Public constructor Create; override;
 
Public destructor Destroy; override;
 
Public procedure Assign(Source: TPersistent); override;
 

Properties

Public property Blending: boolean read FBlending write SetBlending default true;

Render partially transparent objects.

More precisely: if this is True, all shapes with transparent materials or textures with non-trivial (not only yes/no) alpha channel will be rendered using OpenGL blending (with depth test off, like they should for OpenGL).

If this attribute is False, everything will be rendered as opaque.

Public property BlendingSourceFactor: TBlendingSourceFactor read FBlendingSourceFactor write SetBlendingSourceFactor default DefaultBlendingSourceFactor;

Blending function parameters, used when Blending. Note that this is only a default, VRML/X3D model can override this for specific shapes by using our extension BlendMode node. See [http://castle-engine.sourceforge.net/x3d_extensions.php#section_ext_blending].

Public property BlendingDestinationFactor: TBlendingDestinationFactor read FBlendingDestinationFactor write SetBlendingDestinationFactor default DefaultBlendingDestinationFactor;
 
Public property BlendingSort: TBlendingSort read FBlendingSort write SetBlendingSort default DefaultBlendingSort;

How to sort the rendered objects using blending (partial transparency). See the TBlendingSort documentation for possible values.

This may be overridden in a specific 3D models by using NavigationInfo node with blendingSort field, see TNavigationInfoNode.BlendingSort.

Public property ControlBlending: boolean read FControlBlending write SetControlBlending default true;

Setting this to False disables any modification of OpenGL blending (and depth mask) state by TCastleScene. This makes every other Blending setting ignored, and is useful only if you set your own OpenGL blending parameters when rendering this scene.

Public property WireframeEffect: TWireframeEffect read FWireframeEffect write FWireframeEffect default weNormal;

You can use this to turn on some effects related to rendering model in special modes.

When this is weNormal (default), nothing special is done, which means that model polygons are simply passed to OpenGL. Whether this results in filled or wireframe, depends on OpenGL glPolygonMode setting, filled by default.

How the wireframe effects work when Mode = rmDepth is undefined now. Just don't use Mode = rmDepth if you're unsure.

See description of TWireframeEffect for what other modes do.

Public property SolidWireframeScale: Single read FSolidWireframeScale write FSolidWireframeScale default DefaultSolidWireframeScale;
 
Public property SolidWireframeBias: Single read FSolidWireframeBias write FSolidWireframeBias default DefaultSolidWireframeBias;
 
Public property SilhouetteScale: Single read FSilhouetteScale write FSilhouetteScale default DefaultSilhouetteScale;
 
Public property SilhouetteBias: Single read FSilhouetteBias write FSilhouetteBias default DefaultSilhouetteBias;
 
Public property WireframeColor: TVector3Single read FWireframeColor write FWireframeColor;

Wireframe color, used with some WireframeEffect values. Default value is DefaultWireframeColor.

Public property UseOcclusionQuery: boolean read FUseOcclusionQuery write SetUseOcclusionQuery default false;

Should we use ARB_occlusion_query (if available) to avoid rendering shapes that didn't pass occlusion test in previous frame. Ignored if GPU doesn't support ARB_occlusion_query.

True may give you a large speedup in some scenes. OTOH, a lag of one frame may happen between an object should be rendered and it actually appears.

When you render more than once the same instance of TCastleScene scene, you should not activate it (as the occlusion query doesn't make sense if each following render of the scene takes place at totally different translation). Also, when rendering something more than just one TCastleScene scene (maybe many times the same TCastleScene instance, maybe many different TCastleScene instances, maybe some other 3D objects) you should try to sort rendering order from the most to the least possible occluder (otherwise occlusion query will not be as efficient at culling).

This is ignored if UseHierarchicalOcclusionQuery.

Public property UseHierarchicalOcclusionQuery: boolean read FUseHierarchicalOcclusionQuery write FUseHierarchicalOcclusionQuery default false;

Should we use ARB_occlusion_query (if available) with a hierarchical algorithm to avoid rendering shapes that didn't pass occlusion test in previous frame. Ignored if GPU doesn't support ARB_occlusion_query.

True may give you a large speedup in some scenes.

This method doesn't impose any lag of one frame (like UseOcclusionQuery).

This requires the usage of ssRendering in TCastleSceneCore.Spatial. Also, it always does frustum culling (like fcBox for now), regardless of TCastleScene.OctreeFrustumCulling setting.

The algorithm used underneath is "Coherent Hierarchical Culling", described in detail in "GPU Gems 2", Chapter 6: "Hardware Occlusion Queries Made Useful", by Michael Wimmer and Jiri Bittner. Online on [http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter06.html].

Public property DebugHierOcclusionQueryResults: boolean read FDebugHierOcclusionQueryResults write FDebugHierOcclusionQueryResults default false;

View only the shapes that were detected as visible by occlusion query in last Render.

Use this only after render with UseHierarchicalOcclusionQuery. TODO: for UseOcclusionQuery I would also like to make it work, for now not done as frustum information is gone. This will disable actual occlusion query, instead reusing results from last occlusion query done when this debug flag was False.

Useful to quickly visualize the benefits of occlusion query.


Generated by PasDoc 0.14.0.