Advanced Cameras
Summary
The following is a request for comments on a rework of Roblox’s Camera class. This new Camera system would function similarly to the new Audio API, but allow developers to wire Camera instances to any instance capable of displaying Content. This acts as a user-friendly way of introducing render-to-texture (off-screen rendering), and potentially paves the way towards developer-made post-processing effects.
Motivation
I heavily study computer graphics and game engine design, and personally I find Roblox is lacking in a lot of features that game engines of old have been providing for several years now, and one of them is off-screen framebuffers. Seeing the many feature requests for programmable shaders, ViewportFrame improvements, introduction of EditableImage, and the recent Camera changes allowing for 2D game creation, I feel now is a good time to look into bringing the Camera more in-line with other game engines/3D software.
Design
1. Treat the Camera as an Output
Each Camera should come with its own resolution, aspect ratio control, projection/clipping options, and world position. The game will render graphics for a Camera given that it has any connected Output, which can be a Decal, ImageLabel, Sky, any class that allows you to use Content.
2. One Camera, many places
Using a system similar to the Wire class will allow the same rendered image to be used across multiple instances, allowing it to be manipulated and displayed in different ways by each one.
3. Allow Transparency
For use cases such as viewmodels for first-person shooters, Cameras should be capable of rendering images without backgrounds, so that a final image can be assembled as desired by a developer.
4. Studio Visualisation
The current Camera instance has no visualisation within Studio, adding a visualisation would make it easier for developers to manipulate Cameras in the game world, provided is an example.
5. Backwards Compatibility
Roblox’s CoreScripts would be responsible for setting up an ImageLabel below UI elements, with the Image connected to the output of a default Camera instance.
Separate Possibilities
- Programmable graphics effects, perhaps using a new class named something like
CameraEffect - Per-object granular environment mapping, where developers can use render-to-texture (or a regular texture) to create an environment map specific to an object.
- If multiple
Workspaceswere implemented, the full replacement ofViewportFrame.
Prior Implementations
- Unity’s Render Texture
- Offscreen Rendering in Tiny3D, an homebrew N64 3D library, proving it is possible with good performance even on primitive hardware
- Portal
Thoughts?
