Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_motion_triangle.h
| Show All 27 Lines | |||||
| #pragma once | #pragma once | ||||
| #include "kernel/bvh/bvh_util.h" | #include "kernel/bvh/bvh_util.h" | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Time interpolation of vertex positions and normals */ | /* Time interpolation of vertex positions and normals */ | ||||
| ccl_device_inline void motion_triangle_verts_for_step(ccl_global const KernelGlobals *kg, | ccl_device_inline void motion_triangle_verts_for_step(KernelGlobals kg, | ||||
| uint4 tri_vindex, | uint4 tri_vindex, | ||||
| int offset, | int offset, | ||||
| int numverts, | int numverts, | ||||
| int numsteps, | int numsteps, | ||||
| int step, | int step, | ||||
| float3 verts[3]) | float3 verts[3]) | ||||
| { | { | ||||
| if (step == numsteps) { | if (step == numsteps) { | ||||
| Show All 10 Lines | else { | ||||
| offset += step * numverts; | offset += step * numverts; | ||||
| verts[0] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.x)); | verts[0] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.x)); | ||||
| verts[1] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.y)); | verts[1] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.y)); | ||||
| verts[2] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.z)); | verts[2] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.z)); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline void motion_triangle_normals_for_step(ccl_global const KernelGlobals *kg, | ccl_device_inline void motion_triangle_normals_for_step(KernelGlobals kg, | ||||
| uint4 tri_vindex, | uint4 tri_vindex, | ||||
| int offset, | int offset, | ||||
| int numverts, | int numverts, | ||||
| int numsteps, | int numsteps, | ||||
| int step, | int step, | ||||
| float3 normals[3]) | float3 normals[3]) | ||||
| { | { | ||||
| if (step == numsteps) { | if (step == numsteps) { | ||||
| Show All 11 Lines | else { | ||||
| normals[0] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.x)); | normals[0] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.x)); | ||||
| normals[1] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.y)); | normals[1] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.y)); | ||||
| normals[2] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.z)); | normals[2] = float4_to_float3(kernel_tex_fetch(__attributes_float3, offset + tri_vindex.z)); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device_inline void motion_triangle_vertices( | ccl_device_inline void motion_triangle_vertices( | ||||
| ccl_global const KernelGlobals *kg, int object, int prim, float time, float3 verts[3]) | KernelGlobals kg, int object, int prim, float time, float3 verts[3]) | ||||
| { | { | ||||
| /* get motion info */ | /* get motion info */ | ||||
| int numsteps, numverts; | int numsteps, numverts; | ||||
| object_motion_info(kg, object, &numsteps, &numverts, NULL); | object_motion_info(kg, object, &numsteps, &numverts, NULL); | ||||
| /* figure out which steps we need to fetch and their interpolation factor */ | /* figure out which steps we need to fetch and their interpolation factor */ | ||||
| int maxstep = numsteps * 2; | int maxstep = numsteps * 2; | ||||
| int step = min((int)(time * maxstep), maxstep - 1); | int step = min((int)(time * maxstep), maxstep - 1); | ||||
| Show All 11 Lines | ccl_device_inline void motion_triangle_vertices( | ||||
| motion_triangle_verts_for_step(kg, tri_vindex, offset, numverts, numsteps, step + 1, next_verts); | motion_triangle_verts_for_step(kg, tri_vindex, offset, numverts, numsteps, step + 1, next_verts); | ||||
| /* interpolate between steps */ | /* interpolate between steps */ | ||||
| verts[0] = (1.0f - t) * verts[0] + t * next_verts[0]; | verts[0] = (1.0f - t) * verts[0] + t * next_verts[0]; | ||||
| verts[1] = (1.0f - t) * verts[1] + t * next_verts[1]; | verts[1] = (1.0f - t) * verts[1] + t * next_verts[1]; | ||||
| verts[2] = (1.0f - t) * verts[2] + t * next_verts[2]; | verts[2] = (1.0f - t) * verts[2] + t * next_verts[2]; | ||||
| } | } | ||||
| ccl_device_inline float3 motion_triangle_smooth_normal(ccl_global const KernelGlobals *kg, | ccl_device_inline float3 motion_triangle_smooth_normal( | ||||
| float3 Ng, | KernelGlobals kg, float3 Ng, int object, int prim, float u, float v, float time) | ||||
| int object, | |||||
| int prim, | |||||
| float u, | |||||
| float v, | |||||
| float time) | |||||
| { | { | ||||
| /* get motion info */ | /* get motion info */ | ||||
| int numsteps, numverts; | int numsteps, numverts; | ||||
| object_motion_info(kg, object, &numsteps, &numverts, NULL); | object_motion_info(kg, object, &numsteps, &numverts, NULL); | ||||
| /* figure out which steps we need to fetch and their interpolation factor */ | /* figure out which steps we need to fetch and their interpolation factor */ | ||||
| int maxstep = numsteps * 2; | int maxstep = numsteps * 2; | ||||
| int step = min((int)(time * maxstep), maxstep - 1); | int step = min((int)(time * maxstep), maxstep - 1); | ||||
| Show All 27 Lines | |||||