Unit CastleRenderOptions
Description
Configure rendering options. The TCastleRenderOptions component configures the rendering at each particular scene, and is usually accessed through TCastleScene.RenderOptions. This unit contains also related types, constants and some variables.
Uses
Overview
Classes, Interfaces, Objects and Records
Functions and Procedures
Types
Constants
ShadowSamplingNames: array [TShadowSampling] of string =
( 'Simple', 'PCF 4', 'PCF 4 Bilinear', 'PCF 16', 'Variance Shadow Maps (Experimental)' ); |
ShaderTypeName: array [TShaderType] of string =
( 'Vertex', 'Geometry', 'Fragment' ); |
BumpMappingNames: array [TBumpMapping] of string = (
'None',
'Basic',
'Parallax',
'Steep Parallax',
'Steep Parallax With Self-Shadowing'
); |
BlendingSourceFactorNames: array [TBlendingSourceFactor] of string =
(
'SRC_ALPHA',
'ONE_MINUS_SRC_ALPHA',
'ZERO',
'ONE',
'DST_COLOR',
'SRC_COLOR',
'DST_ALPHA',
'ONE_MINUS_DST_COLOR',
'ONE_MINUS_SRC_COLOR',
'ONE_MINUS_DST_ALPHA',
'SRC_ALPHA_SATURATE',
'CONSTANT_COLOR',
'ONE_MINUS_CONSTANT_COLOR',
'CONSTANT_ALPHA',
'ONE_MINUS_CONSTANT_ALPHA'
); |
BlendingDestinationFactorNames: array [TBlendingDestinationFactor] of string =
(
'SRC_ALPHA',
'ONE_MINUS_SRC_ALPHA',
'ZERO',
'ONE',
'DST_COLOR',
'SRC_COLOR',
'DST_ALPHA',
'ONE_MINUS_DST_COLOR',
'ONE_MINUS_SRC_COLOR',
'ONE_MINUS_DST_ALPHA',
'CONSTANT_COLOR',
'ONE_MINUS_CONSTANT_COLOR',
'CONSTANT_ALPHA',
'ONE_MINUS_CONSTANT_ALPHA'
); |
DefaultColorSpace = csLinearWhenPhysicalMaterial; |
Variables
Description
Functions and Procedures
function GetGammaCorrection: TGammaCorrection; deprecated 'use ColorSpace'; |
Warning: this symbol is deprecated: use ColorSpace |
procedure SetGammaCorrection(const Value: TGammaCorrection); deprecated 'use ColorSpace'; |
Warning: this symbol is deprecated: use ColorSpace |
Types
TShaderType = (...); |
Shader types.
Values
-
stVertex
-
stGeometry
-
stFragment
|
TUniformMissing = (...); |
What to do when shader uniform variable is set but doesn't exist in the shader. See TGLSLProgram.UniformMissing.
Values
-
umWarning: Report that uniform variable not found to WritelnWarning.
-
umIgnore: Ignore the fact that uniform variable doesn't exist in the GLSL shader. Do not warn anywhere.
|
TColorSpace = (...); |
Color space. Determines in what color space do we make lighting calculations and do we gamma-correct colors when reading textures and writing to screen. See https://castle-engine.io/color_space .
Values
-
csSRGB: Color calculation is done in sRGB color space. That is, gamma correction is not done.
This results in marginally faster but also incorrect lighting calculation.
This was the "old, traditional" way of calculating lighting in 3D applications, before linear space (with gamma correction) became popular. Some 3D models and their textures may assume it and can look weird with calculation in linear space.
-
csLinearWhenPhysicalMaterial: Color calculation is done in linear space for materials using PBR (TPhysicalMaterialNode), otherwise (for unlit and Phong lighting – TUnlitMaterialNode, TMaterialNode) the calculation is done in sRGB space.
This is like using csSRGB for TUnlitMaterialNode, TMaterialNode, and csLinear for TPhysicalMaterialNode. It is the default color space for Castle Game Engine, as it means that typical materials in modern 3D models (PBR) will behave nicely, while also keeping backward compatibility (for Phong and unlit materials).
-
csLinear: Color calculation is always done in linear space. This results in correct lighting calculation.
It means that texture colors (like for TPhysicalMaterialNode.BaseTexture or TMaterialNode.DiffuseTexture or TUnlitMaterialNode.EmissiveTexture) are converted from sRGB into linear space before using them (to multiply with material and lighting colors) and at the end the resulting color is converted back from linear to display space (likely sRGB) for proper display.
See https://castle-engine.io/color_space and https://github.com/michaliskambi/x3d-tests/wiki/Gamma-correction-in-X3D-and-glTF for more details.
In other words, gamma correction is performed.
|
TGammaCorrection = (...) deprecated 'use TColorSpace'; |
Warning: this symbol is deprecated: use TColorSpace
Deprecated name for TColorSpace.
Values
-
gcNone: Never do gamma correction.
-
gcPhysicalMaterial: Gamma correction only for PhysicalMaterial.
-
gcAlways: Always do gamma correction.
|
TShadersRendering = (...) deprecated 'this was only useful with TCastleRenderOptions.Shaders, which is now deprecated in favor of TCastleRenderOptions.PhongShading'; |
Warning: this symbol is deprecated: this was only useful with TCastleRenderOptions.Shaders, which is now deprecated in favor of TCastleRenderOptions.PhongShading Values
-
srDisable
-
srWhenRequired
-
srAlways
|
TRenderingMode = (...); |
Possible values of TCastleRenderOptions.Mode.
Values
-
rmFull: Normal rendering features. Everything is enabled (as long as other TCastleRenderOptions settings allow them).
-
rmSolidColor: Solid color is used for everything. We do not show any color variation, materials, lights, fog, textures on surfaces. We still do back-face culling and depth test. The idea is that we "hit" the same pixels as normal rendering (with the exception of alpha test textures, this mode doesn't set up alpha test for them). But everything has color TCastleRenderOptions.SolidColor.
This is useful for special tricks.
-
rmDepth: Only the rendering fetures that affect depth buffer work reliably, everything else is undefined (and works as fast as possible). This is suitable if you render only to depth buffer, like for shadow maps.
It's quite similar to rmSolidColor, except alpha testing must work, so (at least some) textures must be applied over the model.
|
TWireframeEffect = (...); |
Values for TCastleRenderOptions.WireframeEffect.
Generally, two other properties may affect the way wireframe is rendered: TCastleRenderOptions.WireframeColor and TCastleRenderOptions.LineWidth, quite self-explanatory.
Values
-
weNormal: Default setting, model polygons are simply passed to OpenGL. Whether this results in filled or wireframe look, depends on OpenGL glPolygonMode setting, filled by default.
-
weWireframeOnly: The model is rendered in wireframe mode.
LineWidth is used as wireframe line width (regardless of TCastleRenderOptions.Mode).
Depending on TCastleRenderOptions.Mode value:
-
weSolidWireframe: The model is rendered as normal, with it's wireframe version visible on top. This is most often called "solid wireframe", since the intention is too see wireframe version of the model but still render shapes solid (e.g. filled polygons with depth test).
Scene.RenderOptions.WireframeColor and Scene.RenderOptions.LineWidth determine the color and width of lines.
This is often used together with the RenderOptions.Mode set to rmSolidColor. In such case, Then TCastleRenderOptions.SolidColor determinesthe fill color.
-
weSilhouette: The model is rendered as normal, with silhouette outlined around it. This works quite like weSolidWireframe, except that weSolidWireframe makes the wireframe mesh slightly in front the model, while
weSilhouette makes the wireframe mesh slightly at the back of the model. This way only the silhouette is visible from the wireframe rendering.
Scene.RenderOptions.WireframeColor and Scene.RenderOptions.LineWidth determine the color and width of silhouette lines.
This is often used together with the RenderOptions.Mode set to rmSolidColor. In such case, Then TCastleRenderOptions.SolidColor determinesthe fill color.
|
TShadowSampling = (...); |
Values for TCastleRenderOptions.ShadowSampling.
Values
-
ssSimple: One sample to shadow map.
-
ssPCF4: Percentage Closer Filtering improve shadow maps look, by sampling the depth map a couple of times. They also make shadow more blurry (increase shadow map size to counteract this), and a little slower. They may also introduce new artifacts (due to bad interaction with the "polygon offset" of shadow map).
-
ssPCF4Bilinear
-
ssPCF16
-
ssVarianceShadowMaps: Variance Shadow Maps, see http://www.punkuser.net/vsm/ . This may generally produce superior results, as shadow maps can be then filtered like normal textures (bilinear, mipmaps, anisotropic filtering). So shadows look much nicer from very close and very far distances. However, this requires new GPU, and may cause artifacts on some scenes.
|
TAutoMinificationFilter = (...); |
Texture minification filter (what happens when many texture pixels are squeezed in one screen pixel).
Values
|
TMinificationFilter = minNearest..minLinearMipmapLinear; |
|
TAutoMagnificationFilter = (...); |
Texture magnification filter (what happens when a single texture pixel in stretched over many screen pixels).
Values
|
TMagnificationFilter = magNearest..magLinear; |
|
TBlendingSourceFactor = (...); |
Values
-
bsSrcAlpha
-
bsOneMinusSrcAlpha
-
bsZero
-
bsOne
-
bsDstColor
-
bsSrcColor: As a source factor only since GL 1.4, check
GLFeatures.Version_1_4
-
bsDstAlpha
-
bsOneMinusDstColor
-
bsOneMinusSrcColor: As a source factor only since GL 1.4, check
GLFeatures.Version_1_4
-
bsOneMinusDstAlpha
-
bsSrcAlphaSaturate
-
bsConstantColor
-
bsOneMinusConstantColor
-
bsConstantAlpha
-
bsOneMinusConstantAlpha
|
TBlendingDestinationFactor = (...); |
Values
-
bdSrcAlpha
-
bdOneMinusSrcAlpha
-
bdZero
-
bdOne
-
bdDstColor: As a destination factor only since GL 1.4, check
GLFeatures.Version_1_4
-
bdSrcColor
-
bdDstAlpha
-
bdOneMinusDstColor: As a destination factor only since GL 1.4, check
GLFeatures.Version_1_4
-
bdOneMinusSrcColor
-
bdOneMinusDstAlpha
-
bdConstantColor
-
bdOneMinusConstantColor
-
bdConstantAlpha
-
bdOneMinusConstantAlpha
|
TBlendingSort = (...); |
Various ways to sort the 3D objects, in particular useful to correctly render the partially-transparent objects.
See also
- TCastleRenderOptions.BlendingSort
- How to sort the rendered objects using blending (partial transparency).
Values
-
bsNone: Do not sort. Using this for Scene.RenderOptions.BlendingSort is fastest, but will cause artifacts if multiple partially-transparent objects may be visible on top of each other.
-
bs2D: Sort objects by their Z coordinate. Using this for Scene.RenderOptions.BlendingSort is very useful for 2D worlds, with flat 2D objects that have zero (or near-zero) size in the Z axis, and they are moved in the Z axis to specify which is on top for another.
More precisely, we take the minimum bounding box Z coordinate of two objects. (We don't bother calculating the middle Z coordinate, as we assume that the bounding box is infinitely small along the Z axis.) The one with larger Z coordinate is considered to be closer, this is consistent with the right-handed coordinate system.
Note that the actual camera position doesn't matter for this sorting. So the 2D object will look OK, even if viewed from an angle, even if viewed from the other side.
-
bs3D: Sort objects by the (3D) distance to the camera. Using this for Scene.RenderOptions.BlendingSort is the best sorting method for 3D scenes with many partially-transparent objects.
The distance is measured from the middle of the bounding box to the camera posotion.
|
Constants
ShadowSamplingNames: array [TShadowSampling] of string =
( 'Simple', 'PCF 4', 'PCF 4 Bilinear', 'PCF 16', 'Variance Shadow Maps (Experimental)' ); |
|
ShaderTypeName: array [TShaderType] of string =
( 'Vertex', 'Geometry', 'Fragment' ); |
|
BumpMappingNames: array [TBumpMapping] of string = (
'None',
'Basic',
'Parallax',
'Steep Parallax',
'Steep Parallax With Self-Shadowing'
); |
|
BlendingSourceFactorNames: array [TBlendingSourceFactor] of string =
(
'SRC_ALPHA',
'ONE_MINUS_SRC_ALPHA',
'ZERO',
'ONE',
'DST_COLOR',
'SRC_COLOR',
'DST_ALPHA',
'ONE_MINUS_DST_COLOR',
'ONE_MINUS_SRC_COLOR',
'ONE_MINUS_DST_ALPHA',
'SRC_ALPHA_SATURATE',
'CONSTANT_COLOR',
'ONE_MINUS_CONSTANT_COLOR',
'CONSTANT_ALPHA',
'ONE_MINUS_CONSTANT_ALPHA'
); |
Names for TBlendingSourceFactor used by TBlendModeNode when it is read/written in X3D file. Deliberately compatible with (a subset of) X3DOM BlendMode specification on https://doc.x3dom.org/author/Shape/BlendMode.html .
|
BlendingDestinationFactorNames: array [TBlendingDestinationFactor] of string =
(
'SRC_ALPHA',
'ONE_MINUS_SRC_ALPHA',
'ZERO',
'ONE',
'DST_COLOR',
'SRC_COLOR',
'DST_ALPHA',
'ONE_MINUS_DST_COLOR',
'ONE_MINUS_SRC_COLOR',
'ONE_MINUS_DST_ALPHA',
'CONSTANT_COLOR',
'ONE_MINUS_CONSTANT_COLOR',
'CONSTANT_ALPHA',
'ONE_MINUS_CONSTANT_ALPHA'
); |
Names for TBlendingDestinationFactor used by TBlendModeNode when it is read/written in X3D file. Deliberately compatible with (a subset of) X3DOM BlendMode specification on https://doc.x3dom.org/author/Shape/BlendMode.html .
|
Variables
ColorSpace: TColorSpace = DefaultColorSpace; |
Determines if color calculation is done in linear space (thus performing gamma correction when reading textures and when storing pixel color to screen) or sRGB (thus not performing gamma correction).
Using linear color space follows reality better and is advised for modern games.
Whatever you choose, your assets (their colors and textures) have to be prepared with the given color space in mind.
See https://castle-engine.io/color_space and possible TColorSpace values documentation.
|
Generated by PasDoc 0.16.0.