forked from blender/blender
WIP: Support more AOVs #72
@ -144,6 +144,8 @@ class HydraRenderEngine(bpy.types.RenderEngine):
|
|||||||
def update_render_passes(self, scene, render_layer):
|
def update_render_passes(self, scene, render_layer):
|
||||||
if render_layer.use_pass_z:
|
if render_layer.use_pass_z:
|
||||||
self.register_pass(scene, render_layer, 'Depth', 1, 'Z', 'VALUE')
|
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):
|
def export_mtlx(material):
|
||||||
|
@ -11,7 +11,7 @@
|
|||||||
#include "GPU_framebuffer.h"
|
#include "GPU_framebuffer.h"
|
||||||
#include "GPU_texture.h"
|
#include "GPU_texture.h"
|
||||||
#include "PIL_time.h"
|
#include "PIL_time.h"
|
||||||
|
#include "BLI_map.hh"
|
||||||
#include "IMB_imbuf_types.h"
|
#include "IMB_imbuf_types.h"
|
||||||
|
|
||||||
#include "camera.h"
|
#include "camera.h"
|
||||||
@ -22,13 +22,13 @@ namespace blender::render::hydra {
|
|||||||
void FinalEngine::render(Depsgraph *depsgraph)
|
void FinalEngine::render(Depsgraph *depsgraph)
|
||||||
{
|
{
|
||||||
prepare_for_render(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_);
|
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];
|
char elapsed_time[32];
|
||||||
double time_begin = PIL_check_seconds_timer();
|
double time_begin = PIL_check_seconds_timer();
|
||||||
float percent_done = 0.0;
|
float percent_done = 0.0;
|
||||||
@ -49,14 +49,14 @@ void FinalEngine::render(Depsgraph *depsgraph)
|
|||||||
if (render_task_delegate_->is_converged()) {
|
if (render_task_delegate_->is_converged()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
for (auto &it : render_images_) {
|
||||||
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels_combined.data());
|
render_task_delegate_->get_renderer_aov_data(aovs_map_.lookup(it.first), it.second.data());
|
||||||
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->depth, pixels_depth.data());
|
}
|
||||||
update_render_result();
|
update_render_result();
|
||||||
}
|
}
|
||||||
|
for (auto &it : render_images_) {
|
||||||
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->color, pixels_combined.data());
|
render_task_delegate_->get_renderer_aov_data(aovs_map_.lookup(it.first), it.second.data());
|
||||||
render_task_delegate_->get_renderer_aov_data(pxr::HdAovTokens->depth, pixels_depth.data());
|
}
|
||||||
update_render_result();
|
update_render_result();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,13 +117,18 @@ void FinalEngine::prepare_for_render(Depsgraph *depsgraph)
|
|||||||
}
|
}
|
||||||
tasks_.push_back(render_task_delegate_->get_task());
|
tasks_.push_back(render_task_delegate_->get_task());
|
||||||
|
|
||||||
render_images_.emplace(
|
aovs_map_.add_new("Combined", pxr::HdAovTokens->color);
|
||||||
"Combined",
|
aovs_map_.add_new("Depth", pxr::HdAovTokens->depth);
|
||||||
std::vector<float>(resolution_[0] * resolution_[1] * 4)); /* 4 - number of channels. */
|
aovs_map_.add_new("Normal", pxr::HdAovTokens->normal);
|
||||||
|
|
||||||
render_images_.emplace(
|
RenderResult *result = RE_engine_get_result(bl_engine_);
|
||||||
"Depth",
|
RenderLayer *layer = (RenderLayer *)result->layers.first;
|
||||||
std::vector<float>(resolution_[0] * resolution_[1] * 1)); /* 1 - number of channels. */
|
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)
|
void FinalEngineGPU::render(Depsgraph *depsgraph)
|
||||||
|
@ -24,6 +24,7 @@ class FinalEngine : public Engine {
|
|||||||
std::string layer_name_;
|
std::string layer_name_;
|
||||||
std::map<std::string, std::vector<float>> render_images_;
|
std::map<std::string, std::vector<float>> render_images_;
|
||||||
pxr::GfVec2i resolution_;
|
pxr::GfVec2i resolution_;
|
||||||
|
Map<std::string, pxr::TfToken> aovs_map_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FinalEngineGPU : public FinalEngine {
|
class FinalEngineGPU : public FinalEngine {
|
||||||
|
Loading…
Reference in New Issue
Block a user