S&box Wiki

Scenes

This is the system used for rendering. Documentation on the scene system for games can be found here or here.

Introduction

The scene system is what manages rendering everything you see.

It can be used to do additional stuff like creating miniature 3D worlds in UI elements, Or adding a SceneCamera to render a CCTV camera to a monitor and so on, you can do a lot with them!

What does the Scene System consist of?

SceneWorld

Contains all the SceneObjects for a specific world we want in one place

A SceneWorld is just a collection of all the SceneObjects that you want to be contained in one separate world for rendering, then extra options for trace related stuff on all SceneObjects.

Every time you want to create anything scene related you need to put it in a SceneWorld. GameObjects in a scene will do that for you, but if you are doing your own SceneWorld you will have to keep it in mind.

SceneCamera

The camera that actually renders what you see

A SceneCamera holds all the data about how we should render stuff to a texture, or view, or screen. The camera is provided a world to render, in which it will now render all the SceneObjects within that world!

There are also a lot of properties you can mess with to change how the SceneCamera will render everything to the screen. Properties like FOV, Orthographic, ZNear, ZFar and so on.

Another thing to remember is you can use RenderTags to dictate what objects to and not to render, and also RenderHooks to hook in and do extra stuff within each render stage when the camera is rendered!

SceneObject

Objects that are rendered models, anything in the SceneWorld that is rendered HAS to inherit from this

So where GameObjects are what allow things to exist physically in our main game world, SceneObjects are what allow models to be rendered by the camera in the SceneWorld underneath it all.

WHATEVER that is in a SceneWorld has to inherit from the SceneObject class to be able to be added to a SceneWorld.

for example all these are children of SceneObjects!

  • SceneLight
  • SceneModel
  • SceneSkybox
  • SceneCubemap

Now with SceneObjects we now have access to messing with materials, dynamic expressions, attributes, body groups, the mesh, interacting with the shaders on the model and so on and so fourth.