diff options
Diffstat (limited to 'intern/cycles/kernel/geom/geom_patch.h')
-rw-r--r-- | intern/cycles/kernel/geom/geom_patch.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/intern/cycles/kernel/geom/geom_patch.h b/intern/cycles/kernel/geom/geom_patch.h index b996294c51f..9c1768f05db 100644 --- a/intern/cycles/kernel/geom/geom_patch.h +++ b/intern/cycles/kernel/geom/geom_patch.h @@ -380,6 +380,43 @@ ccl_device float3 patch_eval_float3(KernelGlobals *kg, return val; } +ccl_device float4 patch_eval_float4(KernelGlobals *kg, + const ShaderData *sd, + int offset, + int patch, + float u, + float v, + int channel, + float4 *du, + float4 *dv) +{ + int indices[PATCH_MAX_CONTROL_VERTS]; + float weights[PATCH_MAX_CONTROL_VERTS]; + float weights_du[PATCH_MAX_CONTROL_VERTS]; + float weights_dv[PATCH_MAX_CONTROL_VERTS]; + + int num_control = patch_eval_control_verts( + kg, sd->object, patch, u, v, channel, indices, weights, weights_du, weights_dv); + + float4 val = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + if (du) + *du = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + if (dv) + *dv = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + + for (int i = 0; i < num_control; i++) { + float4 v = kernel_tex_fetch(__attributes_float3, offset + indices[i]); + + val += v * weights[i]; + if (du) + *du += v * weights_du[i]; + if (dv) + *dv += v * weights_dv[i]; + } + + return val; +} + ccl_device float4 patch_eval_uchar4(KernelGlobals *kg, const ShaderData *sd, int offset, |