[Bf-blender-cvs] [a75a5d3] openvdb: Cycles OpenVDB node: add output sockets based on Blender's node outputs.
Kévin Dietrich
noreply at git.blender.org
Fri Jun 5 14:06:07 CEST 2015
Commit: a75a5d3987d2bc4d75697781132ed669eb4a4aec
Author: Kévin Dietrich
Date: Mon May 11 01:24:37 2015 +0200
Branches: openvdb
https://developer.blender.org/rBa75a5d3987d2bc4d75697781132ed669eb4a4aec
Cycles OpenVDB node: add output sockets based on Blender's node outputs.
In a later commit, the Blender ones will be dynamically added based on
the grids contained in the file so any grid can be accessible for
shading purposes.
===================================================================
M intern/cycles/blender/blender_shader.cpp
M intern/cycles/render/nodes.cpp
M intern/cycles/render/nodes.h
===================================================================
diff --git a/intern/cycles/blender/blender_shader.cpp b/intern/cycles/blender/blender_shader.cpp
index 8cfcd38..8096f46 100644
--- a/intern/cycles/blender/blender_shader.cpp
+++ b/intern/cycles/blender/blender_shader.cpp
@@ -741,6 +741,15 @@ static ShaderNode *add_node(Scene *scene,
OpenVDBNode *vdb_node = new OpenVDBNode();
vdb_node->filename = b_vdb_node.filename();
vdb_node->sampling = b_vdb_node.sampling();
+
+ BL::Node::outputs_iterator b_output;
+
+ for(b_vdb_node.outputs.begin(b_output); b_output != b_vdb_node.outputs.end(); ++b_output) {
+ vdb_node->output_names.push_back(ustring(b_output->name()));
+ vdb_node->add_output(vdb_node->output_names.back().c_str(),
+ convert_socket_type(*b_output));
+ }
+
node = vdb_node;
}
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 8279a96..190b8f3 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -4370,12 +4370,6 @@ OpenVDBNode::OpenVDBNode()
filename = "";
vdb_manager = NULL;
sampling = OPENVDB_SAMPLE_POINT;
-
- add_output("density", SHADER_SOCKET_FLOAT);
- add_output("heat", SHADER_SOCKET_FLOAT);
- add_output("flame", SHADER_SOCKET_FLOAT);
- add_output("fuel", SHADER_SOCKET_FLOAT);
- add_output("velocity", SHADER_SOCKET_VECTOR);
}
void OpenVDBNode::attributes(Shader *shader, AttributeRequestSet *attributes)
@@ -4385,47 +4379,27 @@ void OpenVDBNode::attributes(Shader *shader, AttributeRequestSet *attributes)
void OpenVDBNode::compile(SVMCompiler &compiler)
{
- ShaderOutput *dens_out = output("density");
- ShaderOutput *heat_out = output("heat");
- ShaderOutput *flame_out = output("flame");
- ShaderOutput *temp_out = output("fuel");
- ShaderOutput *vel_out = output("velocity");
-
vdb_manager = compiler.vdb_manager;
- if(!dens_out->links.empty()) {
- grid_slot = vdb_manager->add_volume(filename.string(), dens_out->name, sampling, NODE_VDB_FLOAT);
- compiler.stack_assign(dens_out);
- compiler.add_node(NODE_OPENVDB,
- compiler.encode_uchar4(grid_slot, NODE_VDB_FLOAT, dens_out->stack_offset, sampling));
- }
+ for(size_t i = 0; i < outputs.size(); ++i) {
+ ShaderOutput *out = outputs[i];
- if(!heat_out->links.empty()) {
- grid_slot = vdb_manager->add_volume(filename.string(), heat_out->name, sampling, NODE_VDB_FLOAT);
- compiler.stack_assign(heat_out);
- compiler.add_node(NODE_OPENVDB,
- compiler.encode_uchar4(grid_slot, NODE_VDB_FLOAT, heat_out->stack_offset, sampling));
- }
+ if(out->links.empty()) {
+ continue;
+ }
- if(!flame_out->links.empty()) {
- grid_slot = vdb_manager->add_volume(filename.string(), flame_out->name, sampling, NODE_VDB_FLOAT);
- compiler.stack_assign(flame_out);
- compiler.add_node(NODE_OPENVDB,
- compiler.encode_uchar4(grid_slot, NODE_VDB_FLOAT, flame_out->stack_offset, sampling));
- }
+ int type = NODE_VDB_FLOAT;
- if(!temp_out->links.empty()) {
- grid_slot = vdb_manager->add_volume(filename.string(), temp_out->name, sampling, NODE_VDB_FLOAT);
- compiler.stack_assign(temp_out);
- compiler.add_node(NODE_OPENVDB,
- compiler.encode_uchar4(grid_slot, NODE_VDB_FLOAT, temp_out->stack_offset, sampling));
- }
+ if(out->type == SHADER_SOCKET_VECTOR) {
+ type = NODE_VDB_VEC3S;
+ }
+
+ grid_slot = vdb_manager->add_volume(filename.string(), output_names[i].string(), sampling, type);
+
+ compiler.stack_assign(out);
- if(!vel_out->links.empty()) {
- grid_slot = vdb_manager->add_volume(filename.string(), vel_out->name, sampling, NODE_VDB_VEC3S);
- compiler.stack_assign(vel_out);
compiler.add_node(NODE_OPENVDB,
- compiler.encode_uchar4(grid_slot, NODE_VDB_VEC3S, vel_out->stack_offset, sampling));
+ compiler.encode_uchar4(grid_slot, type, out->stack_offset, sampling));
}
}
diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h
index a257cd8..250ade9 100644
--- a/intern/cycles/render/nodes.h
+++ b/intern/cycles/render/nodes.h
@@ -676,6 +676,7 @@ public:
int grid_slot;
int sampling;
+ vector<ustring> output_names;
};
CCL_NAMESPACE_END
More information about the Bf-blender-cvs
mailing list