From 8ce1090d4e8160165281be4b0827dbc1ba28dc8a Mon Sep 17 00:00:00 2001 From: Karsten Schwenk Date: Sun, 8 Jun 2014 12:16:28 +0200 Subject: Cycles: Ashikhmin-Shirley anisotropic BSDF * Ashikhmin-Shirley anisotropic BSDF was added as closure * Anisotropic BSDF node now has two distributions Reviewers: brecht, dingto Differential Revision: https://developer.blender.org/D549 --- intern/cycles/render/nodes.cpp | 29 ++++++++++++++++++++++------- intern/cycles/render/nodes.h | 8 ++++++-- 2 files changed, 28 insertions(+), 9 deletions(-) (limited to 'intern/cycles/render') diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index a38de8a5cec..8976f958b58 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -1583,11 +1583,23 @@ void BsdfNode::compile(OSLCompiler& compiler) assert(0); } -/* Ward BSDF Closure */ +/* Anisotropic BSDF Closure */ -WardBsdfNode::WardBsdfNode() +static ShaderEnum anisotropic_distribution_init() { - closure = CLOSURE_BSDF_WARD_ID; + ShaderEnum enm; + + enm.insert("Ward", CLOSURE_BSDF_WARD_ID); + enm.insert("Ashikhmin-Shirley", CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID); + + return enm; +} + +ShaderEnum AnisotropicBsdfNode::distribution_enum = anisotropic_distribution_init(); + +AnisotropicBsdfNode::AnisotropicBsdfNode() +{ + distribution = ustring("Ward"); add_input("Tangent", SHADER_SOCKET_VECTOR, ShaderInput::TANGENT); @@ -1596,7 +1608,7 @@ WardBsdfNode::WardBsdfNode() add_input("Rotation", SHADER_SOCKET_FLOAT, 0.0f); } -void WardBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes) +void AnisotropicBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes) { if(shader->has_surface) { ShaderInput *tangent_in = input("Tangent"); @@ -1608,14 +1620,17 @@ void WardBsdfNode::attributes(Shader *shader, AttributeRequestSet *attributes) ShaderNode::attributes(shader, attributes); } -void WardBsdfNode::compile(SVMCompiler& compiler) +void AnisotropicBsdfNode::compile(SVMCompiler& compiler) { + closure = (ClosureType)distribution_enum[distribution]; + BsdfNode::compile(compiler, input("Roughness"), input("Anisotropy"), input("Rotation")); } -void WardBsdfNode::compile(OSLCompiler& compiler) +void AnisotropicBsdfNode::compile(OSLCompiler& compiler) { - compiler.add(this, "node_ward_bsdf"); + compiler.parameter("distribution", distribution); + compiler.add(this, "node_anisotropic_bsdf"); } /* Glossy BSDF Closure */ diff --git a/intern/cycles/render/nodes.h b/intern/cycles/render/nodes.h index cf89bdadaa2..31b6f4e50c4 100644 --- a/intern/cycles/render/nodes.h +++ b/intern/cycles/render/nodes.h @@ -218,9 +218,13 @@ public: bool scattering; }; -class WardBsdfNode : public BsdfNode { +class AnisotropicBsdfNode : public BsdfNode { public: - SHADER_NODE_CLASS(WardBsdfNode) + SHADER_NODE_CLASS(AnisotropicBsdfNode) + + ustring distribution; + static ShaderEnum distribution_enum; + void attributes(Shader *shader, AttributeRequestSet *attributes); }; -- cgit v1.2.3