forked from blender/blender
Make DomeLight visible for Storm delegate #68
@ -107,7 +107,6 @@ void FinalEngine::prepare_for_render(Depsgraph *depsgraph)
|
||||
render_task_delegate_->set_camera_and_viewport(
|
||||
free_camera_delegate_->GetCameraId(), pxr::GfVec4d(0, 0, resolution_[0], resolution_[1]));
|
||||
if (light_tasks_delegate_) {
|
||||
light_tasks_delegate_->set_camera_path(free_camera_delegate_->GetCameraId());
|
||||
light_tasks_delegate_->set_camera_and_viewport(
|
||||
free_camera_delegate_->GetCameraId(), pxr::GfVec4d(0, 0, resolution_[0], resolution_[1]));
|
||||
tasks_ = light_tasks_delegate_->get_tasks();
|
||||
@ -150,20 +149,6 @@ void FinalEngineGPU::render(Depsgraph *depsgraph)
|
||||
|
||||
float clear_color[4] = {0.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
/* Workaround Storm rendering with transparent background. Does not currently work for
|
||||
* USD, and should probably be optional depending on the Blender film transparency setting. */
|
||||
if (hydra_scene_delegate_ && render_delegate_name == "HdStormRendererPlugin") {
|
||||
pxr::VtValue world_color = hydra_scene_delegate_->GetLightParamValue(
|
||||
hydra_scene_delegate_->GetDelegateID().AppendElementString("World"),
|
||||
pxr::HdLightTokens->color);
|
||||
if (!world_color.IsEmpty()) {
|
||||
auto &c = world_color.Get<pxr::GfVec3f>();
|
||||
clear_color[0] = c[0];
|
||||
clear_color[1] = c[1];
|
||||
clear_color[2] = c[2];
|
||||
}
|
||||
}
|
||||
|
||||
GPU_framebuffer_clear_color_depth(framebuffer, clear_color, 1.0f);
|
||||
|
||||
/* Important: we have to create and bind at least one Vertex Array Object (VAO) before render
|
||||
|
@ -12,29 +12,29 @@ LightTasksDelegate::LightTasksDelegate(pxr::HdRenderIndex *parent_index,
|
||||
pxr::SdfPath const &delegate_id)
|
||||
: pxr::HdSceneDelegate(parent_index, delegate_id)
|
||||
{
|
||||
skydome_task = GetDelegateID().AppendElementString("simpleLightTask");
|
||||
simple_light_task = GetDelegateID().AppendElementString("skydomeTask");
|
||||
GetRenderIndex().InsertTask<pxr::HdxSkydomeTask>(this, skydome_task);
|
||||
GetRenderIndex().InsertTask<pxr::HdxSimpleLightTask>(this, simple_light_task);
|
||||
skydome_task_id_ = GetDelegateID().AppendElementString("simpleLightTask");
|
||||
simple_task_id_ = GetDelegateID().AppendElementString("skydomeTask");
|
||||
GetRenderIndex().InsertTask<pxr::HdxSkydomeTask>(this, skydome_task_id_);
|
||||
GetRenderIndex().InsertTask<pxr::HdxSimpleLightTask>(this, simple_task_id_);
|
||||
}
|
||||
|
||||
pxr::HdTaskSharedPtrVector LightTasksDelegate::get_tasks()
|
||||
{
|
||||
return {GetRenderIndex().GetTask(skydome_task), GetRenderIndex().GetTask(simple_light_task)};
|
||||
}
|
||||
|
||||
void LightTasksDelegate::set_camera_path(pxr::SdfPath const &camera_path)
|
||||
{
|
||||
simple_light_task_params_.cameraPath = camera_path;
|
||||
return {GetRenderIndex().GetTask(skydome_task_id_), GetRenderIndex().GetTask(simple_task_id_)};
|
||||
}
|
||||
|
||||
void LightTasksDelegate::set_camera_and_viewport(pxr::SdfPath const &camera_id,
|
||||
pxr::GfVec4d const &viewport)
|
||||
{
|
||||
if (simple_task_params_.cameraPath != camera_id) {
|
||||
simple_task_params_.cameraPath = camera_id;
|
||||
GetRenderIndex().GetChangeTracker().MarkTaskDirty(simple_task_id_,
|
||||
pxr::HdChangeTracker::DirtyParams);
|
||||
}
|
||||
if (skydome_task_params_.viewport != viewport || skydome_task_params_.camera != camera_id) {
|
||||
skydome_task_params_.viewport = viewport;
|
||||
skydome_task_params_.camera = camera_id;
|
||||
GetRenderIndex().GetChangeTracker().MarkTaskDirty(skydome_task,
|
||||
GetRenderIndex().GetChangeTracker().MarkTaskDirty(skydome_task_id_,
|
||||
pxr::HdChangeTracker::DirtyParams);
|
||||
}
|
||||
}
|
||||
@ -42,10 +42,10 @@ void LightTasksDelegate::set_camera_and_viewport(pxr::SdfPath const &camera_id,
|
||||
pxr::VtValue LightTasksDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
|
||||
{
|
||||
if (key == pxr::HdTokens->params) {
|
||||
if (id == simple_light_task) {
|
||||
return pxr::VtValue(simple_light_task_params_);
|
||||
if (id == simple_task_id_) {
|
||||
return pxr::VtValue(simple_task_params_);
|
||||
}
|
||||
else if (id == skydome_task) {
|
||||
else if (id == skydome_task_id_) {
|
||||
return pxr::VtValue(skydome_task_params_);
|
||||
}
|
||||
}
|
||||
|
@ -15,16 +15,15 @@ class LightTasksDelegate : public pxr::HdSceneDelegate {
|
||||
~LightTasksDelegate() override = default;
|
||||
|
||||
pxr::HdTaskSharedPtrVector get_tasks();
|
||||
void set_camera_path(pxr::SdfPath const &);
|
||||
void set_camera_and_viewport(pxr::SdfPath const &camera_id, pxr::GfVec4d const &viewport);
|
||||
|
||||
/* Delegate methods */
|
||||
pxr::VtValue Get(pxr::SdfPath const &id, pxr::TfToken const &key) override;
|
||||
|
||||
private:
|
||||
pxr::SdfPath simple_light_task;
|
||||
pxr::SdfPath skydome_task;
|
||||
pxr::HdxSimpleLightTaskParams simple_light_task_params_;
|
||||
pxr::SdfPath simple_task_id_;
|
||||
pxr::SdfPath skydome_task_id_;
|
||||
pxr::HdxSimpleLightTaskParams simple_task_params_;
|
||||
pxr::HdxRenderTaskParams skydome_task_params_;
|
||||
};
|
||||
|
||||
|
@ -238,7 +238,6 @@ void ViewportEngine::render(Depsgraph * /* depsgraph */, bContext *context)
|
||||
view_settings.border[3]));
|
||||
|
||||
if (light_tasks_delegate_) {
|
||||
light_tasks_delegate_->set_camera_path(free_camera_delegate_->GetCameraId());
|
||||
light_tasks_delegate_->set_camera_and_viewport(free_camera_delegate_->GetCameraId(),
|
||||
pxr::GfVec4d(view_settings.border[0],
|
||||
view_settings.border[1],
|
||||
|
Loading…
Reference in New Issue
Block a user