Graphics: Improve frustum culling (do it once per viewer)
This commit is contained in:
@@ -54,12 +54,6 @@ namespace Nz
|
||||
void ProcessRenderQueue(CommandBufferBuilder& builder, const RenderQueue<RenderElement*>& renderQueue);
|
||||
void UnregisterMaterialPass(MaterialPass* material);
|
||||
|
||||
struct ElementAABB
|
||||
{
|
||||
Boxf aabb;
|
||||
std::size_t count;
|
||||
};
|
||||
|
||||
struct MaterialData
|
||||
{
|
||||
std::size_t usedCount = 0;
|
||||
@@ -72,14 +66,17 @@ namespace Nz
|
||||
NazaraSlot(InstancedRenderable, OnMaterialInvalidated, onMaterialInvalidated);
|
||||
};
|
||||
|
||||
struct VisibleRenderable
|
||||
{
|
||||
const InstancedRenderable* instancedRenderable;
|
||||
const WorldInstance* worldInstance;
|
||||
};
|
||||
|
||||
struct ViewerData
|
||||
{
|
||||
std::size_t colorAttachment;
|
||||
std::size_t depthStencilAttachment;
|
||||
std::size_t depthPrepassVisibilityHash = 0;
|
||||
std::size_t forwardVisibilityHash = 0;
|
||||
std::vector<ElementAABB> depthPrepassAABB;
|
||||
std::vector<ElementAABB> forwardAABB;
|
||||
std::size_t visibilityHash = 0;
|
||||
std::vector<std::unique_ptr<RenderElement>> depthPrepassRenderElements;
|
||||
std::vector<std::unique_ptr<RenderElement>> forwardRenderElements;
|
||||
RenderQueueRegistry depthPrepassRegistry;
|
||||
@@ -101,6 +98,7 @@ namespace Nz
|
||||
std::unordered_set<WorldInstance*> m_invalidatedWorldInstances;
|
||||
std::unordered_set<WorldInstancePtr> m_removedWorldInstances;
|
||||
std::vector<std::unique_ptr<ElementRenderer>> m_elementRenderers;
|
||||
std::vector<VisibleRenderable> m_visibleRenderables;
|
||||
BakedFrameGraph m_bakedFrameGraph;
|
||||
bool m_rebuildFrameGraph;
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Nz
|
||||
InstancedRenderable(InstancedRenderable&&) noexcept = default;
|
||||
~InstancedRenderable();
|
||||
|
||||
virtual void BuildElement(std::size_t passIndex, WorldInstance& worldInstance, std::vector<std::unique_ptr<RenderElement>>& elements) const = 0;
|
||||
virtual void BuildElement(std::size_t passIndex, const WorldInstance& worldInstance, std::vector<std::unique_ptr<RenderElement>>& elements) const = 0;
|
||||
|
||||
inline const Boxf& GetAABB() const;
|
||||
virtual const std::shared_ptr<Material>& GetMaterial(std::size_t i) const = 0;
|
||||
|
||||
@@ -28,7 +28,7 @@ namespace Nz
|
||||
Model(Model&&) noexcept = default;
|
||||
~Model() = default;
|
||||
|
||||
void BuildElement(std::size_t passIndex, WorldInstance& worldInstance, std::vector<std::unique_ptr<RenderElement>>& elements) const override;
|
||||
void BuildElement(std::size_t passIndex, const WorldInstance& worldInstance, std::vector<std::unique_ptr<RenderElement>>& elements) const override;
|
||||
|
||||
const std::shared_ptr<AbstractBuffer>& GetIndexBuffer(std::size_t subMeshIndex) const;
|
||||
std::size_t GetIndexCount(std::size_t subMeshIndex) const;
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -31,7 +31,7 @@ namespace Nz
|
||||
}
|
||||
}
|
||||
|
||||
void Model::BuildElement(std::size_t passIndex, WorldInstance& worldInstance, std::vector<std::unique_ptr<RenderElement>>& elements) const
|
||||
void Model::BuildElement(std::size_t passIndex, const WorldInstance& worldInstance, std::vector<std::unique_ptr<RenderElement>>& elements) const
|
||||
{
|
||||
for (std::size_t i = 0; i < m_submeshes.size(); ++i)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user