forked from bartvdbraak/blender
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.
This commit is contained in:
parent
85818c8209
commit
7503a7edfb
@ -228,7 +228,7 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
|
|||||||
sub.prop(ccam, "aperture_rotation", text="Rotation")
|
sub.prop(ccam, "aperture_rotation", text="Rotation")
|
||||||
|
|
||||||
class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
|
class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
|
||||||
bl_label = "Surface"
|
bl_label = ""
|
||||||
bl_context = "material"
|
bl_context = "material"
|
||||||
bl_options = {'HIDE_HEADER'}
|
bl_options = {'HIDE_HEADER'}
|
||||||
|
|
||||||
@ -400,8 +400,8 @@ class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
|
|||||||
elif lamp.type == 'HEMI':
|
elif lamp.type == 'HEMI':
|
||||||
layout.label(text="Not supported, interpreted as sun lamp.")
|
layout.label(text="Not supported, interpreted as sun lamp.")
|
||||||
|
|
||||||
class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
|
class CyclesLamp_PT_shader(CyclesButtonsPanel, Panel):
|
||||||
bl_label = "Nodes"
|
bl_label = "Shader"
|
||||||
bl_context = "data"
|
bl_context = "data"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -412,10 +412,10 @@ class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
mat = context.lamp
|
mat = context.lamp
|
||||||
panel_node_draw(layout, mat, 'OUTPUT_LAMP', 'Surface')
|
panel_node_draw(layout, mat, 'OUTPUT_LAMP', 'Shader')
|
||||||
|
|
||||||
class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
|
class CyclesWorld_PT_shader(CyclesButtonsPanel, Panel):
|
||||||
bl_label = "Surface"
|
bl_label = "Shader"
|
||||||
bl_context = "world"
|
bl_context = "world"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -426,25 +426,10 @@ class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
mat = context.world
|
mat = context.world
|
||||||
panel_node_draw(layout, mat, 'OUTPUT_WORLD', 'Surface')
|
panel_node_draw(layout, mat, 'OUTPUT_WORLD', 'Shader')
|
||||||
|
|
||||||
class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
|
class CyclesMaterial_PT_shader(CyclesButtonsPanel, Panel):
|
||||||
bl_label = "Volume"
|
bl_label = "Shader"
|
||||||
bl_context = "world"
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
return context.world and CyclesButtonsPanel.poll(context)
|
|
||||||
|
|
||||||
def draw(self, context):
|
|
||||||
layout = self.layout
|
|
||||||
layout.active = False
|
|
||||||
|
|
||||||
world = context.world
|
|
||||||
panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
|
|
||||||
|
|
||||||
class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
|
|
||||||
bl_label = "Surface"
|
|
||||||
bl_context = "material"
|
bl_context = "material"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
@ -455,26 +440,7 @@ class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
|
|||||||
layout = self.layout
|
layout = self.layout
|
||||||
|
|
||||||
mat = context.material
|
mat = context.material
|
||||||
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface')
|
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Shader')
|
||||||
|
|
||||||
class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
|
|
||||||
bl_label = "Volume"
|
|
||||||
bl_context = "material"
|
|
||||||
|
|
||||||
@classmethod
|
|
||||||
def poll(cls, context):
|
|
||||||
return context.material and CyclesButtonsPanel.poll(context)
|
|
||||||
|
|
||||||
def draw(self, context):
|
|
||||||
layout = self.layout
|
|
||||||
layout.active = False
|
|
||||||
|
|
||||||
mat = context.material
|
|
||||||
cmat = mat.cycles
|
|
||||||
|
|
||||||
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume')
|
|
||||||
|
|
||||||
layout.prop(cmat, "homogeneous_volume")
|
|
||||||
|
|
||||||
class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
|
class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
|
||||||
bl_label = "Displacement"
|
bl_label = "Displacement"
|
||||||
|
@ -584,7 +584,7 @@ void BlenderSync::sync_materials()
|
|||||||
closure->input("Color")->value = get_float3(b_mat->diffuse_color());
|
closure->input("Color")->value = get_float3(b_mat->diffuse_color());
|
||||||
out = graph->output();
|
out = graph->output();
|
||||||
|
|
||||||
graph->connect(closure->output("BSDF"), out->input("Surface"));
|
graph->connect(closure->output("BSDF"), out->input("Closure"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* settings */
|
/* settings */
|
||||||
@ -625,7 +625,7 @@ void BlenderSync::sync_world()
|
|||||||
closure->input("Color")->value = get_float3(b_world.horizon_color());
|
closure->input("Color")->value = get_float3(b_world.horizon_color());
|
||||||
out = graph->output();
|
out = graph->output();
|
||||||
|
|
||||||
graph->connect(closure->output("Background"), out->input("Surface"));
|
graph->connect(closure->output("Background"), out->input("Closure"));
|
||||||
}
|
}
|
||||||
|
|
||||||
shader->set_graph(graph);
|
shader->set_graph(graph);
|
||||||
@ -675,7 +675,7 @@ void BlenderSync::sync_lamps()
|
|||||||
closure->input("Strength")->value.x = b_lamp->energy()*10.0f;
|
closure->input("Strength")->value.x = b_lamp->energy()*10.0f;
|
||||||
out = graph->output();
|
out = graph->output();
|
||||||
|
|
||||||
graph->connect(closure->output("Emission"), out->input("Surface"));
|
graph->connect(closure->output("Emission"), out->input("Closure"));
|
||||||
}
|
}
|
||||||
|
|
||||||
shader->set_graph(graph);
|
shader->set_graph(graph);
|
||||||
|
@ -482,7 +482,7 @@ __device void shader_eval_surface(KernelGlobals *kg, ShaderData *sd,
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef __SVM__
|
#ifdef __SVM__
|
||||||
svm_eval_nodes(kg, sd, SHADER_TYPE_SURFACE, randb, path_flag);
|
svm_eval_nodes(kg, sd, SHADER_TYPE_CLOSURE, randb, path_flag);
|
||||||
#else
|
#else
|
||||||
bsdf_diffuse_setup(sd, &sd->closure);
|
bsdf_diffuse_setup(sd, &sd->closure);
|
||||||
sd->closure.weight = make_float3(0.8f, 0.8f, 0.8f);
|
sd->closure.weight = make_float3(0.8f, 0.8f, 0.8f);
|
||||||
@ -500,7 +500,7 @@ __device float3 shader_eval_background(KernelGlobals *kg, ShaderData *sd, int pa
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
#ifdef __SVM__
|
#ifdef __SVM__
|
||||||
svm_eval_nodes(kg, sd, SHADER_TYPE_SURFACE, 0.0f, path_flag);
|
svm_eval_nodes(kg, sd, SHADER_TYPE_CLOSURE, 0.0f, path_flag);
|
||||||
|
|
||||||
#ifdef __MULTI_CLOSURE__
|
#ifdef __MULTI_CLOSURE__
|
||||||
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
|
float3 eval = make_float3(0.0f, 0.0f, 0.0f);
|
||||||
@ -562,7 +562,7 @@ __device void shader_eval_volume(KernelGlobals *kg, ShaderData *sd,
|
|||||||
#ifdef __OSL__
|
#ifdef __OSL__
|
||||||
OSLShader::eval_volume(kg, sd, randb, path_flag);
|
OSLShader::eval_volume(kg, sd, randb, path_flag);
|
||||||
#else
|
#else
|
||||||
svm_eval_nodes(kg, sd, SHADER_TYPE_VOLUME, randb, path_flag);
|
svm_eval_nodes(kg, sd, SHADER_TYPE_CLOSURE, randb, path_flag);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -32,9 +32,8 @@ set(osl_sources
|
|||||||
node_musgrave_texture.osl
|
node_musgrave_texture.osl
|
||||||
node_blend_weight_texture.osl
|
node_blend_weight_texture.osl
|
||||||
node_noise_texture.osl
|
node_noise_texture.osl
|
||||||
|
node_output_closure.osl
|
||||||
node_output_displacement.osl
|
node_output_displacement.osl
|
||||||
node_output_surface.osl
|
|
||||||
node_output_volume.osl
|
|
||||||
node_sky_texture.osl
|
node_sky_texture.osl
|
||||||
node_stucci_texture.osl
|
node_stucci_texture.osl
|
||||||
node_texture_coordinate.osl
|
node_texture_coordinate.osl
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
#include "stdosl.h"
|
#include "stdosl.h"
|
||||||
|
|
||||||
surface node_output_surface(closure color Surface = background())
|
surface node_output_surface(closure color Closure = background())
|
||||||
{
|
{
|
||||||
Ci = Surface;
|
Ci = Closure;
|
||||||
}
|
}
|
||||||
|
|
@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2011, Blender Foundation.
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or
|
|
||||||
* modify it under the terms of the GNU General Public License
|
|
||||||
* as published by the Free Software Foundation; either version 2
|
|
||||||
* of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software Foundation,
|
|
||||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "stdosl.h"
|
|
||||||
|
|
||||||
volume node_output_volume(closure color Volume = background())
|
|
||||||
{
|
|
||||||
Ci = Volume;
|
|
||||||
}
|
|
||||||
|
|
@ -218,8 +218,8 @@ void OSLShader::eval_surface(KernelGlobals *kg, ShaderData *sd, float randb, int
|
|||||||
/* execute shader for this point */
|
/* execute shader for this point */
|
||||||
int shader = sd->shader & SHADER_MASK;
|
int shader = sd->shader & SHADER_MASK;
|
||||||
|
|
||||||
if(kg->osl.surface_state[shader])
|
if(kg->osl.state[shader])
|
||||||
ctx->execute(OSL::pvt::ShadUseSurface, *(kg->osl.surface_state[shader]), *globals);
|
ctx->execute(OSL::pvt::ShadUseSurface, *(kg->osl.state[shader]), *globals);
|
||||||
|
|
||||||
/* flatten closure tree */
|
/* flatten closure tree */
|
||||||
sd->num_closure = 0;
|
sd->num_closure = 0;
|
||||||
@ -355,8 +355,8 @@ void OSLShader::eval_volume(KernelGlobals *kg, ShaderData *sd, float randb, int
|
|||||||
/* execute shader */
|
/* execute shader */
|
||||||
int shader = sd->shader & SHADER_MASK;
|
int shader = sd->shader & SHADER_MASK;
|
||||||
|
|
||||||
if(kg->osl.volume_state[shader])
|
if(kg->osl.state[shader])
|
||||||
ctx->execute(OSL::pvt::ShadUseSurface, *(kg->osl.volume_state[shader]), *globals);
|
ctx->execute(OSL::pvt::ShadUseSurface, *(kg->osl.state[shader]), *globals);
|
||||||
|
|
||||||
/* retrieve resulting closures */
|
/* retrieve resulting closures */
|
||||||
sd->osl_closure.volume_sample_sum = 0.0f;
|
sd->osl_closure.volume_sample_sum = 0.0f;
|
||||||
|
@ -166,8 +166,7 @@ __device_noinline void svm_eval_nodes(KernelGlobals *kg, ShaderData *sd, ShaderT
|
|||||||
|
|
||||||
switch(node.x) {
|
switch(node.x) {
|
||||||
case NODE_SHADER_JUMP: {
|
case NODE_SHADER_JUMP: {
|
||||||
if(type == SHADER_TYPE_SURFACE) offset = node.y;
|
if(type == SHADER_TYPE_CLOSURE) offset = node.y;
|
||||||
else if(type == SHADER_TYPE_VOLUME) offset = node.z;
|
|
||||||
else if(type == SHADER_TYPE_DISPLACEMENT) offset = node.w;
|
else if(type == SHADER_TYPE_DISPLACEMENT) offset = node.w;
|
||||||
else return;
|
else return;
|
||||||
break;
|
break;
|
||||||
|
@ -257,8 +257,7 @@ typedef enum NodeBlendWeightType {
|
|||||||
} NodeBlendWeightType;
|
} NodeBlendWeightType;
|
||||||
|
|
||||||
typedef enum ShaderType {
|
typedef enum ShaderType {
|
||||||
SHADER_TYPE_SURFACE,
|
SHADER_TYPE_CLOSURE,
|
||||||
SHADER_TYPE_VOLUME,
|
|
||||||
SHADER_TYPE_DISPLACEMENT
|
SHADER_TYPE_DISPLACEMENT
|
||||||
} ShaderType;
|
} ShaderType;
|
||||||
|
|
||||||
|
@ -1945,8 +1945,7 @@ void BlendWeightNode::compile(OSLCompiler& compiler)
|
|||||||
OutputNode::OutputNode()
|
OutputNode::OutputNode()
|
||||||
: ShaderNode("output")
|
: ShaderNode("output")
|
||||||
{
|
{
|
||||||
add_input("Surface", SHADER_SOCKET_CLOSURE);
|
add_input("Closure", SHADER_SOCKET_CLOSURE);
|
||||||
add_input("Volume", SHADER_SOCKET_CLOSURE);
|
|
||||||
add_input("Displacement", SHADER_SOCKET_FLOAT);
|
add_input("Displacement", SHADER_SOCKET_FLOAT);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1964,10 +1963,8 @@ void OutputNode::compile(SVMCompiler& compiler)
|
|||||||
|
|
||||||
void OutputNode::compile(OSLCompiler& compiler)
|
void OutputNode::compile(OSLCompiler& compiler)
|
||||||
{
|
{
|
||||||
if(compiler.output_type() == SHADER_TYPE_SURFACE)
|
if(compiler.output_type() == SHADER_TYPE_CLOSURE)
|
||||||
compiler.add(this, "node_output_surface");
|
compiler.add(this, "node_output_closure");
|
||||||
else if(compiler.output_type() == SHADER_TYPE_VOLUME)
|
|
||||||
compiler.add(this, "node_output_volume");
|
|
||||||
else if(compiler.output_type() == SHADER_TYPE_DISPLACEMENT)
|
else if(compiler.output_type() == SHADER_TYPE_DISPLACEMENT)
|
||||||
compiler.add(this, "node_output_displacement");
|
compiler.add(this, "node_output_displacement");
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ void OSLShaderManager::device_update(Device *device, DeviceScene *dscene, Scene
|
|||||||
/* setup shader engine */
|
/* setup shader engine */
|
||||||
og->ss = ss;
|
og->ss = ss;
|
||||||
int background_id = scene->shader_manager->get_shader_id(scene->default_background);
|
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;
|
og->use = true;
|
||||||
|
|
||||||
tls_create(OSLGlobals::ThreadData, og->thread_data);
|
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);
|
tls_delete(OSLGlobals::ThreadData, og->thread_data);
|
||||||
|
|
||||||
og->surface_state.clear();
|
og->state.clear();
|
||||||
og->volume_state.clear();
|
|
||||||
og->displacement_state.clear();
|
og->displacement_state.clear();
|
||||||
og->background_state.reset();
|
og->background_state.reset();
|
||||||
}
|
}
|
||||||
@ -139,7 +138,7 @@ void OSLShaderManager::device_free(Device *device, DeviceScene *dscene)
|
|||||||
OSLCompiler::OSLCompiler(void *shadingsys_)
|
OSLCompiler::OSLCompiler(void *shadingsys_)
|
||||||
{
|
{
|
||||||
shadingsys = shadingsys_;
|
shadingsys = shadingsys_;
|
||||||
current_type = SHADER_TYPE_SURFACE;
|
current_type = SHADER_TYPE_CLOSURE;
|
||||||
current_shader = NULL;
|
current_shader = NULL;
|
||||||
background = false;
|
background = false;
|
||||||
}
|
}
|
||||||
@ -170,9 +169,7 @@ bool OSLCompiler::node_skip_input(ShaderNode *node, ShaderInput *input)
|
|||||||
depending on the current shader type */
|
depending on the current shader type */
|
||||||
|
|
||||||
if(node->name == ustring("output")) {
|
if(node->name == ustring("output")) {
|
||||||
if(strcmp(input->name, "Surface") == 0 && current_type != SHADER_TYPE_SURFACE)
|
if(strcmp(input->name, "Closure") == 0 && current_type != SHADER_TYPE_CLOSURE)
|
||||||
return true;
|
|
||||||
if(strcmp(input->name, "Volume") == 0 && current_type != SHADER_TYPE_VOLUME)
|
|
||||||
return true;
|
return true;
|
||||||
if(strcmp(input->name, "Displacement") == 0 && current_type != SHADER_TYPE_DISPLACEMENT)
|
if(strcmp(input->name, "Displacement") == 0 && current_type != SHADER_TYPE_DISPLACEMENT)
|
||||||
return true;
|
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
|
* because "volume" and "displacement" don't work yet in OSL. the shaders
|
||||||
* work fine, but presumably these values would be used for more strict
|
* 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. */
|
* checking, so when that is fixed, we should update the code here too. */
|
||||||
if(current_type == SHADER_TYPE_SURFACE)
|
if(current_type == SHADER_TYPE_CLOSURE)
|
||||||
ss->Shader("surface", name, id(node).c_str());
|
|
||||||
else if(current_type == SHADER_TYPE_VOLUME)
|
|
||||||
ss->Shader("surface", name, id(node).c_str());
|
ss->Shader("surface", name, id(node).c_str());
|
||||||
else if(current_type == SHADER_TYPE_DISPLACEMENT)
|
else if(current_type == SHADER_TYPE_DISPLACEMENT)
|
||||||
ss->Shader("surface", name, id(node).c_str());
|
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;
|
current_shader->has_surface_emission = true;
|
||||||
if(node->name == ustring("transparent"))
|
if(node->name == ustring("transparent"))
|
||||||
current_shader->has_surface_transparent = true;
|
current_shader->has_surface_transparent = true;
|
||||||
|
if(node->name == ustring("volume"))
|
||||||
|
current_shader->has_volume = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
nodes_done = false;
|
nodes_done = false;
|
||||||
@ -365,15 +362,9 @@ void OSLCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
|
|||||||
ShaderNode *output = graph->output();
|
ShaderNode *output = graph->output();
|
||||||
set<ShaderNode*> dependencies;
|
set<ShaderNode*> dependencies;
|
||||||
|
|
||||||
if(type == SHADER_TYPE_SURFACE) {
|
if(type == SHADER_TYPE_CLOSURE) {
|
||||||
/* generate surface shader */
|
/* generate surface shader */
|
||||||
find_dependencies(dependencies, output->input("Surface"));
|
find_dependencies(dependencies, output->input("Closure"));
|
||||||
generate_nodes(dependencies);
|
|
||||||
output->compile(*this);
|
|
||||||
}
|
|
||||||
else if(type == SHADER_TYPE_VOLUME) {
|
|
||||||
/* generate volume shader */
|
|
||||||
find_dependencies(dependencies, output->input("Volume"));
|
|
||||||
generate_nodes(dependencies);
|
generate_nodes(dependencies);
|
||||||
output->compile(*this);
|
output->compile(*this);
|
||||||
}
|
}
|
||||||
@ -396,7 +387,7 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
|
|||||||
ShaderNode *output = (graph)? graph->output(): NULL;
|
ShaderNode *output = (graph)? graph->output(): NULL;
|
||||||
|
|
||||||
/* copy graph for shader with bump mapping */
|
/* 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)
|
if(!shader->graph_bump)
|
||||||
shader->graph_bump = shader->graph->copy();
|
shader->graph_bump = shader->graph->copy();
|
||||||
|
|
||||||
@ -407,46 +398,29 @@ void OSLCompiler::compile(OSLGlobals *og, Shader *shader)
|
|||||||
|
|
||||||
current_shader = shader;
|
current_shader = shader;
|
||||||
|
|
||||||
shader->has_surface = false;
|
|
||||||
shader->has_surface_emission = false;
|
shader->has_surface_emission = false;
|
||||||
shader->has_surface_transparent = false;
|
shader->has_surface_transparent = false;
|
||||||
shader->has_volume = false;
|
shader->has_volume = false;
|
||||||
shader->has_displacement = false;
|
shader->has_displacement = false;
|
||||||
|
|
||||||
/* generate surface shader */
|
/* generate surface shader */
|
||||||
if(graph && output->input("Surface")->link) {
|
if(graph && output->input("Closure")->link) {
|
||||||
compile_type(shader, shader->graph, SHADER_TYPE_SURFACE);
|
compile_type(shader, shader->graph, SHADER_TYPE_CLOSURE);
|
||||||
og->surface_state.push_back(ss->state());
|
og->state.push_back(ss->state());
|
||||||
|
|
||||||
if(shader->graph_bump) {
|
if(shader->graph_bump) {
|
||||||
ss->clear_state();
|
ss->clear_state();
|
||||||
compile_type(shader, shader->graph_bump, SHADER_TYPE_SURFACE);
|
compile_type(shader, shader->graph_bump, SHADER_TYPE_CLOSURE);
|
||||||
og->surface_state.push_back(ss->state());
|
og->state.push_back(ss->state());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
og->surface_state.push_back(ss->state());
|
og->state.push_back(ss->state());
|
||||||
|
|
||||||
ss->clear_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->volume_state.push_back(ss->state());
|
|
||||||
og->volume_state.push_back(ss->state());
|
|
||||||
ss->clear_state();
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
og->volume_state.push_back(OSL::ShadingAttribStateRef());
|
og->state.push_back(OSL::ShadingAttribStateRef());
|
||||||
og->volume_state.push_back(OSL::ShadingAttribStateRef());
|
og->state.push_back(OSL::ShadingAttribStateRef());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* generate displacement shader */
|
/* generate displacement shader */
|
||||||
|
@ -42,7 +42,6 @@ Shader::Shader()
|
|||||||
sample_as_light = true;
|
sample_as_light = true;
|
||||||
homogeneous_volume = false;
|
homogeneous_volume = false;
|
||||||
|
|
||||||
has_surface = false;
|
|
||||||
has_surface_transparent = false;
|
has_surface_transparent = false;
|
||||||
has_surface_emission = false;
|
has_surface_emission = false;
|
||||||
has_volume = 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);
|
closure->input("Color")->value = make_float3(0.8f, 0.8f, 0.8f);
|
||||||
out = graph->output();
|
out = graph->output();
|
||||||
|
|
||||||
graph->connect(closure->output("BSDF"), out->input("Surface"));
|
graph->connect(closure->output("BSDF"), out->input("Closure"));
|
||||||
|
|
||||||
shader = new Shader();
|
shader = new Shader();
|
||||||
shader->name = "default_surface";
|
shader->name = "default_surface";
|
||||||
@ -228,7 +227,7 @@ void ShaderManager::add_default(Scene *scene)
|
|||||||
closure->input("Strength")->value.x = 0.0f;
|
closure->input("Strength")->value.x = 0.0f;
|
||||||
out = graph->output();
|
out = graph->output();
|
||||||
|
|
||||||
graph->connect(closure->output("Emission"), out->input("Surface"));
|
graph->connect(closure->output("Emission"), out->input("Closure"));
|
||||||
|
|
||||||
shader = new Shader();
|
shader = new Shader();
|
||||||
shader->name = "default_light";
|
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);
|
closure->input("Color")->value = make_float3(0.8f, 0.8f, 0.8f);
|
||||||
out = graph->output();
|
out = graph->output();
|
||||||
|
|
||||||
graph->connect(closure->output("Background"), out->input("Surface"));
|
graph->connect(closure->output("Background"), out->input("Closure"));
|
||||||
|
|
||||||
shader = new Shader();
|
shader = new Shader();
|
||||||
shader->name = "default_background";
|
shader->name = "default_background";
|
||||||
|
@ -39,8 +39,8 @@ struct float3;
|
|||||||
|
|
||||||
/* Shader describing the appearance of a Mesh, Light or Background.
|
/* Shader describing the appearance of a Mesh, Light or Background.
|
||||||
*
|
*
|
||||||
* While there is only a single shader graph, it has three outputs: surface,
|
* While there is only a single shader graph, it has two outputs: shader,
|
||||||
* volume and displacement, that the shader manager will compile and execute
|
* displacement, that the shader manager will compile and execute
|
||||||
* separately. */
|
* separately. */
|
||||||
|
|
||||||
class Shader {
|
class Shader {
|
||||||
@ -65,11 +65,10 @@ public:
|
|||||||
bool need_update_attributes;
|
bool need_update_attributes;
|
||||||
|
|
||||||
/* information about shader after compiling */
|
/* information about shader after compiling */
|
||||||
bool has_surface;
|
|
||||||
bool has_surface_emission;
|
bool has_surface_emission;
|
||||||
bool has_surface_transparent;
|
bool has_surface_transparent;
|
||||||
bool has_volume;
|
|
||||||
bool has_displacement;
|
bool has_displacement;
|
||||||
|
bool has_volume;
|
||||||
|
|
||||||
/* requested mesh attributes */
|
/* requested mesh attributes */
|
||||||
AttributeRequestSet attributes;
|
AttributeRequestSet attributes;
|
||||||
|
@ -107,7 +107,7 @@ SVMCompiler::SVMCompiler(ShaderManager *shader_manager_, ImageManager *image_man
|
|||||||
image_manager = image_manager_;
|
image_manager = image_manager_;
|
||||||
sunsky = NULL;
|
sunsky = NULL;
|
||||||
max_stack_use = 0;
|
max_stack_use = 0;
|
||||||
current_type = SHADER_TYPE_SURFACE;
|
current_type = SHADER_TYPE_CLOSURE;
|
||||||
current_shader = NULL;
|
current_shader = NULL;
|
||||||
background = false;
|
background = false;
|
||||||
mix_weight_offset = SVM_STACK_INVALID;
|
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;
|
current_shader->has_surface_emission = true;
|
||||||
if(node->name == ustring("transparent"))
|
if(node->name == ustring("transparent"))
|
||||||
current_shader->has_surface_transparent = true;
|
current_shader->has_surface_transparent = true;
|
||||||
|
if(node->name == ustring("volume"))
|
||||||
|
current_shader->has_volume = true;
|
||||||
|
|
||||||
/* end node is added outside of this */
|
/* 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();
|
ShaderNode *node = graph->output();
|
||||||
ShaderInput *clin = NULL;
|
ShaderInput *clin = NULL;
|
||||||
|
|
||||||
if(type == SHADER_TYPE_SURFACE)
|
if(type == SHADER_TYPE_CLOSURE)
|
||||||
clin = node->input("Surface");
|
clin = node->input("Closure");
|
||||||
else if(type == SHADER_TYPE_VOLUME)
|
|
||||||
clin = node->input("Volume");
|
|
||||||
else if(type == SHADER_TYPE_DISPLACEMENT)
|
else if(type == SHADER_TYPE_DISPLACEMENT)
|
||||||
clin = node->input("Displacement");
|
clin = node->input("Displacement");
|
||||||
else
|
else
|
||||||
@ -599,15 +599,9 @@ void SVMCompiler::compile_type(Shader *shader, ShaderGraph *graph, ShaderType ty
|
|||||||
|
|
||||||
if(clin->link) {
|
if(clin->link) {
|
||||||
bool generate = false;
|
bool generate = false;
|
||||||
if(type == SHADER_TYPE_SURFACE) {
|
if(type == SHADER_TYPE_CLOSURE) {
|
||||||
/* generate surface shader */
|
/* generate surface shader */
|
||||||
generate = true;
|
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) {
|
else if(type == SHADER_TYPE_DISPLACEMENT) {
|
||||||
/* generate displacement shader */
|
/* 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 */
|
/* copy graph for shader with bump mapping */
|
||||||
ShaderNode *node = shader->graph->output();
|
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)
|
if(!shader->graph_bump)
|
||||||
shader->graph_bump = shader->graph->copy();
|
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;
|
current_shader = shader;
|
||||||
|
|
||||||
shader->has_surface = false;
|
|
||||||
shader->has_surface_emission = false;
|
shader->has_surface_emission = false;
|
||||||
shader->has_surface_transparent = false;
|
shader->has_surface_transparent = false;
|
||||||
shader->has_volume = false;
|
shader->has_volume = false;
|
||||||
shader->has_displacement = false;
|
shader->has_displacement = false;
|
||||||
|
|
||||||
/* generate surface shader */
|
/* 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 + 0].y = global_svm_nodes.size();
|
||||||
global_svm_nodes[index*2 + 1].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());
|
global_svm_nodes.insert(global_svm_nodes.end(), svm_nodes.begin(), svm_nodes.end());
|
||||||
|
|
||||||
if(shader->graph_bump) {
|
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[index*2 + 1].y = global_svm_nodes.size();
|
||||||
global_svm_nodes.insert(global_svm_nodes.end(), svm_nodes.begin(), svm_nodes.end());
|
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 */
|
/* generate displacement shader */
|
||||||
compile_type(shader, shader->graph, SHADER_TYPE_DISPLACEMENT);
|
compile_type(shader, shader->graph, SHADER_TYPE_DISPLACEMENT);
|
||||||
global_svm_nodes[index*2 + 0].w = global_svm_nodes.size();
|
global_svm_nodes[index*2 + 0].w = global_svm_nodes.size();
|
||||||
|
@ -2086,6 +2086,9 @@ static void ntree_tmp_cycles_version_patch(bNodeTree *ntree)
|
|||||||
if(strcmp(sock->name, "Closure2") == 0)
|
if(strcmp(sock->name, "Closure2") == 0)
|
||||||
strcpy(sock->name, "Shader2");
|
strcpy(sock->name, "Shader2");
|
||||||
|
|
||||||
|
if(strcmp(sock->name, "Surface") == 0)
|
||||||
|
strcpy(sock->name, "Shader");
|
||||||
|
|
||||||
if(strcmp(sock->name, "Fresnel") == 0) {
|
if(strcmp(sock->name, "Fresnel") == 0) {
|
||||||
strcpy(sock->name, "IOR");
|
strcpy(sock->name, "IOR");
|
||||||
sock->ns.vec[0] = 1.0f/MAX2(1.0f - sock->ns.vec[0], 1e-5f);
|
sock->ns.vec[0] = 1.0f/MAX2(1.0f - sock->ns.vec[0], 1e-5f);
|
||||||
|
@ -2114,8 +2114,8 @@ void node_light_path(
|
|||||||
|
|
||||||
/* output */
|
/* output */
|
||||||
|
|
||||||
void node_output_material(vec4 surface, vec4 volume, float displacement, out vec4 result)
|
void node_output_material(vec4 shader, float displacement, out vec4 result)
|
||||||
{
|
{
|
||||||
result = surface;
|
result = shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -32,7 +32,7 @@
|
|||||||
/* **************** OUTPUT ******************** */
|
/* **************** OUTPUT ******************** */
|
||||||
|
|
||||||
static bNodeSocketTemplate sh_node_output_lamp_in[]= {
|
static bNodeSocketTemplate sh_node_output_lamp_in[]= {
|
||||||
{ SOCK_SHADER, 1, "Surface", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
{ SOCK_SHADER, 1, "Shader"},
|
||||||
{ -1, 0, "" }
|
{ -1, 0, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
/* **************** OUTPUT ******************** */
|
/* **************** OUTPUT ******************** */
|
||||||
|
|
||||||
static bNodeSocketTemplate sh_node_output_material_in[]= {
|
static bNodeSocketTemplate sh_node_output_material_in[]= {
|
||||||
{ SOCK_SHADER, 1, "Surface"},
|
{ SOCK_SHADER, 1, "Shader"},
|
||||||
{ SOCK_SHADER, 1, "Volume"},
|
|
||||||
{ SOCK_FLOAT, 1, "Displacement", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
|
{ SOCK_FLOAT, 1, "Displacement", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, PROP_NONE, SOCK_HIDE_VALUE},
|
||||||
{ -1, 0, "" }
|
{ -1, 0, "" }
|
||||||
};
|
};
|
||||||
|
@ -32,8 +32,7 @@
|
|||||||
/* **************** OUTPUT ******************** */
|
/* **************** OUTPUT ******************** */
|
||||||
|
|
||||||
static bNodeSocketTemplate sh_node_output_world_in[]= {
|
static bNodeSocketTemplate sh_node_output_world_in[]= {
|
||||||
{ SOCK_SHADER, 1, "Surface", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
{ SOCK_SHADER, 1, "Shader"},
|
||||||
{ SOCK_SHADER, 1, "Volume", 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f},
|
|
||||||
{ -1, 0, "" }
|
{ -1, 0, "" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user