WIP: Support more AOVs #72

Closed
Georgiy Markelov wants to merge 6 commits from DagerD/blender:BLEN-461 into hydra-render

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
3 changed files with 25 additions and 17 deletions
Showing only changes of commit 1f8c6572e5 - Show all commits

View File

@ -144,6 +144,8 @@ class HydraRenderEngine(bpy.types.RenderEngine):
def update_render_passes(self, scene, render_layer):
if render_layer.use_pass_z:
self.register_pass(scene, render_layer, 'Depth', 1, 'Z', 'VALUE')
if render_layer.use_pass_normal:
self.register_pass(scene, render_layer, 'Normal', 3, 'XYZ', 'VECTOR')
def export_mtlx(material):

View File

@ -11,7 +11,7 @@
#include "GPU_framebuffer.h"
#include "GPU_texture.h"
#include "PIL_time.h"
#include "BLI_map.hh"
#include "IMB_imbuf_types.h"
#include "camera.h"
@ -22,13 +22,13 @@ namespace blender::render::hydra {
void FinalEngine::render(Depsgraph *depsgraph)
{
prepare_for_render(depsgraph);
render_task_delegate_->set_renderer_aov(pxr::HdAovTokens->color);
render_task_delegate_->set_renderer_aov(pxr::HdAovTokens->depth);
for (auto &it : render_images_) {
render_task_delegate_->set_renderer_aov(aovs_map_.lookup(it.first));
}
engine_->Execute(render_index_.get(), &tasks_);
std::vector<float> &pixels_depth = render_images_["Depth"];
std::vector<float> &pixels_combined = render_images_["Combined"];
char elapsed_time[32];
double time_begin = PIL_check_seconds_timer();
float percent_done = 0.0;
@ -49,14 +49,14 @@ void FinalEngine::render(Depsgraph *depsgraph)
if (render_task_delegate_->is_converged()) {
break;
}
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels_combined.data());
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->depth, pixels_depth.data());
for (auto &it : render_images_) {
render_task_delegate_->get_renderer_aov_data(aovs_map_.lookup(it.first), it.second.data());
}
update_render_result();
}
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels_combined.data());
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->depth, pixels_depth.data());
for (auto &it : render_images_) {
render_task_delegate_->get_renderer_aov_data(aovs_map_.lookup(it.first), it.second.data());
}
update_render_result();
}
@ -117,13 +117,18 @@ void FinalEngine::prepare_for_render(Depsgraph *depsgraph)
}
tasks_.push_back(render_task_delegate_->get_task());
render_images_.emplace(
"Combined",
std::vector<float>(resolution_[0] * resolution_[1] * 4)); /* 4 - number of channels. */
aovs_map_.add_new("Combined", pxr::HdAovTokens->color);
aovs_map_.add_new("Depth", pxr::HdAovTokens->depth);
aovs_map_.add_new("Normal", pxr::HdAovTokens->normal);
render_images_.emplace(
"Depth",
std::vector<float>(resolution_[0] * resolution_[1] * 1)); /* 1 - number of channels. */
RenderResult *result = RE_engine_get_result(bl_engine_);
RenderLayer *layer = (RenderLayer *)result->layers.first;
for (RenderPass *pass = (RenderPass *)layer->passes.first; pass != nullptr; pass = pass->next) {
if (aovs_map_.lookup_key_ptr(pass->name)) {
render_images_.emplace(pass->name,
std::vector<float>(pass->rectx * pass->recty * pass->channels));
}
}
}
void FinalEngineGPU::render(Depsgraph *depsgraph)

View File

@ -24,6 +24,7 @@ class FinalEngine : public Engine {
std::string layer_name_;
std::map<std::string, std::vector<float>> render_images_;
pxr::GfVec2i resolution_;
Map<std::string, pxr::TfToken> aovs_map_;
};
class FinalEngineGPU : public FinalEngine {