Fix #123324: Improve Cycles camera bounding box size calculation #123341
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset System
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Code Documentation
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Viewport & EEVEE
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Asset Browser Project
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Asset System
Module
Core
Module
Development Management
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Module
Viewport & EEVEE
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Severity
High
Severity
Low
Severity
Normal
Severity
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#123341
Loading…
Reference in New Issue
Block a user
No description provided.
Delete Branch "Alaska/blender:fix-123324"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Cycles runs a check to see if the camera is possibly inside a
volumetric object by seeing if the bounding box of the camera
and volumetric object intersect.
If the calculation is wrong (Cycles says the camera is outside the
volume when it's inside it), then the volume will not render properly.
This commit resolves most of these issues by making the camera
bounding box larger than before, taking into consideration
features like:
that should impact the bounding box size.
orthographic camera due to a oversight in a previous commit
(
08cc73a9bb
).There are still cases where it can be wrong. Specifically when depth of field is in use, and there is a volume object which a DOF ray starts in, but the volume object does not intersect with the orthographic camera bounding view. This case is now more common after
08cc73a9bb
.A fix for this is listed as a TODO:
/* TODO(sergey): Aperture support? */
An alternative fix can be found here: !123343
If you would prefer that pull request, just say so.
The same issue with some volumetric objects not rendering properly with DOF also applies there.
I think the fix should be in
Camera::viewplane_bounds_get
. We can make the bounds bigger to account for the near clipping and aperture. Something like this, but I have not tested or checked the math closely. And maybe the panorama case needs work too.There might be more exact ways to do it, but it doesn't matter much if the bounds are a bit bigger or smaller, it's just to avoid the volume check in the most common cases.
I've updated the pull request with a variant of what @brecht recommended.
My concern is that this configuration may not work perfectly for cameras that aren't aligned with the world axis. But I haven't investigated it yet.In theory this isn't a issue. But I have been wrong before.
Fix #123324: Incorrect camera bbox for involume check of orthographic camerato WIP: Fix #123324: Incorrect camera bbox for involume check of orthographic cameraWIP: Fix #123324: Incorrect camera bbox for involume check of orthographic camerato Fix #123324: Incorrect camera BBox for involume check of orthographic cameraThanks!
For the panorama case, I think we also want to replace
nearclip
bymax_aperture_size + nearclip
.@ -625,0 +627,4 @@
scaled value is larger than nearclip, in which case we add it to `extend` to extend the
bounding box to account for these rays.
----------------- nearclip plane
This diagram and the corrisponding code matches the orhtographic implementation of DOF with nearcliping.
Pespective cameras differ and technically should use a smaller
extend
value (justmax_aperture_size + nearclip
) because of how DOF with nearcliping is implemented thereray->P += nearclip * ray->D
.Fix #123324: Incorrect camera BBox for involume check of orthographic camerato Fix #123324: Improve Cycles camera bounding box size calculationOnly minor nitpicks about style.
@ -593,40 +593,73 @@ BoundBox Camera::viewplane_bounds_get()
* checks we need in a more clear and smart fashion? */
BoundBox bounds = BoundBox::empty;
float extend;
It's better to use
const float extend =
twice than declaring in advance. Less chance of using uninitialized variables.@ -623,2 +626,2 @@
bounds.grow(transform_raster_to_world((float)width, (float)height));
bounds.grow(transform_raster_to_world((float)width, 0.0f));
/* max_aperture_size = Max horizontal distance a ray travels from aperture edge to focus point.
Scale that value based on the ratio between focaldistance and nearclip to figure out the
Multiline comment style is:
@ -625,0 +647,4 @@
float scaled_horz_dof_ray = 0.0f;
if (max_aperture_size > 0.0f) {
scaled_horz_dof_ray = max_aperture_size * (nearclip / focaldistance);
}
Prefer single initialization:
@blender-bot build