20const std::unordered_map<TfToken, PassType, TfToken::HashFunctor>
kAovToPass = {
31 : scene(static_cast<const
HdCyclesSession *>(renderParam)->session->scene),
32 sceneLock(scene->
mutex)
39 : session(session_), keep_nodes(
true), _ownCyclesSession(
false)
46 Scene *
const scene = session->scene;
56 graph->connect(bgNode->
output(
"Background"), graph->output()->input(
"Surface"));
58 scene->default_background->set_graph(graph);
59 scene->default_background->tag_update(scene);
67 graph->add(objectNode);
70 graph->add(diffuseNode);
72 graph->connect(objectNode->
output(
"Color"), diffuseNode->
input(
"Color"));
73 graph->connect(diffuseNode->
output(
"BSDF"), graph->output()->input(
"Surface"));
77 const ustring instanceId(HdAovTokens->instanceId.GetString());
80 aovNode->set_name(instanceId);
84 instanceIdNode->set_attribute(instanceId);
85 graph->add(instanceIdNode);
87 graph->connect(instanceIdNode->
output(
"Fac"), aovNode->
input(
"Value"));
90 scene->default_surface->set_graph(graph);
91 scene->default_surface->tag_update(scene);
97 if (_ownCyclesSession) {
107 if (scene->light_manager->need_update()) {
108 Light *background_light =
nullptr;
109 for (
Light *light : scene->lights) {
111 background_light = light;
116 if (!background_light) {
117 scene->background->set_shader(scene->default_background);
118 scene->background->set_transparent(
true);
122 for (
ShaderNode *node : scene->default_background->graph->nodes) {
123 if (node->is_a(BackgroundNode::get_node_type())) {
130 scene->background->set_shader(background_light->get_shader());
131 scene->background->set_transparent(
false);
134 scene->background->tag_update(scene);
143 scene->
delete_nodes(set<Pass *>(scene->passes.begin(), scene->passes.end()));
146 _aovBindings = aovBindings;
147 for (
const HdRenderPassAovBinding &aovBinding : aovBindings) {
148 const auto cyclesAov = kAovToPass.find(aovBinding.aovName);
149 if (cyclesAov == kAovToPass.end()) {
151 TF_WARN(
"Unknown pass %s", aovBinding.aovName.GetText());
155 const PassType type = cyclesAov->second;
158 Pass *pass = scene->create_node<
Pass>();
159 pass->set_type(type);
160 pass->set_mode(mode);
161 pass->set_name(ustring(aovBinding.aovName.GetString()));
167 for (HdRenderPassAovBinding &aovBinding : _aovBindings) {
168 if (renderBuffer == aovBinding.renderBuffer) {
169 aovBinding.renderBuffer =
nullptr;
174 if (renderBuffer == _displayAovBinding.renderBuffer) {
175 _displayAovBinding.renderBuffer =
nullptr;
HdCyclesSession(CCL_NS::Session *session_, const bool keep_nodes)
~HdCyclesSession() override
CCL_NS::Session * session
void RemoveAovBinding(PXR_NS::HdRenderBuffer *renderBuffer)
void SyncAovBindings(const PXR_NS::HdRenderPassAovBindingVector &aovBindings)
ShaderInput * input(const char *name)
ShaderOutput * output(const char *name)
#define HDCYCLES_NAMESPACE_CLOSE_SCOPE
ccl_device_inline float3 one_float3()
CCL_NAMESPACE_BEGIN ccl_device_inline float3 zero_float3()
const std::unordered_map< TfToken, PassType, TfToken::HashFunctor > kAovToPass
SceneLock(const PXR_NS::HdRenderParam *renderParam)
void delete_nodes(const set< T * > &nodes)