boberfly / GafferCycles

Cycles for Gaffer
BSD 3-Clause "New" or "Revised" License
85 stars 10 forks source link

Panoramic camera support #45

Open kubo-von opened 4 years ago

kubo-von commented 4 years ago

Cycles in Blender support other camera models like fisheye, mirroball etc, it could be useful to have those in Gaffer as well.

Screenshot from 2020-02-10 22-41-26

Not sure where these settings would live though. cyclesAttributes or cyclesOptions?

Cheers

sschwungsau commented 4 years ago

+5 for fisheye !

On Mon, 10 Feb 2020 at 14:46, Jakub Vondra notifications@github.com wrote:

Cycles in Blender support other camera models like fisheye, mirroball etc, it could be useful to have those in Gaffer as well.

[image: Screenshot from 2020-02-10 22-41-26] https://user-images.githubusercontent.com/46250374/74197204-42877880-4c5f-11ea-86a2-03d5d9ead67a.jpg

Not sure where these settings would live though. cyclesAttributes or cyclesOptions?

Cheers

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/boberfly/GafferCycles/issues/45?email_source=notifications&email_token=ABTWUK5BC2QQZNDPSNASOVLRCHKLDA5CNFSM4KSW6W6KYY3PNVWWK3TUL52HS4DFUVEXG43VMWVGG33NNVSW45C7NFSM4IMMZCXA, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTWUK3IOOFAFRYDBKVPF73RCHKLDANCNFSM4KSW6W6A .

boberfly commented 4 years ago

Sure, sounds good.

boberfly commented 4 years ago

https://github.com/boberfly/GafferCycles/commit/ddc6b79cd0f495b889e6f457c0f0d376c2aac993

I was just using a CameraTweaks node to specify custom options, this is much like how Arnold is treated right now, so no nice UI really (yet) but it did work from what I see.

boberfly commented 4 years ago

Hey @kubo-von and @sschwungsau

This build should have a way to set these via a CameraTweaks node: https://github.com/boberfly/GafferCycles/releases/tag/0.17.0

I was able to do panoramas by adding the string parameter panoramaType and setting it with: equirectangular, mirrorball, fisheyeEquidistant or fisheyeEquisolid

https://github.com/boberfly/GafferCycles/blob/master/src/GafferCycles/IECoreCyclesPreview/CameraAlgo.cpp#L137

To set other parameters, it'll be doing a for-loop over custom parameters and will try to set the socket connection if the names match eg. "fisheye_fov" with a float value. They can be found here: https://github.com/boberfly/cycles/blob/74f4cbdee302eaacbdacf513bc76d7fe057bf220/src/render/camera.cpp#L59 ( eg. SOCKET_FLOAT(fisheye_fov, "Fisheye FOV", M_PI_F); ).

Cheers

sschwungsau commented 4 years ago

coolio ! thanks !

kubo-von commented 4 years ago

Awesome, thanks @boberfly ! I'll look into how to add the parameters automatically with python.

kubo-von commented 4 years ago

Hey @boberfly I've been trying to get it work for a while but either I'm not doing it right or something is off. Without panoramic: Screenshot from 2020-02-20 21-19-57 With panoramic: Screenshot from 2020-02-20 21-19-10 camera tweaks node: Screenshot from 2020-02-20 21-19-23 (these values are only ones where I could actually see the scene in camera, with blender-like values nothing was there.) Since the camera looks like it's rotated maybe some blender vs gaffer coordinates conversion is not happening? Scene: https://drive.google.com/file/d/13XIR7CjZMvDSMKVtFEwFKKJx5MP8qBFw/view?usp=sharing

Cheers

boberfly commented 4 years ago

Hey @kubo-von Can you simply just rotate the camera itself to adjust it? I am doing some funky matrix conversion to get it to work with cameras in general eg. https://github.com/boberfly/GafferCycles/blob/master/src/GafferCycles/IECoreCyclesPreview/Renderer.cpp#L2641

kubo-von commented 4 years ago

Hey @boberfly Playing with it more I've managed to get the same view by rotating the camera Screenshot from 2020-02-21 13-21-40 Screenshot from 2020-02-21 13-21-15 But not by any logical values like -90 etc: Screenshot from 2020-02-21 13-22-07

But at least for the fisheye_fov parameter I figured it expects radians not degrees like in blender UI For fisheye_lens I have no idea what the conversion is yet, as it doesn't seem to be any metric units.

Updated scene: panoramic.gfr

Cheers

boberfly commented 4 years ago

Ahh radians alright, yeah I have had to make conversions of that in many places I can do this with those values also.

kubo-von commented 4 years ago

Cool! As for the orientation of the camera, this is just a long shot, but maybe the Y and Z axis are not switched ? Because for environment_texture is also rotated like this unless you switch Y and Z axes in the mapping section.

boberfly commented 4 years ago

Yeah I am thinking it's this. Not sure what to do about it though without modifying Cycles source code eg. flipping some stuff here: https://github.com/boberfly/cycles/blob/ac1d47427950769a7b022fdb85fb84d003d3f72a/src/render/camera.cpp#L400

kubo-von commented 4 years ago

What about modifying the transform matrix of the camera when it's switched to panoramic before sending it to cycles ? Would that be possible ?

I will try to find some matrix multiplication/modification which would fix the camera angle.