6
$\begingroup$

To clarify, I was talking with a friend and we started to wonder if there were camera modes beyond orthographic and perspective. As an example, one that defined its edges not with a cuboid or frustum, but a curved volume?

There are all kinds of cool effects that could be done with that, especially if the curvature was animated. However, I know that perspective and orthographic modes are generally just done with matrices, so it might take some tinkering.

Blender is open to add on construction and open source at that, but I honestly have no idea where to begin. Would it be Python, or can I do it in OSL? Or would I have to actually dive into C for this?

Hopefully this question isn't too broad.

EDIT: I am purely attempting to extend the camera modes, not to simulate it with post processing (which has a number of additional drawbacks in efficiency). This question is about plugin development.

These are the familiar viewing transforms we use on a day to day basis, outlined by volume of rendered geometry (not volume of geometry, volume of rendered space) :

Perspective - smaller with depth:

enter image description here

Panoramic - projected from center in all direction:

Panoramic

Orthographic - same size:

Orthographic

In all cases, depth goes along a straight path in a specific direction, in Blender it's typically the camera's local Z. For panoramic, it is local r in sphere-space. Note that in all cases, depth is measured along straight lines, in a simplistic manner.

My proposal is to allow for the construction of cameras which are not confined to simplistic single-dimension radius, but actually measure depth along a curve:

enter image description here

As an example, with a rendering space which was defined like a curved volume, with a taper curve and a bevel curve, we could still define (in linear time) a path to each rendered pixel in Cycles; but that path would be unconstrained, and could say look at an object behind the red demo object. It would also only gather necessary data, where gathering all data from a panoramic camera and operating on that would still spend roughly six times the amount of time to render, plus post processing; and still wouldn't have all of the data necessary.

$\endgroup$
  • $\begingroup$ OK, I get it now. If the volume is curved though, I assume the rays would be curved as well, so wouldnt that give the same result as if the volume was straight? I suppose using bake functionality and refractive objects, it is possible to construct any such camera. You define the form of the 'sensor' plane by reflective geometry and you can use refractive objects to bend light in any kind of way as well this way defining the view volume. It can be any shape I can think of, but it's not a curve, its a 3d volume - that was what confused me. $\endgroup$ – Martin Z Dec 20 '18 at 21:37
  • $\begingroup$ Since the 'sensor' is a UV mapped 3d object you can even have pieces of the volume in completely different locations and orientations in 3d space. $\endgroup$ – Martin Z Dec 20 '18 at 21:39
  • $\begingroup$ OK, that's interesting. There is also nothing preventing you from making any lens from any object using refractive shaders. That might be a more elegant solution for an addon. $\endgroup$ – Martin Z Dec 20 '18 at 22:01
  • $\begingroup$ I wonder whether it's possible to write a volumetric refraction shader in OSL? .. one in which instead of a ray being scattered, absorbed, or returning an emission value at each sampled point in a volume, it was bent by a function of X,Y and Z? The 3-texture which did the bending could be in the camera space.. $\endgroup$ – Robin Betts Dec 20 '18 at 22:49
  • 1
    $\begingroup$ I think this is actually a really good question. I tired to make it a bit clearer and added a few pictures. I hope you don't mind my edit. Please correct it if I changed anything not to your liking. $\endgroup$ – Martin Z Dec 21 '18 at 15:25
4
$\begingroup$

Deforming the Image as Lenses Would

Camera lenses deform the view. If you want to deform the rendered image, there are quite a lot of ways to do that in Blender. You could use Blender's compositing functionality, or you could also use an emission shader for shade-less material and map an image or a movie to some 3d object like a plane and use all the tools available in material nodes, that would include manipulating texture coordinate vectors with any math or manipulating the UV mapping or you could even deform the geometry that has the image or movie projected on it in 3d space. Obviously you could also do all the mentioned things together one on top another if you wanted.

Image Deformation

Projections

Programming unrealistic projections or manipulating volume of the camera view does not seem to be possible using Python. It might be possible in OSL.

You could however achieve some interesting results without programming:

Baking Functionality

It is possible to bake a color of a completely reflective surface so it is possible to define the shape of the projection with any geometry you wish:

Baking Projection

Its best to disable all Cycles rays except camera so that the 'camera' object does not interact with the lighting in the scene in this case. Rendering an animation with this way would require some Python scripting.

In addition to that objects with Refraction BSDF shader could be used to construct lenses.

Constructing Lenses for Cameras out of Refractive Objects

Another way with an actual camera would be to make a lens from a refractive object:

Refractive Object Lens

This kind of 'lens' could approximate the curvature of the volume visible by the camera as well because it can be constructed out of multiple objects. It might be very intensive on render resources if you wanted it to be more precise and it is limited by the way refraction works in Blender's Refractive BSDF shader, but it is possible:

Curved Space

$\endgroup$
  • $\begingroup$ The principles by which orthographic and perspective cameras work are cuboid and frustrum volumes, expressed as transform matrices. For panoramics it would be a cylinder or sphere. It's basic 3D low level programming, pick up The Red Book and it will go over it in detail. To define a camera by a Bezier is to alter the shape of that enclosing view volume, and would allow for things like turning the view more than 180 degrees, which invalidates your proposed approach. $\endgroup$ – Michael Eric Oberlin Dec 20 '18 at 18:56
  • $\begingroup$ Panoramic cameras are 360 degrees in any direction. You can deform images rendered with them. $\endgroup$ – Martin Z Dec 20 '18 at 19:10
  • $\begingroup$ Go ahead - tell me a scenario in which you cannot deform an image mapped onto geometry with nodes :) $\endgroup$ – Martin Z Dec 20 '18 at 19:14
  • $\begingroup$ You're assuming that your panoramic camera is of infinite resolution, which it isn't and if it was would still be a massive inefficiency. Please don't make this personal. $\endgroup$ – Michael Eric Oberlin Dec 20 '18 at 19:20
  • $\begingroup$ If you are talking about manipulating the volume that is rendered, it still cannot be defined by a curve. The question needs clarification in that case. $\endgroup$ – Martin Z Dec 20 '18 at 19:27
1
$\begingroup$

This might possibly help:

Fulstrum plane formula for a 3D camera- http://www.lighthouse3d.com/tutorials/view-frustum-culling/view-frustums-shape/

Blender's accessible parameters- https://docs.blender.org/api/2.79/bpy.types.Camera.html#bpy.types.Camera

Maybe someone else might know how to implement those formulas in Python however. But if you can pull that off, it might make a really accurate heat gas distortion effect using fluid dynamics within the volume.

$\endgroup$
  • $\begingroup$ That enum bothers me quite a bit; those things are generally set in stone. However, it looks like the major players of the camera, like its position and lens factors, are directly editable by Python script. You think it might be possible to create something that does not directly derive from camera, but has a camera attached, and change its factors per pixel rendered? $\endgroup$ – Michael Eric Oberlin Dec 20 '18 at 21:25
  • $\begingroup$ With math anything is possible even approximation, I guess it just eventually boils down to efficiency. $\endgroup$ – ACopeLan Dec 21 '18 at 1:18
  • $\begingroup$ I haven't looked it up, but perhaps performing matrix transformations along the Z-channel with the clipping planes as the container may be a readily available parameter set. $\endgroup$ – ACopeLan Dec 21 '18 at 2:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.