forked from blender/blender
WIP Make shadows visible for Storm delegate #80
@ -44,6 +44,7 @@ class HydraSceneDelegate : public pxr::HdSceneDelegate {
|
||||
std::string studiolight_name;
|
||||
float studiolight_rotation;
|
||||
float studiolight_intensity;
|
||||
bool use_storm_shadows = false;
|
||||
Vasyl-Pidhirskyi marked this conversation as resolved
Outdated
|
||||
|
||||
bool operator==(const ShadingSettings &other);
|
||||
};
|
||||
|
@ -52,6 +52,7 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
||||
render_task_delegate_->set_viewport(pxr::GfVec4d(0, 0, resolution_[0], resolution_[1]));
|
||||
if (light_tasks_delegate_) {
|
||||
light_tasks_delegate_->set_viewport(pxr::GfVec4d(0, 0, resolution_[0], resolution_[1]));
|
||||
light_tasks_delegate_->set_shadows(hydra_scene_delegate_->shading_settings.use_storm_shadows);
|
||||
}
|
||||
|
||||
render_task_delegate_->add_aov(pxr::HdAovTokens->color);
|
||||
@ -63,6 +64,7 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
||||
tasks.push_back(light_tasks_delegate_->skydome_task());
|
||||
}
|
||||
tasks.push_back(light_tasks_delegate_->simple_task());
|
||||
tasks.push_back(light_tasks_delegate_->shadow_task());
|
||||
}
|
||||
tasks.push_back(render_task_delegate_->task());
|
||||
|
||||
|
@ -13,6 +13,8 @@ LightTasksDelegate::LightTasksDelegate(pxr::HdRenderIndex *parent_index,
|
||||
GetRenderIndex().InsertTask<pxr::HdxSimpleLightTask>(this, simple_task_id_);
|
||||
skydome_task_id_ = GetDelegateID().AppendElementString("skydomeTask");
|
||||
GetRenderIndex().InsertTask<pxr::HdxSkydomeTask>(this, skydome_task_id_);
|
||||
shadow_task_id_ = GetDelegateID().AppendElementString("shadowTask");
|
||||
GetRenderIndex().InsertTask<pxr::HdxShadowTask>(this, shadow_task_id_);
|
||||
}
|
||||
|
||||
pxr::VtValue LightTasksDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
|
||||
@ -24,6 +26,9 @@ pxr::VtValue LightTasksDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const
|
||||
else if (id == skydome_task_id_) {
|
||||
return pxr::VtValue(skydome_task_params_);
|
||||
}
|
||||
else if (id == shadow_task_id_) {
|
||||
return pxr::VtValue(shadow_task_params_);
|
||||
}
|
||||
}
|
||||
return pxr::VtValue();
|
||||
}
|
||||
@ -33,6 +38,11 @@ pxr::HdTaskSharedPtr LightTasksDelegate::simple_task()
|
||||
return GetRenderIndex().GetTask(simple_task_id_);
|
||||
}
|
||||
|
||||
pxr::HdTaskSharedPtr LightTasksDelegate::shadow_task()
|
||||
{
|
||||
return GetRenderIndex().GetTask(shadow_task_id_);
|
||||
}
|
||||
|
||||
pxr::HdTaskSharedPtr LightTasksDelegate::skydome_task()
|
||||
{
|
||||
/* Note that this task is intended to be the first "Render Task",
|
||||
@ -52,6 +62,23 @@ void LightTasksDelegate::set_camera(pxr::SdfPath const &camera_id)
|
||||
skydome_task_params_.camera = camera_id;
|
||||
GetRenderIndex().GetChangeTracker().MarkTaskDirty(skydome_task_id_,
|
||||
pxr::HdChangeTracker::DirtyParams);
|
||||
|
||||
GetRenderIndex().GetChangeTracker().MarkTaskDirty(shadow_task_id_,
|
||||
pxr::HdChangeTracker::DirtyParams);
|
||||
}
|
||||
|
||||
void LightTasksDelegate::set_shadows(bool const &enable_shadows)
|
||||
{
|
||||
if (simple_task_params_.enableShadows == enable_shadows) {
|
||||
return;
|
||||
}
|
||||
shadow_task_params_.depthBiasEnable = true;
|
||||
simple_task_params_.enableShadows = enable_shadows;
|
||||
GetRenderIndex().GetChangeTracker().MarkTaskDirty(simple_task_id_,
|
||||
pxr::HdChangeTracker::DirtyParams);
|
||||
|
||||
GetRenderIndex().GetChangeTracker().MarkTaskDirty(shadow_task_id_,
|
||||
pxr::HdChangeTracker::DirtyParams);
|
||||
}
|
||||
|
||||
void LightTasksDelegate::set_viewport(pxr::GfVec4d const &viewport)
|
||||
|
@ -4,6 +4,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <pxr/imaging/hd/sceneDelegate.h>
|
||||
#include <pxr/imaging/hdx/shadowTask.h>
|
||||
#include <pxr/imaging/hdx/simpleLightTask.h>
|
||||
#include <pxr/imaging/hdx/skydomeTask.h>
|
||||
|
||||
@ -19,14 +20,18 @@ class LightTasksDelegate : public pxr::HdSceneDelegate {
|
||||
|
||||
pxr::HdTaskSharedPtr simple_task();
|
||||
pxr::HdTaskSharedPtr skydome_task();
|
||||
pxr::HdTaskSharedPtr shadow_task();
|
||||
void set_camera(pxr::SdfPath const &camera_id);
|
||||
void set_viewport(pxr::GfVec4d const &viewport);
|
||||
void set_shadows(bool const &enable_shadows);
|
||||
|
||||
private:
|
||||
pxr::SdfPath simple_task_id_;
|
||||
pxr::SdfPath skydome_task_id_;
|
||||
pxr::SdfPath shadow_task_id_;
|
||||
pxr::HdxSimpleLightTaskParams simple_task_params_;
|
||||
pxr::HdxRenderTaskParams skydome_task_params_;
|
||||
pxr::HdxShadowTaskParams shadow_task_params_;
|
||||
};
|
||||
|
||||
} // namespace blender::render::hydra
|
||||
|
@ -235,6 +235,7 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
||||
render_task_delegate_->set_viewport(viewport);
|
||||
if (light_tasks_delegate_) {
|
||||
light_tasks_delegate_->set_viewport(viewport);
|
||||
light_tasks_delegate_->set_shadows(hydra_scene_delegate_->shading_settings.use_storm_shadows);
|
||||
}
|
||||
|
||||
render_task_delegate_->add_aov(pxr::HdAovTokens->color);
|
||||
@ -246,6 +247,7 @@ void ViewportEngine::render(Depsgraph *depsgraph, bContext *context)
|
||||
tasks.push_back(light_tasks_delegate_->skydome_task());
|
||||
}
|
||||
tasks.push_back(light_tasks_delegate_->simple_task());
|
||||
tasks.push_back(light_tasks_delegate_->shadow_task());
|
||||
}
|
||||
tasks.push_back(render_task_delegate_->task());
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
This parameter not needed, instead create function like
HydraSceneDelegate::has_shadows()