BudgiePanic / PushingP

A Whitted ray tracing implementation written in Java
Apache License 2.0
1 stars 0 forks source link

add motion blur effect #89

Closed BudgiePanic closed 7 months ago

BudgiePanic commented 7 months ago

section in chapter 17 of the book

BudgiePanic commented 7 months ago

working on this looks like it needs the following:

BudgiePanic commented 7 months ago

exposure camera needs to convey more information to motion shapes so they can bake their AABBs

BudgiePanic commented 7 months ago

following the book's advice on this feature, we need to extend the Ray record to include some more information:

BudgiePanic commented 7 months ago

tests to create

BudgiePanic commented 7 months ago

created tests for motion shape cube and plane, now working on creating the shutter camera

I believe world will now need method overloads where the time the color is computed / time the occlusion is checked for, must be passed in as a parameter

BudgiePanic commented 7 months ago

To make this work, I think I need to change the perspective camera API, they need to expose the code they use to generate the color for one pixel, so the shutter camera can call it multiple times with different time stamps

BudgiePanic commented 7 months ago

These camera's have a code smell in my opinion, methods across various subclasses sharing the exact same structure The only camera that can't have its takePicture logic extracted to a consumer lambda is depthCamera, but that's because the depth camera is doing a post processing step as part of its takePicture method, which could easily be removed to another method

BudgiePanic commented 7 months ago

you could almost make a single camera class with behaviour delegates for ray generation, pixel imaging, and whole imaging

BudgiePanic commented 7 months ago

tomorrow we need to modify world functionality to use the new time field in rays

BudgiePanic commented 7 months ago

something is up with ray-shape intersection testing when they are nested in a linear motion shape

BudgiePanic commented 7 months ago

motion blur is not appearing in reflective surfaces either

BudgiePanic commented 7 months ago

motion blur is not appearing in reflective surfaces either

fixed now, just had to pass in the time, which is now stored in shading info object

BudgiePanic commented 7 months ago

something is up with ray-shape intersection testing when they are nested in a linear motion shape

I think it is because we are currently transforming the ray by negative velocity in local object space instead of in world space

edit: was actually because not calculating AABB correctly for motion shapes

BudgiePanic commented 7 months ago

alright now that that is working, last thing we need to do is make the shutter camera bake the scene with exposure end time

BudgiePanic commented 7 months ago

future issue to deal with hmm, baking the motion shapes with the camera's exposure end time to optimize their AABBs is going to create an implicit coupling between the camera and the world being imaged, for example, you wouldn't be able to have two shutter cameras imaging the same world at different times

we could modify motion shapes so they have to be provided a motion end time at construction time?

we could use a design pattern to have all motion shapes in a world listen for time end events, and update AABBs when a shutter camera announces their exposure duration or something

BudgiePanic commented 7 months ago

going to change the motion shape so if the end time is unknown, then we don't use the AABB's bounding box this will allow correct behaviour of the program for rays cast at time != 0 for motion shapes even when their end time is not set

going to make shutter camera baking the exposure duration a higher level function so the user is causing that behaviour, rather than the camera automatically baking the times when Camera::imageWorld is called

BudgiePanic commented 7 months ago

looks like everything is working