Skip to content

PhongMaterial

Implements the Blinn–Phong shading model for glossy surfaces.

This material implements a classic Blinn–Phong lighting model with diffuse and specular reflection. It is intended for standard lit geometry that requires view-dependent highlights, such as polished surfaces or simple metals.

cpp
auto material = vglx::PhongMaterial::Create({
  .color = 0x049EF4,
  .specular_color = 0x333333,
  .shininess = 64.0f,
  .albedo_map = texture
});

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

INFO

Derives from Material and inherits all public properties and methods.

Construction

Constructors


PhongMaterial()

Constructs a Phong material with default parameters.

cpp
PhongMaterial::PhongMaterial();

PhongMaterial()

Constructs a Phong material from the given parameters.

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

Factories preferred


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

Creates a shared instance of PhongMaterial with default parameters.

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

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

Creates a shared instance of PhongMaterial.

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

Types

PhongMaterial::Parameters struct

Parameters for constructing a PhongMaterial object.

ParameterDescription
color ColorDiffuse base color.
specular_color ColorSpecular highlight tint.
emissive_color ColorEmissive color independent of lighting.
ao_intensity floatAO contribution strength.
shininess floatSpecular highlight glossiness.
emissive_intensity floatEmissive multiplier.
normal_intensity floatNormal map strength.
reflectivity floatEnvironment reflection strength.
albedo_map std::shared_ptr<Texture>Diffuse color map.
alpha_map std::shared_ptr<Texture>Per-pixel opacity map.
ao_map std::shared_ptr<Texture>Ambient occlusion map (R channel).
emissive_map std::shared_ptr<Texture>Emissive color map.
environment_map std::shared_ptr<CubeTexture>Environment reflection cube map.
normal_map std::shared_ptr<Texture>Surface normal map.
specular_map std::shared_ptr<Texture>Specular intensity map.

Properties

albedo_map std::shared_ptr<Texture>

Albedo (diffuse) map defining base color and optional alpha channel.

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 used for diffuse reflection.

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 {};

environment_map std::shared_ptr<CubeTexture>

Environment cube map sampled for reflection contribution.

cpp
std::shared_ptr<CubeTexture> environment_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 {};

reflectivity float

Strength of the environment map reflection contribution.

cpp
float reflectivity {};

shininess float

Controls the glossiness of highlights; higher values yield sharper specular peaks.

cpp
float shininess {};

specular_color Color

Specular color controlling the tint of specular highlights.

cpp
Color specular_color {};

specular_map std::shared_ptr<Texture>

Specular map scaling the intensity of specular highlights.

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

Functions

GetType() Type virtual

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

cpp
Type PhongMaterial::GetType() const override;

Released under the MIT License.