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.

It supports a base color, specular color, shininess exponent, and optional texture maps for albedo, alpha, normals, and specular intensity.

cpp
auto material = vglx::PhongMaterial::Create(0x049EF4);
material->specular = 0x333333;
material->shininess = 64.0f;
material->albedo_map = texture;

auto mesh = vglx::Mesh::Create(geometry, material);
scene->Add(mesh);

INFO

Derives from Material and inherits all public properties and methods.

Construction

Constructors


PhongMaterial()

Constructs a Phong material with a given base color.

cpp
PhongMaterial::PhongMaterial(const Color& color);
ParameterDescription
colorBase diffuse color of the material.

Factories preferred


PhongMaterial::Create() auto

Creates a shared instance of PhongMaterial.

cpp
static auto PhongMaterial::Create(const Color& color=0xFFFFFF);
ParameterDescription
colorBase diffuse color of the material.

Properties

albedo_map std::shared_ptr<Texture2D>

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

cpp
std::shared_ptr<Texture2D> albedo_map {nullptr};

alpha_map std::shared_ptr<Texture2D>

Alpha map defining per-pixel opacity.

cpp
std::shared_ptr<Texture2D> alpha_map {nullptr};

color Color

Base surface color used for diffuse reflection.

cpp
Color color {0xFFFFFF};

normal_map std::shared_ptr<Texture2D>

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

cpp
std::shared_ptr<Texture2D> normal_map {nullptr};

shininess float

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

cpp
float shininess {32.0f};

specular Color

Specular color controlling the tint of specular highlights.

cpp
Color specular {0x111111};

specular_map std::shared_ptr<Texture2D>

Specular map scaling the intensity of specular highlights.

cpp
std::shared_ptr<Texture2D> specular_map {nullptr};

Functions

GetType() Type virtual

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

cpp
Type PhongMaterial::GetType() const override;

Released under the MIT License.