Camera: Move panoramic projection settings to DNA #111310
No reviewers
Labels
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
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, Assets & 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
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
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
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
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
4 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: blender/blender#111310
Loading…
Reference in New Issue
No description provided.
Delete Branch "fclem/blender:blender-camear-panoramic-parameters"
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?
This is in prevision of EEVEE panoramic projection support.
EEVEE-Next is planned to add support for these parameters.
Not having these parameters in Blender DNA will make Cycles
and EEVEE not share the same parameters and will be confusing
for the user.
We handle forward compatibility by still writing the parameters
as ID properties as previous cycles versions expect.
Since this change will break the API compatibility it is crucial
to make it for the 4.0 release.
Related Task #109639
@blender-bot build
The patch seems to miss a subverison bump. Without it I don't think this will properly when file is modified and re-loaded after landing the change.
The
cycles_camera_cpu
test seems to be failing as well, and it does not seem to be caused by some compositor tests which are currently failing (I'm looking into those).As for forward compatibility. Blender 3.6 is supposed to be forward compatible with Blender 4.0. Nut I am not sure it will be practical to try to support such change in there.
Curious what @mont29 opinion here.
@ -210,2 +196,2 @@
bcam->fisheye_polynomial_k3 = RNA_float_get(&ccamera, "fisheye_polynomial_k3");
bcam->fisheye_polynomial_k4 = RNA_float_get(&ccamera, "fisheye_polynomial_k4");
switch (b_camera.panorama_type()) {
default:
Don't use
default
, and let compiler to point out at missing cases, to help in the future to who are adding new panorama types.What if you are loading a newer file with a non existing panorama type?
Good point.
Then you move the switch to a function like
blender_panorama_type_to_cycles
, replace assignment withreturn
, and explicitly outside of theswitch
statement returnPANORAMA_EQUIRECTANGULAR
with a comment that it is for the forward compatibility.best of many worlds:
@ -700,0 +707,4 @@
camera->fisheye_fov = version_cycles_property_float(ccam, "fisheye_fov", M_PI);
camera->fisheye_lens = version_cycles_property_float(ccam, "fisheye_lens", 10.5f);
camera->latitude_min = version_cycles_property_float(
ccam, "latitude_min", -0.5f * (float)M_PI);
Use functional cast:
float(M_PI)
More about it https://wiki.blender.org/wiki/Style_Guide/C_Cpp#C.2B.2B_Type_Cast
@ -700,0 +710,4 @@
ccam, "latitude_min", -0.5f * (float)M_PI);
camera->latitude_max = version_cycles_property_float(
ccam, "latitude_max", 0.5f * (float)M_PI);
camera->longitude_min = version_cycles_property_float(ccam, "longitude_min", -M_PI);
Why is it in some cases there is explicit cast to float, but not in others?
Because explicit cast is usually to avoid
double
promotion. Or maybe I'm missing something.Ah, it is expression vs. single value as an argument. Makes sense now.
Don't think there is a need for subversion bump here, using something like
DNA_struct_elem_find
would work since new members are added to a DNA struct. However, given how big and disruptive this change is, think a file subversion bump would be good indeed.Regarding forward compatibility, think that these properties should also be written as 'old' Cycles IDProperties on filewrite. Not having properties from EEVEE next load in 3.6 EEVEE is one thing and acceptable, fully breaking some existing Cycles camera settings when loading a 4.0+ file into 3.6 is something else and absolutely not acceptable imho.
@ -212,0 +199,4 @@
bcam->panorama_type = PANORAMA_EQUIRECTANGULAR;
break;
case BL::Camera::panorama_type_EQUIANGULAR_CUBEMAP_FACE:
bcam->panorama_type = PANORAMA_FISHEYE_EQUIDISTANT;
These types don't match
@ -699,1 +700,4 @@
/* Panorama properties shared with Eevee. */
LISTBASE_FOREACH (Camera *, camera, &bmain->cameras) {
IDProperty *ccam = version_cycles_properties_from_ID(&camera->id);
I think it's not enough to do versioning for
ccam
. If there is a camera in the scene, but the render engine is not Cycles (as in the default file), then after changing to Cycles all the camera parameters in panoramic type are zero instead of the default values.@ -44,0 +50,4 @@
.longitude_min = -M_PI,\
.longitude_max = M_PI,\
/* Fit to match default projective camera with focal_length 50 and sensor_width 36. */ \
.fisheye_polynomial_k0 = -1.1735143712967577e-05,\
There should be a
f
suffix.The default values inTurns out that the wholeaddon/camera.py
can be deleted I think.addon/camera.py
is just for reference and not used. Probably fine to keep the default values there, but maybe refer to the functionfisheye_lens_polynomial_from_projective()
here to make it more clear where these values come from.The change to
camera_blend_write
should be isolated in their own set of functions, e.g.camera_write_cycles_compatibility_data_create()
/camera_write_cycles_compatibility_data_clear()
@ -110,0 +135,4 @@
/* For forward compatibility, still write panoramic properties as ID properties for
* previous cycles versions. */
IDProperty *idprop = IDP_GetProperties(id, false);
The write code should not modify the input ID. In fact, the ID should be const-qualified.
One way to achieve this I can think of is to make a shallow copy of the Camera, duplicate the ID properties, set the required properties, write using
BLO_write_struct_at_address
, and free the copied version of ID properties.Additionally, such versioning should not happen for undo pushes.
@Sergey all IDs are already shallow-duplicated by generic write code, precisely because we do 'modify' these a lot when writing (esp. by setting many runtime data to NULL e.g.).
Then no shallow-copy needed, but you still should not add ID properties to the original data-block.
@ -106,0 +148,4 @@
};
/* For forward compatibility, still write panoramic properties as ID properties for
* previous cycles versions. */
previous blender versions
@ -106,0 +181,4 @@
if (data.idprop_temp) {
IDP_FreeProperty(data.idprop_temp);
}
More of a 'good practice' than strictly required, but would clear both IDPropoerty pointers in
data
. That way, any potential future access to these would give an obvious 'accessing NULL pointer' error.@ -109,1 +190,4 @@
CameraCyclesCompatibilityData cycles_data;
if (!BLO_write_is_undo(writer)) {
Could be stored as a
const bool is_undo
variable, instead of calling the function several times.@ -700,0 +713,4 @@
camera->fisheye_polynomial_k4 = version_cycles_property_float(
ccam, "fisheye_polynomial_k4", -2.6064646454854524e-08f);
}
else {
Rather than duplicating the info here (and risking future out-of-sync issues), would rather create a temp dummy
Camera
data, initialize it (callingcamera_init_data
on it), and then copy the variables' values from it into the real ID. That way you get defaults as defined in DNA.@blender-bot build
@ -8,6 +8,7 @@
#include <cstddef>
#include <cstdlib>
#include <iostream>
Unused include?
@fclem You can try merging main to your patch, the failing matte test should pass. In theory :)
From Core PoV LGTM now. Will let the Cycles team give the final green light ;)
@blender-bot build
From the design perspective it seems good to me, as well as trying to carefully read the code.
One of the builds is already green, so probably the rest are good as well, but worth waiting a bit before landing.
After adding version bump (
0e5639d003
), when I save a file using this patch, then open it in an older version and try to overwrite the file, I get eitherterminated by signal SIGSEGV (Address boundary error)
or
Seems like a problem in main introduced by forward compatibility handling, not by this patch, so I'm accepting.