diff --git a/src/datatypes/material.c b/src/datatypes/material.c index f9e6a8e9..1cda2092 100644 --- a/src/datatypes/material.c +++ b/src/datatypes/material.c @@ -49,6 +49,12 @@ const struct bsdfNode *try_to_guess_bsdf(const struct node_storage *s, const str default: break; } + + if (mat->emission.red > 0.0f || + mat->emission.blue > 0.0f || + mat->emission.green > 0.0f) { + chosen_bsdf = newEmission(s, newConstantTexture(s, mat->emission), NULL); + } if (chosen_bsdf) goto skip; diff --git a/src/utils/loaders/sceneloader.c b/src/utils/loaders/sceneloader.c index ab9b26a4..573f98cf 100644 --- a/src/utils/loaders/sceneloader.c +++ b/src/utils/loaders/sceneloader.c @@ -788,17 +788,6 @@ static void parse_mesh_instances(struct renderer *r, const cJSON *data, struct m new.bsdf_count = material_count; new.bsdfs = calloc(material_count, sizeof(void *)); - for (size_t m = 0; m < material_count; ++m) { - if (meshes[i].materials[m].emission.red > 0.0f || - meshes[i].materials[m].emission.green > 0.0f || - meshes[i].materials[m].emission.blue > 0.0f || - meshes[i].materials[m].emission.alpha > 0.0f) { - new.emits_light = true; - // const struct node_storage *s = &r->scene->storage; - // new.bsdfs[m] = newEmission(&r->scene->storage, newConstantTexture(s, meshes[i].materials[m].emission), newConstantValue(&r->scene->storage, 1.0f)); - } - } - apply_materials_to_instance(r, &new, overrides, meshes[i].materials, meshes[i].materialCount); new.composite = parse_composite_transform(cJSON_GetObjectItem(instance, "transforms")); addInstanceToScene(r->scene, new);