Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/svm/svm_attribute.h
| Show All 39 Lines | else { | ||||
| desc = attribute_not_found(); | desc = attribute_not_found(); | ||||
| desc.offset = 0; | desc.offset = 0; | ||||
| desc.type = (NodeAttributeType)node.w; | desc.type = (NodeAttributeType)node.w; | ||||
| } | } | ||||
| return desc; | return desc; | ||||
| } | } | ||||
| ccl_device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) | ccl_device void svm_node_attr(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) | ||||
brecht: The Attribute node still needs to support both surface and volume attributes, it seems to be… | |||||
| { | { | ||||
| NodeAttributeType type; | NodeAttributeType type; | ||||
| uint out_offset; | uint out_offset; | ||||
| AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | ||||
| /* fetch and store attribute */ | /* fetch and store attribute */ | ||||
| if(type == NODE_ATTR_FLOAT) { | |||||
| if(desc.type == NODE_ATTR_FLOAT) { | if (desc.type == NODE_ATTR_FLOAT) { | ||||
| float f = primitive_attribute_float(kg, sd, desc, NULL, NULL); | float f = primitive_attribute_float(kg, sd, desc, NULL, NULL); | ||||
| if (type == NODE_ATTR_FLOAT) { | |||||
| stack_store_float(stack, out_offset, f); | stack_store_float(stack, out_offset, f); | ||||
| } | } | ||||
| else { | else { | ||||
| float3 f = primitive_attribute_float3(kg, sd, desc, NULL, NULL); | stack_store_float3(stack, out_offset, make_float3(f, f, f)); | ||||
| stack_store_float(stack, out_offset, average(f)); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if(desc.type == NODE_ATTR_FLOAT3) { | |||||
| float3 f = primitive_attribute_float3(kg, sd, desc, NULL, NULL); | float3 f = primitive_attribute_float3(kg, sd, desc, NULL, NULL); | ||||
| stack_store_float3(stack, out_offset, f); | if (type == NODE_ATTR_FLOAT) { | ||||
| stack_store_float(stack, out_offset, average(f)); | |||||
| } | } | ||||
| else { | else { | ||||
| float f = primitive_attribute_float(kg, sd, desc, NULL, NULL); | stack_store_float3(stack, out_offset, f); | ||||
| stack_store_float3(stack, out_offset, make_float3(f, f, f)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #ifndef __KERNEL_CUDA__ | #ifndef __KERNEL_CUDA__ | ||||
| ccl_device | ccl_device | ||||
| #else | #else | ||||
| ccl_device_noinline | ccl_device_noinline | ||||
| #endif | #endif | ||||
| void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) | void svm_node_attr_bump_dx(KernelGlobals *kg, ShaderData *sd, float *stack, uint4 node) | ||||
| { | { | ||||
| NodeAttributeType type; | NodeAttributeType type; | ||||
| uint out_offset; | uint out_offset; | ||||
| AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | ||||
| /* fetch and store attribute */ | /* fetch and store attribute */ | ||||
| if(type == NODE_ATTR_FLOAT) { | |||||
| if(desc.type == NODE_ATTR_FLOAT) { | if (desc.type == NODE_ATTR_FLOAT) { | ||||
| float dx; | float dx; | ||||
| float f = primitive_attribute_float(kg, sd, desc, &dx, NULL); | float f = primitive_surface_attribute_float(kg, sd, desc, &dx, NULL); | ||||
| if (type == NODE_ATTR_FLOAT) { | |||||
| stack_store_float(stack, out_offset, f+dx); | stack_store_float(stack, out_offset, f+dx); | ||||
| } | } | ||||
| else { | else { | ||||
| float3 dx; | stack_store_float3(stack, out_offset, make_float3(f+dx, f+dx, f+dx)); | ||||
| float3 f = primitive_attribute_float3(kg, sd, desc, &dx, NULL); | |||||
| stack_store_float(stack, out_offset, average(f+dx)); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if(desc.type == NODE_ATTR_FLOAT3) { | |||||
| float3 dx; | float3 dx; | ||||
| float3 f = primitive_attribute_float3(kg, sd, desc, &dx, NULL); | float3 f = primitive_surface_attribute_float3(kg, sd, desc, &dx, NULL); | ||||
| stack_store_float3(stack, out_offset, f+dx); | if (type == NODE_ATTR_FLOAT) { | ||||
| stack_store_float(stack, out_offset, average(f+dx)); | |||||
| } | } | ||||
| else { | else { | ||||
| float dx; | stack_store_float3(stack, out_offset, f+dx); | ||||
| float f = primitive_attribute_float(kg, sd, desc, &dx, NULL); | |||||
| stack_store_float3(stack, out_offset, make_float3(f+dx, f+dx, f+dx)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #ifndef __KERNEL_CUDA__ | #ifndef __KERNEL_CUDA__ | ||||
| ccl_device | ccl_device | ||||
| #else | #else | ||||
| ccl_device_noinline | ccl_device_noinline | ||||
| #endif | #endif | ||||
| void svm_node_attr_bump_dy(KernelGlobals *kg, | void svm_node_attr_bump_dy(KernelGlobals *kg, | ||||
| ShaderData *sd, | ShaderData *sd, | ||||
| float *stack, | float *stack, | ||||
| uint4 node) | uint4 node) | ||||
| { | { | ||||
| NodeAttributeType type; | NodeAttributeType type; | ||||
| uint out_offset; | uint out_offset; | ||||
| AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | AttributeDescriptor desc = svm_node_attr_init(kg, sd, node, &type, &out_offset); | ||||
| /* fetch and store attribute */ | /* fetch and store attribute */ | ||||
| if(type == NODE_ATTR_FLOAT) { | |||||
| if(desc.type == NODE_ATTR_FLOAT) { | if (desc.type == NODE_ATTR_FLOAT) { | ||||
| float dy; | float dy; | ||||
| float f = primitive_attribute_float(kg, sd, desc, NULL, &dy); | float f = primitive_surface_attribute_float(kg, sd, desc, NULL, &dy); | ||||
| if (type == NODE_ATTR_FLOAT) { | |||||
| stack_store_float(stack, out_offset, f+dy); | stack_store_float(stack, out_offset, f+dy); | ||||
| } | } | ||||
| else { | else { | ||||
| float3 dy; | stack_store_float3(stack, out_offset, make_float3(f+dy, f+dy, f+dy)); | ||||
| float3 f = primitive_attribute_float3(kg, sd, desc, NULL, &dy); | |||||
| stack_store_float(stack, out_offset, average(f+dy)); | |||||
| } | } | ||||
| } | } | ||||
| else { | else { | ||||
| if(desc.type == NODE_ATTR_FLOAT3) { | |||||
| float3 dy; | float3 dy; | ||||
| float3 f = primitive_attribute_float3(kg, sd, desc, NULL, &dy); | float3 f = primitive_surface_attribute_float3(kg, sd, desc, NULL, &dy); | ||||
| stack_store_float3(stack, out_offset, f+dy); | if (type == NODE_ATTR_FLOAT) { | ||||
| stack_store_float(stack, out_offset, average(f+dy)); | |||||
| } | } | ||||
| else { | else { | ||||
| float dy; | stack_store_float3(stack, out_offset, f+dy); | ||||
| float f = primitive_attribute_float(kg, sd, desc, NULL, &dy); | |||||
| stack_store_float3(stack, out_offset, make_float3(f+dy, f+dy, f+dy)); | |||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||
The Attribute node still needs to support both surface and volume attributes, it seems to be just for surfaces now?