Cycles Hair:
* Implemented the Hair Info Node for OSL.
This commit is contained in:
@@ -74,6 +74,12 @@ ustring OSLRenderServices::u_geom_numpolyvertices("geom:numpolyvertices");
|
|||||||
ustring OSLRenderServices::u_geom_trianglevertices("geom:trianglevertices");
|
ustring OSLRenderServices::u_geom_trianglevertices("geom:trianglevertices");
|
||||||
ustring OSLRenderServices::u_geom_polyvertices("geom:polyvertices");
|
ustring OSLRenderServices::u_geom_polyvertices("geom:polyvertices");
|
||||||
ustring OSLRenderServices::u_geom_name("geom:name");
|
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_path_ray_length("path:ray_length");
|
||||||
ustring OSLRenderServices::u_trace("trace");
|
ustring OSLRenderServices::u_trace("trace");
|
||||||
ustring OSLRenderServices::u_hit("hit");
|
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);
|
float3 f = particle_angular_velocity(kg, particle_id);
|
||||||
return set_attribute_float3(f, type, derivatives, val);
|
return set_attribute_float3(f, type, derivatives, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Geometry Attributes */
|
||||||
else if (name == u_geom_numpolyvertices) {
|
else if (name == u_geom_numpolyvertices) {
|
||||||
return set_attribute_int(3, type, derivatives, val);
|
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];
|
ustring object_name = kg->osl->object_names[sd->object];
|
||||||
return set_attribute_string(object_name, type, derivatives, val);
|
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
|
else
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@@ -130,6 +130,10 @@ public:
|
|||||||
static ustring u_geom_trianglevertices;
|
static ustring u_geom_trianglevertices;
|
||||||
static ustring u_geom_polyvertices;
|
static ustring u_geom_polyvertices;
|
||||||
static ustring u_geom_name;
|
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_path_ray_length;
|
||||||
static ustring u_trace;
|
static ustring u_trace;
|
||||||
static ustring u_hit;
|
static ustring u_hit;
|
||||||
|
@@ -27,6 +27,7 @@ set(SRC_OSL
|
|||||||
node_glass_bsdf.osl
|
node_glass_bsdf.osl
|
||||||
node_glossy_bsdf.osl
|
node_glossy_bsdf.osl
|
||||||
node_gradient_texture.osl
|
node_gradient_texture.osl
|
||||||
|
node_hair_info.osl
|
||||||
node_holdout.osl
|
node_holdout.osl
|
||||||
node_hsv.osl
|
node_hsv.osl
|
||||||
node_image_texture.osl
|
node_image_texture.osl
|
||||||
|
32
intern/cycles/kernel/shaders/node_hair_info.osl
Normal file
32
intern/cycles/kernel/shaders/node_hair_info.osl
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
|
@@ -2283,7 +2283,7 @@ void HairInfoNode::compile(SVMCompiler& compiler)
|
|||||||
|
|
||||||
void HairInfoNode::compile(OSLCompiler& compiler)
|
void HairInfoNode::compile(OSLCompiler& compiler)
|
||||||
{
|
{
|
||||||
compiler.add(this, "NODE_HAIR_INFO");
|
compiler.add(this, "node_hair_info");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Value */
|
/* Value */
|
||||||
|
Reference in New Issue
Block a user