Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/render/nodes.cpp
| Show First 20 Lines • Show All 2,730 Lines • ▼ Show 20 Lines | NODE_DEFINE(PrincipledBsdfNode) | ||||
| static NodeEnum distribution_enum; | static NodeEnum distribution_enum; | ||||
| distribution_enum.insert("GGX", CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID); | distribution_enum.insert("GGX", CLOSURE_BSDF_MICROFACET_GGX_GLASS_ID); | ||||
| distribution_enum.insert("Multiscatter GGX", CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID); | distribution_enum.insert("Multiscatter GGX", CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID); | ||||
| SOCKET_ENUM( | SOCKET_ENUM( | ||||
| distribution, "Distribution", distribution_enum, CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID); | distribution, "Distribution", distribution_enum, CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID); | ||||
| static NodeEnum subsurface_method_enum; | static NodeEnum subsurface_method_enum; | ||||
| subsurface_method_enum.insert("burley", CLOSURE_BSSRDF_PRINCIPLED_ID); | subsurface_method_enum.insert("random_walk_fixed_radius", | ||||
| subsurface_method_enum.insert("random_walk", CLOSURE_BSSRDF_PRINCIPLED_RANDOM_WALK_ID); | CLOSURE_BSSRDF_RANDOM_WALK_FIXED_RADIUS_ID); | ||||
| subsurface_method_enum.insert("random_walk", CLOSURE_BSSRDF_RANDOM_WALK_ID); | |||||
| SOCKET_ENUM(subsurface_method, | SOCKET_ENUM(subsurface_method, | ||||
| "Subsurface Method", | "Subsurface Method", | ||||
| subsurface_method_enum, | subsurface_method_enum, | ||||
| CLOSURE_BSSRDF_PRINCIPLED_ID); | CLOSURE_BSSRDF_RANDOM_WALK_ID); | ||||
| SOCKET_IN_COLOR(base_color, "Base Color", make_float3(0.8f, 0.8f, 0.8f)); | SOCKET_IN_COLOR(base_color, "Base Color", make_float3(0.8f, 0.8f, 0.8f)); | ||||
| SOCKET_IN_COLOR(subsurface_color, "Subsurface Color", make_float3(0.8f, 0.8f, 0.8f)); | SOCKET_IN_COLOR(subsurface_color, "Subsurface Color", make_float3(0.8f, 0.8f, 0.8f)); | ||||
| SOCKET_IN_FLOAT(metallic, "Metallic", 0.0f); | SOCKET_IN_FLOAT(metallic, "Metallic", 0.0f); | ||||
| SOCKET_IN_FLOAT(subsurface, "Subsurface", 0.0f); | SOCKET_IN_FLOAT(subsurface, "Subsurface", 0.0f); | ||||
| SOCKET_IN_VECTOR(subsurface_radius, "Subsurface Radius", make_float3(0.1f, 0.1f, 0.1f)); | SOCKET_IN_VECTOR(subsurface_radius, "Subsurface Radius", make_float3(0.1f, 0.1f, 0.1f)); | ||||
| SOCKET_IN_FLOAT(subsurface_ior, "Subsurface IOR", 1.4f); | |||||
| SOCKET_IN_FLOAT(subsurface_anisotropy, "Subsurface Anisotropy", 0.0f); | |||||
| SOCKET_IN_FLOAT(specular, "Specular", 0.0f); | SOCKET_IN_FLOAT(specular, "Specular", 0.0f); | ||||
| SOCKET_IN_FLOAT(roughness, "Roughness", 0.5f); | SOCKET_IN_FLOAT(roughness, "Roughness", 0.5f); | ||||
| SOCKET_IN_FLOAT(specular_tint, "Specular Tint", 0.0f); | SOCKET_IN_FLOAT(specular_tint, "Specular Tint", 0.0f); | ||||
| SOCKET_IN_FLOAT(anisotropic, "Anisotropic", 0.0f); | SOCKET_IN_FLOAT(anisotropic, "Anisotropic", 0.0f); | ||||
| SOCKET_IN_FLOAT(sheen, "Sheen", 0.0f); | SOCKET_IN_FLOAT(sheen, "Sheen", 0.0f); | ||||
| SOCKET_IN_FLOAT(sheen_tint, "Sheen Tint", 0.0f); | SOCKET_IN_FLOAT(sheen_tint, "Sheen Tint", 0.0f); | ||||
| SOCKET_IN_FLOAT(clearcoat, "Clearcoat", 0.0f); | SOCKET_IN_FLOAT(clearcoat, "Clearcoat", 0.0f); | ||||
| SOCKET_IN_FLOAT(clearcoat_roughness, "Clearcoat Roughness", 0.03f); | SOCKET_IN_FLOAT(clearcoat_roughness, "Clearcoat Roughness", 0.03f); | ||||
| ▲ Show 20 Lines • Show All 93 Lines • ▼ Show 20 Lines | void PrincipledBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes) | ||||
| ShaderNode::attributes(shader, attributes); | ShaderNode::attributes(shader, attributes); | ||||
| } | } | ||||
| void PrincipledBsdfNode::compile(SVMCompiler &compiler, | void PrincipledBsdfNode::compile(SVMCompiler &compiler, | ||||
| ShaderInput *p_metallic, | ShaderInput *p_metallic, | ||||
| ShaderInput *p_subsurface, | ShaderInput *p_subsurface, | ||||
| ShaderInput *p_subsurface_radius, | ShaderInput *p_subsurface_radius, | ||||
| ShaderInput *p_subsurface_ior, | |||||
| ShaderInput *p_subsurface_anisotropy, | |||||
| ShaderInput *p_specular, | ShaderInput *p_specular, | ||||
| ShaderInput *p_roughness, | ShaderInput *p_roughness, | ||||
| ShaderInput *p_specular_tint, | ShaderInput *p_specular_tint, | ||||
| ShaderInput *p_anisotropic, | ShaderInput *p_anisotropic, | ||||
| ShaderInput *p_sheen, | ShaderInput *p_sheen, | ||||
| ShaderInput *p_sheen_tint, | ShaderInput *p_sheen_tint, | ||||
| ShaderInput *p_clearcoat, | ShaderInput *p_clearcoat, | ||||
| ShaderInput *p_clearcoat_roughness, | ShaderInput *p_clearcoat_roughness, | ||||
| Show All 23 Lines | void PrincipledBsdfNode::compile(SVMCompiler &compiler, | ||||
| int sheen_tint_offset = compiler.stack_assign(p_sheen_tint); | int sheen_tint_offset = compiler.stack_assign(p_sheen_tint); | ||||
| int clearcoat_offset = compiler.stack_assign(p_clearcoat); | int clearcoat_offset = compiler.stack_assign(p_clearcoat); | ||||
| int clearcoat_roughness_offset = compiler.stack_assign(p_clearcoat_roughness); | int clearcoat_roughness_offset = compiler.stack_assign(p_clearcoat_roughness); | ||||
| int ior_offset = compiler.stack_assign(p_ior); | int ior_offset = compiler.stack_assign(p_ior); | ||||
| int transmission_offset = compiler.stack_assign(p_transmission); | int transmission_offset = compiler.stack_assign(p_transmission); | ||||
| int transmission_roughness_offset = compiler.stack_assign(p_transmission_roughness); | int transmission_roughness_offset = compiler.stack_assign(p_transmission_roughness); | ||||
| int anisotropic_rotation_offset = compiler.stack_assign(p_anisotropic_rotation); | int anisotropic_rotation_offset = compiler.stack_assign(p_anisotropic_rotation); | ||||
| int subsurface_radius_offset = compiler.stack_assign(p_subsurface_radius); | int subsurface_radius_offset = compiler.stack_assign(p_subsurface_radius); | ||||
| int subsurface_ior_offset = compiler.stack_assign(p_subsurface_ior); | |||||
| int subsurface_anisotropy_offset = compiler.stack_assign(p_subsurface_anisotropy); | |||||
| compiler.add_node(NODE_CLOSURE_BSDF, | compiler.add_node(NODE_CLOSURE_BSDF, | ||||
| compiler.encode_uchar4(closure, | compiler.encode_uchar4(closure, | ||||
| compiler.stack_assign(p_metallic), | compiler.stack_assign(p_metallic), | ||||
| compiler.stack_assign(p_subsurface), | compiler.stack_assign(p_subsurface), | ||||
| compiler.closure_mix_weight_offset()), | compiler.closure_mix_weight_offset()), | ||||
| __float_as_int((p_metallic) ? get_float(p_metallic->socket_type) : 0.0f), | __float_as_int((p_metallic) ? get_float(p_metallic->socket_type) : 0.0f), | ||||
| __float_as_int((p_subsurface) ? get_float(p_subsurface->socket_type) : 0.0f)); | __float_as_int((p_subsurface) ? get_float(p_subsurface->socket_type) : 0.0f)); | ||||
| Show All 17 Lines | void PrincipledBsdfNode::compile(SVMCompiler &compiler, | ||||
| float3 bc_default = get_float3(base_color_in->socket_type); | float3 bc_default = get_float3(base_color_in->socket_type); | ||||
| compiler.add_node( | compiler.add_node( | ||||
| ((base_color_in->link) ? compiler.stack_assign(base_color_in) : SVM_STACK_INVALID), | ((base_color_in->link) ? compiler.stack_assign(base_color_in) : SVM_STACK_INVALID), | ||||
| __float_as_int(bc_default.x), | __float_as_int(bc_default.x), | ||||
| __float_as_int(bc_default.y), | __float_as_int(bc_default.y), | ||||
| __float_as_int(bc_default.z)); | __float_as_int(bc_default.z)); | ||||
| compiler.add_node( | compiler.add_node(clearcoat_normal_offset, | ||||
| clearcoat_normal_offset, subsurface_radius_offset, SVM_STACK_INVALID, SVM_STACK_INVALID); | subsurface_radius_offset, | ||||
| subsurface_ior_offset, | |||||
| subsurface_anisotropy_offset); | |||||
| float3 ss_default = get_float3(subsurface_color_in->socket_type); | float3 ss_default = get_float3(subsurface_color_in->socket_type); | ||||
| compiler.add_node(((subsurface_color_in->link) ? compiler.stack_assign(subsurface_color_in) : | compiler.add_node(((subsurface_color_in->link) ? compiler.stack_assign(subsurface_color_in) : | ||||
| SVM_STACK_INVALID), | SVM_STACK_INVALID), | ||||
| __float_as_int(ss_default.x), | __float_as_int(ss_default.x), | ||||
| __float_as_int(ss_default.y), | __float_as_int(ss_default.y), | ||||
| __float_as_int(ss_default.z)); | __float_as_int(ss_default.z)); | ||||
| } | } | ||||
| bool PrincipledBsdfNode::has_integrator_dependency() | bool PrincipledBsdfNode::has_integrator_dependency() | ||||
| { | { | ||||
| ShaderInput *roughness_input = input("Roughness"); | ShaderInput *roughness_input = input("Roughness"); | ||||
| return !roughness_input->link && roughness <= 1e-4f; | return !roughness_input->link && roughness <= 1e-4f; | ||||
| } | } | ||||
| void PrincipledBsdfNode::compile(SVMCompiler &compiler) | void PrincipledBsdfNode::compile(SVMCompiler &compiler) | ||||
| { | { | ||||
| compile(compiler, | compile(compiler, | ||||
| input("Metallic"), | input("Metallic"), | ||||
| input("Subsurface"), | input("Subsurface"), | ||||
| input("Subsurface Radius"), | input("Subsurface Radius"), | ||||
| input("Subsurface IOR"), | |||||
| input("Subsurface Anisotropy"), | |||||
| input("Specular"), | input("Specular"), | ||||
| input("Roughness"), | input("Roughness"), | ||||
| input("Specular Tint"), | input("Specular Tint"), | ||||
| input("Anisotropic"), | input("Anisotropic"), | ||||
| input("Sheen"), | input("Sheen"), | ||||
| input("Sheen Tint"), | input("Sheen Tint"), | ||||
| input("Clearcoat"), | input("Clearcoat"), | ||||
| input("Clearcoat Roughness"), | input("Clearcoat Roughness"), | ||||
| ▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | |||||
| NODE_DEFINE(SubsurfaceScatteringNode) | NODE_DEFINE(SubsurfaceScatteringNode) | ||||
| { | { | ||||
| NodeType *type = NodeType::add("subsurface_scattering", create, NodeType::SHADER); | NodeType *type = NodeType::add("subsurface_scattering", create, NodeType::SHADER); | ||||
| SOCKET_IN_COLOR(color, "Color", make_float3(0.8f, 0.8f, 0.8f)); | SOCKET_IN_COLOR(color, "Color", make_float3(0.8f, 0.8f, 0.8f)); | ||||
| SOCKET_IN_NORMAL(normal, "Normal", zero_float3(), SocketType::LINK_NORMAL); | SOCKET_IN_NORMAL(normal, "Normal", zero_float3(), SocketType::LINK_NORMAL); | ||||
| SOCKET_IN_FLOAT(surface_mix_weight, "SurfaceMixWeight", 0.0f, SocketType::SVM_INTERNAL); | SOCKET_IN_FLOAT(surface_mix_weight, "SurfaceMixWeight", 0.0f, SocketType::SVM_INTERNAL); | ||||
| static NodeEnum falloff_enum; | static NodeEnum method_enum; | ||||
| falloff_enum.insert("cubic", CLOSURE_BSSRDF_CUBIC_ID); | method_enum.insert("random_walk_fixed_radius", CLOSURE_BSSRDF_RANDOM_WALK_FIXED_RADIUS_ID); | ||||
| falloff_enum.insert("gaussian", CLOSURE_BSSRDF_GAUSSIAN_ID); | method_enum.insert("random_walk", CLOSURE_BSSRDF_RANDOM_WALK_ID); | ||||
| falloff_enum.insert("burley", CLOSURE_BSSRDF_BURLEY_ID); | SOCKET_ENUM(method, "Method", method_enum, CLOSURE_BSSRDF_RANDOM_WALK_ID); | ||||
| falloff_enum.insert("random_walk", CLOSURE_BSSRDF_RANDOM_WALK_ID); | |||||
| SOCKET_ENUM(falloff, "Falloff", falloff_enum, CLOSURE_BSSRDF_BURLEY_ID); | |||||
| SOCKET_IN_FLOAT(scale, "Scale", 0.01f); | SOCKET_IN_FLOAT(scale, "Scale", 0.01f); | ||||
| SOCKET_IN_VECTOR(radius, "Radius", make_float3(0.1f, 0.1f, 0.1f)); | SOCKET_IN_VECTOR(radius, "Radius", make_float3(0.1f, 0.1f, 0.1f)); | ||||
| SOCKET_IN_FLOAT(sharpness, "Sharpness", 0.0f); | |||||
| SOCKET_IN_FLOAT(texture_blur, "Texture Blur", 1.0f); | SOCKET_IN_FLOAT(subsurface_ior, "IOR", 1.4f); | ||||
| SOCKET_IN_FLOAT(subsurface_anisotropy, "Anisotropy", 0.0f); | |||||
| SOCKET_OUT_CLOSURE(BSSRDF, "BSSRDF"); | SOCKET_OUT_CLOSURE(BSSRDF, "BSSRDF"); | ||||
| return type; | return type; | ||||
| } | } | ||||
| SubsurfaceScatteringNode::SubsurfaceScatteringNode() : BsdfNode(get_node_type()) | SubsurfaceScatteringNode::SubsurfaceScatteringNode() : BsdfNode(get_node_type()) | ||||
| { | { | ||||
| closure = falloff; | closure = method; | ||||
| } | } | ||||
| void SubsurfaceScatteringNode::compile(SVMCompiler &compiler) | void SubsurfaceScatteringNode::compile(SVMCompiler &compiler) | ||||
| { | { | ||||
| closure = falloff; | closure = method; | ||||
| BsdfNode::compile( | BsdfNode::compile(compiler, input("Scale"), input("IOR"), input("Radius"), input("Anisotropy")); | ||||
| compiler, input("Scale"), input("Texture Blur"), input("Radius"), input("Sharpness")); | |||||
| } | } | ||||
| void SubsurfaceScatteringNode::compile(OSLCompiler &compiler) | void SubsurfaceScatteringNode::compile(OSLCompiler &compiler) | ||||
| { | { | ||||
| closure = falloff; | closure = method; | ||||
| compiler.parameter(this, "falloff"); | compiler.parameter(this, "method"); | ||||
| compiler.add(this, "node_subsurface_scattering"); | compiler.add(this, "node_subsurface_scattering"); | ||||
| } | } | ||||
| bool SubsurfaceScatteringNode::has_bssrdf_bump() | bool SubsurfaceScatteringNode::has_bssrdf_bump() | ||||
| { | { | ||||
| /* detect if anything is plugged into the normal input besides the default */ | /* detect if anything is plugged into the normal input besides the default */ | ||||
| ShaderInput *normal_in = input("Normal"); | ShaderInput *normal_in = input("Normal"); | ||||
| return (normal_in->link && | return (normal_in->link && | ||||
| ▲ Show 20 Lines • Show All 690 Lines • ▼ Show 20 Lines | void GeometryNode::compile(OSLCompiler &compiler) | ||||
| else if (bump == SHADER_BUMP_DY) | else if (bump == SHADER_BUMP_DY) | ||||
| compiler.parameter("bump_offset", "dy"); | compiler.parameter("bump_offset", "dy"); | ||||
| else | else | ||||
| compiler.parameter("bump_offset", "center"); | compiler.parameter("bump_offset", "center"); | ||||
| compiler.add(this, "node_geometry"); | compiler.add(this, "node_geometry"); | ||||
| } | } | ||||
| int GeometryNode::get_group() | |||||
| { | |||||
| ShaderOutput *out; | |||||
| int result = ShaderNode::get_group(); | |||||
| /* Backfacing uses NODE_LIGHT_PATH */ | |||||
| out = output("Backfacing"); | |||||
| if (!out->links.empty()) { | |||||
| result = max(result, NODE_GROUP_LEVEL_1); | |||||
| } | |||||
| return result; | |||||
| } | |||||
| /* TextureCoordinate */ | /* TextureCoordinate */ | ||||
| NODE_DEFINE(TextureCoordinateNode) | NODE_DEFINE(TextureCoordinateNode) | ||||
| { | { | ||||
| NodeType *type = NodeType::add("texture_coordinate", create, NodeType::SHADER); | NodeType *type = NodeType::add("texture_coordinate", create, NodeType::SHADER); | ||||
| SOCKET_BOOLEAN(from_dupli, "From Dupli", false); | SOCKET_BOOLEAN(from_dupli, "From Dupli", false); | ||||
| SOCKET_BOOLEAN(use_transform, "Use Transform", false); | SOCKET_BOOLEAN(use_transform, "Use Transform", false); | ||||
| ▲ Show 20 Lines • Show All 2,110 Lines • ▼ Show 20 Lines | NODE_DEFINE(OutputAOVNode) | ||||
| SOCKET_STRING(name, "AOV Name", ustring("")); | SOCKET_STRING(name, "AOV Name", ustring("")); | ||||
| return type; | return type; | ||||
| } | } | ||||
| OutputAOVNode::OutputAOVNode() : ShaderNode(get_node_type()) | OutputAOVNode::OutputAOVNode() : ShaderNode(get_node_type()) | ||||
| { | { | ||||
| special_type = SHADER_SPECIAL_TYPE_OUTPUT_AOV; | special_type = SHADER_SPECIAL_TYPE_OUTPUT_AOV; | ||||
| slot = -1; | offset = -1; | ||||
| } | } | ||||
| void OutputAOVNode::simplify_settings(Scene *scene) | void OutputAOVNode::simplify_settings(Scene *scene) | ||||
| { | { | ||||
| slot = scene->film->get_aov_offset(scene, name.string(), is_color); | offset = scene->film->get_aov_offset(scene, name.string(), is_color); | ||||
| if (slot == -1) { | if (offset == -1) { | ||||
| slot = scene->film->get_aov_offset(scene, name.string(), is_color); | offset = scene->film->get_aov_offset(scene, name.string(), is_color); | ||||
| } | } | ||||
| if (slot == -1 || is_color) { | if (offset == -1 || is_color) { | ||||
| input("Value")->disconnect(); | input("Value")->disconnect(); | ||||
| } | } | ||||
| if (slot == -1 || !is_color) { | if (offset == -1 || !is_color) { | ||||
| input("Color")->disconnect(); | input("Color")->disconnect(); | ||||
| } | } | ||||
| } | } | ||||
| void OutputAOVNode::compile(SVMCompiler &compiler) | void OutputAOVNode::compile(SVMCompiler &compiler) | ||||
| { | { | ||||
| assert(slot >= 0); | assert(offset >= 0); | ||||
| if (is_color) { | if (is_color) { | ||||
| compiler.add_node(NODE_AOV_COLOR, compiler.stack_assign(input("Color")), slot); | compiler.add_node(NODE_AOV_COLOR, compiler.stack_assign(input("Color")), offset); | ||||
| } | } | ||||
| else { | else { | ||||
| compiler.add_node(NODE_AOV_VALUE, compiler.stack_assign(input("Value")), slot); | compiler.add_node(NODE_AOV_VALUE, compiler.stack_assign(input("Value")), offset); | ||||
| } | } | ||||
| } | } | ||||
| void OutputAOVNode::compile(OSLCompiler & /*compiler*/) | void OutputAOVNode::compile(OSLCompiler & /*compiler*/) | ||||
| { | { | ||||
| /* TODO */ | /* TODO */ | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,126 Lines • Show Last 20 Lines | |||||