Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_wireframe.h
| Show All 29 Lines | |||||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| */ | */ | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| /* Wireframe Node */ | /* Wireframe Node */ | ||||
| ccl_device_inline float wireframe( | ccl_device_inline float wireframe( | ||||
| KernelGlobals *kg, ShaderData *sd, float size, int pixel_size, float3 *P) | const KernelGlobals *kg, ShaderData *sd, float size, int pixel_size, float3 *P) | ||||
| { | { | ||||
| #ifdef __HAIR__ | #ifdef __HAIR__ | ||||
| if (sd->prim != PRIM_NONE && sd->type & PRIMITIVE_ALL_TRIANGLE) | if (sd->prim != PRIM_NONE && sd->type & PRIMITIVE_ALL_TRIANGLE) | ||||
| #else | #else | ||||
| if (sd->prim != PRIM_NONE) | if (sd->prim != PRIM_NONE) | ||||
| #endif | #endif | ||||
| { | { | ||||
| float3 Co[3]; | float3 Co[3]; | ||||
| Show All 36 Lines | for (int i = 0; i < np; i++) { | ||||
| // distance to the edge. | // distance to the edge. | ||||
| if (dot(crs, crs) < (dot(edge, edge) * pixelwidth)) | if (dot(crs, crs) < (dot(edge, edge) * pixelwidth)) | ||||
| return 1.0f; | return 1.0f; | ||||
| } | } | ||||
| } | } | ||||
| return 0.0f; | return 0.0f; | ||||
| } | } | ||||
| ccl_device void svm_node_wireframe(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) | ccl_device_noinline void svm_node_wireframe(const KernelGlobals *kg, | ||||
| ShaderData *sd, | |||||
| float *stack, | |||||
| uint4 node) | |||||
| { | { | ||||
| uint in_size = node.y; | uint in_size = node.y; | ||||
| uint out_fac = node.z; | uint out_fac = node.z; | ||||
| uint use_pixel_size, bump_offset; | uint use_pixel_size, bump_offset; | ||||
| svm_unpack_node_uchar2(node.w, &use_pixel_size, &bump_offset); | svm_unpack_node_uchar2(node.w, &use_pixel_size, &bump_offset); | ||||
| /* Input Data */ | /* Input Data */ | ||||
| float size = stack_load_float(stack, in_size); | float size = stack_load_float(stack, in_size); | ||||
| int pixel_size = (int)use_pixel_size; | int pixel_size = (int)use_pixel_size; | ||||
| /* Calculate wireframe */ | /* Calculate wireframe */ | ||||
| #ifdef __SPLIT_KERNEL__ | |||||
| /* TODO(sergey): This is because sd is actually a global space, | |||||
| * which makes it difficult to re-use same wireframe() function. | |||||
| * | |||||
| * With OpenCL 2.0 it's possible to avoid this change, but for until | |||||
| * then we'll be living with such an exception. | |||||
| */ | |||||
| float3 P = sd->P; | |||||
| float f = wireframe(kg, sd, size, pixel_size, &P); | |||||
| #else | |||||
| float f = wireframe(kg, sd, size, pixel_size, &sd->P); | float f = wireframe(kg, sd, size, pixel_size, &sd->P); | ||||
| #endif | |||||
| /* TODO(sergey): Think of faster way to calculate derivatives. */ | /* TODO(sergey): Think of faster way to calculate derivatives. */ | ||||
| if (bump_offset == NODE_BUMP_OFFSET_DX) { | if (bump_offset == NODE_BUMP_OFFSET_DX) { | ||||
| float3 Px = sd->P - sd->dP.dx; | float3 Px = sd->P - sd->dP.dx; | ||||
| f += (f - wireframe(kg, sd, size, pixel_size, &Px)) / len(sd->dP.dx); | f += (f - wireframe(kg, sd, size, pixel_size, &Px)) / len(sd->dP.dx); | ||||
| } | } | ||||
| else if (bump_offset == NODE_BUMP_OFFSET_DY) { | else if (bump_offset == NODE_BUMP_OFFSET_DY) { | ||||
| float3 Py = sd->P - sd->dP.dy; | float3 Py = sd->P - sd->dP.dy; | ||||
| f += (f - wireframe(kg, sd, size, pixel_size, &Py)) / len(sd->dP.dy); | f += (f - wireframe(kg, sd, size, pixel_size, &Py)) / len(sd->dP.dy); | ||||
| } | } | ||||
| if (stack_valid(out_fac)) | if (stack_valid(out_fac)) | ||||
| stack_store_float(stack, out_fac, f); | stack_store_float(stack, out_fac, f); | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||