Skip to content

Book 3.12: Bug in final code? Black image when using lambert material for nearest object to camera in mixed density pdf approach #1265

@hollasch

Description

@hollasch

Discussed in #1240

Originally posted by 1vx-437312114 August 25, 2023
This is the result of the final code of book 3 (src/TheRestOfYourLife/main.cc ):

theRestOfYourLife_400

When i change the material of the glass sphere in the cornell_box() - function into a lambert diffuse material i get a nearly black image with basically only the light source visible when i render the image:

theRestOfYourLife

This is what it should look like (rendered for comparison in the brute force path tracer without the mixed density pdf approach):

cornell_box

I tried a few things e.g. replacing the sphere with a box or changing materials of the box inside the scene to lambert diffuse. My results so far are that whenever the object which is nearest to the camera is lambert diffuse the rendering breaks and i get the nearly black image from above as the result.

I came to this after i tried implementing the mixed density pdf approach from book 3 in my own path tracer where i tried to render the original cornell box (in which everything has a diffuse material) and i got the same bad results which got me trying to test the original code.

Here are the "changes" (just one line) in the cornell_box() - function of the main.cc file inside the folder src/TheRestOfYourLife/ for changing the glas sphere in the front to a blue colored diffuse sphere:

 hittable_list cornell_box() {
    ...
    shared_ptr<material> blue = make_shared<lambertian>(color(0.0, 0.0, 0.75));   // blue lambert diffuse
    //auto glass = make_shared<dielectric>(1.5);
    objects.add(make_shared<sphere>(point3(190,90,190), 90 , blue));  // changed from 'glass' to 'blue'

    return objects;
}

Has anyone any idea what is going wrong here or what i did wrong and how to fix this? Thanks in advance.

Here is the "modified" main.cc if anyone wants to test it:

main_cc.txt

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions