Skip to content

PBRMaterial

Implements physically-based shading using the metallic-roughness workflow.

This material implements physically-based rendering with a Cook-Torrance specular term and Lambertian diffuse, parameterized by metallic and roughness factors. It is intended for realistic lit geometry from rough dielectrics such as wood or plastic to polished metals.

cpp
auto material = vglx::PBRMaterial::Create({
  .color = 0xFFFFFF,
  .metallic = 1.0f,
  .roughness = 0.4f,
  .albedo_map = texture
});

my_scene->Add(vglx::Mesh::Create(geometry, material));

INFO

Derives from Material and inherits all public properties and methods.

Construction

Constructors


PBRMaterial()

Constructs a PBR material with default parameters.

cpp
PBRMaterial::PBRMaterial();

PBRMaterial()

Constructs a PBR material from the given parameters.

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

Factories preferred


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

Creates a shared instance of PBRMaterial with default parameters.

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

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

Creates a shared instance of PBRMaterial.

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

Types

PBRMaterial::Parameters struct

Parameters for constructing a PBRMaterial object.

ParameterDescription
color ColorBase surface color.
emissive_color ColorEmissive color independent of lighting.
ao_intensity floatAO contribution strength.
emissive_intensity floatEmissive multiplier.
metallic floatMetallic factor.
normal_intensity floatNormal map strength.
roughness floatRoughness factor.
alpha_map std::shared_ptr<Texture>Per-pixel opacity map.
ao_map std::shared_ptr<Texture>Ambient occlusion map (R channel).
albedo_map std::shared_ptr<Texture>Base color map.
emissive_map std::shared_ptr<Texture>Emissive color map.
metallic_map std::shared_ptr<Texture>Metallic map (B channel).
normal_map std::shared_ptr<Texture>Surface normal map.
roughness_map std::shared_ptr<Texture>Roughness map (G channel).

Properties

albedo_map std::shared_ptr<Texture>

Albedo (base color) map multiplied with color per texel.

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

alpha_map std::shared_ptr<Texture>

Alpha map defining per-pixel opacity.

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

ao_intensity float

Strength of the ambient occlusion contribution.

cpp
float ao_intensity {};

ao_map std::shared_ptr<Texture>

Ambient occlusion map sampled from the R channel; modulates the ambient term.

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

color Color

Base surface color; for metals this acts as the specular tint.

cpp
Color color {};

emissive_color Color

Emissive color added to the final shaded result, independent of lighting.

cpp
Color emissive_color {};

emissive_intensity float

Scalar multiplier for emissive contribution.

cpp
float emissive_intensity {};

emissive_map std::shared_ptr<Texture>

Emissive map modulating the emissive color per texel.

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

metallic float

Metallic factor.

cpp
float metallic {};

metallic_map std::shared_ptr<Texture>

Metallic map sampled from the B channel; multiplied with metallic per texel.

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

normal_intensity float

Scalar multiplier for normal map perturbation.

cpp
float normal_intensity {};

normal_map std::shared_ptr<Texture>

Normal map for per-pixel surface detail and lighting variation.

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

roughness float

Roughness factor.

cpp
float roughness {};

roughness_map std::shared_ptr<Texture>

Roughness map sampled from the G channel; multiplied with roughness per texel.

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

Functions

GetType() Type virtual

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

cpp
Type PBRMaterial::GetType() const override;

Released under the MIT License.