Class TRenderingAttributes

Unit

Declaration

type TRenderingAttributes = class(TPersistent)

Description

Various properties that control rendering done with TGLRenderer.

They are collected here, in a class separate from TGLRenderer, to allow TCastleScene to hide internal TGLRenderer but still expose TRenderingAttributes instance.

Hierarchy

  • TPersistent
  • TRenderingAttributes

Overview

Fields

Public nested const DefaultPointSize = 3.0;
Public nested const DefaultLineWidth = 2.0;
Public nested const DefaultBumpMapping = bmSteepParallaxShadowing;
Public nested const DefaultPhongShading = false;

Methods

Protected procedure SetOnRadianceTransfer(const Value: TRadianceTransferFunction); virtual;
Protected procedure SetOnVertexColor(const Value: TVertexColorFunction); virtual;
Protected procedure SetEnableTextures(const Value: boolean); virtual;
Protected procedure SetMinificationFilter(const Value: TMinificationFilter); virtual;
Protected procedure SetMagnificationFilter(const Value: TMagnificationFilter); virtual;
Protected procedure SetBumpMapping(const Value: TBumpMapping); virtual;
Protected procedure SetMode(const Value: TRenderingMode); virtual;
Protected procedure SetShadowSampling(const Value: TShadowSampling); virtual;
Protected procedure SetVertexBufferObject(const Value: boolean); virtual;
Protected procedure SetVisualizeDepthMap(const Value: boolean); virtual;
Protected procedure SetPhongShading(const Value: boolean); virtual;
Protected procedure ReleaseCachedResources; virtual;
Public constructor Create; virtual;
Public procedure Assign(Source: TPersistent); override;
Public function EqualForShapeCache(SecondValue: TRenderingAttributes): boolean; virtual;
Public function TextureFilter: TTextureFilter;

Properties

Public property OnRadianceTransfer: TRadianceTransferFunction read FOnRadianceTransfer write SetOnRadianceTransfer;
Public property OnVertexColor: TVertexColorFunction read FOnVertexColor write SetOnVertexColor;
Public property Lighting: boolean read FLighting write FLighting default true;
Public property UseSceneLights: boolean read FUseSceneLights write FUseSceneLights default true;
Public property Opacity: Single read FOpacity write FOpacity default 1;
Public property EnableTextures: boolean read FEnableTextures write SetEnableTextures default true;
Public property MinificationFilter: TMinificationFilter read FMinificationFilter write SetMinificationFilter default minLinearMipmapLinear;
Public property MagnificationFilter: TMagnificationFilter read FMagnificationFilter write SetMagnificationFilter default magLinear;
Public property PointSize: TGLFloat read FPointSize write FPointSize default DefaultPointSize;
Public property LineWidth: Single read FLineWidth write FLineWidth default DefaultLineWidth;
Public property BumpMapping: TBumpMapping read FBumpMapping write SetBumpMapping default DefaultBumpMapping;
Public property Shaders: TShadersRendering read GetShaders write SetShaders; deprecated 'use PhongShading';
Public property PhongShading: boolean read FPhongShading write SetPhongShading default DefaultPhongShading;
Public property CustomShader: TX3DShaderProgramBase read FCustomShader write FCustomShader;
Public property CustomShaderAlphaTest: TX3DShaderProgramBase read FCustomShaderAlphaTest write FCustomShaderAlphaTest;
Public property Mode: TRenderingMode read FMode write SetMode default rmFull;
Public property VertexBufferObject: boolean read FVertexBufferObject write SetVertexBufferObject default true;
Public property ShadowSampling: TShadowSampling read FShadowSampling write SetShadowSampling default DefaultShadowSampling;
Public property VisualizeDepthMap: boolean read FVisualizeDepthMap write SetVisualizeDepthMap default false;
Public property DepthTest: boolean read FDepthTest write FDepthTest default true;
Public property SolidColor: TCastleColorRGB read FSolidColor write FSolidColor;
Public property SeparateDiffuseTexture: boolean read FSeparateDiffuseTexture write FSeparateDiffuseTexture default false;

Description

Fields

Public nested const DefaultPointSize = 3.0;
 
Public nested const DefaultLineWidth = 2.0;
 
Public nested const DefaultBumpMapping = bmSteepParallaxShadowing;
 
Public nested const DefaultPhongShading = false;
 

Methods

Protected procedure SetOnRadianceTransfer(const Value: TRadianceTransferFunction); virtual;

These methods just set the value on given property, eventually (some of them) calling ReleaseCachedResources.

Protected procedure SetOnVertexColor(const Value: TVertexColorFunction); virtual;
 
Protected procedure SetEnableTextures(const Value: boolean); virtual;
 
Protected procedure SetMinificationFilter(const Value: TMinificationFilter); virtual;
 
