correctly mixed diffuse map color when rendering to preserve not overwrite it

This commit is contained in:
Chris 2019-10-18 07:57:05 +01:00
parent c79942b348
commit c8f43d4f45

View File

@ -2382,8 +2382,15 @@ void DrawModelEx(Model model, Vector3 position, Vector3 rotationAxis, float rota
for (int i = 0; i < model.meshCount; i++)
{
//model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = tint;
Color c = model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color;
Color s = c;
c.r = ((c.r/255) * (tint.r/255)) * 255;
c.g = ((c.g/255) * (tint.g/255)) * 255;
c.b = ((c.b/255) * (tint.b/255)) * 255;
c.a = ((c.a/255) * (tint.a/255)) * 255;
model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = c;
rlDrawMesh(model.meshes[i], model.materials[model.meshMaterial[i]], model.transform);
model.materials[model.meshMaterial[i]].maps[MAP_DIFFUSE].color = s;
}
}
@ -3534,8 +3541,8 @@ static Model LoadGLTF(const char *fileName)
model.materials[i].maps[MAP_ALBEDO].texture = LoadTextureFromCGLTFTextureView(data->materials[i].pbr_metallic_roughness.base_color_texture.texture->image, tint, texPath);
}
//tint isn't need for other textures.. pass null or clear?
//tint = (Color){ 0.0f, 0.0f, 0.0f, 0.0f };
//tint isn't need for other textures.. pass null or clear? (try full white because of mixing (multiplying * white has no effect))
tint = (Color){ 255, 255, 255, 255 };
if (data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture) {
model.materials[i].maps[MAP_ROUGHNESS].texture = LoadTextureFromCGLTFTextureView(data->materials[i].pbr_metallic_roughness.metallic_roughness_texture.texture->image, tint, texPath);