diff options
author | Stuart Broadfoot <gbroadfoot@hotmail.com> | 2012-12-28 18:21:30 +0400 |
---|---|---|
committer | Stuart Broadfoot <gbroadfoot@hotmail.com> | 2012-12-28 18:21:30 +0400 |
commit | e9ba345c46c93a193193f01d4bfac714a666d384 (patch) | |
tree | 49df9d78dc9327de642779e300e1592e5d7b3a42 /intern/cycles/kernel/kernel_object.h | |
parent | 857df8065face58eff5556953cdf2dd72e09f2b6 (diff) |
New feature
Patch [#33445] - Experimental Cycles Hair Rendering (CPU only)
This patch allows hair data to be exported to cycles and introduces a new line segment primitive to render with.
The UI appears under the particle tab and there is a new hair info node available.
It is only available under the experimental feature set and for cpu rendering.
Diffstat (limited to 'intern/cycles/kernel/kernel_object.h')
-rw-r--r-- | intern/cycles/kernel/kernel_object.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/intern/cycles/kernel/kernel_object.h b/intern/cycles/kernel/kernel_object.h index 40aa4753daa..2260094aa70 100644 --- a/intern/cycles/kernel/kernel_object.h +++ b/intern/cycles/kernel/kernel_object.h @@ -288,5 +288,55 @@ __device float3 particle_angular_velocity(KernelGlobals *kg, int particle) return make_float3(f3.z, f3.w, f4.x); } +#ifdef __HAIR__ +/* Hair Info Node fns */ + +__device float hair_radius(KernelGlobals *kg, int prim, float u) +{ + float r = 0.0f; + + if (prim != -1) { + float4 v00 = kernel_tex_fetch(__cur_segs, prim); + + int v1 = __float_as_int(v00.x); + int v2 = __float_as_int(v00.y); + + float4 P1 = kernel_tex_fetch(__cur_keys, v1); + float4 P2 = kernel_tex_fetch(__cur_keys, v2); + r = (P2.w - P1.w) * u + P1.w; + } + + return r; +} + +__device float3 hair_tangent_normal(KernelGlobals *kg, ShaderData *sd) +{ + float3 tgN = make_float3(0.0f,0.0f,0.0f); + + if (sd->curve_seg != ~0) { + tgN = -(-sd->I - sd->dPdu * (dot(sd->dPdu,-sd->I) * kernel_data.curve_kernel_data.normalmix / len_squared(sd->dPdu))); + tgN = normalize(tgN); + /*if (kernel_data.curve_kernel_data.use_tangent_normal_correction) need to find suitable scaled gd for corrected normal + { + tgN = normalize(tgN - gd * sd->dPdu); + }*/ + } + + return tgN; +} + +__device float intercept(KernelGlobals *kg, int prim, int triAddr, float u) +{ + float t = 0.0f; + + if (prim != -1) { + float4 sd2 = kernel_tex_fetch(__tri_woop, triAddr*3+2); + t = (sd2.y - sd2.x) * u + sd2.x; + } + + return t; +} +#endif + CCL_NAMESPACE_END |