Maniphest T34400

[Cycles] Settings to restrict polar range for equirectangular panoramas
Closed, ResolvedPATCH

Assigned To
Thomas Dinges (dingto)
Authored By
Andreas Stöckel (aurelian15)
Feb 24 2013, 1:54 PM
Tags
  • BF Blender
  • Cycles
Subscribers
Andreas Stöckel (aurelian15)
Brecht Van Lommel (brecht)
Dalai Felinto (dfelinto)
Paul Phillips (capsicumpie)
Thomas Dinges (dingto)
Zsolt Stefan (zsoltst)

Description

Motivation:

For my current university project I need to create spherical panorama images for verifying an algorithm. In the real world those panorama images are created by a panoramic camera mounted on a mobile robot. Yet my real world images only contain a certain polar range, e.g. from the horizon at 0° to above the horizon at 30°, while the "equirectangular" panorama image setting in cycles produces images spanning from below the camera at -90° to above the camera at 90°.

Obviously, for producing useful images without wasting lots of render time on regions I don't really use, I needed to restrict the polar range.


Changes to the user:

The patch below adds two new input boxes when choosing the "equirectangular" image mode in cycles: "Elevation" and "Depression". "Elevation" is the angle between the camera horizon and the last row in the output image. "Depression" is the angle between the camera horizon and the upper edge of the output image. I've attached a small image (blender_depression_elevation_explained.svg) that should explain the two settings. The default settings are Elevation at -90° and Depression at 90° so no change to the original implementation should be visible.


Implementation:

Basically those two settings just remap the original output texture "v"-coordinate to a subset of that coordinate. It is equivalent to rendering the image at a higher resolution without the patch and then cropping everything above and below the desired range away. Remapping is done in the kernel functions "panorama_to_direction" and the inverse is done in "direction_to_panorama"; a few calculations are done in the "camera.cpp" code.


I've attached a few example images and an example scene. I hope this patch might be found useful. This is the first time I ever had a look at the blender source code and I am astonished how simple it was to add this feature.

All attached files are hereby public domain.

Related Objects

Mentioned In
rBS4118c1b4e6ae: Cycles: Adding field-of-view options to the equirectangular panorama camera
rC42fdfb4bc5f2: Adding field-of-view options to the equirectangular panorama camera
rB4118c1b4e6ae: Cycles: Adding field-of-view options to the equirectangular panorama camera
D960: Cycles: Adding field-of-view options to the equirectangular panorama camera

Event Timeline

Andreas Stöckel (aurelian15) edited a custom field.Feb 24 2013, 1:54 PM
Andreas Stöckel (aurelian15) attached 1 file(s): F23449: blender_equirectangular_region.patch.
Andreas Stöckel (aurelian15) attached 1 file(s): F23451: patch_test_scene.blend.
Andreas Stöckel (aurelian15) attached 1 file(s): F23453: blender_depression_elevation_explained.svg.
Andreas Stöckel (aurelian15) attached 1 file(s): F23456: test_scene_elevation_-10_depression_20.png.
Andreas Stöckel (aurelian15) attached 1 file(s): F23458: test_scene_elevation_-90_depression_90.png.
Thomas Dinges (dingto) added a comment.Mar 16 2013, 12:56 PM

Assigning to Dalai first, Dalai can you check on this? I guess Brecht should take a look too later. :)

Dalai Felinto (dfelinto) added a comment.May 29 2013, 11:25 PM

Hi Andreas,

I like the patch, and I see myself using this. However, this is a not so common use case and this is doable in python (using Border Render to crop the effective render area). So I'm not sure it makes sense to be added in the core. And addon may work better in this case.

(and sorry about the long delay, I've been pondering about this since I saw the patch., but I wasn't so sure on how to phrase that)

I'm assigning to Brecht for his 2 cents.

Andreas Stöckel (aurelian15) added a comment.May 30 2013, 12:21 AM

Hi Dalai,

thank you for your response.

I wasn't aware of the "Border Render" functionality and it took me fifteen minutes and a glance at the documentation to find it. Despite from that I agree that "Border Render" plus a nifty Python Addon which does the tiresome calculations in the background would be a perfectly good solution.

Yet I see a few problems with this approach, which might be invalid, as I'm not very experienced with the capabilities of the Python API: In order to be as simple to use as possible the scene description containing the output image resolution has to be duplicated, as you want the user to set the actual output image resolution in the scene setup. Thus the addon has to transparently recalculate the output image resolution for the current render job, add the border range, but should not change these settings in the UI.

Additionally the Addon would have to "hook" into the "begin render event" -- I cannot imagine having an additional "Render Restricted Panoramic Image" button.

As I said, I cannot asses if these requirements can be met with a Python Addon.

An even better solution might be to change the code I've written to adapt the "border range" settings in the C++ code depending on the "elevation" and "depression" settings. This removes the need of adding two additional variables to the cycles kernel constants. Unfortunately I wont have time implementing (and more critical: testing and verifying) this until mid-august.

Thank you again and keep up the good work!

Dalai Felinto (dfelinto) added a comment.May 30 2013, 12:43 AM

Hi

"Additionally the Addon would have to "hook" into the "begin render event" -- I cannot imagine having an additional "Render Restricted Panoramic Image" button."
That's totally doable in Python.

You can change the size before rendering, and re-change after rendering it.
Since we are talking about a equirectangular panorama, when you change the depression/elevation what you are doing is exactly that.
The approach in Python has a big advantage that it will make easier to keep the aspect ratio of the final image correct.

Otherwise with your patch one would need to calculate the correct height for the given angle range.

Brecht Van Lommel (brecht) added a comment.May 30 2013, 10:50 AM

I think it makes sense to have these angles configurable as part of the core. I'd suggest to rename these to Vertical min/max and to add Horizontal min/max.

Brecht Van Lommel (brecht) added a comment.Mar 30 2014, 1:50 AM

This came up in T39165: Cycles equirectangular panoramic camera missing Field-of-view settings.

Just to be clear, I'm fine with having this feature, just needs a better name and control for both vertical and horizontal min/max to be committable.

Zsolt Stefan (zsoltst) added a subscriber: Zsolt Stefan (zsoltst).Apr 24 2014, 2:33 PM

@Andreas Stöckel (aurelian15) : Hi, do you plan to finish this feature with the two things @Brecht Van Lommel (brecht) mentioned? Would be great to have the feature in trunk, this is the only camera type with no field-of-view settings. Thanks!

Paul Phillips (capsicumpie) added a subscriber: Paul Phillips (capsicumpie).Jul 22 2014, 5:08 PM
Brecht Van Lommel (brecht) removed Brecht Van Lommel (brecht) as the assignee of this task.Nov 9 2014, 3:07 PM
Brecht Van Lommel (brecht) edited projects, added Cycles; removed Render Pipeline.
Sergey Sharybin (sergey) mentioned this in rB4118c1b4e6ae: Cycles: Adding field-of-view options to the equirectangular panorama camera.Jan 14 2015, 7:23 PM
Sergey Sharybin (sergey) mentioned this in rC42fdfb4bc5f2: Adding field-of-view options to the equirectangular panorama camera.Jan 15 2015, 5:28 PM
Thomas Dinges (dingto) changed the task status from Unknown Status to Resolved.Jan 21 2015, 7:55 AM
Thomas Dinges (dingto) claimed this task.

This has been implemented now, closing.

Sergey Sharybin (sergey) mentioned this in rBS4118c1b4e6ae: Cycles: Adding field-of-view options to the equirectangular panorama camera.Mar 25 2015, 12:16 PM