Skip to content

DepthMaterial

Depth-only material used for shadow map rendering.

Writes fragment depth without producing any color output. The renderer uses a single instance of this material internally to draw shadow casters, reconfiguring it per object, so it rarely needs to be created directly.

The texture maps exist solely to feed the alpha test. When a caster uses cutout transparency, its maps are assigned here so that discarded fragments leave holes in the shadow map. Color content is ignored; only the sampled alpha participates.

cpp
auto material = vglx::DepthMaterial::Create({
  .albedo_map = foliage_texture
});

material->alpha_test = 0.5f;

INFO

Derives from Material and inherits all public properties and methods.

Construction

Constructors


DepthMaterial()

Constructs a depth material with default parameters.

cpp
DepthMaterial::DepthMaterial();

DepthMaterial()

Constructs a depth material from the given parameters.

cpp
DepthMaterial::DepthMaterial(const Parameters& params);
ParameterDescription
paramsInitialization parameters.

Factories preferred


DepthMaterial::Create() std::shared_ptr<DepthMaterial>

Creates a shared instance of DepthMaterial with default parameters.

cpp
static std::shared_ptr<DepthMaterial> DepthMaterial::Create();

DepthMaterial::Create() std::shared_ptr<DepthMaterial>

Creates a shared instance of DepthMaterial.

cpp
static std::shared_ptr<DepthMaterial> DepthMaterial::Create(const Parameters& params);
ParameterDescription
paramsInitialization parameters.

Types

DepthMaterial::Parameters struct

Parameters for constructing a DepthMaterial object.

ParameterDescription
albedo_map std::shared_ptr<Texture>Color texture whose alpha channel feeds the alpha test.
alpha_map std::shared_ptr<Texture>Alpha-only texture feeding the alpha test.

Properties

albedo_map std::shared_ptr<Texture>

Color texture sampled for its alpha channel only.

cpp
std::shared_ptr<Texture> albedo_map {};

alpha_map std::shared_ptr<Texture>

Alpha-only texture providing per-pixel opacity.

cpp
std::shared_ptr<Texture> alpha_map {};

Functions

GetType() Type virtual

Identifies this material as Material::Type::DepthMaterial.

cpp
Type DepthMaterial::GetType() const override;

Released under the MIT License.