diff options
Diffstat (limited to 'intern/cycles/render/nodes.cpp')
-rw-r--r-- | intern/cycles/render/nodes.cpp | 75 |
1 files changed, 50 insertions, 25 deletions
diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 7a39811cacd..69ae2078216 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -186,7 +186,7 @@ ShaderEnum ImageTextureNode::color_space_enum = color_space_init(); ShaderEnum ImageTextureNode::projection_enum = image_projection_init(); ImageTextureNode::ImageTextureNode() -: TextureNode("image_texture") +: ImageSlotTextureNode("image_texture") { image_manager = NULL; slot = -1; @@ -227,7 +227,7 @@ void ImageTextureNode::attributes(Shader *shader, AttributeRequestSet *attribute #ifdef WITH_PTEX /* todo: avoid loading other texture coordinates when using ptex, * and hide texture coordinate socket in the UI */ - if (shader->has_surface && string_endswith(filename, ".ptx")) { + if(shader->has_surface && string_endswith(filename, ".ptx")) { /* ptex */ attributes->add(ATTR_STD_PTEX_FACE_ID); attributes->add(ATTR_STD_PTEX_UV); @@ -380,7 +380,7 @@ ShaderEnum EnvironmentTextureNode::color_space_enum = color_space_init(); ShaderEnum EnvironmentTextureNode::projection_enum = env_projection_init(); EnvironmentTextureNode::EnvironmentTextureNode() -: TextureNode("environment_texture") +: ImageSlotTextureNode("environment_texture") { image_manager = NULL; slot = -1; @@ -417,7 +417,7 @@ ShaderNode *EnvironmentTextureNode::clone() const void EnvironmentTextureNode::attributes(Shader *shader, AttributeRequestSet *attributes) { #ifdef WITH_PTEX - if (shader->has_surface && string_endswith(filename, ".ptx")) { + if(shader->has_surface && string_endswith(filename, ".ptx")) { /* ptex */ attributes->add(ATTR_STD_PTEX_FACE_ID); attributes->add(ATTR_STD_PTEX_UV); @@ -632,7 +632,7 @@ static void sky_texture_precompute_new(SunSky *sunsky, float3 dir, float turbidi sky_state = arhosek_xyz_skymodelstate_alloc_init(turbidity, ground_albedo, solarElevation); /* Copy values from sky_state to SunSky */ - for (int i = 0; i < 9; ++i) { + for(int i = 0; i < 9; ++i) { sunsky->config_x[i] = (float)sky_state->configs[0][i]; sunsky->config_y[i] = (float)sky_state->configs[1][i]; sunsky->config_z[i] = (float)sky_state->configs[2][i]; @@ -1507,11 +1507,11 @@ ProxyNode::ProxyNode(ShaderSocketType type_) add_output("Output", type); } -void ProxyNode::compile(SVMCompiler& compiler) +void ProxyNode::compile(SVMCompiler& /*compiler*/) { } -void ProxyNode::compile(OSLCompiler& compiler) +void ProxyNode::compile(OSLCompiler& /*compiler*/) { } @@ -1520,6 +1520,8 @@ void ProxyNode::compile(OSLCompiler& compiler) BsdfNode::BsdfNode(bool scattering_) : ShaderNode("bsdf"), scattering(scattering_) { + special_type = SHADER_SPECIAL_TYPE_CLOSURE; + add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); add_input("Normal", SHADER_SOCKET_NORMAL, ShaderInput::NORMAL); add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); @@ -1587,7 +1589,7 @@ void BsdfNode::compile(SVMCompiler& compiler) compile(compiler, NULL, NULL); } -void BsdfNode::compile(OSLCompiler& compiler) +void BsdfNode::compile(OSLCompiler& /*compiler*/) { assert(0); } @@ -1609,6 +1611,7 @@ ShaderEnum AnisotropicBsdfNode::distribution_enum = aniso_distribution_init(); AnisotropicBsdfNode::AnisotropicBsdfNode() { + closure = CLOSURE_BSDF_MICROFACET_GGX_ANISO_ID; distribution = ustring("GGX"); add_input("Tangent", SHADER_SOCKET_VECTOR, ShaderInput::TANGENT); @@ -1661,6 +1664,7 @@ ShaderEnum GlossyBsdfNode::distribution_enum = glossy_distribution_init(); GlossyBsdfNode::GlossyBsdfNode() { + closure = CLOSURE_BSDF_MICROFACET_GGX_ID; distribution = ustring("GGX"); add_input("Roughness", SHADER_SOCKET_FLOAT, 0.2f); @@ -1699,6 +1703,7 @@ ShaderEnum GlassBsdfNode::distribution_enum = glass_distribution_init(); GlassBsdfNode::GlassBsdfNode() { + closure = CLOSURE_BSDF_SHARP_GLASS_ID; distribution = ustring("Sharp"); add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f); @@ -1738,6 +1743,7 @@ ShaderEnum RefractionBsdfNode::distribution_enum = refraction_distribution_init( RefractionBsdfNode::RefractionBsdfNode() { + closure = CLOSURE_BSDF_REFRACTION_ID; distribution = ustring("Sharp"); add_input("Roughness", SHADER_SOCKET_FLOAT, 0.0f); @@ -1776,6 +1782,7 @@ ShaderEnum ToonBsdfNode::component_enum = toon_component_init(); ToonBsdfNode::ToonBsdfNode() { + closure = CLOSURE_BSDF_DIFFUSE_TOON_ID; component = ustring("Diffuse"); add_input("Size", SHADER_SOCKET_FLOAT, 0.5f); @@ -1916,6 +1923,8 @@ bool SubsurfaceScatteringNode::has_bssrdf_bump() EmissionNode::EmissionNode() : ShaderNode("emission") { + special_type = SHADER_SPECIAL_TYPE_EMISSION; + add_input("Color", SHADER_SOCKET_COLOR, make_float3(0.8f, 0.8f, 0.8f)); add_input("Strength", SHADER_SOCKET_FLOAT, 10.0f); add_input("SurfaceMixWeight", SHADER_SOCKET_FLOAT, 0.0f, ShaderInput::USE_SVM); @@ -2078,7 +2087,7 @@ void VolumeNode::compile(SVMCompiler& compiler) compile(compiler, NULL, NULL); } -void VolumeNode::compile(OSLCompiler& compiler) +void VolumeNode::compile(OSLCompiler& /*compiler*/) { assert(0); } @@ -2135,6 +2144,7 @@ ShaderEnum HairBsdfNode::component_enum = hair_component_init(); HairBsdfNode::HairBsdfNode() { + closure = CLOSURE_BSDF_HAIR_REFLECTION_ID; component = ustring("Reflection"); add_input("Offset", SHADER_SOCKET_FLOAT); @@ -2248,10 +2258,15 @@ void GeometryNode::compile(SVMCompiler& compiler) out = output("Pointiness"); if(!out->links.empty()) { compiler.stack_assign(out); - compiler.add_node(attr_node, - ATTR_STD_POINTINESS, - out->stack_offset, - NODE_ATTR_FLOAT); + if(compiler.output_type() != SHADER_TYPE_VOLUME) { + compiler.add_node(attr_node, + ATTR_STD_POINTINESS, + out->stack_offset, + NODE_ATTR_FLOAT); + } + else { + compiler.add_node(NODE_VALUE_F, __float_as_int(0.0f), out->stack_offset); + } } } @@ -2442,7 +2457,7 @@ void UVMapNode::attributes(Shader *shader, AttributeRequestSet *attributes) if(shader->has_surface) { if(!from_dupli) { if(!output("UV")->links.empty()) { - if (attribute != "") + if(attribute != "") attributes->add(attribute); else attributes->add(ATTR_STD_UV); @@ -2475,7 +2490,7 @@ void UVMapNode::compile(SVMCompiler& compiler) compiler.add_node(texco_node, NODE_TEXCO_DUPLI_UV, out->stack_offset); } else { - if (attribute != "") + if(attribute != "") attr = compiler.attribute(attribute); else attr = compiler.attribute(ATTR_STD_UV); @@ -2916,7 +2931,7 @@ AddClosureNode::AddClosureNode() add_output("Closure", SHADER_SOCKET_CLOSURE); } -void AddClosureNode::compile(SVMCompiler& compiler) +void AddClosureNode::compile(SVMCompiler& /*compiler*/) { /* handled in the SVM compiler */ } @@ -2939,7 +2954,7 @@ MixClosureNode::MixClosureNode() add_output("Closure", SHADER_SOCKET_CLOSURE); } -void MixClosureNode::compile(SVMCompiler& compiler) +void MixClosureNode::compile(SVMCompiler& /*compiler*/) { /* handled in the SVM compiler */ } @@ -2977,7 +2992,7 @@ void MixClosureWeightNode::compile(SVMCompiler& compiler) weight1_out->stack_offset, weight2_out->stack_offset)); } -void MixClosureWeightNode::compile(OSLCompiler& compiler) +void MixClosureWeightNode::compile(OSLCompiler& /*compiler*/) { assert(0); } @@ -3647,9 +3662,17 @@ void BlackbodyNode::compile(SVMCompiler& compiler) ShaderInput *temperature_in = input("Temperature"); ShaderOutput *color_out = output("Color"); - compiler.stack_assign(temperature_in); compiler.stack_assign(color_out); - compiler.add_node(NODE_BLACKBODY, temperature_in->stack_offset, color_out->stack_offset); + + if(temperature_in->link == NULL) { + float3 color = svm_math_blackbody_color(temperature_in->value.x); + compiler.add_node(NODE_VALUE_V, color_out->stack_offset); + compiler.add_node(NODE_VALUE_V, color); + } + else { + compiler.stack_assign(temperature_in); + compiler.add_node(NODE_BLACKBODY, temperature_in->stack_offset, color_out->stack_offset); + } } void BlackbodyNode::compile(OSLCompiler& compiler) @@ -3747,7 +3770,7 @@ void MathNode::compile(SVMCompiler& compiler) value1_in->value.x, value2_in->value.x); if(use_clamp) { - optimized_value = clamp(optimized_value, 0.0f, 1.0f); + optimized_value = saturate(optimized_value); } compiler.add_node(NODE_VALUE_F, __float_as_int(optimized_value), @@ -3911,6 +3934,8 @@ BumpNode::BumpNode() { invert = false; + special_type = SHADER_SPECIAL_TYPE_BUMP; + /* this input is used by the user, but after graph transform it is no longer * used and moved to sampler center/x/y instead */ add_input("Height", SHADER_SOCKET_FLOAT); @@ -3987,7 +4012,7 @@ void RGBCurvesNode::compile(OSLCompiler& compiler) { float ramp[RAMP_TABLE_SIZE][3]; - for (int i = 0; i < RAMP_TABLE_SIZE; ++i) { + for(int i = 0; i < RAMP_TABLE_SIZE; ++i) { ramp[i][0] = curves[i].x; ramp[i][1] = curves[i].y; ramp[i][2] = curves[i].z; @@ -4025,7 +4050,7 @@ void VectorCurvesNode::compile(OSLCompiler& compiler) { float ramp[RAMP_TABLE_SIZE][3]; - for (int i = 0; i < RAMP_TABLE_SIZE; ++i) { + for(int i = 0; i < RAMP_TABLE_SIZE; ++i) { ramp[i][0] = curves[i].x; ramp[i][1] = curves[i].y; ramp[i][2] = curves[i].z; @@ -4075,7 +4100,7 @@ void RGBRampNode::compile(OSLCompiler& compiler) float ramp_color[RAMP_TABLE_SIZE][3]; float ramp_alpha[RAMP_TABLE_SIZE]; - for (int i = 0; i < RAMP_TABLE_SIZE; ++i) { + for(int i = 0; i < RAMP_TABLE_SIZE; ++i) { ramp_color[i][0] = ramp[i].x; ramp_color[i][1] = ramp[i].y; ramp_color[i][2] = ramp[i].z; @@ -4122,7 +4147,7 @@ OSLScriptNode::OSLScriptNode() special_type = SHADER_SPECIAL_TYPE_SCRIPT; } -void OSLScriptNode::compile(SVMCompiler& compiler) +void OSLScriptNode::compile(SVMCompiler& /*compiler*/) { /* doesn't work for SVM, obviously ... */ } |