Class TRenderingAttributes

DescriptionHierarchyFieldsMethodsProperties

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, 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

  • TPersistent
  • TRenderingAttributes

Overview

Fields

Public internal const DefaultPointSize = 3.0;
Public internal const DefaultLineWidth = 2.0;
Public internal const DefaultShaders = srWhenRequired;
Public internal const DefaultBumpMapping = bmBasic;

Methods

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

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 TextureMinFilter: TGLint read FTextureMinFilter write SetTextureMinFilter default GL_LINEAR_MIPMAP_LINEAR;
Public property TextureMagFilter: TGLint read FTextureMagFilter write SetTextureMagFilter default GL_LINEAR;
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 FShaders write FShaders default DefaultShaders;
Public property CustomShader: TGLSLProgram read FCustomShader write FCustomShader;
Public property CustomShaderAlphaTest: TGLSLProgram read FCustomShaderAlphaTest write FCustomShaderAlphaTest;
Public property Mode: TRenderingMode read FMode write SetMode default rmFull;
Public property TextureModeGrayscale: TGLenum read FTextureModeGrayscale write SetTextureModeGrayscale default GL_MODULATE;
Public property TextureModeRGB: TGLenum read FTextureModeRGB write SetTextureModeRGB default GL_MODULATE;
Public property VertexBufferObject: boolean read FVertexBufferObject write SetVertexBufferObject default true;
Public property PreserveOpenGLState: boolean read FPreserveOpenGLState write FPreserveOpenGLState default false;
Public property ShadowSampling: TShadowSampling read FShadowSampling write SetShadowSampling default DefaultShadowSampling;
Public property VisualizeDepthMap: boolean read FVisualizeDepthMap write SetVisualizeDepthMap default false;

Description

Fields

Public internal const DefaultPointSize = 3.0;
 
Public internal const DefaultLineWidth = 2.0;
 
Public internal const DefaultShaders = srWhenRequired;
 
Public internal const DefaultBumpMapping = bmBasic;
 

Methods

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.

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 [http://castle-engine.sourceforge.net/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 TextureMinFilter: TGLint read FTextureMinFilter write SetTextureMinFilter default GL_LINEAR_MIPMAP_LINEAR;

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 TextureMagFilter: TGLint read FTextureMagFilter write SetTextureMagFilter default GL_LINEAR;
 
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 FShaders write FShaders default DefaultShaders;

When GLSL shaders are used.

  • srDisable Never use shaders for anything. This means that "shaders", "effects" VRML/X3D fields are ignored, and various effects are disabled (like shadow maps, bump mapping, screen effects). No GLSL program is active, we always force fixed-function pipeline.

  • srWhenRequired Enable only for shapes that require it. For shapes that don't strictly require shaders (don't have ComposedShader, don't use shadow maps, don't have any shader effects etc.) use fixed-function pipeline.

  • srAlways Enable for all shapes, render everything by GLSL shaders. Everything will look beautiful (per-pixel lighting for all shapes), but rendering may be slower.

Note that Mode <> rmFull also disables all shaders. That is, when Mode <> rmFull, the value of this property doesn't matter, it's always treated like srDisable.

Public property CustomShader: TGLSLProgram read FCustomShader write FCustomShader;

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

Public property CustomShaderAlphaTest: TGLSLProgram 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 TextureModeGrayscale: TGLenum read FTextureModeGrayscale write SetTextureModeGrayscale default GL_MODULATE;

Default texture mode for single texturing. For X3D MultiTexture nodes, they are always explicitly given by MultiTexture.mode field. This field applies only to non-multi textures.

VRML 2 / X3D specifications say that the mode for TextureModeRGB should be GL_REPLACE to be conforming (see "Lighting model" spec). So our default value here contradicts the spec — but, practically, it's much more useful, so I decided that, as an exception, I can contradict the spec in this case.

Note that this should specify the mode only on non-alpha channels. On the alpha channel, specification says clearly that texture alpha should replace (never modulate) alpha channel, if only texture has any alpha channel.

TODO: this is not honored, for now setting below controls mode on both alpha and non-alpha channels.

Public property TextureModeRGB: TGLenum read FTextureModeRGB write SetTextureModeRGB default GL_MODULATE;
 
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 PreserveOpenGLState: boolean read FPreserveOpenGLState write FPreserveOpenGLState default false;

Do we have to restore OpenGL state at the end of rendering. If True, then RenderEnd restores the exact OpenGL state that was before RenderBegin. This is comfortable if you do some other rendering besides TCastleScene, and depend on some state preserved. Unfortunately this is also quite expensive, and can slow down the rendering.

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.


Generated by PasDoc 0.12.1 on 2013-02-04 20:26:51