| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237 |
- Create a new scene organisation that follows some rules:
- - Be extendable from outside AnKi
- - Has a simple interface and correct containers
- - Be able to fast cast and fast check type (llvm isa<>)
- Every scene node has a few properties that are actually interfaces. This interfaces are:
- +========================+==================+===================================+=====================+
- | Class name | Base class | Interface | Used |
- +========================+==================+===================================+=====================+
- | BaseRenderable | - | - getVao(level, type) | - |
- | | | - getVertIdsNum(level, type) | |
- | | | - getModelMatrix(level, type) | |
- +------------------------+------------------+-----------------------------------+---------------------+
- | Renderable | BaseRenderable | - getMaterial | PatchNode |
- | | VisibleCheckable | - getMaterialRuntime (Mutable) | |
- | | | - getMaterialRuntime (Const) | |
- | | | - renderInMs (its not virtual) | |
- +------------------------+------------------+-----------------------------------+---------------------+
- | DebugRenderable | BaseRenderable | - | Camera, Light |
- +------------------------+------------------+-----------------------------------+---------------------+
- | IsRenderable | BaseRenderable | getShaderProgram | Light |
- +------------------------+------------------+-----------------------------------+---------------------+
- | VisiblesContainable | - | - getVisiblesInfo | Camera, Light |
- | | | - testFrustum(VisibleCheckable) | |
- +------------------------+------------------+-----------------------------------+---------------------+
- | VisibleCheckable | - | getCollisionShape | Camera, Light, |
- | | | | ModelNode, SkinNode,|
- | | | | PatchNode |
- +------------------------+------------------+-----------------------------------+---------------------+
- | RenderablesContainable | - | - getRenderables | ModelNode, SkinNode |
- | | | - nodesInheritCollisionShape | |
- +------------------------+------------------+-----------------------------------+---------------------+
- | Projectable | - | - getViewMatrix | Light, Camera |
- | | | - getProjectionMatrix | |
- +------------------------+------------------+-----------------------------------+---------------------+
- - VisibleCheckable
- - getCollisionShape [virtual]
- - getVisible
- - setVisible
- - getVisibilityGroup
-
- - Renderable
- - material [virtual]
- - getVao(level, passType) [virtual]
-
- - Light (aka IsRenderable)
- - getMaterialRuntime [virtual]
- - getVao() [virtual]
-
- - VisiblesContainable
- - N * M sceneNodes where N is 4 (renderables and lights) and M is the number of the scene nodes
- - testFrustum(VisibleCheckable)
-
- - RenderablesContainable
- - N * SceneNode
- - nodesInheritCollisionShape
- PatchNode: Renderable, VisibleCheckable
- Light: IsRenderable, VisibleCheckable, VisiblesContainable
- Camera: VisibleCheckable, VisiblesContainable
- ModelNode: VisibleCheckable, RenderablesContainable
- Rendering passes:
- - Level n
- - Color
- - Depth
- - DepthParaboloid
- - Debug
- Other classes:
-
- **BaseRenderableInfo**: Contains a class with public interface of:
- -
- **VisiblesInfo**: Contains the lists of:
- - Renderables
- - renderables in MS
- - renderables in BS
- - IsRenderables
- - point lights
- - spot lights
-
- ==================
- Visibility testing
- ==================
- In visibility testing we gather the visible renderables of MS and BS and the lights for IS. Also for every visible light we gather the renderables.
- Real flow:
- function test(cam)
- for
- endfunction
- ::
- function test(Camera cam)
- for node in scene's nodes
- set node not visible
- endfor
-
- for rcn in all scene's renderablesContainableNodes
- if rcn not inside cam's frustum
- break
- endif
-
- set rcn to visible
-
- # eg skin
- if rcn renderablesInheritContainingCollisionShape
- for renderable in rcn's renderables
- set renderable visible
- put renderable in cam's container
- endfor
- # eg model node
- else
- for renderable in rcn's renderables
- if renderable inside cam frustum
- put renderable in cam's container
- endif
- endfor
- endif
- endif
- endfor
-
- for l in all scene's lights
- if l inside cam's frustum
- put l in cam's container
-
- if l is shadow caster
- test(l)
- endif
-
- endfor
- endfor
-
- endfunction
-
-
- - Find all the octree nodes that are inside the given frustum
- - Norrow down them using the Renderer and other tests
- - For all those octree nodes get the scene nodes
- - Resolve buckets
- - Finaly call SceneNode::visibleUpdate() for all visibles
- Method declaration: void performVisibilityTests(const Octree&, const Frustum&, const Renderer&, uint passMask);
- The Renderer is for hardware occlusion queries
- =========
- Rendering
- =========
- ::
- function render(VisiblesContainable obj, PassType pt)
- for renderable obj's renderables
- level = calc from distance of obj and renderable
-
- setupShaderProgram for obj in pt and level
- render using vao of level
- endfor
- endfunction
- ========
- Problems
- ========
- - All properties should contain the world transform
- - What happens in a second pass for other camera (for split screen for example). Now the renderings happen sequential so no problem. It may fuck up the visibility vectors
- ====
- ToDo
- ====
- - Move update redesign
- - First update the world transforms for all nodes
- - then for the nodes that have moved (we allready keep the previ world transform) call the SceneNode::moveUpdate
-
-
- ===
- xxx
- ===
- Scene
- - N x SceneNode
- - 1 x Octree
-
- - Update transforms
- - Call move updates if moved
- SceneObject
- StaticObject: SceneObject
- SceneNode: SceneObject
- - static | moving
- - TRF
- - parent & children
-
- Renderable
- - stage? MS | BS | LS | DBG
- - material
- - world transform [for moving]
- - collision shape [for moving]
-
- Frustum
- - N x renderables
|