Protected procedure SetMagnificationFilter(const Value: TMagnificationFilter); virtual;
 
Protected procedure SetBumpMapping(const Value: TBumpMapping); virtual;
 
Protected procedure SetMode(const Value: TRenderingMode); virtual;
 
Protected procedure SetShadowSampling(const Value: TShadowSampling); virtual;
 
Protected procedure SetVertexBufferObject(const Value: boolean); virtual;
 
Protected procedure SetVisualizeDepthMap(const Value: boolean); virtual;
 
Protected procedure SetPhongShading(const Value: boolean); virtual;
 
Protected procedure ReleaseCachedResources; virtual;

Called before changing an attribute that requires the release of things cached in a renderer. This includes attributes that affect:

  • How TShapeCache.Arrays contents are generated. For example, Generator uses TexCoordsNeeded, so changing any attribute that affects TexCoordsNeeded calls this method. Likewise OnVertexColor determines if color array will be loaded at all.

  • How (and if) TShapeCache.Vbo are loaded.

  • How textures are loaded (texture filtering options affect them).

Public constructor Create; virtual;
 
Public procedure Assign(Source: TPersistent); override;
 
Public function EqualForShapeCache(SecondValue: TRenderingAttributes): boolean; virtual;

Is the second TRenderingAttributes instance on all fields that affect TShapeCache, that is things that affect generated geometry arrays or vbo. This compares the subset of variables that call ReleaseCachedResources — only the ones that affect TShapeCache.

Public function TextureFilter: TTextureFilter;
 

Properties

Public property OnRadianceTransfer: TRadianceTransferFunction read FOnRadianceTransfer write SetOnRadianceTransfer;

