Repository navigation
Cameras
Previously, when exporting cameras through Tetra3D, they would have a node added to correct the orientation difference between Blender and Tetra3D / OpenGL / GLTF. However, this is no longer done with the latest version of the GLTF exporter in the current version of Blender (3.2.1). Now, cameras are serialized and deserialized as individual nodes with no corrections, as one might expect.
All Cameras in a given blend file share the same global render resolution - this can be altered in the Tetra3D Render Properties panel.

Cameras can be dynamically created with tetra3d.NewCamera(w, h), and takes the width and height of the camera's backing texture. If a camera needs to be resized, you can do so with Camera.Resize(newWidth, newHeight).
In Blender, the field of view is changeable on the Camera's Camera Data panel. The field of view as displayed in Blender is either the vertical or horizontal field of view, depending on the aspect ratio of the game resolution - in Tetra3D, the field of view is always vertical. For simplicity, the Tetra3D Camera Properties panel has the relevant fields, as well as a FOV slider that works for vertical field of view values to ensure consistency between Blender's camera view and Tetra3D.
In Blender, the ortho scale of an orthographic camera indicates how many world units across the camera covers from left to right - this is the same in Tetra3D.
Camera size influences the overall fidelity of the render, as well as its aspect ratio. The aspect ratio can be changed on the fly to match the game window, for example, by resizing the camera in the game's Layout() function. If you take into account a "base size" when resizing, this allows you to keep your game render looking consistent while also scaling it to match your player's monitor / window size. Here's a simple example:
var MinimumScreenSize = 320
type Game struct {
Level *Level
}
...
type Level struct {
Camera *tetra3d.Camera
}
...
func (game *Game) Layout(w, h int) (int, int) {
var newWidth, newHeight int
if w > h {
asr := float32(w) / float32(h)
// height = 320, width is 320 + however much wider the window is
newHeight = MinimumScreenSize
newWidth = int(float32(MinimumScreenSize) * asr)
} else {
asr := float32(h) / float32(w)
// width = 320, height is 320 + however much taller the window is
newWidth = MinimumScreenSize
newHeight = int(float32(MinimumScreenSize) * asr)
}
game.Level.Camera.Resize(newWidth, newHeight)
return newWidth, newHeight
}Of course, this isn't necessary if you're not aiming for a low-res look (as you can just use the new width and height directly to resize the camera).
The depth texture is, by default, rendered when rendering a Model in Tetra3D. The texture allows objects to intersect by checking to see if a previous object has written to the texture with a higher depth value. If so, the rendering object can draw on top. If not, it can't, and so you get a visual intersection.
Previously, the depth texture was a simple grayscale texture, indicating the overall depth from 0.0 to 1.0. Because this was a grayscale texture, there was a maximum of 256 depth values. Now, the depth texture has been upgraded to give more precision by embedding the depth in the R, G, and B channels of the texture. Below is an example.
As can be seen in the gif, depth increases in the R, G, and B channels separately the further away it gets from the camera, with each channel cycling as it reaches its upper limit of 255. To get the actual depth value (from 0 to 1) from this texture using Kage, you would decode the depth of the color from the texture using the following decoding function:
func decodeDepth(rgba vec4) float {
return rgba.r + (rgba.g / 255) + (rgba.b / 65025)
}