Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r--intern/cycles/kernel/geom/geom_patch.h3
-rw-r--r--intern/cycles/kernel/geom/geom_subd_triangle.h12
-rw-r--r--intern/cycles/kernel/geom/geom_subd_triangle.h.orig698
-rw-r--r--intern/cycles/kernel/geom/geom_triangle.h9
-rw-r--r--intern/cycles/kernel/geom/geom_triangle.h.orig348
-rw-r--r--intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h28
-rw-r--r--intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h10
-rw-r--r--intern/cycles/kernel/shaders/node_clamp.osl5
-rw-r--r--intern/cycles/kernel/shaders/node_gradient_texture.osl4
-rw-r--r--intern/cycles/kernel/shaders/node_map_range.osl8
-rw-r--r--intern/cycles/kernel/shaders/node_mapping.osl10
-rw-r--r--intern/cycles/kernel/shaders/node_math.osl82
-rw-r--r--intern/cycles/kernel/shaders/node_mix.osl38
-rw-r--r--intern/cycles/kernel/shaders/node_musgrave_texture.osl42
-rw-r--r--intern/cycles/kernel/shaders/node_sky_texture.osl8
-rw-r--r--intern/cycles/kernel/shaders/node_vector_math.osl50
-rw-r--r--intern/cycles/kernel/shaders/node_vector_rotate.osl10
-rw-r--r--intern/cycles/kernel/shaders/node_vector_transform.osl8
-rw-r--r--intern/cycles/kernel/shaders/node_wave_texture.osl4
19 files changed, 1219 insertions, 158 deletions
diff --git a/intern/cycles/kernel/geom/geom_patch.h b/intern/cycles/kernel/geom/geom_patch.h
index 1de05fa9e0d..9c1768f05db 100644
--- a/intern/cycles/kernel/geom/geom_patch.h
+++ b/intern/cycles/kernel/geom/geom_patch.h
@@ -442,7 +442,8 @@ ccl_device float4 patch_eval_uchar4(KernelGlobals *kg,
*dv = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
for (int i = 0; i < num_control; i++) {
- float4 v = color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, offset + indices[i]));
+ float4 v = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, offset + indices[i])));
val += v * weights[i];
if (du)
diff --git a/intern/cycles/kernel/geom/geom_subd_triangle.h b/intern/cycles/kernel/geom/geom_subd_triangle.h
index 2a569852659..9eceb996926 100644
--- a/intern/cycles/kernel/geom/geom_subd_triangle.h
+++ b/intern/cycles/kernel/geom/geom_subd_triangle.h
@@ -627,10 +627,14 @@ ccl_device_noinline float4 subd_triangle_attribute_float4(KernelGlobals *kg,
float4 f0, f1, f2, f3;
if (desc.element == ATTR_ELEMENT_CORNER_BYTE) {
- f0 = color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[0] + desc.offset));
- f1 = color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[1] + desc.offset));
- f2 = color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[2] + desc.offset));
- f3 = color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[3] + desc.offset));
+ f0 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[0] + desc.offset)));
+ f1 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[1] + desc.offset)));
+ f2 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[2] + desc.offset)));
+ f3 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[3] + desc.offset)));
}
else {
f0 = kernel_tex_fetch(__attributes_float3, corners[0] + desc.offset);
diff --git a/intern/cycles/kernel/geom/geom_subd_triangle.h.orig b/intern/cycles/kernel/geom/geom_subd_triangle.h.orig
new file mode 100644
index 00000000000..cce71b0bec1
--- /dev/null
+++ b/intern/cycles/kernel/geom/geom_subd_triangle.h.orig
@@ -0,0 +1,698 @@
+/*
+ * Copyright 2011-2016 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Functions for retrieving attributes on triangles produced from subdivision meshes */
+
+CCL_NAMESPACE_BEGIN
+
+/* Patch index for triangle, -1 if not subdivision triangle */
+
+ccl_device_inline uint subd_triangle_patch(KernelGlobals *kg, const ShaderData *sd)
+{
+ return (sd->prim != PRIM_NONE) ? kernel_tex_fetch(__tri_patch, sd->prim) : ~0;
+}
+
+/* UV coords of triangle within patch */
+
+ccl_device_inline void subd_triangle_patch_uv(KernelGlobals *kg,
+ const ShaderData *sd,
+ float2 uv[3])
+{
+ uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
+
+ uv[0] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.x);
+ uv[1] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.y);
+ uv[2] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.z);
+}
+
+/* Vertex indices of patch */
+
+ccl_device_inline uint4 subd_triangle_patch_indices(KernelGlobals *kg, int patch)
+{
+ uint4 indices;
+
+ indices.x = kernel_tex_fetch(__patches, patch + 0);
+ indices.y = kernel_tex_fetch(__patches, patch + 1);
+ indices.z = kernel_tex_fetch(__patches, patch + 2);
+ indices.w = kernel_tex_fetch(__patches, patch + 3);
+
+ return indices;
+}
+
+/* Originating face for patch */
+
+ccl_device_inline uint subd_triangle_patch_face(KernelGlobals *kg, int patch)
+{
+ return kernel_tex_fetch(__patches, patch + 4);
+}
+
+/* Number of corners on originating face */
+
+ccl_device_inline uint subd_triangle_patch_num_corners(KernelGlobals *kg, int patch)
+{
+ return kernel_tex_fetch(__patches, patch + 5) & 0xffff;
+}
+
+/* Indices of the four corners that are used by the patch */
+
+ccl_device_inline void subd_triangle_patch_corners(KernelGlobals *kg, int patch, int corners[4])
+{
+ uint4 data;
+
+ data.x = kernel_tex_fetch(__patches, patch + 4);
+ data.y = kernel_tex_fetch(__patches, patch + 5);
+ data.z = kernel_tex_fetch(__patches, patch + 6);
+ data.w = kernel_tex_fetch(__patches, patch + 7);
+
+ int num_corners = data.y & 0xffff;
+
+ if (num_corners == 4) {
+ /* quad */
+ corners[0] = data.z;
+ corners[1] = data.z + 1;
+ corners[2] = data.z + 2;
+ corners[3] = data.z + 3;
+ }
+ else {
+ /* ngon */
+ int c = data.y >> 16;
+
+ corners[0] = data.z + c;
+ corners[1] = data.z + mod(c + 1, num_corners);
+ corners[2] = data.w;
+ corners[3] = data.z + mod(c - 1, num_corners);
+ }
+}
+
+/* Reading attributes on various subdivision triangle elements */
+
+ccl_device_noinline float subd_triangle_attribute_float(
+ KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy)
+{
+ int patch = subd_triangle_patch(kg, sd);
+
+#ifdef __PATCH_EVAL__
+ if (desc.flags & ATTR_SUBDIVIDED) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ float2 dpdu = uv[0] - uv[2];
+ float2 dpdv = uv[1] - uv[2];
+
+ /* p is [s, t] */
+ float2 p = dpdu * sd->u + dpdv * sd->v + uv[2];
+
+ float a, dads, dadt;
+ a = patch_eval_float(kg, sd, desc.offset, patch, p.x, p.y, 0, &dads, &dadt);
+
+# ifdef __RAY_DIFFERENTIALS__
+ if (dx || dy) {
+ float dsdu = dpdu.x;
+ float dtdu = dpdu.y;
+ float dsdv = dpdv.x;
+ float dtdv = dpdv.y;
+
+ if (dx) {
+ float dudx = sd->du.dx;
+ float dvdx = sd->dv.dx;
+
+ float dsdx = dsdu * dudx + dsdv * dvdx;
+ float dtdx = dtdu * dudx + dtdv * dvdx;
+
+ *dx = dads * dsdx + dadt * dtdx;
+ }
+ if (dy) {
+ float dudy = sd->du.dy;
+ float dvdy = sd->dv.dy;
+
+ float dsdy = dsdu * dudy + dsdv * dvdy;
+ float dtdy = dtdu * dudy + dtdv * dvdy;
+
+ *dy = dads * dsdy + dadt * dtdy;
+ }
+ }
+# endif
+
+ return a;
+ }
+ else
+#endif /* __PATCH_EVAL__ */
+ if (desc.element == ATTR_ELEMENT_FACE) {
+ if (dx)
+ *dx = 0.0f;
+ if (dy)
+ *dy = 0.0f;
+
+ return kernel_tex_fetch(__attributes_float, desc.offset + subd_triangle_patch_face(kg, patch));
+ }
+ else if (desc.element == ATTR_ELEMENT_VERTEX || desc.element == ATTR_ELEMENT_VERTEX_MOTION) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ uint4 v = subd_triangle_patch_indices(kg, patch);
+
+ float f0 = kernel_tex_fetch(__attributes_float, desc.offset + v.x);
+ float f1 = kernel_tex_fetch(__attributes_float, desc.offset + v.y);
+ float f2 = kernel_tex_fetch(__attributes_float, desc.offset + v.z);
+ float f3 = kernel_tex_fetch(__attributes_float, desc.offset + v.w);
+
+ if (subd_triangle_patch_num_corners(kg, patch) != 4) {
+ f1 = (f1 + f0) * 0.5f;
+ f3 = (f3 + f0) * 0.5f;
+ }
+
+ float a = mix(mix(f0, f1, uv[0].x), mix(f3, f2, uv[0].x), uv[0].y);
+ float b = mix(mix(f0, f1, uv[1].x), mix(f3, f2, uv[1].x), uv[1].y);
+ float c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * a + sd->dv.dx * b - (sd->du.dx + sd->dv.dx) * c;
+ if (dy)
+ *dy = sd->du.dy * a + sd->dv.dy * b - (sd->du.dy + sd->dv.dy) * c;
+#endif
+
+ return sd->u * a + sd->v * b + (1.0f - sd->u - sd->v) * c;
+ }
+ else if (desc.element == ATTR_ELEMENT_CORNER) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ int corners[4];
+ subd_triangle_patch_corners(kg, patch, corners);
+
+ float f0 = kernel_tex_fetch(__attributes_float, corners[0] + desc.offset);
+ float f1 = kernel_tex_fetch(__attributes_float, corners[1] + desc.offset);
+ float f2 = kernel_tex_fetch(__attributes_float, corners[2] + desc.offset);
+ float f3 = kernel_tex_fetch(__attributes_float, corners[3] + desc.offset);
+
+ if (subd_triangle_patch_num_corners(kg, patch) != 4) {
+ f1 = (f1 + f0) * 0.5f;
+ f3 = (f3 + f0) * 0.5f;
+ }
+
+ float a = mix(mix(f0, f1, uv[0].x), mix(f3, f2, uv[0].x), uv[0].y);
+ float b = mix(mix(f0, f1, uv[1].x), mix(f3, f2, uv[1].x), uv[1].y);
+ float c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * a + sd->dv.dx * b - (sd->du.dx + sd->dv.dx) * c;
+ if (dy)
+ *dy = sd->du.dy * a + sd->dv.dy * b - (sd->du.dy + sd->dv.dy) * c;
+#endif
+
+ return sd->u * a + sd->v * b + (1.0f - sd->u - sd->v) * c;
+ }
+ else if (desc.element == ATTR_ELEMENT_OBJECT || desc.element == ATTR_ELEMENT_MESH) {
+ if (dx)
+ *dx = 0.0f;
+ if (dy)
+ *dy = 0.0f;
+
+ return kernel_tex_fetch(__attributes_float, desc.offset);
+ }
+ else {
+ if (dx)
+ *dx = 0.0f;
+ if (dy)
+ *dy = 0.0f;
+
+ return 0.0f;
+ }
+}
+
+ccl_device_noinline float2 subd_triangle_attribute_float2(KernelGlobals *kg,
+ const ShaderData *sd,
+ const AttributeDescriptor desc,
+ float2 *dx,
+ float2 *dy)
+{
+ int patch = subd_triangle_patch(kg, sd);
+
+#ifdef __PATCH_EVAL__
+ if (desc.flags & ATTR_SUBDIVIDED) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ float2 dpdu = uv[0] - uv[2];
+ float2 dpdv = uv[1] - uv[2];
+
+ /* p is [s, t] */
+ float2 p = dpdu * sd->u + dpdv * sd->v + uv[2];
+
+ float2 a, dads, dadt;
+
+ a = patch_eval_float2(kg, sd, desc.offset, patch, p.x, p.y, 0, &dads, &dadt);
+
+# ifdef __RAY_DIFFERENTIALS__
+ if (dx || dy) {
+ float dsdu = dpdu.x;
+ float dtdu = dpdu.y;
+ float dsdv = dpdv.x;
+ float dtdv = dpdv.y;
+
+ if (dx) {
+ float dudx = sd->du.dx;
+ float dvdx = sd->dv.dx;
+
+ float dsdx = dsdu * dudx + dsdv * dvdx;
+ float dtdx = dtdu * dudx + dtdv * dvdx;
+
+ *dx = dads * dsdx + dadt * dtdx;
+ }
+ if (dy) {
+ float dudy = sd->du.dy;
+ float dvdy = sd->dv.dy;
+
+ float dsdy = dsdu * dudy + dsdv * dvdy;
+ float dtdy = dtdu * dudy + dtdv * dvdy;
+
+ *dy = dads * dsdy + dadt * dtdy;
+ }
+ }
+# endif
+
+ return a;
+ }
+ else
+#endif /* __PATCH_EVAL__ */
+ if (desc.element == ATTR_ELEMENT_FACE) {
+ if (dx)
+ *dx = make_float2(0.0f, 0.0f);
+ if (dy)
+ *dy = make_float2(0.0f, 0.0f);
+
+ return kernel_tex_fetch(__attributes_float2,
+ desc.offset + subd_triangle_patch_face(kg, patch));
+ }
+ else if (desc.element == ATTR_ELEMENT_VERTEX || desc.element == ATTR_ELEMENT_VERTEX_MOTION) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ uint4 v = subd_triangle_patch_indices(kg, patch);
+
+ float2 f0 = kernel_tex_fetch(__attributes_float2, desc.offset + v.x);
+ float2 f1 = kernel_tex_fetch(__attributes_float2, desc.offset + v.y);
+ float2 f2 = kernel_tex_fetch(__attributes_float2, desc.offset + v.z);
+ float2 f3 = kernel_tex_fetch(__attributes_float2, desc.offset + v.w);
+
+ if (subd_triangle_patch_num_corners(kg, patch) != 4) {
+ f1 = (f1 + f0) * 0.5f;
+ f3 = (f3 + f0) * 0.5f;
+ }
+
+ float2 a = mix(mix(f0, f1, uv[0].x), mix(f3, f2, uv[0].x), uv[0].y);
+ float2 b = mix(mix(f0, f1, uv[1].x), mix(f3, f2, uv[1].x), uv[1].y);
+ float2 c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * a + sd->dv.dx * b - (sd->du.dx + sd->dv.dx) * c;
+ if (dy)
+ *dy = sd->du.dy * a + sd->dv.dy * b - (sd->du.dy + sd->dv.dy) * c;
+#endif
+
+ return sd->u * a + sd->v * b + (1.0f - sd->u - sd->v) * c;
+ }
+ else if (desc.element == ATTR_ELEMENT_CORNER) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ int corners[4];
+ subd_triangle_patch_corners(kg, patch, corners);
+
+ float2 f0, f1, f2, f3;
+
+ f0 = kernel_tex_fetch(__attributes_float2, corners[0] + desc.offset);
+ f1 = kernel_tex_fetch(__attributes_float2, corners[1] + desc.offset);
+ f2 = kernel_tex_fetch(__attributes_float2, corners[2] + desc.offset);
+ f3 = kernel_tex_fetch(__attributes_float2, corners[3] + desc.offset);
+
+ if (subd_triangle_patch_num_corners(kg, patch) != 4) {
+ f1 = (f1 + f0) * 0.5f;
+ f3 = (f3 + f0) * 0.5f;
+ }
+
+ float2 a = mix(mix(f0, f1, uv[0].x), mix(f3, f2, uv[0].x), uv[0].y);
+ float2 b = mix(mix(f0, f1, uv[1].x), mix(f3, f2, uv[1].x), uv[1].y);
+ float2 c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * a + sd->dv.dx * b - (sd->du.dx + sd->dv.dx) * c;
+ if (dy)
+ *dy = sd->du.dy * a + sd->dv.dy * b - (sd->du.dy + sd->dv.dy) * c;
+#endif
+
+ return sd->u * a + sd->v * b + (1.0f - sd->u - sd->v) * c;
+ }
+ else if (desc.element == ATTR_ELEMENT_OBJECT || desc.element == ATTR_ELEMENT_MESH) {
+ if (dx)
+ *dx = make_float2(0.0f, 0.0f);
+ if (dy)
+ *dy = make_float2(0.0f, 0.0f);
+
+ return kernel_tex_fetch(__attributes_float2, desc.offset);
+ }
+ else {
+ if (dx)
+ *dx = make_float2(0.0f, 0.0f);
+ if (dy)
+ *dy = make_float2(0.0f, 0.0f);
+
+ return make_float2(0.0f, 0.0f);
+ }
+}
+
+ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals *kg,
+ const ShaderData *sd,
+ const AttributeDescriptor desc,
+ float3 *dx,
+ float3 *dy)
+{
+ int patch = subd_triangle_patch(kg, sd);
+
+#ifdef __PATCH_EVAL__
+ if (desc.flags & ATTR_SUBDIVIDED) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ float2 dpdu = uv[0] - uv[2];
+ float2 dpdv = uv[1] - uv[2];
+
+ /* p is [s, t] */
+ float2 p = dpdu * sd->u + dpdv * sd->v + uv[2];
+
+ float3 a, dads, dadt;
+ a = patch_eval_float3(kg, sd, desc.offset, patch, p.x, p.y, 0, &dads, &dadt);
+
+# ifdef __RAY_DIFFERENTIALS__
+ if (dx || dy) {
+ float dsdu = dpdu.x;
+ float dtdu = dpdu.y;
+ float dsdv = dpdv.x;
+ float dtdv = dpdv.y;
+
+ if (dx) {
+ float dudx = sd->du.dx;
+ float dvdx = sd->dv.dx;
+
+ float dsdx = dsdu * dudx + dsdv * dvdx;
+ float dtdx = dtdu * dudx + dtdv * dvdx;
+
+ *dx = dads * dsdx + dadt * dtdx;
+ }
+ if (dy) {
+ float dudy = sd->du.dy;
+ float dvdy = sd->dv.dy;
+
+ float dsdy = dsdu * dudy + dsdv * dvdy;
+ float dtdy = dtdu * dudy + dtdv * dvdy;
+
+ *dy = dads * dsdy + dadt * dtdy;
+ }
+ }
+# endif
+
+ return a;
+ }
+ else
+#endif /* __PATCH_EVAL__ */
+ if (desc.element == ATTR_ELEMENT_FACE) {
+ if (dx)
+ *dx = make_float3(0.0f, 0.0f, 0.0f);
+ if (dy)
+ *dy = make_float3(0.0f, 0.0f, 0.0f);
+
+ return float4_to_float3(
+ kernel_tex_fetch(__attributes_float3, desc.offset + subd_triangle_patch_face(kg, patch)));
+ }
+ else if (desc.element == ATTR_ELEMENT_VERTEX || desc.element == ATTR_ELEMENT_VERTEX_MOTION) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ uint4 v = subd_triangle_patch_indices(kg, patch);
+
+ float3 f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + v.x));
+ float3 f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + v.y));
+ float3 f2 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + v.z));
+ float3 f3 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + v.w));
+
+ if (subd_triangle_patch_num_corners(kg, patch) != 4) {
+ f1 = (f1 + f0) * 0.5f;
+ f3 = (f3 + f0) * 0.5f;
+ }
+
+ float3 a = mix(mix(f0, f1, uv[0].x), mix(f3, f2, uv[0].x), uv[0].y);
+ float3 b = mix(mix(f0, f1, uv[1].x), mix(f3, f2, uv[1].x), uv[1].y);
+ float3 c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * a + sd->dv.dx * b - (sd->du.dx + sd->dv.dx) * c;
+ if (dy)
+ *dy = sd->du.dy * a + sd->dv.dy * b - (sd->du.dy + sd->dv.dy) * c;
+#endif
+
+ return sd->u * a + sd->v * b + (1.0f - sd->u - sd->v) * c;
+ }
+ else if (desc.element == ATTR_ELEMENT_CORNER) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ int corners[4];
+ subd_triangle_patch_corners(kg, patch, corners);
+
+ float3 f0, f1, f2, f3;
+
+ f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, corners[0] + desc.offset));
+ f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, corners[1] + desc.offset));
+ f2 = float4_to_float3(kernel_tex_fetch(__attributes_float3, corners[2] + desc.offset));
+ f3 = float4_to_float3(kernel_tex_fetch(__attributes_float3, corners[3] + desc.offset));
+
+ if (subd_triangle_patch_num_corners(kg, patch) != 4) {
+ f1 = (f1 + f0) * 0.5f;
+ f3 = (f3 + f0) * 0.5f;
+ }
+
+ float3 a = mix(mix(f0, f1, uv[0].x), mix(f3, f2, uv[0].x), uv[0].y);
+ float3 b = mix(mix(f0, f1, uv[1].x), mix(f3, f2, uv[1].x), uv[1].y);
+ float3 c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * a + sd->dv.dx * b - (sd->du.dx + sd->dv.dx) * c;
+ if (dy)
+ *dy = sd->du.dy * a + sd->dv.dy * b - (sd->du.dy + sd->dv.dy) * c;
+#endif
+
+ return sd->u * a + sd->v * b + (1.0f - sd->u - sd->v) * c;
+ }
+ else if (desc.element == ATTR_ELEMENT_OBJECT || desc.element == ATTR_ELEMENT_MESH) {
+ if (dx)
+ *dx = make_float3(0.0f, 0.0f, 0.0f);
+ if (dy)
+ *dy = make_float3(0.0f, 0.0f, 0.0f);
+
+ return float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset));
+ }
+ else {
+ if (dx)
+ *dx = make_float3(0.0f, 0.0f, 0.0f);
+ if (dy)
+ *dy = make_float3(0.0f, 0.0f, 0.0f);
+
+ return make_float3(0.0f, 0.0f, 0.0f);
+ }
+}
+
+ccl_device_noinline float4 subd_triangle_attribute_float4(KernelGlobals *kg,
+ const ShaderData *sd,
+ const AttributeDescriptor desc,
+ float4 *dx,
+ float4 *dy)
+{
+ int patch = subd_triangle_patch(kg, sd);
+
+#ifdef __PATCH_EVAL__
+ if (desc.flags & ATTR_SUBDIVIDED) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ float2 dpdu = uv[0] - uv[2];
+ float2 dpdv = uv[1] - uv[2];
+
+ /* p is [s, t] */
+ float2 p = dpdu * sd->u + dpdv * sd->v + uv[2];
+
+ float4 a, dads, dadt;
+ if (desc.type == NODE_ATTR_RGBA) {
+ a = patch_eval_uchar4(kg, sd, desc.offset, patch, p.x, p.y, 0, &dads, &dadt);
+ }
+ else {
+ a = patch_eval_float4(kg, sd, desc.offset, patch, p.x, p.y, 0, &dads, &dadt);
+ }
+
+# ifdef __RAY_DIFFERENTIALS__
+ if (dx || dy) {
+ float dsdu = dpdu.x;
+ float dtdu = dpdu.y;
+ float dsdv = dpdv.x;
+ float dtdv = dpdv.y;
+
+ if (dx) {
+ float dudx = sd->du.dx;
+ float dvdx = sd->dv.dx;
+
+ float dsdx = dsdu * dudx + dsdv * dvdx;
+ float dtdx = dtdu * dudx + dtdv * dvdx;
+
+ *dx = dads * dsdx + dadt * dtdx;
+ }
+ if (dy) {
+ float dudy = sd->du.dy;
+ float dvdy = sd->dv.dy;
+
+ float dsdy = dsdu * dudy + dsdv * dvdy;
+ float dtdy = dtdu * dudy + dtdv * dvdy;
+
+ *dy = dads * dsdy + dadt * dtdy;
+ }
+ }
+# endif
+
+ return a;
+ }
+ else
+#endif /* __PATCH_EVAL__ */
+ if (desc.element == ATTR_ELEMENT_FACE) {
+ if (dx)
+ *dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ if (dy)
+ *dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+
+ return kernel_tex_fetch(__attributes_float3,
+ desc.offset + subd_triangle_patch_face(kg, patch));
+ }
+ else if (desc.element == ATTR_ELEMENT_VERTEX || desc.element == ATTR_ELEMENT_VERTEX_MOTION) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ uint4 v = subd_triangle_patch_indices(kg, patch);
+
+ float4 f0 = kernel_tex_fetch(__attributes_float3, desc.offset + v.x);
+ float4 f1 = kernel_tex_fetch(__attributes_float3, desc.offset + v.y);
+ float4 f2 = kernel_tex_fetch(__attributes_float3, desc.offset + v.z);
+ float4 f3 = kernel_tex_fetch(__attributes_float3, desc.offset + v.w);
+
+ if (subd_triangle_patch_num_corners(kg, patch) != 4) {
+ f1 = (f1 + f0) * 0.5f;
+ f3 = (f3 + f0) * 0.5f;
+ }
+
+ float4 a = mix(mix(f0, f1, uv[0].x), mix(f3, f2, uv[0].x), uv[0].y);
+ float4 b = mix(mix(f0, f1, uv[1].x), mix(f3, f2, uv[1].x), uv[1].y);
+ float4 c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * a + sd->dv.dx * b - (sd->du.dx + sd->dv.dx) * c;
+ if (dy)
+ *dy = sd->du.dy * a + sd->dv.dy * b - (sd->du.dy + sd->dv.dy) * c;
+#endif
+
+ return sd->u * a + sd->v * b + (1.0f - sd->u - sd->v) * c;
+ }
+ else if (desc.element == ATTR_ELEMENT_CORNER || desc.element == ATTR_ELEMENT_CORNER_BYTE) {
+ float2 uv[3];
+ subd_triangle_patch_uv(kg, sd, uv);
+
+ int corners[4];
+ subd_triangle_patch_corners(kg, patch, corners);
+
+<<<<<<< HEAD
+ float4 f0, f1, f2, f3;
+
+ if (desc.element == ATTR_ELEMENT_CORNER_BYTE) {
+ f0 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[0] + desc.offset)));
+ f1 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[1] + desc.offset)));
+ f2 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[2] + desc.offset)));
+ f3 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[3] + desc.offset)));
+ }
+ else {
+ f0 = kernel_tex_fetch(__attributes_float3, corners[0] + desc.offset);
+ f1 = kernel_tex_fetch(__attributes_float3, corners[1] + desc.offset);
+ f2 = kernel_tex_fetch(__attributes_float3, corners[2] + desc.offset);
+ f3 = kernel_tex_fetch(__attributes_float3, corners[3] + desc.offset);
+ }
+=======
+ float4 f0 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[0] + desc.offset)));
+ float4 f1 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[1] + desc.offset)));
+ float4 f2 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[2] + desc.offset)));
+ float4 f3 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, corners[3] + desc.offset)));
+>>>>>>> blender-v2.91-release
+
+ if (subd_triangle_patch_num_corners(kg, patch) != 4) {
+ f1 = (f1 + f0) * 0.5f;
+ f3 = (f3 + f0) * 0.5f;
+ }
+
+ float4 a = mix(mix(f0, f1, uv[0].x), mix(f3, f2, uv[0].x), uv[0].y);
+ float4 b = mix(mix(f0, f1, uv[1].x), mix(f3, f2, uv[1].x), uv[1].y);
+ float4 c = mix(mix(f0, f1, uv[2].x), mix(f3, f2, uv[2].x), uv[2].y);
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * a + sd->dv.dx * b - (sd->du.dx + sd->dv.dx) * c;
+ if (dy)
+ *dy = sd->du.dy * a + sd->dv.dy * b - (sd->du.dy + sd->dv.dy) * c;
+#endif
+
+ return sd->u * a + sd->v * b + (1.0f - sd->u - sd->v) * c;
+ }
+ else if (desc.element == ATTR_ELEMENT_OBJECT || desc.element == ATTR_ELEMENT_MESH) {
+ if (dx)
+ *dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ if (dy)
+ *dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+
+<<<<<<< HEAD
+ return kernel_tex_fetch(__attributes_float3, desc.offset);
+=======
+ return color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, desc.offset)));
+>>>>>>> blender-v2.91-release
+ }
+ else {
+ if (dx)
+ *dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ if (dy)
+ *dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+
+ return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ }
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/geom/geom_triangle.h b/intern/cycles/kernel/geom/geom_triangle.h
index 2d9da23371e..e8e5d8c5b34 100644
--- a/intern/cycles/kernel/geom/geom_triangle.h
+++ b/intern/cycles/kernel/geom/geom_triangle.h
@@ -282,9 +282,12 @@ ccl_device float4 triangle_attribute_float4(KernelGlobals *kg,
f2 = kernel_tex_fetch(__attributes_float3, tri + 2);
}
else {
- f0 = color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 0));
- f1 = color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 1));
- f2 = color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 2));
+ f0 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 0)));
+ f1 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 1)));
+ f2 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 2)));
}
}
diff --git a/intern/cycles/kernel/geom/geom_triangle.h.orig b/intern/cycles/kernel/geom/geom_triangle.h.orig
new file mode 100644
index 00000000000..768c168327e
--- /dev/null
+++ b/intern/cycles/kernel/geom/geom_triangle.h.orig
@@ -0,0 +1,348 @@
+/*
+ * Copyright 2011-2013 Blender Foundation
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/* Triangle Primitive
+ *
+ * Basic triangle with 3 vertices is used to represent mesh surfaces. For BVH
+ * ray intersection we use a precomputed triangle storage to accelerate
+ * intersection at the cost of more memory usage */
+
+CCL_NAMESPACE_BEGIN
+
+/* normal on triangle */
+ccl_device_inline float3 triangle_normal(KernelGlobals *kg, ShaderData *sd)
+{
+ /* load triangle vertices */
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
+ const float3 v0 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 0));
+ const float3 v1 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 1));
+ const float3 v2 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 2));
+
+ /* return normal */
+ if (sd->object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
+ return normalize(cross(v2 - v0, v1 - v0));
+ }
+ else {
+ return normalize(cross(v1 - v0, v2 - v0));
+ }
+}
+
+/* point and normal on triangle */
+ccl_device_inline void triangle_point_normal(
+ KernelGlobals *kg, int object, int prim, float u, float v, float3 *P, float3 *Ng, int *shader)
+{
+ /* load triangle vertices */
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, prim);
+ float3 v0 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 0));
+ float3 v1 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 1));
+ float3 v2 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 2));
+ /* compute point */
+ float t = 1.0f - u - v;
+ *P = (u * v0 + v * v1 + t * v2);
+ /* get object flags */
+ int object_flag = kernel_tex_fetch(__object_flag, object);
+ /* compute normal */
+ if (object_flag & SD_OBJECT_NEGATIVE_SCALE_APPLIED) {
+ *Ng = normalize(cross(v2 - v0, v1 - v0));
+ }
+ else {
+ *Ng = normalize(cross(v1 - v0, v2 - v0));
+ }
+ /* shader`*/
+ *shader = kernel_tex_fetch(__tri_shader, prim);
+}
+
+/* Triangle vertex locations */
+
+ccl_device_inline void triangle_vertices(KernelGlobals *kg, int prim, float3 P[3])
+{
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, prim);
+ P[0] = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 0));
+ P[1] = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 1));
+ P[2] = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 2));
+}
+
+/* Interpolate smooth vertex normal from vertices */
+
+ccl_device_inline float3
+triangle_smooth_normal(KernelGlobals *kg, float3 Ng, int prim, float u, float v)
+{
+ /* load triangle vertices */
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, prim);
+ float3 n0 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.x));
+ float3 n1 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.y));
+ float3 n2 = float4_to_float3(kernel_tex_fetch(__tri_vnormal, tri_vindex.z));
+
+ float3 N = safe_normalize((1.0f - u - v) * n2 + u * n0 + v * n1);
+
+ return is_zero(N) ? Ng : N;
+}
+
+/* Ray differentials on triangle */
+
+ccl_device_inline void triangle_dPdudv(KernelGlobals *kg,
+ int prim,
+ ccl_addr_space float3 *dPdu,
+ ccl_addr_space float3 *dPdv)
+{
+ /* fetch triangle vertex coordinates */
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, prim);
+ const float3 p0 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 0));
+ const float3 p1 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 1));
+ const float3 p2 = float4_to_float3(kernel_tex_fetch(__prim_tri_verts, tri_vindex.w + 2));
+
+ /* compute derivatives of P w.r.t. uv */
+ *dPdu = (p0 - p2);
+ *dPdv = (p1 - p2);
+}
+
+/* Reading attributes on various triangle elements */
+
+ccl_device float triangle_attribute_float(
+ KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy)
+{
+ if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION | ATTR_ELEMENT_CORNER)) {
+ float f0, f1, f2;
+
+ if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION)) {
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
+ f0 = kernel_tex_fetch(__attributes_float, desc.offset + tri_vindex.x);
+ f1 = kernel_tex_fetch(__attributes_float, desc.offset + tri_vindex.y);
+ f2 = kernel_tex_fetch(__attributes_float, desc.offset + tri_vindex.z);
+ }
+ else {
+ const int tri = desc.offset + sd->prim * 3;
+ f0 = kernel_tex_fetch(__attributes_float, tri + 0);
+ f1 = kernel_tex_fetch(__attributes_float, tri + 1);
+ f2 = kernel_tex_fetch(__attributes_float, tri + 2);
+ }
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * f0 + sd->dv.dx * f1 - (sd->du.dx + sd->dv.dx) * f2;
+ if (dy)
+ *dy = sd->du.dy * f0 + sd->dv.dy * f1 - (sd->du.dy + sd->dv.dy) * f2;
+#endif
+
+ return sd->u * f0 + sd->v * f1 + (1.0f - sd->u - sd->v) * f2;
+ }
+ else {
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = 0.0f;
+ if (dy)
+ *dy = 0.0f;
+#endif
+
+ if (desc.element & (ATTR_ELEMENT_FACE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) {
+ const int offset = (desc.element == ATTR_ELEMENT_FACE) ? desc.offset + sd->prim :
+ desc.offset;
+ return kernel_tex_fetch(__attributes_float, offset);
+ }
+ else {
+ return 0.0f;
+ }
+ }
+}
+
+ccl_device float2 triangle_attribute_float2(KernelGlobals *kg,
+ const ShaderData *sd,
+ const AttributeDescriptor desc,
+ float2 *dx,
+ float2 *dy)
+{
+ if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION | ATTR_ELEMENT_CORNER)) {
+ float2 f0, f1, f2;
+
+ if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION)) {
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
+ f0 = kernel_tex_fetch(__attributes_float2, desc.offset + tri_vindex.x);
+ f1 = kernel_tex_fetch(__attributes_float2, desc.offset + tri_vindex.y);
+ f2 = kernel_tex_fetch(__attributes_float2, desc.offset + tri_vindex.z);
+ }
+ else {
+ const int tri = desc.offset + sd->prim * 3;
+ f0 = kernel_tex_fetch(__attributes_float2, tri + 0);
+ f1 = kernel_tex_fetch(__attributes_float2, tri + 1);
+ f2 = kernel_tex_fetch(__attributes_float2, tri + 2);
+ }
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * f0 + sd->dv.dx * f1 - (sd->du.dx + sd->dv.dx) * f2;
+ if (dy)
+ *dy = sd->du.dy * f0 + sd->dv.dy * f1 - (sd->du.dy + sd->dv.dy) * f2;
+#endif
+
+ return sd->u * f0 + sd->v * f1 + (1.0f - sd->u - sd->v) * f2;
+ }
+ else {
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = make_float2(0.0f, 0.0f);
+ if (dy)
+ *dy = make_float2(0.0f, 0.0f);
+#endif
+
+ if (desc.element & (ATTR_ELEMENT_FACE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) {
+ const int offset = (desc.element == ATTR_ELEMENT_FACE) ? desc.offset + sd->prim :
+ desc.offset;
+ return kernel_tex_fetch(__attributes_float2, offset);
+ }
+ else {
+ return make_float2(0.0f, 0.0f);
+ }
+ }
+}
+
+ccl_device float3 triangle_attribute_float3(KernelGlobals *kg,
+ const ShaderData *sd,
+ const AttributeDescriptor desc,
+ float3 *dx,
+ float3 *dy)
+{
+ if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION | ATTR_ELEMENT_CORNER)) {
+ float3 f0, f1, f2;
+
+ if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION)) {
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
+ f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + tri_vindex.x));
+ f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + tri_vindex.y));
+ f2 = float4_to_float3(kernel_tex_fetch(__attributes_float3, desc.offset + tri_vindex.z));
+ }
+ else {
+ const int tri = desc.offset + sd->prim * 3;
+ f0 = float4_to_float3(kernel_tex_fetch(__attributes_float3, tri + 0));
+ f1 = float4_to_float3(kernel_tex_fetch(__attributes_float3, tri + 1));
+ f2 = float4_to_float3(kernel_tex_fetch(__attributes_float3, tri + 2));
+ }
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * f0 + sd->dv.dx * f1 - (sd->du.dx + sd->dv.dx) * f2;
+ if (dy)
+ *dy = sd->du.dy * f0 + sd->dv.dy * f1 - (sd->du.dy + sd->dv.dy) * f2;
+#endif
+
+ return sd->u * f0 + sd->v * f1 + (1.0f - sd->u - sd->v) * f2;
+ }
+ else {
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = make_float3(0.0f, 0.0f, 0.0f);
+ if (dy)
+ *dy = make_float3(0.0f, 0.0f, 0.0f);
+#endif
+
+ if (desc.element & (ATTR_ELEMENT_FACE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) {
+ const int offset = (desc.element == ATTR_ELEMENT_FACE) ? desc.offset + sd->prim :
+ desc.offset;
+ return float4_to_float3(kernel_tex_fetch(__attributes_float3, offset));
+ }
+ else {
+ return make_float3(0.0f, 0.0f, 0.0f);
+ }
+ }
+}
+
+ccl_device float4 triangle_attribute_float4(KernelGlobals *kg,
+ const ShaderData *sd,
+ const AttributeDescriptor desc,
+ float4 *dx,
+ float4 *dy)
+{
+ if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION | ATTR_ELEMENT_CORNER |
+ ATTR_ELEMENT_CORNER_BYTE)) {
+ float4 f0, f1, f2;
+
+<<<<<<< HEAD
+ if (desc.element & (ATTR_ELEMENT_VERTEX | ATTR_ELEMENT_VERTEX_MOTION)) {
+ const uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
+=======
+ if (desc.element == ATTR_ELEMENT_CORNER_BYTE) {
+ int tri = desc.offset + sd->prim * 3;
+ f0 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 0)));
+ f1 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 1)));
+ f2 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 2)));
+ }
+ else {
+ uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim);
+>>>>>>> blender-v2.91-release
+ f0 = kernel_tex_fetch(__attributes_float3, desc.offset + tri_vindex.x);
+ f1 = kernel_tex_fetch(__attributes_float3, desc.offset + tri_vindex.y);
+ f2 = kernel_tex_fetch(__attributes_float3, desc.offset + tri_vindex.z);
+ }
+ else {
+ const int tri = desc.offset + sd->prim * 3;
+ if (desc.element == ATTR_ELEMENT_CORNER) {
+ f0 = kernel_tex_fetch(__attributes_float3, tri + 0);
+ f1 = kernel_tex_fetch(__attributes_float3, tri + 1);
+ f2 = kernel_tex_fetch(__attributes_float3, tri + 2);
+ }
+ else {
+ f0 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 0)));
+ f1 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 1)));
+ f2 = color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, tri + 2)));
+ }
+ }
+
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = sd->du.dx * f0 + sd->dv.dx * f1 - (sd->du.dx + sd->dv.dx) * f2;
+ if (dy)
+ *dy = sd->du.dy * f0 + sd->dv.dy * f1 - (sd->du.dy + sd->dv.dy) * f2;
+#endif
+
+ return sd->u * f0 + sd->v * f1 + (1.0f - sd->u - sd->v) * f2;
+ }
+<<<<<<< HEAD
+=======
+ else if (desc.element == ATTR_ELEMENT_OBJECT || desc.element == ATTR_ELEMENT_MESH) {
+ if (dx)
+ *dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ if (dy)
+ *dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+
+ return color_srgb_to_linear_v4(
+ color_uchar4_to_float4(kernel_tex_fetch(__attributes_uchar4, desc.offset)));
+ }
+>>>>>>> blender-v2.91-release
+ else {
+#ifdef __RAY_DIFFERENTIALS__
+ if (dx)
+ *dx = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ if (dy)
+ *dy = make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+#endif
+
+ if (desc.element & (ATTR_ELEMENT_FACE | ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) {
+ const int offset = (desc.element == ATTR_ELEMENT_FACE) ? desc.offset + sd->prim :
+ desc.offset;
+ return kernel_tex_fetch(__attributes_float3, offset);
+ }
+ else {
+ return make_float4(0.0f, 0.0f, 0.0f, 0.0f);
+ }
+ }
+}
+
+CCL_NAMESPACE_END
diff --git a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
index b97400a443a..44c658d4cab 100644
--- a/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
+++ b/intern/cycles/kernel/kernels/cpu/kernel_cpu_image.h
@@ -37,7 +37,7 @@ namespace {
} \
(void)0
-ccl_always_inline float frac(float x, int *ix)
+ccl_device_inline float frac(float x, int *ix)
{
int i = float_to_int(x) - ((x < 0.0f) ? 1 : 0);
*ix = i;
@@ -478,7 +478,7 @@ template<typename T> struct TextureInterpolator {
#ifdef WITH_NANOVDB
template<typename T> struct NanoVDBInterpolator {
- typedef nanovdb::ReadAccessor<nanovdb::NanoRoot<T>> ReadAccessorT;
+ typedef typename nanovdb::NanoGrid<T>::AccessorType AccessorType;
static ccl_always_inline float4 read(float r)
{
@@ -490,16 +490,22 @@ template<typename T> struct NanoVDBInterpolator {
return make_float4(r[0], r[1], r[2], 1.0f);
}
- static ccl_always_inline float4 interp_3d_closest(ReadAccessorT acc, float x, float y, float z)
+ static ccl_always_inline float4 interp_3d_closest(const AccessorType &acc,
+ float x,
+ float y,
+ float z)
{
const nanovdb::Vec3f xyz(x, y, z);
- return read(nanovdb::NearestNeighborSampler<ReadAccessorT, false>(acc)(xyz));
+ return read(nanovdb::SampleFromVoxels<AccessorType, 0, false>(acc)(xyz));
}
- static ccl_always_inline float4 interp_3d_linear(ReadAccessorT acc, float x, float y, float z)
+ static ccl_always_inline float4 interp_3d_linear(const AccessorType &acc,
+ float x,
+ float y,
+ float z)
{
const nanovdb::Vec3f xyz(x - 0.5f, y - 0.5f, z - 0.5f);
- return read(nanovdb::TrilinearSampler<ReadAccessorT, false>(acc)(xyz));
+ return read(nanovdb::SampleFromVoxels<AccessorType, 1, false>(acc)(xyz));
}
# if defined(__GNUC__) || defined(__clang__)
@@ -508,7 +514,7 @@ template<typename T> struct NanoVDBInterpolator {
static ccl_never_inline
# endif
float4
- interp_3d_cubic(ReadAccessorT acc, float x, float y, float z)
+ interp_3d_cubic(const AccessorType &acc, float x, float y, float z)
{
int ix, iy, iz;
int nix, niy, niz;
@@ -561,15 +567,15 @@ template<typename T> struct NanoVDBInterpolator {
using namespace nanovdb;
NanoGrid<T> *const grid = (NanoGrid<T> *)info.data;
- const NanoRoot<T> &root = grid->tree().root();
+ AccessorType acc = grid->getAccessor();
switch ((interp == INTERPOLATION_NONE) ? info.interpolation : interp) {
case INTERPOLATION_CLOSEST:
- return interp_3d_closest(root, x, y, z);
+ return interp_3d_closest(acc, x, y, z);
case INTERPOLATION_LINEAR:
- return interp_3d_linear(root, x, y, z);
+ return interp_3d_linear(acc, x, y, z);
default:
- return interp_3d_cubic(root, x, y, z);
+ return interp_3d_cubic(acc, x, y, z);
}
}
};
diff --git a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h
index b8aaacba960..001bc652810 100644
--- a/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h
+++ b/intern/cycles/kernel/kernels/cuda/kernel_cuda_image.h
@@ -159,18 +159,18 @@ ccl_device_inline T kernel_tex_image_interp_nanovdb(
const TextureInfo &info, float x, float y, float z, uint interpolation)
{
using namespace nanovdb;
- typedef ReadAccessor<NanoRoot<T>> ReadAccessorT;
NanoGrid<T> *const grid = (NanoGrid<T> *)info.data;
- const NanoRoot<T> &root = grid->tree().root();
+ typedef typename nanovdb::NanoGrid<T>::AccessorType AccessorType;
+ AccessorType acc = grid->getAccessor();
switch (interpolation) {
case INTERPOLATION_CLOSEST:
- return NearestNeighborSampler<ReadAccessorT, false>(root)(Vec3f(x, y, z));
+ return SampleFromVoxels<AccessorType, 0, false>(acc)(Vec3f(x, y, z));
case INTERPOLATION_LINEAR:
- return TrilinearSampler<ReadAccessorT, false>(root)(Vec3f(x - 0.5f, y - 0.5f, z - 0.5f));
+ return SampleFromVoxels<AccessorType, 1, false>(acc)(Vec3f(x - 0.5f, y - 0.5f, z - 0.5f));
default:
- TrilinearSampler<ReadAccessorT, false> s(root);
+ SampleFromVoxels<AccessorType, 1, false> s(acc);
return kernel_tex_image_interp_tricubic_nanovdb<T>(s, x - 0.5f, y - 0.5f, z - 0.5f);
}
}
diff --git a/intern/cycles/kernel/shaders/node_clamp.osl b/intern/cycles/kernel/shaders/node_clamp.osl
index ce9392a0d98..b600fb7c455 100644
--- a/intern/cycles/kernel/shaders/node_clamp.osl
+++ b/intern/cycles/kernel/shaders/node_clamp.osl
@@ -16,11 +16,12 @@
#include "stdcycles.h"
-shader node_clamp(string type = "minmax",
+shader node_clamp(string clamp_type = "minmax",
float Value = 1.0,
float Min = 0.0,
float Max = 1.0,
output float Result = 0.0)
{
- Result = (type == "range" && (Min > Max)) ? clamp(Value, Max, Min) : clamp(Value, Min, Max);
+ Result = (clamp_type == "range" && (Min > Max)) ? clamp(Value, Max, Min) :
+ clamp(Value, Min, Max);
}
diff --git a/intern/cycles/kernel/shaders/node_gradient_texture.osl b/intern/cycles/kernel/shaders/node_gradient_texture.osl
index e9acebc0572..c7faee0d022 100644
--- a/intern/cycles/kernel/shaders/node_gradient_texture.osl
+++ b/intern/cycles/kernel/shaders/node_gradient_texture.osl
@@ -62,7 +62,7 @@ float gradient(point p, string type)
shader node_gradient_texture(
int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- string type = "linear",
+ string gradient_type = "linear",
point Vector = P,
output float Fac = 0.0,
output color Color = 0.0)
@@ -72,6 +72,6 @@ shader node_gradient_texture(
if (use_mapping)
p = transform(mapping, p);
- Fac = gradient(p, type);
+ Fac = gradient(p, gradient_type);
Color = color(Fac, Fac, Fac);
}
diff --git a/intern/cycles/kernel/shaders/node_map_range.osl b/intern/cycles/kernel/shaders/node_map_range.osl
index 1c49027e6dd..2fcc664a80e 100644
--- a/intern/cycles/kernel/shaders/node_map_range.osl
+++ b/intern/cycles/kernel/shaders/node_map_range.osl
@@ -27,7 +27,7 @@ float smootherstep(float edge0, float edge1, float x)
return t * t * t * (t * (t * 6.0 - 15.0) + 10.0);
}
-shader node_map_range(string type = "linear",
+shader node_map_range(string range_type = "linear",
float Value = 1.0,
float FromMin = 0.0,
float FromMax = 1.0,
@@ -38,15 +38,15 @@ shader node_map_range(string type = "linear",
{
if (FromMax != FromMin) {
float Factor = Value;
- if (type == "stepped") {
+ if (range_type == "stepped") {
Factor = (Value - FromMin) / (FromMax - FromMin);
Factor = (Steps > 0) ? floor(Factor * (Steps + 1.0)) / Steps : 0.0;
}
- else if (type == "smoothstep") {
+ else if (range_type == "smoothstep") {
Factor = (FromMin > FromMax) ? 1.0 - smoothstep(FromMax, FromMin, Value) :
smoothstep(FromMin, FromMax, Value);
}
- else if (type == "smootherstep") {
+ else if (range_type == "smootherstep") {
Factor = (FromMin > FromMax) ? 1.0 - smootherstep(FromMax, FromMin, Value) :
smootherstep(FromMin, FromMax, Value);
}
diff --git a/intern/cycles/kernel/shaders/node_mapping.osl b/intern/cycles/kernel/shaders/node_mapping.osl
index 8d204999630..131640685bc 100644
--- a/intern/cycles/kernel/shaders/node_mapping.osl
+++ b/intern/cycles/kernel/shaders/node_mapping.osl
@@ -47,24 +47,24 @@ matrix euler_to_mat(point euler)
return mat;
}
-shader node_mapping(string type = "point",
+shader node_mapping(string mapping_type = "point",
point VectorIn = point(0.0, 0.0, 0.0),
point Location = point(0.0, 0.0, 0.0),
point Rotation = point(0.0, 0.0, 0.0),
point Scale = point(1.0, 1.0, 1.0),
output point VectorOut = point(0.0, 0.0, 0.0))
{
- if (type == "point") {
+ if (mapping_type == "point") {
VectorOut = transform(euler_to_mat(Rotation), (VectorIn * Scale)) + Location;
}
- else if (type == "texture") {
+ else if (mapping_type == "texture") {
VectorOut = safe_divide(transform(transpose(euler_to_mat(Rotation)), (VectorIn - Location)),
Scale);
}
- else if (type == "vector") {
+ else if (mapping_type == "vector") {
VectorOut = transform(euler_to_mat(Rotation), (VectorIn * Scale));
}
- else if (type == "normal") {
+ else if (mapping_type == "normal") {
VectorOut = normalize((vector)transform(euler_to_mat(Rotation), safe_divide(VectorIn, Scale)));
}
else {
diff --git a/intern/cycles/kernel/shaders/node_math.osl b/intern/cycles/kernel/shaders/node_math.osl
index dbaa7ccb60e..66884610561 100644
--- a/intern/cycles/kernel/shaders/node_math.osl
+++ b/intern/cycles/kernel/shaders/node_math.osl
@@ -18,91 +18,91 @@
#include "stdcycles.h"
/* OSL asin, acos, and pow functions are safe by default. */
-shader node_math(string type = "add",
+shader node_math(string math_type = "add",
float Value1 = 0.5,
float Value2 = 0.5,
float Value3 = 0.5,
output float Value = 0.0)
{
- if (type == "add")
+ if (math_type == "add")
Value = Value1 + Value2;
- else if (type == "subtract")
+ else if (math_type == "subtract")
Value = Value1 - Value2;
- else if (type == "multiply")
+ else if (math_type == "multiply")
Value = Value1 * Value2;
- else if (type == "divide")
+ else if (math_type == "divide")
Value = safe_divide(Value1, Value2);
- else if (type == "power")
+ else if (math_type == "power")
Value = pow(Value1, Value2);
- else if (type == "logarithm")
+ else if (math_type == "logarithm")
Value = safe_log(Value1, Value2);
- else if (type == "sqrt")
+ else if (math_type == "sqrt")
Value = safe_sqrt(Value1);
- else if (type == "inversesqrt")
+ else if (math_type == "inversesqrt")
Value = inversesqrt(Value1);
- else if (type == "absolute")
+ else if (math_type == "absolute")
Value = fabs(Value1);
- else if (type == "radians")
+ else if (math_type == "radians")
Value = radians(Value1);
- else if (type == "degrees")
+ else if (math_type == "degrees")
Value = degrees(Value1);
- else if (type == "minimum")
+ else if (math_type == "minimum")
Value = min(Value1, Value2);
- else if (type == "maximum")
+ else if (math_type == "maximum")
Value = max(Value1, Value2);
- else if (type == "less_than")
+ else if (math_type == "less_than")
Value = Value1 < Value2;
- else if (type == "greater_than")
+ else if (math_type == "greater_than")
Value = Value1 > Value2;
- else if (type == "round")
+ else if (math_type == "round")
Value = floor(Value1 + 0.5);
- else if (type == "floor")
+ else if (math_type == "floor")
Value = floor(Value1);
- else if (type == "ceil")
+ else if (math_type == "ceil")
Value = ceil(Value1);
- else if (type == "fraction")
+ else if (math_type == "fraction")
Value = Value1 - floor(Value1);
- else if (type == "modulo")
+ else if (math_type == "modulo")
Value = safe_modulo(Value1, Value2);
- else if (type == "trunc")
+ else if (math_type == "trunc")
Value = trunc(Value1);
- else if (type == "snap")
+ else if (math_type == "snap")
Value = floor(safe_divide(Value1, Value2)) * Value2;
- else if (type == "wrap")
+ else if (math_type == "wrap")
Value = wrap(Value1, Value2, Value3);
- else if (type == "pingpong")
+ else if (math_type == "pingpong")
Value = pingpong(Value1, Value2);
- else if (type == "sine")
+ else if (math_type == "sine")
Value = sin(Value1);
- else if (type == "cosine")
+ else if (math_type == "cosine")
Value = cos(Value1);
- else if (type == "tangent")
+ else if (math_type == "tangent")
Value = tan(Value1);
- else if (type == "sinh")
+ else if (math_type == "sinh")
Value = sinh(Value1);
- else if (type == "cosh")
+ else if (math_type == "cosh")
Value = cosh(Value1);
- else if (type == "tanh")
+ else if (math_type == "tanh")
Value = tanh(Value1);
- else if (type == "arcsine")
+ else if (math_type == "arcsine")
Value = asin(Value1);
- else if (type == "arccosine")
+ else if (math_type == "arccosine")
Value = acos(Value1);
- else if (type == "arctangent")
+ else if (math_type == "arctangent")
Value = atan(Value1);
- else if (type == "arctan2")
+ else if (math_type == "arctan2")
Value = atan2(Value1, Value2);
- else if (type == "sign")
+ else if (math_type == "sign")
Value = sign(Value1);
- else if (type == "exponent")
+ else if (math_type == "exponent")
Value = exp(Value1);
- else if (type == "compare")
+ else if (math_type == "compare")
Value = ((Value1 == Value2) || (abs(Value1 - Value2) <= max(Value3, 1e-5))) ? 1.0 : 0.0;
- else if (type == "multiply_add")
+ else if (math_type == "multiply_add")
Value = Value1 * Value2 + Value3;
- else if (type == "smoothmin")
+ else if (math_type == "smoothmin")
Value = smoothmin(Value1, Value2, Value3);
- else if (type == "smoothmax")
+ else if (math_type == "smoothmax")
Value = -(smoothmin(-Value1, -Value2, Value3));
else
warning("%s", "Unknown math operator!");
diff --git a/intern/cycles/kernel/shaders/node_mix.osl b/intern/cycles/kernel/shaders/node_mix.osl
index a13b4bb7b96..dcd9f014f3e 100644
--- a/intern/cycles/kernel/shaders/node_mix.osl
+++ b/intern/cycles/kernel/shaders/node_mix.osl
@@ -279,7 +279,7 @@ color node_mix_clamp(color col)
return outcol;
}
-shader node_mix(string type = "mix",
+shader node_mix(string mix_type = "mix",
int use_clamp = 0,
float Fac = 0.5,
color Color1 = 0.0,
@@ -288,41 +288,41 @@ shader node_mix(string type = "mix",
{
float t = clamp(Fac, 0.0, 1.0);
- if (type == "mix")
+ if (mix_type == "mix")
Color = node_mix_blend(t, Color1, Color2);
- if (type == "add")
+ if (mix_type == "add")
Color = node_mix_add(t, Color1, Color2);
- if (type == "multiply")
+ if (mix_type == "multiply")
Color = node_mix_mul(t, Color1, Color2);
- if (type == "screen")
+ if (mix_type == "screen")
Color = node_mix_screen(t, Color1, Color2);
- if (type == "overlay")
+ if (mix_type == "overlay")
Color = node_mix_overlay(t, Color1, Color2);
- if (type == "subtract")
+ if (mix_type == "subtract")
Color = node_mix_sub(t, Color1, Color2);
- if (type == "divide")
+ if (mix_type == "divide")
Color = node_mix_div(t, Color1, Color2);
- if (type == "difference")
+ if (mix_type == "difference")
Color = node_mix_diff(t, Color1, Color2);
- if (type == "darken")
+ if (mix_type == "darken")
Color = node_mix_dark(t, Color1, Color2);
- if (type == "lighten")
+ if (mix_type == "lighten")
Color = node_mix_light(t, Color1, Color2);
- if (type == "dodge")
+ if (mix_type == "dodge")
Color = node_mix_dodge(t, Color1, Color2);
- if (type == "burn")
+ if (mix_type == "burn")
Color = node_mix_burn(t, Color1, Color2);
- if (type == "hue")
+ if (mix_type == "hue")
Color = node_mix_hue(t, Color1, Color2);
- if (type == "saturation")
+ if (mix_type == "saturation")
Color = node_mix_sat(t, Color1, Color2);
- if (type == "value")
+ if (mix_type == "value")
Color = node_mix_val(t, Color1, Color2);
- if (type == "color")
+ if (mix_type == "color")
Color = node_mix_color(t, Color1, Color2);
- if (type == "soft_light")
+ if (mix_type == "soft_light")
Color = node_mix_soft(t, Color1, Color2);
- if (type == "linear_light")
+ if (mix_type == "linear_light")
Color = node_mix_linear(t, Color1, Color2);
if (use_clamp)
diff --git a/intern/cycles/kernel/shaders/node_musgrave_texture.osl b/intern/cycles/kernel/shaders/node_musgrave_texture.osl
index d03b84c1ab4..0e71ce74c29 100644
--- a/intern/cycles/kernel/shaders/node_musgrave_texture.osl
+++ b/intern/cycles/kernel/shaders/node_musgrave_texture.osl
@@ -684,7 +684,7 @@ float noise_musgrave_ridged_multi_fractal_4d(
shader node_musgrave_texture(
int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- string type = "fBM",
+ string musgrave_type = "fBM",
string dimensions = "3D",
point Vector = P,
float W = 0.0,
@@ -707,21 +707,21 @@ shader node_musgrave_texture(
if (dimensions == "1D") {
float p = W * Scale;
- if (type == "multifractal") {
+ if (musgrave_type == "multifractal") {
Fac = noise_musgrave_multi_fractal_1d(p, dimension, lacunarity, octaves);
}
- else if (type == "fBM") {
+ else if (musgrave_type == "fBM") {
Fac = noise_musgrave_fBm_1d(p, dimension, lacunarity, octaves);
}
- else if (type == "hybrid_multifractal") {
+ else if (musgrave_type == "hybrid_multifractal") {
Fac = noise_musgrave_hybrid_multi_fractal_1d(
p, dimension, lacunarity, octaves, Offset, Gain);
}
- else if (type == "ridged_multifractal") {
+ else if (musgrave_type == "ridged_multifractal") {
Fac = noise_musgrave_ridged_multi_fractal_1d(
p, dimension, lacunarity, octaves, Offset, Gain);
}
- else if (type == "hetero_terrain") {
+ else if (musgrave_type == "hetero_terrain") {
Fac = noise_musgrave_hetero_terrain_1d(p, dimension, lacunarity, octaves, Offset);
}
else {
@@ -730,21 +730,21 @@ shader node_musgrave_texture(
}
else if (dimensions == "2D") {
vector2 p = vector2(s[0], s[1]) * Scale;
- if (type == "multifractal") {
+ if (musgrave_type == "multifractal") {
Fac = noise_musgrave_multi_fractal_2d(p, dimension, lacunarity, octaves);
}
- else if (type == "fBM") {
+ else if (musgrave_type == "fBM") {
Fac = noise_musgrave_fBm_2d(p, dimension, lacunarity, octaves);
}
- else if (type == "hybrid_multifractal") {
+ else if (musgrave_type == "hybrid_multifractal") {
Fac = noise_musgrave_hybrid_multi_fractal_2d(
p, dimension, lacunarity, octaves, Offset, Gain);
}
- else if (type == "ridged_multifractal") {
+ else if (musgrave_type == "ridged_multifractal") {
Fac = noise_musgrave_ridged_multi_fractal_2d(
p, dimension, lacunarity, octaves, Offset, Gain);
}
- else if (type == "hetero_terrain") {
+ else if (musgrave_type == "hetero_terrain") {
Fac = noise_musgrave_hetero_terrain_2d(p, dimension, lacunarity, octaves, Offset);
}
else {
@@ -753,21 +753,21 @@ shader node_musgrave_texture(
}
else if (dimensions == "3D") {
vector3 p = s * Scale;
- if (type == "multifractal") {
+ if (musgrave_type == "multifractal") {
Fac = noise_musgrave_multi_fractal_3d(p, dimension, lacunarity, octaves);
}
- else if (type == "fBM") {
+ else if (musgrave_type == "fBM") {
Fac = noise_musgrave_fBm_3d(p, dimension, lacunarity, octaves);
}
- else if (type == "hybrid_multifractal") {
+ else if (musgrave_type == "hybrid_multifractal") {
Fac = noise_musgrave_hybrid_multi_fractal_3d(
p, dimension, lacunarity, octaves, Offset, Gain);
}
- else if (type == "ridged_multifractal") {
+ else if (musgrave_type == "ridged_multifractal") {
Fac = noise_musgrave_ridged_multi_fractal_3d(
p, dimension, lacunarity, octaves, Offset, Gain);
}
- else if (type == "hetero_terrain") {
+ else if (musgrave_type == "hetero_terrain") {
Fac = noise_musgrave_hetero_terrain_3d(p, dimension, lacunarity, octaves, Offset);
}
else {
@@ -776,21 +776,21 @@ shader node_musgrave_texture(
}
else if (dimensions == "4D") {
vector4 p = vector4(s[0], s[1], s[2], W) * Scale;
- if (type == "multifractal") {
+ if (musgrave_type == "multifractal") {
Fac = noise_musgrave_multi_fractal_4d(p, dimension, lacunarity, octaves);
}
- else if (type == "fBM") {
+ else if (musgrave_type == "fBM") {
Fac = noise_musgrave_fBm_4d(p, dimension, lacunarity, octaves);
}
- else if (type == "hybrid_multifractal") {
+ else if (musgrave_type == "hybrid_multifractal") {
Fac = noise_musgrave_hybrid_multi_fractal_4d(
p, dimension, lacunarity, octaves, Offset, Gain);
}
- else if (type == "ridged_multifractal") {
+ else if (musgrave_type == "ridged_multifractal") {
Fac = noise_musgrave_ridged_multi_fractal_4d(
p, dimension, lacunarity, octaves, Offset, Gain);
}
- else if (type == "hetero_terrain") {
+ else if (musgrave_type == "hetero_terrain") {
Fac = noise_musgrave_hetero_terrain_4d(p, dimension, lacunarity, octaves, Offset);
}
else {
diff --git a/intern/cycles/kernel/shaders/node_sky_texture.osl b/intern/cycles/kernel/shaders/node_sky_texture.osl
index a12e7a9dc17..43d7bd36973 100644
--- a/intern/cycles/kernel/shaders/node_sky_texture.osl
+++ b/intern/cycles/kernel/shaders/node_sky_texture.osl
@@ -212,7 +212,7 @@ shader node_sky_texture(
int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
vector Vector = P,
- string type = "hosek_wilkie",
+ string sky_type = "hosek_wilkie",
float theta = 0.0,
float phi = 0.0,
string filename = "",
@@ -228,10 +228,10 @@ shader node_sky_texture(
if (use_mapping)
p = transform(mapping, p);
- if (type == "nishita_improved")
+ if (sky_type == "nishita_improved")
Color = sky_radiance_nishita(p, nishita_data, filename);
- if (type == "hosek_wilkie")
+ if (sky_type == "hosek_wilkie")
Color = sky_radiance_hosek(p, phi, theta, radiance, config_x, config_y, config_z);
- if (type == "preetham")
+ if (sky_type == "preetham")
Color = sky_radiance_preetham(p, phi, theta, radiance, config_x, config_y, config_z);
}
diff --git a/intern/cycles/kernel/shaders/node_vector_math.osl b/intern/cycles/kernel/shaders/node_vector_math.osl
index 218851598b4..30f0b1daf4c 100644
--- a/intern/cycles/kernel/shaders/node_vector_math.osl
+++ b/intern/cycles/kernel/shaders/node_vector_math.osl
@@ -17,7 +17,7 @@
#include "node_math.h"
#include "stdcycles.h"
-shader node_vector_math(string type = "add",
+shader node_vector_math(string math_type = "add",
vector Vector1 = vector(0.0, 0.0, 0.0),
vector Vector2 = vector(0.0, 0.0, 0.0),
vector Vector3 = vector(0.0, 0.0, 0.0),
@@ -25,76 +25,76 @@ shader node_vector_math(string type = "add",
output float Value = 0.0,
output vector Vector = vector(0.0, 0.0, 0.0))
{
- if (type == "add") {
+ if (math_type == "add") {
Vector = Vector1 + Vector2;
}
- else if (type == "subtract") {
+ else if (math_type == "subtract") {
Vector = Vector1 - Vector2;
}
- else if (type == "multiply") {
+ else if (math_type == "multiply") {
Vector = Vector1 * Vector2;
}
- else if (type == "divide") {
+ else if (math_type == "divide") {
Vector = safe_divide(Vector1, Vector2);
}
- else if (type == "cross_product") {
+ else if (math_type == "cross_product") {
Vector = cross(Vector1, Vector2);
}
- else if (type == "project") {
+ else if (math_type == "project") {
Vector = project(Vector1, Vector2);
}
- else if (type == "reflect") {
+ else if (math_type == "reflect") {
Vector = reflect(Vector1, normalize(Vector2));
}
- else if (type == "dot_product") {
+ else if (math_type == "dot_product") {
Value = dot(Vector1, Vector2);
}
- else if (type == "distance") {
+ else if (math_type == "distance") {
Value = distance(Vector1, Vector2);
}
- else if (type == "length") {
+ else if (math_type == "length") {
Value = length(Vector1);
}
- else if (type == "scale") {
+ else if (math_type == "scale") {
Vector = Vector1 * Scale;
}
- else if (type == "normalize") {
+ else if (math_type == "normalize") {
Vector = normalize(Vector1);
}
- else if (type == "snap") {
+ else if (math_type == "snap") {
Vector = snap(Vector1, Vector2);
}
- else if (type == "floor") {
+ else if (math_type == "floor") {
Vector = floor(Vector1);
}
- else if (type == "ceil") {
+ else if (math_type == "ceil") {
Vector = ceil(Vector1);
}
- else if (type == "modulo") {
+ else if (math_type == "modulo") {
Vector = fmod(Vector1, Vector2);
}
- else if (type == "wrap") {
+ else if (math_type == "wrap") {
Vector = wrap(Vector1, Vector2, Vector3);
}
- else if (type == "fraction") {
+ else if (math_type == "fraction") {
Vector = Vector1 - floor(Vector1);
}
- else if (type == "absolute") {
+ else if (math_type == "absolute") {
Vector = abs(Vector1);
}
- else if (type == "minimum") {
+ else if (math_type == "minimum") {
Vector = min(Vector1, Vector2);
}
- else if (type == "maximum") {
+ else if (math_type == "maximum") {
Vector = max(Vector1, Vector2);
}
- else if (type == "sine") {
+ else if (math_type == "sine") {
Vector = sin(Vector1);
}
- else if (type == "cosine") {
+ else if (math_type == "cosine") {
Vector = cos(Vector1);
}
- else if (type == "tangent") {
+ else if (math_type == "tangent") {
Vector = tan(Vector1);
}
else {
diff --git a/intern/cycles/kernel/shaders/node_vector_rotate.osl b/intern/cycles/kernel/shaders/node_vector_rotate.osl
index 2efe3470ae2..e99bf7d81b0 100644
--- a/intern/cycles/kernel/shaders/node_vector_rotate.osl
+++ b/intern/cycles/kernel/shaders/node_vector_rotate.osl
@@ -18,7 +18,7 @@
#include "stdcycles.h"
shader node_vector_rotate(int invert = 0,
- string type = "axis",
+ string rotate_type = "axis",
vector VectorIn = vector(0.0, 0.0, 0.0),
point Center = point(0.0, 0.0, 0.0),
point Rotation = point(0.0, 0.0, 0.0),
@@ -26,19 +26,19 @@ shader node_vector_rotate(int invert = 0,
float Angle = 0.0,
output vector VectorOut = vector(0.0, 0.0, 0.0))
{
- if (type == "euler_xyz") {
+ if (rotate_type == "euler_xyz") {
matrix rmat = (invert) ? transpose(euler_to_mat(Rotation)) : euler_to_mat(Rotation);
VectorOut = transform(rmat, VectorIn - Center) + Center;
}
else {
float a = (invert) ? -Angle : Angle;
- if (type == "x_axis") {
+ if (rotate_type == "x_axis") {
VectorOut = rotate(VectorIn - Center, a, point(0.0), vector(1.0, 0.0, 0.0)) + Center;
}
- else if (type == "y_axis") {
+ else if (rotate_type == "y_axis") {
VectorOut = rotate(VectorIn - Center, a, point(0.0), vector(0.0, 1.0, 0.0)) + Center;
}
- else if (type == "z_axis") {
+ else if (rotate_type == "z_axis") {
VectorOut = rotate(VectorIn - Center, a, point(0.0), vector(0.0, 0.0, 1.0)) + Center;
}
else { // axis
diff --git a/intern/cycles/kernel/shaders/node_vector_transform.osl b/intern/cycles/kernel/shaders/node_vector_transform.osl
index 1db799cfc9e..b71c6ec4824 100644
--- a/intern/cycles/kernel/shaders/node_vector_transform.osl
+++ b/intern/cycles/kernel/shaders/node_vector_transform.osl
@@ -16,18 +16,18 @@
#include "stdcycles.h"
-shader node_vector_transform(string type = "vector",
+shader node_vector_transform(string transform_type = "vector",
string convert_from = "world",
string convert_to = "object",
vector VectorIn = vector(0.0, 0.0, 0.0),
output vector VectorOut = vector(0.0, 0.0, 0.0))
{
- if (type == "vector" || type == "normal") {
+ if (transform_type == "vector" || transform_type == "normal") {
VectorOut = transform(convert_from, convert_to, VectorIn);
- if (type == "normal")
+ if (transform_type == "normal")
VectorOut = normalize(VectorOut);
}
- else if (type == "point") {
+ else if (transform_type == "point") {
point Point = (point)VectorIn;
VectorOut = transform(convert_from, convert_to, Point);
}
diff --git a/intern/cycles/kernel/shaders/node_wave_texture.osl b/intern/cycles/kernel/shaders/node_wave_texture.osl
index 874bfb8d3af..71d81dff7ec 100644
--- a/intern/cycles/kernel/shaders/node_wave_texture.osl
+++ b/intern/cycles/kernel/shaders/node_wave_texture.osl
@@ -86,7 +86,7 @@ float wave(point p_input,
shader node_wave_texture(int use_mapping = 0,
matrix mapping = matrix(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0),
- string type = "bands",
+ string wave_type = "bands",
string bands_direction = "x",
string rings_direction = "x",
string profile = "sine",
@@ -106,7 +106,7 @@ shader node_wave_texture(int use_mapping = 0,
p = transform(mapping, p);
Fac = wave(p * Scale,
- type,
+ wave_type,
bands_direction,
rings_direction,
profile,