Calculate vertex color from radiance transfer. If this is assigned, and geometry object has radianceTransfer field (see [https://castle-engine.io/x3d_extensions.php#section_ext_radiance_transfer]) then this is used to calculate the color of each vertex.

Note that this is evaluated when object is rendered. It causes the shapes resources to be regenerated at each render frame, since we have to assume that results of this function change.

Public property OnVertexColor: TVertexColorFunction read FOnVertexColor write SetOnVertexColor;

Calculate vertex color for given vertex by a callback. If this is assigned, then this is used to calculate the color of each vertex.

Note that this is evaluated when object is rendered. It causes the shapes resources to be regenerated at each render frame, since we have to assume that results of this function change.

Public property Lighting: boolean read FLighting write FLighting default true;

Enable OpenGL lighting when rendering. This is True by default, since it's almost always wanted.

When Lighting is False, we disable OpenGL lighting. (We had previously a different approach, when we left GL_LIGHTING untouched and caller could enable/disable it. But this doesn't really work for modern OpenGL, the renderer really has to know if lighting is enabled. (to generate proper shaders, and to avoid clumsy glPushAttrib / glPopAttrib at some places).)

Public property UseSceneLights: boolean read FUseSceneLights write FUseSceneLights default true;

Should we setup VRML/X3D lights as OpenGL lights during rendering.

VRML/X3D lights are loaded into OpenGL lights. All OpenGL lights are always used (we always start from the first OpenGL light 0, up to the last available OpenGL light — this is necessary, as shader pipeline must know all the lights anyway).

Initial OpenGL lights are reserved for BaseLights (useful for you to define any lights from outside of the scene). Then following OpenGL lights are reserved for the lights defined in your scene (if this property is True). The remaining OpenGL lights, if any, are not used (we make sure they are disabled for fixed-function pipeline).

This is independent from the Lighting property (which merely says whether we will turn OpenGL lighting on at all).

Public property Opacity: Single read FOpacity write FOpacity default 1;

Opacity for all rendered shapes. Setting this to something < 1 you can make every shape transparent.

Public property EnableTextures: boolean read FEnableTextures write SetEnableTextures default true;

Take model textures into account. When True (default), then our engine takes care of everything related to texturing for you: enabling and using textures for textured parts of the model, disabling textures for non-textured parts.

Otherwise, textures are disabled.

Public property MinificationFilter: TMinificationFilter read FMinificationFilter write SetMinificationFilter default minLinearMipmapLinear;

Default minification and magnification filters for textures. These can be overridden on a per-texture basis in VRML / X3D files by X3D TextureProperties node (see X3D specification).

Public property MagnificationFilter: TMagnificationFilter read FMagnificationFilter write SetMagnificationFilter default magLinear;
 
Public property PointSize: TGLFloat read FPointSize write FPointSize default DefaultPointSize;

Size of points. This has an effect on VRML/X3D PointSet rendering. Must be > 0.

Public property LineWidth: Single read FLineWidth write FLineWidth default DefaultLineWidth;

Line width. This has an effect on VRML/X3D LineSet rendering, and on wireframe rendering for TSceneRenderingAttributes.WireframeEffect. Must be > 0.

Public property BumpMapping: TBumpMapping read FBumpMapping write SetBumpMapping default DefaultBumpMapping;

Use bump mapping. To actually use this, particular shape must also provide normal map (and height map, if you want parallax bump mapping). This also requires some OpenGL capabilities, in particular GLSL.

Simple bump mapping (when only normal map is available) means that normals are provided in the texture, and lighting is calculated per-fragment.

Parallax bump mapping means that additionally the texture coordinate is perturbed, based on height map and camera direction, to create illusion of 3D shape instead of flat surface. This makes e.g. the bricks on the texture really visible as "standing out", in 3D, from the wall. And self-shadowing means that these bricks even cast appropriate shadows on each other.

Steep parallax mapping requires good GPU to work correctly and fast enough.

Public property Shaders: TShadersRendering read GetShaders write SetShaders; deprecated 'use PhongShading';

Warning: this symbol is deprecated: use PhongShading

When GLSL shaders are used. This is now a deprecated property, better use PhongShading to determine the shading. The engine auto-detects whether to use shaders based on OpenGL capabilities, particular shape needs (phong shading, bump mapping, shadow maps, compositing shader effects), and GLFeatures.EnableFixedFunction.

Public property PhongShading: boolean read FPhongShading write SetPhongShading default DefaultPhongShading;

Whether to use Phong shading by default for all shapes. Note that each shape may override it by TAbstractShapeNode.Shading field.

Public property CustomShader: TX3DShaderProgramBase read FCustomShader write FCustomShader;

Custom GLSL shader to use for the whole scene. When this is assigned, Shaders value is ignored.

Avoid using this. It's not easy to create portable shaders, that work both with OpenGL and OpenGLES. Try using "compositing shaders" instead https://castle-engine.io/compositing_shaders.php which still allow you to write GLSL effects, but they are integrated into standard shader code.

Public property CustomShaderAlphaTest: TX3DShaderProgramBase read FCustomShaderAlphaTest write FCustomShaderAlphaTest;

Alternative custom GLSL shader used when alpha test is necessary. Relevant only if CustomShader <> nil.

Do not use this. This is a temporary hack to enable VSM working with alpha test. It's not clean, and should not be used for anything else.

Public property Mode: TRenderingMode read FMode write SetMode default rmFull;

Rendering mode, can be used to disable many rendering features at once.

Public property VertexBufferObject: boolean read FVertexBufferObject write SetVertexBufferObject default true;

Use OpenGL vertex buffer object. This is always a good idea. You can set this to False for debug purposes, e.g. to check how much speedup you get from VBO.

Public property ShadowSampling: TShadowSampling read FShadowSampling write SetShadowSampling default DefaultShadowSampling;

Shadow maps sampling. Various approaches result in various quality and speed.

Public property VisualizeDepthMap: boolean read FVisualizeDepthMap write SetVisualizeDepthMap default false;

Visualize depths stored in the shadow maps, instead of using them to actually make shadow.

Even without turning this on, VRML author can always activate it explicitly for specific lights. For this, you have to use X3DLightNode.defaultShadowMap field, and place a GeneratedShadowMap node there. If the GeneratedShadowMap.compareMode is set to 'NONE', we will always visualize depths of this shadow map.

Setting this property to True has the same effect as setting compareMode to "NONE" on all (explicit and implicitly created) GeneratedShadowMap nodes.

Public property DepthTest: boolean read FDepthTest write FDepthTest default true;

By default, we use depth testing to determine which objects are in front of the others. This allows to display all 3D content (all TCastleScene instances, and all shapes inside them) in any order.

For very special purposes, you can disable depth testing. This means that 3D objects will always be drawn in front of the previous ones, in the order in which they are rendered, ignoring the contents of the depth buffer. Use only if you know what you're doing, if you're sure that the order of rendering will always be good.

Public property SolidColor: TCastleColorRGB read FSolidColor write FSolidColor;

Color used when Mode is rmSolidColor.

Public property SeparateDiffuseTexture: boolean read FSeparateDiffuseTexture write FSeparateDiffuseTexture default false;

Set to True to make diffuse texture affect only material diffuse color when the shape is lit and shading is Phong. This affects both textures from X3D Appearance.texture, and textures from CommonSurfaceShader.diffuseTexture. This is more correct (following X3D lighting equations), and is more impressive (e.g. specular highlights may be better visible, as they are not darkened by a dark diffuse texture).

For historic reasons and for Gouraud shading, by default, this is False. Which means that "diffuse texture" is actually used to multiply a complete result of the lighting calculation. This is not correct, but it is necessary for Gouraud shading, and it is also depended upon by some applications (since the "diffuse texture" effectively multiplies all factors, so it also multiplies e.g. emissive factor for "pure emissive materials", which may be useful sometimes).


Generated by PasDoc 0.15.0.