diff options
author | Thomas Dinges <blender@dingto.org> | 2012-12-29 05:57:32 +0400 |
---|---|---|
committer | Thomas Dinges <blender@dingto.org> | 2012-12-29 05:57:32 +0400 |
commit | 6b05c887d3395e6377a24e0fdac6500a61d594c7 (patch) | |
tree | e1fd7e876120a316959a601b7648ced97cb7b4be /intern | |
parent | 4a427d8e0dad2e252fedf55c5941d5877e139b09 (diff) |
Cycles Hair:
* Implemented the Hair Info Node for OSL.
Diffstat (limited to 'intern')
-rw-r--r-- | intern/cycles/kernel/osl/osl_services.cpp | 28 | ||||
-rw-r--r-- | intern/cycles/kernel/osl/osl_services.h | 4 | ||||
-rw-r--r-- | intern/cycles/kernel/shaders/CMakeLists.txt | 1 | ||||
-rw-r--r-- | intern/cycles/kernel/shaders/node_hair_info.osl | 32 | ||||
-rw-r--r-- | intern/cycles/render/nodes.cpp | 2 |
5 files changed, 66 insertions, 1 deletions
diff --git a/intern/cycles/kernel/osl/osl_services.cpp b/intern/cycles/kernel/osl/osl_services.cpp index 498d10f385b..64c4d109452 100644 --- a/intern/cycles/kernel/osl/osl_services.cpp +++ b/intern/cycles/kernel/osl/osl_services.cpp @@ -74,6 +74,12 @@ ustring OSLRenderServices::u_geom_numpolyvertices("geom:numpolyvertices"); ustring OSLRenderServices::u_geom_trianglevertices("geom:trianglevertices"); ustring OSLRenderServices::u_geom_polyvertices("geom:polyvertices"); ustring OSLRenderServices::u_geom_name("geom:name"); +#ifdef __HAIR__ +ustring OSLRenderServices::u_curve_is_strand("curve:is_strand"); +ustring OSLRenderServices::u_curve_intercept("curve:intercept"); +ustring OSLRenderServices::u_curve_thickness("curve:thickness"); +ustring OSLRenderServices::u_curve_tangent_normal("curve:tangent_normal"); +#endif ustring OSLRenderServices::u_path_ray_length("path:ray_length"); ustring OSLRenderServices::u_trace("trace"); ustring OSLRenderServices::u_hit("hit"); @@ -593,6 +599,8 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD float3 f = particle_angular_velocity(kg, particle_id); return set_attribute_float3(f, type, derivatives, val); } + + /* Geometry Attributes */ else if (name == u_geom_numpolyvertices) { return set_attribute_int(3, type, derivatives, val); } @@ -612,6 +620,26 @@ bool OSLRenderServices::get_object_standard_attribute(KernelGlobals *kg, ShaderD ustring object_name = kg->osl->object_names[sd->object]; return set_attribute_string(object_name, type, derivatives, val); } + +#ifdef __HAIR__ + /* Hair Attributes */ + else if (name == u_curve_is_strand) { + float f = !(sd->curve_seg == ~0); + return set_attribute_float(f, type, derivatives, val); + } + else if (name == u_curve_intercept) { + float f = intercept(kg, sd->curve_seg, sd->prim, sd->u); + return set_attribute_float(f, type, derivatives, val); + } + else if (name == u_curve_thickness) { + float f = 2 * hair_radius(kg, sd->curve_seg, sd->u); + return set_attribute_float(f, type, derivatives, val); + } + else if (name == u_curve_tangent_normal) { + float3 f = hair_tangent_normal(kg, sd); + return set_attribute_float3(f, type, derivatives, val); + } +#endif else return false; } diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h index cd4a4163209..9b7c9a423ff 100644 --- a/intern/cycles/kernel/osl/osl_services.h +++ b/intern/cycles/kernel/osl/osl_services.h @@ -130,6 +130,10 @@ public: static ustring u_geom_trianglevertices; static ustring u_geom_polyvertices; static ustring u_geom_name; + static ustring u_curve_is_strand; + static ustring u_curve_intercept; + static ustring u_curve_thickness; + static ustring u_curve_tangent_normal; static ustring u_path_ray_length; static ustring u_trace; static ustring u_hit; diff --git a/intern/cycles/kernel/shaders/CMakeLists.txt b/intern/cycles/kernel/shaders/CMakeLists.txt index 70fc8610c98..acae46f1615 100644 --- a/intern/cycles/kernel/shaders/CMakeLists.txt +++ b/intern/cycles/kernel/shaders/CMakeLists.txt @@ -27,6 +27,7 @@ set(SRC_OSL node_glass_bsdf.osl node_glossy_bsdf.osl node_gradient_texture.osl + node_hair_info.osl node_holdout.osl node_hsv.osl node_image_texture.osl diff --git a/intern/cycles/kernel/shaders/node_hair_info.osl b/intern/cycles/kernel/shaders/node_hair_info.osl new file mode 100644 index 00000000000..a44fc67f4bc --- /dev/null +++ b/intern/cycles/kernel/shaders/node_hair_info.osl @@ -0,0 +1,32 @@ +/* + * Copyright 2012, 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" + +shader node_hair_info( + output float IsStrand = 0.0, + output float Intercept = 0.0, + output float Thickness = 0.0, + output normal TangentNormal = N) +{ + getattribute("curve:is_strand", IsStrand); + getattribute("curve:intercept", Intercept); + getattribute("curve:thickness", Thickness); + getattribute("curve:tangent_normal", TangentNormal); +} + diff --git a/intern/cycles/render/nodes.cpp b/intern/cycles/render/nodes.cpp index 23d6432616c..13e9ae81cf0 100644 --- a/intern/cycles/render/nodes.cpp +++ b/intern/cycles/render/nodes.cpp @@ -2283,7 +2283,7 @@ void HairInfoNode::compile(SVMCompiler& compiler) void HairInfoNode::compile(OSLCompiler& compiler) { - compiler.add(this, "NODE_HAIR_INFO"); + compiler.add(this, "node_hair_info"); } /* Value */ |