Skip to content

Commit

Permalink
Check AssImp shading model and use it to determine when to use Phong …
Browse files Browse the repository at this point in the history
…instead of PBR

There are other AssImp shading models, but some of them aren't things the VSG's got a built-in shader for, and there's some dumbness with the available values as the list of options was originally taken from Blender back when Blender's shading models were total nonsense (e.g. Cook-Torrance was actually Blinn-Phong, Blinn-Phong had some parts of Cook-Torrance added etc.).
I've therefore ignored lots of them.

Previously, the value was put into a variable, but then never read, and that only happened on the Phong path, which was more-or-less unreachable as most assimp format loaders set AI_MATKEY_COLOR_SPECULAR for the Phong specular colour, so it wasn't a good signal to use to decide that PBR shaders should be used.
  • Loading branch information
AnyOldName3 committed Oct 3, 2024
1 parent cf43aff commit 7450eae
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/assimp/SceneConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,10 @@ void SceneConverter::convert(const aiMaterial* material, vsg::DescriptorConfigur
defines.insert("VSG_TWO_SIDED_LIGHTING");
}

if (getColor(material, AI_MATKEY_BASE_COLOR, pbr.baseColorFactor) || hasPbrSpecularGlossiness)
aiShadingMode shadingMode;
material->Get(AI_MATKEY_SHADING_MODEL, shadingMode);

if (!(shadingMode & aiShadingMode_Phong || shadingMode & aiShadingMode_Blinn) && (getColor(material, AI_MATKEY_BASE_COLOR, pbr.baseColorFactor) || hasPbrSpecularGlossiness))
{
// PBR path
convertedMaterial.shaderSet = getOrCreatePbrShaderSet();
Expand Down Expand Up @@ -622,9 +625,6 @@ void SceneConverter::convert(const aiMaterial* material, vsg::DescriptorConfigur
const auto emissiveResult = getColor(material, AI_MATKEY_COLOR_EMISSIVE, mat.emissive);
const auto specularResult = getColor(material, AI_MATKEY_COLOR_SPECULAR, mat.specular);

aiShadingMode shadingModel = aiShadingMode_Phong;
material->Get(AI_MATKEY_SHADING_MODEL, shadingModel);

unsigned int maxValue = 1;
float strength = 1.0f;
if (aiGetMaterialFloatArray(material, AI_MATKEY_SHININESS, &mat.shininess, &maxValue) == AI_SUCCESS)
Expand Down

0 comments on commit 7450eae

Please sign in to comment.