Api Sandbox CameraComponent
class

CameraComponent

public sealed class CameraComponent : Component

Every scene should have at least one Camera.

Constructors

CameraComponent()

Properties

Name Type Description
AutoExposure AutoExposureSetup Enables and configures auto exposure on the camera. This is usually controlled by the Tonemapping component. But if you're not using that, it can be controlled manually here.
ClearFlags ClearFlags The clear flags for this camera.
BackgroundColor Color The background color of this camera's view if there's no 2D Sky in the scene.
IsMainCamera Boolean Returns true if this is the main game camera.
FovAxis Axis The axis to use for the field of view.
FieldOfView Single The field of view of this camera.
ZNear Single The camera's near clip plane distance. This is the closest distance this camera will be able to render. A good value for this is about 5. Below 5 and particularly below 1 you're going to start to see a lot of artifacts like z-fighting.
ZFar Single The camera's far clip plane distance. This is the furthest distance this camera will be able to render. This value totally depends on the game you're making. Shorter the better, sensible ranges would be between about 1000 and 30000, but if you want it to be further out you can balance that out by making ZNear larger.
Priority Int32 The priority of this camera. Dictates which camera gets rendered on top of another. Higher means it'll be rendered on top.
Orthographic Boolean Whether or not to use orthographic projection instead of perspective.
OrthographicHeight Single The orthographic size for this camera while Orthographic is set to true.
TargetEye StereoTargetEye The HMD eye that this camera is targeting. Use None for the user's monitor (i.e. the companion window).
RenderTags TagSet A list of tags that will be checked to include specific game objects when rendering this camera. If none are set, it will include everything.
RenderExcludeTags TagSet A list of tags that will be checked to exclude specific game objects when rendering this camera.
Viewport Vector4 The size of the camera represented on the screen. Normalized between 0 and 1.
RenderTarget Texture The texture to draw this camera to. Requires CreateRenderTarget
DebugMode SceneCameraDebugMode Render this camera using a different render mode
WireframeMode Boolean Render this camera using a wireframe view.
ScreenRect Rect The size of the viewport, in screen coordinates
CustomProjectionMatrix Matrix? Allows specifying a custom projection matrix for this camera
CustomSize Vector2? Allows specifying a custom aspect ratio for this camera. By default (or when null) the camera size is screen size or render target size.
ProjectionMatrix Matrix Get frustum projection matrix.
Hud HudPainter Allows drawing on the camera. This is drawn before the post processing.
Overlay HudPainter Used to draw to the screen. This is drawn on top of everything, so is good for debug overlays etc.
EnablePostProcessing Boolean Enable or disable post processing for this camera.
PostProcessAnchor GameObject If set then we'll trigger post process volumes from this position, instead of the camera's position.

Methods

Void AddCommandList(CommandList buffer, Stage stage, Int32 order = 0)

Add a command list to the render

Void RemoveCommandList(CommandList buffer, Stage stage)

Remove an entry

Void RemoveCommandList(CommandList buffer)

Remove an entry

Void ClearCommandLists(Stage stage)

Remove all entries in this stage

Void ClearCommandLists()

Remove all entries in this stage

virtual Void Reset()
Void UpdateSceneCamera(SceneCamera camera, Boolean includeTags = True)

Update a SceneCamera with the settings from this component

IDisposable AddHookAfterOpaque(String debugName, Int32 order, Action<SceneCamera> renderEffect)
IDisposable AddHookAfterTransparent(String debugName, Int32 order, Action<SceneCamera> renderEffect)
IDisposable AddHookBeforeOverlay(String debugName, Int32 order, Action<SceneCamera> renderEffect)
IDisposable AddHookAfterUI(String debugName, Int32 order, Action<SceneCamera> renderEffect)
Vector2 PointToScreenNormal(Vector3 worldPosition)
Vector2 PointToScreenPixels(Vector3 worldPosition)
Rect BBoxToScreenPixels(BBox bounds, Boolean isBehind)

Given a BBox in world space, will return the screen space rect that totally contains the box.

Vector2 PointToScreenPixels(Vector3 worldPosition, Boolean isBehind)
Vector2 PointToScreenNormal(Vector3 worldPosition, Boolean isBehind)
Ray ScreenPixelToRay(Vector2 pixelPosition)
Ray ScreenNormalToRay(Vector3 normalPosition)
Vector3 ScreenToWorld(Vector2 screen)

Convert from screen coords to world coords on the near frustum plane.

Frustum GetFrustum()

Returns the view frustum of the current screen rect.

Frustum GetFrustum(Rect screenRect)

Given a pixel rect return a frustum on the current camera.

Frustum GetFrustum(Rect screenRect, Vector3 screenSize)

Given a pixel rect return a frustum on the current camera. Pass in 1 to ScreenSize to use normalized screen coords.

Boolean RenderToTexture(Texture target, ViewSetup config = null)

Render scene to a texture from this camera's point of view

Matrix CalculateObliqueMatrix(Plane clipPlane)

Calculates a projection matrix with an oblique clip-plane defined in world space.

Void RenderToBitmap(Bitmap targetBitmap)

Render this camera to the target bitmap.

Fields

Name Type Description
RenderTexture RenderTextureAsset If specified, this camera will render to this RenderTexture instead of the screen. This can then be used in other stuff like materials.
Assembly: Sandbox.Engine Namespace: Sandbox Full Name: Sandbox.CameraComponent