Support more AOVs #78

Merged
Bogdan Nagirniak merged 11 commits from DagerD/blender:BLEN-462_3 into hydra-render 2023-07-29 14:45:16 +02:00
2 changed files with 26 additions and 7 deletions
Showing only changes of commit 790e6a289e - Show all commits

View File

@ -2,6 +2,7 @@
* Copyright 2011-2022 Blender Foundation */ * Copyright 2011-2022 Blender Foundation */
#include "light_tasks_delegate.h" #include "light_tasks_delegate.h"
#include "engine.h"
namespace blender::render::hydra { namespace blender::render::hydra {
@ -13,10 +14,15 @@ LightTasksDelegate::LightTasksDelegate(pxr::HdRenderIndex *parent_index,
GetRenderIndex().InsertTask<pxr::HdxSimpleLightTask>(this, simple_task_id_); GetRenderIndex().InsertTask<pxr::HdxSimpleLightTask>(this, simple_task_id_);
skydome_task_id_ = GetDelegateID().AppendElementString("skydomeTask"); skydome_task_id_ = GetDelegateID().AppendElementString("skydomeTask");
GetRenderIndex().InsertTask<pxr::HdxSkydomeTask>(this, skydome_task_id_); GetRenderIndex().InsertTask<pxr::HdxSkydomeTask>(this, skydome_task_id_);
CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", simple_task_id_.GetText());
CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", skydome_task_id_.GetText());
} }
pxr::VtValue LightTasksDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) pxr::VtValue LightTasksDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
{ {
CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s, %s", id.GetText(), key.GetText());
if (key == pxr::HdTokens->params) { if (key == pxr::HdTokens->params) {
if (id == simple_task_id_) { if (id == simple_task_id_) {
return pxr::VtValue(simple_task_params_); return pxr::VtValue(simple_task_params_);

View File

@ -10,6 +10,7 @@
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "render_task_delegate.h" #include "render_task_delegate.h"
#include "engine.h"
namespace blender::render::hydra { namespace blender::render::hydra {
@ -22,10 +23,14 @@ RenderTaskDelegate::RenderTaskDelegate(pxr::HdRenderIndex *parent_index,
render_task_params_.enableLighting = true; render_task_params_.enableLighting = true;
render_task_params_.alphaThreshold = 0.1f; render_task_params_.alphaThreshold = 0.1f;
CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", render_task_id_.GetText());
} }
pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & /*id*/, pxr::TfToken const &key) pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & id, pxr::TfToken const &key)
{ {
CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s, %s", id.GetText(), key.GetText());
if (key == pxr::HdTokens->params) { if (key == pxr::HdTokens->params) {
return pxr::VtValue(render_task_params_); return pxr::VtValue(render_task_params_);
} }
@ -36,13 +41,17 @@ pxr::VtValue RenderTaskDelegate::Get(pxr::SdfPath const & /*id*/, pxr::TfToken c
return pxr::VtValue(); return pxr::VtValue();
} }
pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const & /*id*/) pxr::TfTokenVector RenderTaskDelegate::GetTaskRenderTags(pxr::SdfPath const & id)
{ {
CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s", id.GetText());
return {pxr::HdRenderTagTokens->geometry}; return {pxr::HdRenderTagTokens->geometry};
} }
pxr::HdRenderBufferDescriptor RenderTaskDelegate::GetRenderBufferDescriptor(pxr::SdfPath const &id) pxr::HdRenderBufferDescriptor RenderTaskDelegate::GetRenderBufferDescriptor(pxr::SdfPath const &id)
{ {
CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s", id.GetText());
return buffer_descriptors_[id]; return buffer_descriptors_[id];
} }
@ -109,6 +118,8 @@ void RenderTaskDelegate::add_aov(pxr::TfToken const &aov_key)
binding.aovSettings = aov_desc.aovSettings; binding.aovSettings = aov_desc.aovSettings;
render_task_params_.aovBindings.push_back(binding); render_task_params_.aovBindings.push_back(binding);
render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams); render_index.GetChangeTracker().MarkTaskDirty(render_task_id_, pxr::HdChangeTracker::DirtyParams);
CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText());
} }
void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data) void RenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data)
@ -152,14 +163,14 @@ GPURenderTaskDelegate::GPURenderTaskDelegate(pxr::HdRenderIndex *parent_index,
{ {
aov_task_id_ = GetDelegateID().AppendElementString("aovTask"); aov_task_id_ = GetDelegateID().AppendElementString("aovTask");
GetRenderIndex().InsertTask<pxr::HdxVisualizeAovTask>(this, aov_task_id_); GetRenderIndex().InsertTask<pxr::HdxVisualizeAovTask>(this, aov_task_id_);
GetRenderIndex().GetChangeTracker().MarkTaskDirty(aov_task_id_,
pxr::HdChangeTracker::DirtyCollection); CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_task_id_.GetText());
GetRenderIndex().GetChangeTracker().MarkTaskDirty(aov_task_id_,
pxr::HdChangeTracker::DirtyRenderTags);
} }
pxr::VtValue GPURenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key) pxr::VtValue GPURenderTaskDelegate::Get(pxr::SdfPath const &id, pxr::TfToken const &key)
{ {
CLOG_INFO(LOG_RENDER_HYDRA, 3, "%s, %s", id.GetText(), key.GetText());
if (id == render_task_id_) { if (id == render_task_id_) {
return RenderTaskDelegate::Get(id, key); return RenderTaskDelegate::Get(id, key);
} }
@ -224,6 +235,8 @@ void GPURenderTaskDelegate::add_aov(pxr::TfToken const &aov_key)
format, format,
GPU_TEXTURE_USAGE_GENERAL, GPU_TEXTURE_USAGE_GENERAL,
nullptr); nullptr);
CLOG_INFO(LOG_RENDER_HYDRA, 1, "%s", aov_key.GetText());
} }
void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data) void GPURenderTaskDelegate::read_aov(pxr::TfToken const &aov_key, void *data)
@ -282,7 +295,7 @@ void GPURenderTaskDelegate::bind()
GPU_framebuffer_clear_color_depth(framebuffer_, clear_color, 1.0f); 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 /* Important: we have to create and bind at least one Vertex Array Object (VAO) before render
execution: More info at https://open.gl/drawing */ * execution: More info at https://open.gl/drawing */
if (VAO_ == 0) { if (VAO_ == 0) {
glGenVertexArrays(1, &VAO_); glGenVertexArrays(1, &VAO_);
} }