Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Principled material: parameter specularMetallic #599

Merged
merged 1 commit into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ Version History
of the first *non-specular* hit for denoising)
- Channel `OSP_FB_POSITION` holds the world-space position of the first hit
- Improved sampling of layered materials
- New parameter `specularMetallic` for the Principled material to
optionally disable the incluence of `specular` to metallicness,
improving compatibility with glTF `KHR_materials_specular`

### Changes in v3.2.0:

Expand Down
2 changes: 2 additions & 0 deletions doc/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1977,6 +1977,8 @@ listed in the table below.

float specular 1 specular reflection/transmission weight in [0–1]

bool specularMetallic true whether specular influences metallic

float ior 1 dielectric index of refraction

float transmission 0 specular transmission weight in [0–1]
Expand Down
2 changes: 2 additions & 0 deletions modules/cpu/render/materials/Principled.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ void Principled::commit()
metallic = getMaterialParam1f("metallic", 0.f);
diffuse = getMaterialParam1f("diffuse", 1.f);
specular = getMaterialParam1f("specular", 1.f);
bool specularMetallic = getParam<bool>("specularMetallic", true);
ior = getMaterialParam1f("ior", 1.f);
transmission = getMaterialParam1f("transmission", 0.f);
transmissionColor = getMaterialParam3f("transmissionColor", vec3f(1.f));
Expand Down Expand Up @@ -88,6 +89,7 @@ void Principled::commit()
getSh()->diffuse = diffuse.factor;
getSh()->diffuseMap = diffuse.tex;
getSh()->specular = specular.factor;
getSh()->specularMetallic = specularMetallic;
getSh()->specularMap = specular.tex;
getSh()->ior = ior.factor;
getSh()->iorMap = ior.tex;
Expand Down
3 changes: 2 additions & 1 deletion modules/cpu/render/materials/Principled.ispc
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,8 @@ SYCL_EXTERNAL const varying BSDF *uniform Principled_getBSDF(
}

// conductor base
const float conductor = metallic * specular;
const float conductor =
metallic * (self->specularMetallic ? specular : 1.0f);
if (conductor > EPS) {
const vec3f edgeColor = clamp(
self->edgeColor * get3f(self->edgeColorMap, dg, make_vec3f(1.f)));
Expand Down
2 changes: 2 additions & 0 deletions modules/cpu/render/materials/PrincipledShared.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ struct Principled
// specular weight in [0, 1]
float specular;
TextureParam specularMap;
bool specularMetallic;

// index of refraction
float ior;
Expand Down Expand Up @@ -132,6 +133,7 @@ struct Principled
metallic(0.f),
diffuse(1.f),
specular(1.f),
specularMetallic(true),
ior(1.f),
transmission(0.f),
transmissionColor(1.f),
Expand Down