Class RenderTextureCameraExtensions
- Namespace
- Stride.CommunityToolkit.Rendering.Compositing
- Assembly
- Stride.CommunityToolkit.dll
Adds cameras that draw into textures: a rear-view mirror, a security monitor, a minimap, a picture-in-picture, or a camera with a look of its own.
public static class RenderTextureCameraExtensions
- Inheritance
-
RenderTextureCameraExtensions
Methods
AddRenderTextureCamera(Game, Entity, int, int, PixelFormat, Action<PostProcessingEffects>?)
Makes an entity's camera draw into a texture of the given size, every frame, alongside the main view. The entity gets a CameraComponent if it has none.
public static RenderTextureCamera AddRenderTextureCamera(this Game game, Entity cameraEntity, int width, int height, PixelFormat format = PixelFormat.R16G16B16A16_Float, Action<PostProcessingEffects>? postEffects = null)
Parameters
gameGameThe game whose compositor draws the feed.
cameraEntityEntityThe entity that is the camera: already in the scene, or added to it afterwards.
widthintThe texture's width in pixels.
heightintThe texture's height in pixels.
formatPixelFormatThe texture's format. The default is HDR, and it should stay HDR unless the feed tone-maps itself: the scene is lit in HDR and a feed has no tone map of its own, so an 8-bit texture saturates to white, while an HDR one is tone-mapped by the main view along with everything else drawn from it.
postEffectsAction<PostProcessingEffects>A look for the feed. Receives a PostProcessingEffects with every effect switched off; enable what the feed should have, or add colour transforms. Left out, the feed draws the scene as it is.
Returns
- RenderTextureCamera
The feed: its texture, its camera, and what was added to the compositor.
Remarks
The feed is a SceneCameraRenderer for a camera slot of its own, wrapping a RenderTextureSceneRenderer for the texture, wrapping a second ForwardRenderer over the compositor's existing opaque and transparent stages - the structure of the engine's own multiple-output test. Sharing the stages is what makes the feed draw the same meshes, particles and shapes as the main view. It has to be a second forward renderer: the compositor's own is reference-counted and cannot hang in two places.
The feed is appended after the main view, so the texture shows the previous frame. Anything that submits per frame and is drawn once per view, like a shape batch, appears in the feed as it appears in the main view.
Exceptions
- InvalidOperationException
The game has no graphics compositor, or its opaque and transparent stages are missing.