Skip to content

Commit

Permalink
Fix mtllib emitter parsing
Browse files Browse the repository at this point in the history
I recently broke it while shuffling things around. The whole premise of
trying to come up with reasonable materials from the incredibly
restrictive mtllib description is a bit shaky at best, but we still
make a best effort to produce defaults, with the assumption that
materials get overridden with proper material graphs in json.
  • Loading branch information
vkoskiv committed Nov 4, 2023
1 parent 264803c commit 6433eb7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 11 deletions.
6 changes: 6 additions & 0 deletions src/datatypes/material.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
11 changes: 0 additions & 11 deletions src/utils/loaders/sceneloader.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6433eb7

Please sign in to comment.