Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-10-12 19:42:35 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-10-12 19:42:35 +0400
commit7503a7edfba9496521baefd70fe6cbcbfce5127b (patch)
tree9800ef871191ce52396048681d393d62c0c30cc5 /intern/cycles/render
parent85818c8209bc6df4f60c7e86173521f5fa1a5a96 (diff)
Cycles: replace surface/volume sockets in output nodes with a single shader socket,
decided it's better to render objects as either surface or volume. This may break the volume rendering patch, but shaders with volume closures still get tagged as having volume closures, so it should be fixable without too many changes.
Diffstat (limited to 'intern/cycles/render')
-rw-r--r--intern/cycles/render/nodes.cpp9
-rw-r--r--intern/cycles/render/osl.cpp62
-rw-r--r--intern/cycles/render/shader.cpp7
-rw-r--r--intern/cycles/render/shader.h7
-rw-r--r--intern/cycles/render/svm.cpp31
5 files changed, 36 insertions, 80 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp
index 9e7e2a8a81d..1d21e43217a 100644
--- a/intern/cycles/render/nodes.cpp
+++ b/intern/cycles/render/nodes.cpp
@@ -1945,8 +1945,7 @@ void BlendWeightNode::compile(OSLCompiler& compiler)
OutputNode::OutputNode()
: ShaderNode("output")
{
- add_input("Surface", SHADER_SOCKET_CLOSURE);
- add_input("Volume", SHADER_SOCKET_CLOSURE);
+ add_input("Closure", SHADER_SOCKET_CLOSURE);
add_input("Displacement", SHADER_SOCKET_FLOAT);
}
@@ -1964,10 +1963,8 @@ void OutputNode::compile(SVMCompiler& compiler)
void OutputNode::compile(OSLCompiler& compiler)
{
- if(compiler.output_type() == SHADER_TYPE_SURFACE)
- compiler.add(this, "node_output_surface");
- else if(compiler.output_type() == SHADER_TYPE_VOLUME)
- compiler.add(this, "node_output_volume");
+ if(compiler.output_type() == SHADER_TYPE_CLOSURE)
+ compiler.add(this, "node_output_closure");
else if(compiler.output_type() == SHADER_TYPE_DISPLACEMENT)
compiler.add(this, "node_output_displacement");
}
diff --git a/intern/cycles/render/osl.cpp b/intern/cycles/render/osl.cpp
index b0173334c76..492529c30a2 100644
--- a/intern/cycles/render/osl.cpp
+++ b/intern/cycles/render/osl.cpp
@@ -102,7 +102,7 @@ void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
/* setup shader engine */
og->ss = ss;
int background_id = scene->shader_manager->get_shader_id(scene->default_background);
- og->background_state = og->surface_state[background_id];
+ og->background_state = og->state[background_id];
og->use = true;
tls_create(OSLGlobals::ThreadData, og->thread_data);
@@ -128,8 +128,7 @@ void OSLShaderManager::device_free(Device *device, DeviceScene *dscene)
tls_delete(OSLGlobals::ThreadData, og->thread_data);
- og->surface_state.clear();
- og->volume_state.clear();
+ og->state.clear();
og->displacement_state.clear();
og->background_state.reset();
}
@@ -139,7 +138,7 @@ void OSLShaderManager::device_free(Device *device, DeviceScene *dscene)
OSLCompiler::OSLCompiler(void *shadingsys_)
{
shadingsys = shadingsys_;
- current_type = SHADER_TYPE_SURFACE;
+ current_type = SHADER_TYPE_CLOSURE;
current_shader = NULL;
background = false;
}
@@ -170,9 +169,7 @@ bool OSLCompiler::node_skip_input(ShaderNode *node, ShaderInput *input)
depending on the current shader type */
if(node->name == ustring("output")) {
- if(strcmp(input->name, "Surface") == 0 && current_type != SHADER_TYPE_SURFACE)
- return true;
- if(strcmp(input->name, "Volume") == 0 && current_type != SHADER_TYPE_VOLUME)
+ if(strcmp(input->name, "Closure") == 0 && current_type != SHADER_TYPE_CLOSURE)
return true;
if(strcmp(input->name, "Displacement") == 0 && current_type != SHADER_TYPE_DISPLACEMENT)
return true;
@@ -223,9 +220,7 @@ void OSLCompiler::add(ShaderNode *node, const char *name)
* because "volume" and "displacement" don't work yet in OSL. the shaders
* work fine, but presumably these values would be used for more strict
* checking, so when that is fixed, we should update the code here too. */
- if(current_type == SHADER_TYPE_SURFACE)
- ss->Shader("surface", name, id(node).c_str());
- else if(current_type == SHADER_TYPE_VOLUME)
+ if(current_type == SHADER_TYPE_CLOSURE)
ss->Shader("surface", name, id(node).c_str());
else if(current_type == SHADER_TYPE_DISPLACEMENT)
ss->Shader("surface", name, id(node).c_str());
@@ -346,6 +341,8 @@ void OSLCompiler::generate_nodes(const set<ShaderNode*>& nodes)
current_shader->has_surface_emission = true;
if(node->name == ustring("transparent"))
current_shader->has_surface_transparent = true;
+ if(node->name == ustring("volume"))
+ current_shader->has_volume = true;
}
else
nodes_done = false;
@@ -365,15 +362,9 @@ void OSLCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
ShaderNode *output = graph->output();
set<ShaderNode*> dependencies;
- if(type == SHADER_TYPE_SURFACE) {
+ if(type == SHADER_TYPE_CLOSURE) {
/* generate surface shader */
- find_dependencies(dependencies, output->input("Surface"));
- generate_nodes(dependencies);
- output->compile(*this);
- }
- else if(type == SHADER_TYPE_VOLUME) {
- /* generate volume shader */
- find_dependencies(dependencies, output->input("Volume"));
+ find_dependencies(dependencies, output->input("Closure"));
generate_nodes(dependencies);
output->compile(*this);
}
@@ -396,7 +387,7 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
ShaderNode *output = (graph)? graph->output(): NULL;
/* copy graph for shader with bump mapping */
- if(output->input("Surface")->link && output->input("Displacement")->link)
+ if(output->input("Closure")->link && output->input("Displacement")->link)
if(!shader->graph_bump)
shader->graph_bump = shader->graph->copy();
@@ -407,46 +398,29 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
current_shader = shader;
- shader->has_surface = false;
shader->has_surface_emission = false;
shader->has_surface_transparent = false;
shader->has_volume = false;
shader->has_displacement = false;
/* generate surface shader */
- if(graph && output->input("Surface")->link) {
- compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
- og->surface_state.push_back(ss->state());
+ if(graph && output->input("Closure")->link) {
+ compile_type(shader, shader->graph, SHADER_TYPE_CLOSURE);
+ og->state.push_back(ss->state());
if(shader->graph_bump) {
ss->clear_state();
- compile_type(shader, shader->graph_bump, SHADER_TYPE_SURFACE);
- og->surface_state.push_back(ss->state());
+ compile_type(shader, shader->graph_bump, SHADER_TYPE_CLOSURE);
+ og->state.push_back(ss->state());
}
else
- og->surface_state.push_back(ss->state());
-
- ss->clear_state();
-
- shader->has_surface = true;
- }
- else {
- og->surface_state.push_back(OSL::ShadingAttribStateRef());
- og->surface_state.push_back(OSL::ShadingAttribStateRef());
- }
-
- /* generate volume shader */
- if(graph && output->input("Volume")->link) {
- compile_type(shader, shader->graph, SHADER_TYPE_VOLUME);
- shader->has_volume = true;
+ og->state.push_back(ss->state());
- og->volume_state.push_back(ss->state());
- og->volume_state.push_back(ss->state());
ss->clear_state();
}
else {
- og->volume_state.push_back(OSL::ShadingAttribStateRef());
- og->volume_state.push_back(OSL::ShadingAttribStateRef());
+ og->state.push_back(OSL::ShadingAttribStateRef());
+ og->state.push_back(OSL::ShadingAttribStateRef());
}
/* generate displacement shader */
diff --git a/intern/cycles/render/shader.cpp b/intern/cycles/render/shader.cpp
index 6e827ec94bb..c0d450db22b 100644
--- a/intern/cycles/render/shader.cpp
+++ b/intern/cycles/render/shader.cpp
@@ -42,7 +42,6 @@ Shader::Shader()
sample_as_light = true;
homogeneous_volume = false;
- has_surface = false;
has_surface_transparent = false;
has_surface_emission = false;
has_volume = false;
@@ -210,7 +209,7 @@ void ShaderManager::add_default(Scene *scene)
closure->input("Color")->value = make_float3(0.8f, 0.8f, 0.8f);
out = graph->output();
- graph->connect(closure->output("BSDF"), out->input("Surface"));
+ graph->connect(closure->output("BSDF"), out->input("Closure"));
shader = new Shader();
shader->name = "default_surface";
@@ -228,7 +227,7 @@ void ShaderManager::add_default(Scene *scene)
closure->input("Strength")->value.x = 0.0f;
out = graph->output();
- graph->connect(closure->output("Emission"), out->input("Surface"));
+ graph->connect(closure->output("Emission"), out->input("Closure"));
shader = new Shader();
shader->name = "default_light";
@@ -245,7 +244,7 @@ void ShaderManager::add_default(Scene *scene)
closure->input("Color")->value = make_float3(0.8f, 0.8f, 0.8f);
out = graph->output();
- graph->connect(closure->output("Background"), out->input("Surface"));
+ graph->connect(closure->output("Background"), out->input("Closure"));
shader = new Shader();
shader->name = "default_background";
diff --git a/intern/cycles/render/shader.h b/intern/cycles/render/shader.h
index 45efa123ef6..17ffc75924b 100644
--- a/intern/cycles/render/shader.h
+++ b/intern/cycles/render/shader.h
@@ -39,8 +39,8 @@ struct float3;
/* Shader describing the appearance of a Mesh, Light or Background.
*
- * While there is only a single shader graph, it has three outputs: surface,
- * volume and displacement, that the shader manager will compile and execute
+ * While there is only a single shader graph, it has two outputs: shader,
+ * displacement, that the shader manager will compile and execute
* separately. */
class Shader {
@@ -65,11 +65,10 @@ public:
bool need_update_attributes;
/* information about shader after compiling */
- bool has_surface;
bool has_surface_emission;
bool has_surface_transparent;
- bool has_volume;
bool has_displacement;
+ bool has_volume;
/* requested mesh attributes */
AttributeRequestSet attributes;
diff --git a/intern/cycles/render/svm.cpp b/intern/cycles/render/svm.cpp
index a1687ae5e29..054989bbc28 100644
--- a/intern/cycles/render/svm.cpp
+++ b/intern/cycles/render/svm.cpp
@@ -107,7 +107,7 @@ SVMCompiler::SVMCompiler(ShaderManager *shader_manager_, ImageManager *image_man
image_manager = image_manager_;
sunsky = NULL;
max_stack_use = 0;
- current_type = SHADER_TYPE_SURFACE;
+ current_type = SHADER_TYPE_CLOSURE;
current_shader = NULL;
background = false;
mix_weight_offset = SVM_STACK_INVALID;
@@ -467,6 +467,8 @@ void SVMCompiler::generate_closure(ShaderNode *node, set<ShaderNode*>& done)
current_shader->has_surface_emission = true;
if(node->name == ustring("transparent"))
current_shader->has_surface_transparent = true;
+ if(node->name == ustring("volume"))
+ current_shader->has_volume = true;
/* end node is added outside of this */
}
@@ -577,10 +579,8 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
ShaderNode *node = graph->output();
ShaderInput *clin = NULL;
- if(type == SHADER_TYPE_SURFACE)
- clin = node->input("Surface");
- else if(type == SHADER_TYPE_VOLUME)
- clin = node->input("Volume");
+ if(type == SHADER_TYPE_CLOSURE)
+ clin = node->input("Closure");
else if(type == SHADER_TYPE_DISPLACEMENT)
clin = node->input("Displacement");
else
@@ -599,15 +599,9 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
if(clin->link) {
bool generate = false;
- if(type == SHADER_TYPE_SURFACE) {
+ if(type == SHADER_TYPE_CLOSURE) {
/* generate surface shader */
generate = true;
- shader->has_surface = true;
- }
- else if(type == SHADER_TYPE_VOLUME) {
- /* generate volume shader */
- generate = true;
- shader->has_volume = true;
}
else if(type == SHADER_TYPE_DISPLACEMENT) {
/* generate displacement shader */
@@ -636,7 +630,7 @@ void SVMCompiler::compile(Shader *shader, vector<int4>& global_svm_nodes, int in
/* copy graph for shader with bump mapping */
ShaderNode *node = shader->graph->output();
- if(node->input("Surface")->link && node->input("Displacement")->link)
+ if(node->input("Closure")->link && node->input("Displacement")->link)
if(!shader->graph_bump)
shader->graph_bump = shader->graph->copy();
@@ -647,30 +641,23 @@ void SVMCompiler::compile(Shader *shader, vector<int4>& global_svm_nodes, int in
current_shader = shader;
- shader->has_surface = false;
shader->has_surface_emission = false;
shader->has_surface_transparent = false;
shader->has_volume = false;
shader->has_displacement = false;
/* generate surface shader */
- compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
+ compile_type(shader, shader->graph, SHADER_TYPE_CLOSURE);
global_svm_nodes[index*2 + 0].y = global_svm_nodes.size();
global_svm_nodes[index*2 + 1].y = global_svm_nodes.size();
global_svm_nodes.insert(global_svm_nodes.end(), svm_nodes.begin(), svm_nodes.end());
if(shader->graph_bump) {
- compile_type(shader, shader->graph_bump, SHADER_TYPE_SURFACE);
+ compile_type(shader, shader->graph_bump, SHADER_TYPE_CLOSURE);
global_svm_nodes[index*2 + 1].y = global_svm_nodes.size();
global_svm_nodes.insert(global_svm_nodes.end(), svm_nodes.begin(), svm_nodes.end());
}
- /* generate volume shader */
- compile_type(shader, shader->graph, SHADER_TYPE_VOLUME);
- global_svm_nodes[index*2 + 0].z = global_svm_nodes.size();
- global_svm_nodes[index*2 + 1].z = global_svm_nodes.size();
- global_svm_nodes.insert(global_svm_nodes.end(), svm_nodes.begin(), svm_nodes.end());
-
/* generate displacement shader */
compile_type(shader, shader->graph, SHADER_TYPE_DISPLACEMENT);
global_svm_nodes[index*2 + 0].w = global_svm_nodes.size();