Class TAbstractTextureNode

Unit

Declaration

type TAbstractTextureNode = class(TAbstractAppearanceChildNode)

Description

Base for all nodes which specify a texture, possibly multi-texture.

Hierarchy

Overview

Methods

Public procedure InternalRendererResourceFree;
Public destructor Destroy; override;
Public function TextureDescription: string; virtual;
Public function AlphaChannelFinal: TAlphaChannel; virtual;
Public function Color(const TexCoord: TVector2): TCastleColor; overload;
Public function Color(const TexCoord: TVector4): TCastleColor; overload;
Public procedure CreateNode; override;
Public class function ClassX3DType: String; override;

Description

Methods

Public procedure InternalRendererResourceFree;

Free InternalRendererResource, if any.

Public destructor Destroy; override;

This item has no description.

Public function TextureDescription: string; virtual;

Short description how texture is defined, is it inline or loaded from URL, is it video of simple image texture. "none" if it's not defined at all.

Calling this may not cause automatically loading the texture data (for exampe, from file in case of TAbstractTexture2DNode). So it cannot describe the actually loaded data.

In this class, simply returns X3DType. Override to say something more descriptive.

Public function AlphaChannelFinal: TAlphaChannel; virtual;

Alpha channel of the loaded texture data. Looks at loaded texture data, and at alphaChannel field (see https://castle-engine.io/x3d_extensions.php#section_ext_alpha_channel_detection ). In case of MultiTexture node, looks at children.

Public function Color(const TexCoord: TVector2): TCastleColor; overload;

Query pixel color of the texture at the given texture coordinates.

Texture coordinates can be given as 2D or 4D vector.

  • 2D texture coordinates are most common way to address 2D textures.

    The X coordinate is horizontal, going from left to right, in the range 0..1. The Y coordinate is vertical, going from bottom to top, in the range 0..1 For example, Vector2(0, 0) is the bottom-left corner of the texture, Vector2(1, 1) is the top-right corner of the texture, Vector2(0.5, 0.5) is the center of the texture.

  • 4D texture coordinates can be used to address 2D or 3D textures using homogeneous coordinates.

  • Using 2D coordinates is just a shortcut for 4D coordinates with Z = 0, W = 1. So MyTexture.Color(Vector2(0.123, 0.456)) is equivalent to MyTexture.Color(Vector4(0.123, 0.456, 0, 1)).

This method replicates (doing on CPU) what the GPU is doing when rendering a shape with this texture set as the main texture (TX3DGraphTraverseState.MainTexture). We handle the most common texture setups, but we do not handle all the possibilities that OpenGL rendering supports. Details:

  • We support texture filtering using either "nearest" or "bilinear" modes.

    We do not support texture filtering using mipmaps, we ignore mipmaps for now. We do not support different filtering along different axes, e.g. X axis doing "nearest" while Y axis doing "bilinear". We do not support anisotropic filtering (this would actually need additional information to be given as input).

  • We handle single textures (not TMultiTextureNode).

    When the TMultiTextureNode is used, we only consider the first texture.

  • We handle TAbstractTexture2DNode (like TImageTextureNode, TPixelTextureNode).

    We do not handle TMovieTextureNode for now. We do not handle 3D textures or cubemap textures, for now. Though they could be added — as you see, we allow 3D and even 4D texture coordinates.

  • We only handle the situation when the image defined is not GPU compressed. That is, image must be TCastleImage, not TGPUCompressedImage.

  • In case of situations mentioned above that are not implemented (e.g. TGPUCompressedImage), this method will return opaque White color.

See https://forum.castle-engine.io/t/transformundermouse-with-alpha-pixels-check-for-quad-based-transforms/1494/3 for a practical usage example of this.

Public function Color(const TexCoord: TVector4): TCastleColor; overload;

This item has no description.

Public procedure CreateNode; override;

Create node fields and events.

Public class function ClassX3DType: String; override;

This item has no description. Showing description inherited from TX3DNode.ClassX3DType.

Node type name in VRML/X3D, for this class. Normal VRML/X3D node classes should override this to return something non-empty, and then X3DType automatically will return the same value.

Empty for classes that don't have a hardcoded VRML/X3D node name, like a special TX3DUnknownNode. Such special classes should override then X3DType to return actual non-empty name there.

You usually should call X3DType. The only use of this method is that it works on classes (it's "class function"), without needing at actual instance.


Generated by PasDoc 0.16.0-snapshot.