Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_subd_triangle.h
| Show All 16 Lines | |||||
| /* Functions for retrieving attributes on triangles produced from subdivision meshes */ | /* Functions for retrieving attributes on triangles produced from subdivision meshes */ | ||||
| #pragma once | #pragma once | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Patch index for triangle, -1 if not subdivision triangle */ | /* Patch index for triangle, -1 if not subdivision triangle */ | ||||
| ccl_device_inline uint subd_triangle_patch(ccl_global const KernelGlobals *kg, | ccl_device_inline uint subd_triangle_patch(KernelGlobals kg, ccl_private const ShaderData *sd) | ||||
| ccl_private const ShaderData *sd) | |||||
| { | { | ||||
| return (sd->prim != PRIM_NONE) ? kernel_tex_fetch(__tri_patch, sd->prim) : ~0; | return (sd->prim != PRIM_NONE) ? kernel_tex_fetch(__tri_patch, sd->prim) : ~0; | ||||
| } | } | ||||
| /* UV coords of triangle within patch */ | /* UV coords of triangle within patch */ | ||||
| ccl_device_inline void subd_triangle_patch_uv(ccl_global const KernelGlobals *kg, | ccl_device_inline void subd_triangle_patch_uv(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| float2 uv[3]) | float2 uv[3]) | ||||
| { | { | ||||
| uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim); | uint4 tri_vindex = kernel_tex_fetch(__tri_vindex, sd->prim); | ||||
| uv[0] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.x); | uv[0] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.x); | ||||
| uv[1] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.y); | uv[1] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.y); | ||||
| uv[2] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.z); | uv[2] = kernel_tex_fetch(__tri_patch_uv, tri_vindex.z); | ||||
| } | } | ||||
| /* Vertex indices of patch */ | /* Vertex indices of patch */ | ||||
| ccl_device_inline uint4 subd_triangle_patch_indices(ccl_global const KernelGlobals *kg, int patch) | ccl_device_inline uint4 subd_triangle_patch_indices(KernelGlobals kg, int patch) | ||||
| { | { | ||||
| uint4 indices; | uint4 indices; | ||||
| indices.x = kernel_tex_fetch(__patches, patch + 0); | indices.x = kernel_tex_fetch(__patches, patch + 0); | ||||
| indices.y = kernel_tex_fetch(__patches, patch + 1); | indices.y = kernel_tex_fetch(__patches, patch + 1); | ||||
| indices.z = kernel_tex_fetch(__patches, patch + 2); | indices.z = kernel_tex_fetch(__patches, patch + 2); | ||||
| indices.w = kernel_tex_fetch(__patches, patch + 3); | indices.w = kernel_tex_fetch(__patches, patch + 3); | ||||
| return indices; | return indices; | ||||
| } | } | ||||
| /* Originating face for patch */ | /* Originating face for patch */ | ||||
| ccl_device_inline uint subd_triangle_patch_face(ccl_global const KernelGlobals *kg, int patch) | ccl_device_inline uint subd_triangle_patch_face(KernelGlobals kg, int patch) | ||||
| { | { | ||||
| return kernel_tex_fetch(__patches, patch + 4); | return kernel_tex_fetch(__patches, patch + 4); | ||||
| } | } | ||||
| /* Number of corners on originating face */ | /* Number of corners on originating face */ | ||||
| ccl_device_inline uint subd_triangle_patch_num_corners(ccl_global const KernelGlobals *kg, | ccl_device_inline uint subd_triangle_patch_num_corners(KernelGlobals kg, int patch) | ||||
| int patch) | |||||
| { | { | ||||
| return kernel_tex_fetch(__patches, patch + 5) & 0xffff; | return kernel_tex_fetch(__patches, patch + 5) & 0xffff; | ||||
| } | } | ||||
| /* Indices of the four corners that are used by the patch */ | /* Indices of the four corners that are used by the patch */ | ||||
| ccl_device_inline void subd_triangle_patch_corners(ccl_global const KernelGlobals *kg, | ccl_device_inline void subd_triangle_patch_corners(KernelGlobals kg, int patch, int corners[4]) | ||||
| int patch, | |||||
| int corners[4]) | |||||
| { | { | ||||
| uint4 data; | uint4 data; | ||||
| data.x = kernel_tex_fetch(__patches, patch + 4); | data.x = kernel_tex_fetch(__patches, patch + 4); | ||||
| data.y = kernel_tex_fetch(__patches, patch + 5); | data.y = kernel_tex_fetch(__patches, patch + 5); | ||||
| data.z = kernel_tex_fetch(__patches, patch + 6); | data.z = kernel_tex_fetch(__patches, patch + 6); | ||||
| data.w = kernel_tex_fetch(__patches, patch + 7); | data.w = kernel_tex_fetch(__patches, patch + 7); | ||||
| Show All 14 Lines | else { | ||||
| corners[1] = data.z + mod(c + 1, num_corners); | corners[1] = data.z + mod(c + 1, num_corners); | ||||
| corners[2] = data.w; | corners[2] = data.w; | ||||
| corners[3] = data.z + mod(c - 1, num_corners); | corners[3] = data.z + mod(c - 1, num_corners); | ||||
| } | } | ||||
| } | } | ||||
| /* Reading attributes on various subdivision triangle elements */ | /* Reading attributes on various subdivision triangle elements */ | ||||
| ccl_device_noinline float subd_triangle_attribute_float(ccl_global const KernelGlobals *kg, | ccl_device_noinline float subd_triangle_attribute_float(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc, | const AttributeDescriptor desc, | ||||
| ccl_private float *dx, | ccl_private float *dx, | ||||
| ccl_private float *dy) | ccl_private float *dy) | ||||
| { | { | ||||
| int patch = subd_triangle_patch(kg, sd); | int patch = subd_triangle_patch(kg, sd); | ||||
| #ifdef __PATCH_EVAL__ | #ifdef __PATCH_EVAL__ | ||||
| ▲ Show 20 Lines • Show All 122 Lines • ▼ Show 20 Lines | if (dx) | ||||
| *dx = 0.0f; | *dx = 0.0f; | ||||
| if (dy) | if (dy) | ||||
| *dy = 0.0f; | *dy = 0.0f; | ||||
| return 0.0f; | return 0.0f; | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_noinline float2 subd_triangle_attribute_float2(ccl_global const KernelGlobals *kg, | ccl_device_noinline float2 subd_triangle_attribute_float2(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc, | const AttributeDescriptor desc, | ||||
| ccl_private float2 *dx, | ccl_private float2 *dx, | ||||
| ccl_private float2 *dy) | ccl_private float2 *dy) | ||||
| { | { | ||||
| int patch = subd_triangle_patch(kg, sd); | int patch = subd_triangle_patch(kg, sd); | ||||
| #ifdef __PATCH_EVAL__ | #ifdef __PATCH_EVAL__ | ||||
| ▲ Show 20 Lines • Show All 126 Lines • ▼ Show 20 Lines | if (dx) | ||||
| *dx = make_float2(0.0f, 0.0f); | *dx = make_float2(0.0f, 0.0f); | ||||
| if (dy) | if (dy) | ||||
| *dy = make_float2(0.0f, 0.0f); | *dy = make_float2(0.0f, 0.0f); | ||||
| return make_float2(0.0f, 0.0f); | return make_float2(0.0f, 0.0f); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_noinline float3 subd_triangle_attribute_float3(ccl_global const KernelGlobals *kg, | ccl_device_noinline float3 subd_triangle_attribute_float3(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc, | const AttributeDescriptor desc, | ||||
| ccl_private float3 *dx, | ccl_private float3 *dx, | ||||
| ccl_private float3 *dy) | ccl_private float3 *dy) | ||||
| { | { | ||||
| int patch = subd_triangle_patch(kg, sd); | int patch = subd_triangle_patch(kg, sd); | ||||
| #ifdef __PATCH_EVAL__ | #ifdef __PATCH_EVAL__ | ||||
| ▲ Show 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | if (dx) | ||||
| *dx = make_float3(0.0f, 0.0f, 0.0f); | *dx = make_float3(0.0f, 0.0f, 0.0f); | ||||
| if (dy) | if (dy) | ||||
| *dy = make_float3(0.0f, 0.0f, 0.0f); | *dy = make_float3(0.0f, 0.0f, 0.0f); | ||||
| return 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(ccl_global const KernelGlobals *kg, | ccl_device_noinline float4 subd_triangle_attribute_float4(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc, | const AttributeDescriptor desc, | ||||
| ccl_private float4 *dx, | ccl_private float4 *dx, | ||||
| ccl_private float4 *dy) | ccl_private float4 *dy) | ||||
| { | { | ||||
| int patch = subd_triangle_patch(kg, sd); | int patch = subd_triangle_patch(kg, sd); | ||||
| #ifdef __PATCH_EVAL__ | #ifdef __PATCH_EVAL__ | ||||
| ▲ Show 20 Lines • Show All 151 Lines • Show Last 20 Lines | |||||