renderer layermask refactor
This commit is contained in:
@@ -501,20 +501,22 @@ void RenderPath3D::Update(float dt)
|
||||
scene->Update(dt * wiRenderer::GetGameSpeed());
|
||||
|
||||
// Frustum culling for main camera:
|
||||
visibility_main.layerMask = getLayerMask();
|
||||
visibility_main.scene = scene;
|
||||
visibility_main.camera = camera;
|
||||
visibility_main.flags = wiRenderer::Visibility::ALLOW_EVERYTHING;
|
||||
wiRenderer::UpdateVisibility(visibility_main, getLayerMask());
|
||||
wiRenderer::UpdateVisibility(visibility_main);
|
||||
|
||||
if (visibility_main.planar_reflection_visible)
|
||||
{
|
||||
// Frustum culling for planar reflections:
|
||||
camera_reflection = *camera;
|
||||
camera_reflection.Reflect(visibility_main.reflectionPlane);
|
||||
visibility_reflection.layerMask = getLayerMask();
|
||||
visibility_reflection.scene = scene;
|
||||
visibility_reflection.camera = &camera_reflection;
|
||||
visibility_reflection.flags = wiRenderer::Visibility::ALLOW_OBJECTS;
|
||||
wiRenderer::UpdateVisibility(visibility_reflection, getLayerMask());
|
||||
wiRenderer::UpdateVisibility(visibility_reflection);
|
||||
}
|
||||
|
||||
wiRenderer::OcclusionCulling_Read(*scene, visibility_main);
|
||||
@@ -536,7 +538,7 @@ void RenderPath3D::Render() const
|
||||
{
|
||||
cmd = device->BeginCommandList();
|
||||
wiJobSystem::Execute(ctx, [this, cmd](wiJobArgs args) {
|
||||
wiRenderer::DrawShadowmaps(visibility_main, cmd, getLayerMask());
|
||||
wiRenderer::DrawShadowmaps(visibility_main, cmd);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
+11
-12
@@ -3111,7 +3111,7 @@ void ProcessDeferredMipGenRequests(CommandList cmd)
|
||||
deferredMIPGenLock.unlock();
|
||||
}
|
||||
|
||||
void UpdateVisibility(Visibility& vis, uint32_t layerMask)
|
||||
void UpdateVisibility(Visibility& vis)
|
||||
{
|
||||
// Perform parallel frustum culling and obtain closest reflector:
|
||||
wiJobSystem::context ctx;
|
||||
@@ -3144,7 +3144,7 @@ void UpdateVisibility(Visibility& vis, uint32_t layerMask)
|
||||
|
||||
Entity entity = vis.scene->aabb_lights.GetEntity(args.jobIndex);
|
||||
const LayerComponent* layer = vis.scene->layers.GetComponent(entity);
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & layerMask))
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & vis.layerMask))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -3196,7 +3196,7 @@ void UpdateVisibility(Visibility& vis, uint32_t layerMask)
|
||||
|
||||
Entity entity = vis.scene->aabb_objects.GetEntity(args.jobIndex);
|
||||
const LayerComponent* layer = vis.scene->layers.GetComponent(entity);
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & layerMask))
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & vis.layerMask))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -3260,7 +3260,7 @@ void UpdateVisibility(Visibility& vis, uint32_t layerMask)
|
||||
|
||||
Entity entity = vis.scene->aabb_decals.GetEntity(args.jobIndex);
|
||||
const LayerComponent* layer = vis.scene->layers.GetComponent(entity);
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & layerMask))
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & vis.layerMask))
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -3302,7 +3302,7 @@ void UpdateVisibility(Visibility& vis, uint32_t layerMask)
|
||||
{
|
||||
Entity entity = vis.scene->aabb_probes.GetEntity(i);
|
||||
const LayerComponent* layer = vis.scene->layers.GetComponent(entity);
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & layerMask))
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & vis.layerMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -3325,7 +3325,7 @@ void UpdateVisibility(Visibility& vis, uint32_t layerMask)
|
||||
{
|
||||
Entity entity = vis.scene->emitters.GetEntity(i);
|
||||
const LayerComponent* layer = vis.scene->layers.GetComponent(entity);
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & layerMask))
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & vis.layerMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -3342,7 +3342,7 @@ void UpdateVisibility(Visibility& vis, uint32_t layerMask)
|
||||
{
|
||||
Entity entity = vis.scene->hairs.GetEntity(i);
|
||||
const LayerComponent* layer = vis.scene->layers.GetComponent(entity);
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & layerMask))
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & vis.layerMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -4746,8 +4746,7 @@ void SetShadowPropsCube(int resolution, int count)
|
||||
}
|
||||
void DrawShadowmaps(
|
||||
const Visibility& vis,
|
||||
CommandList cmd,
|
||||
uint32_t layerMask
|
||||
CommandList cmd
|
||||
)
|
||||
{
|
||||
if (IsWireRender())
|
||||
@@ -4817,7 +4816,7 @@ void DrawShadowmaps(
|
||||
{
|
||||
Entity cullable_entity = vis.scene->aabb_objects.GetEntity(i);
|
||||
const LayerComponent* layer = vis.scene->layers.GetComponent(cullable_entity);
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & layerMask))
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & vis.layerMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -4893,7 +4892,7 @@ void DrawShadowmaps(
|
||||
{
|
||||
Entity cullable_entity = vis.scene->aabb_objects.GetEntity(i);
|
||||
const LayerComponent* layer = vis.scene->layers.GetComponent(cullable_entity);
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & layerMask))
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & vis.layerMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -4968,7 +4967,7 @@ void DrawShadowmaps(
|
||||
{
|
||||
Entity cullable_entity = vis.scene->aabb_objects.GetEntity(i);
|
||||
const LayerComponent* layer = vis.scene->layers.GetComponent(cullable_entity);
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & layerMask))
|
||||
if (layer != nullptr && !(layer->GetLayerMask() & vis.layerMask))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ namespace wiRenderer
|
||||
struct Visibility
|
||||
{
|
||||
// User fills these:
|
||||
uint32_t layerMask = ~0u;
|
||||
const wiScene::Scene* scene = nullptr;
|
||||
const wiScene::CameraComponent* camera = nullptr;
|
||||
enum FLAGS
|
||||
@@ -131,8 +132,8 @@ namespace wiRenderer
|
||||
}
|
||||
};
|
||||
|
||||
// Performs frustum culling. Specify layerMask to only include specific layers in rendering
|
||||
void UpdateVisibility(Visibility& vis, uint32_t layerMask = ~0);
|
||||
// Performs frustum culling.
|
||||
void UpdateVisibility(Visibility& vis);
|
||||
// Prepares the scene for rendering
|
||||
void UpdatePerFrameData(wiScene::Scene& scene, const Visibility& vis, float dt);
|
||||
// Updates the GPU state according to the previously called UpdatePerFrameData()
|
||||
@@ -186,8 +187,7 @@ namespace wiRenderer
|
||||
// Draw shadow maps for each visible light that has associated shadow maps
|
||||
void DrawShadowmaps(
|
||||
const Visibility& vis,
|
||||
wiGraphics::CommandList cmd,
|
||||
uint32_t layerMask = ~0
|
||||
wiGraphics::CommandList cmd
|
||||
);
|
||||
// Draw debug world. You must also enable what parts to draw, eg. SetToDrawGridHelper, etc, see implementation for details what can be enabled.
|
||||
void DrawDebugWorld(
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wiVersion
|
||||
// minor features, major updates, breaking API changes
|
||||
const int minor = 50;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 14;
|
||||
const int revision = 15;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user