Camera
Pause looping videos for performance
This page talks about the parallax projection parameters and their effects. Most are direct matches to the base shader engine Camera model, but some like #steady and #focus are complex linear algebra transformations done internally, already managed for you
Height¶
Controls the scale factor of the projection surface growing towards the camera, acting like a global parallax intensity scalar. When depth maps are normalized:
- A value of (0) zero generates no 3D displacements, the surface is flat at z=1.
- A value of (1) one makes the surface's peak be on the same xy plane as the camera.
- Note how in the video, the center doesn't touch the camera, as its relative depth value isn't 1, but the closer bottom edge "gets below" the camera's view - where the peak is.
Offset¶
Controls the camera position relative to the #center, generating the parallax effect.
Visual changes are proportional to the #height parameter, so larger values are required for flatter surfaces to displace the same. Note that this increases the "incident" angle at the opposite sides, creating stretchy regions - see #isometric for reducing them at the cost of perspective.
Coordinates are normalized vertically and scale horizontally with the aspect ratio:
- A value of y=1 always positions the camera at the upper edge
- For a 16:9 image, 1.77 positions it on the right side.
There's two main operation modes, default being #sticky (seen on video above):
Sticky¶
Just after the flat plane projections are calculated, the camera position is subtracted from the ray intersections, making the background stay fixed in place (camera always looks at the origin).
This is an extremely non-linear transformation; to control what depth stays fixed see #steady.
Tiles¶
Corrections seen in #sticky aren't applied in this mode, so offsets makes the camera freely roam around like in most 2.5D games. Since the texture repeats in the shader, using image tiles that seamleslly connect is recommended for this mode, as seen on the video below:
Steady¶
Controls the depth plane at which #offsets changes cause no displacement in #sticky mode.
- A value of (0.0) zero makes the far background always static.
- A value of (0.5) half "pivots around the middle", inverting offsets past it.
-> Think about it as an Offsets Focal Depth.
Isometric¶
Controls how much perspective is applied, acting like a planification effect.
- A value of (0) zero gives maximum perspective (3D-ness), making all rays originate from the camera's position point, at the cost of more "sideways" indicent angles at the edges.
- A value of (1) one makes all rays parallel, giving a completely flat projection without depth sensation, as if only offsets were applied to thousands of layers in the image (video below).
Intermediate values are recommended to mitigate strechy regions, reducing how much sideways distortion and/or enchroaching happens. For a better understanding, let's think about the internal angles at which the upper edge operates:
The camera plane is always at z=0, surface plane at z=1, upper screen edge at y=1. Isometric controls the relative size between both planes, therefore:
- For isometric=1 all rays are parallel, so the incoming angle is 0° at the surface.
- For isometric=0, a right-triangle of distance 1 and height 1 forms between the ray origin, surface center, and upper screen, so the angle is 45° via isosceles triangle.
- Intermediate values follow atan(1 - isometric), in fact all cases does.
-> Check this Desmos graph with the formulas.
Dolly¶
For the traditional 'dolly zoom' effect, combine it with the #focus parameter.
Sibling of #isometric virtually doing the same thing, however with different units and may break other parameters projections since it's not a "natural parameter".
Internally, it moves the ray origin plane backwards, so a value of is the same as isometric=1.
As far as I know, the conversion factor between the two is given by:
def isometric(dolly: float) -> float:
return 1 - 1/(1 + dolly)
def dolly(isometric: float) -> float:
return 1/(1 - isometric) - 1
-> Check this Desmos graph with the formulas.
Focus¶
Controls the depth plane at which #isometric changes cause no displacement.
- Notice how in the video, the green line doesn't move when the
isometricchanges, and the mirroring of perspective directions when crossing this boundary. - This parameter makes this depth value the surface plane internally.
-> Think about it as an Isometric Focal Depth.
Quality¶
Controls the number of ray marching steps. Lower values increases the algorithm discreteness, causing layers to not blend together in an unwanted "cutout" effect, but increases performance.
Note that a high quality value makes no difference for small offsets, be conservative for speed.
Zoom¶
Controls the camera field of view, acting like a digital zoom or cropping.
A value of 1 means the image is fully visible, while a value of 0.5 means a quarter of the image is visible.
Center¶
Follows #offset coordinates model, simply offsets the image texture.
Origin¶
Virtual parameter that controls at which point #height changes causes no displacement, and where #offset projections are relative to (as if the camera was above this point). Since the default is zero, the center point of the screen receives this treatment as one expects.