feat: opacity + shininess + illumination support

This commit is contained in:
2025-10-01 11:25:00 +02:00
parent 69dbe5ae2f
commit 303b931fb7
2 changed files with 24 additions and 1 deletions

View File

@ -142,6 +142,20 @@ void Object::LoadMaterials(const std::filesystem::path& filename) {
currentMaterial->SetDiffuseColor(glm::vec3(r, g, b));
break;
}
case MtlElement::D:
{
float d;
iss >> d;
currentMaterial->SetOpacity(d);
break;
}
case MtlElement::ILLUM:
{
int illum;
iss >> illum;
currentMaterial->SetIllumination(illum);
break;
}
case MtlElement::MAP_KD:
{
std::string texturePath;
@ -325,7 +339,10 @@ void Object::Render(Shader& shader)
auto material = GetMaterial(mesh.materialName);
shader.setFloat("ambientStrength", 0.2f);
shader.setFloat("specularStrength", material->GetSpecularWeight());
shader.setFloat("shininess", material->GetSpecularWeight());
shader.setFloat("opacity", material->GetOpacity());
shader.setBool("useSpecular", material->GetIllumination() >= 2);
shader.setFloat("specularStrength", 1.0f);
shader.setVec3("ambientColor", material->GetAmbientColor());
shader.setVec3("diffuseColor", material->GetDiffuseColor());
shader.setVec3("specularColor", material->GetSpecularColor());