Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_volume.h
| Show First 20 Lines • Show All 41 Lines • ▼ Show 20 Lines | ccl_device_inline float3 volume_normalized_position(KernelGlobals *kg, | ||||
| if(desc.offset != ATTR_STD_NOT_FOUND) { | if(desc.offset != ATTR_STD_NOT_FOUND) { | ||||
| Transform tfm = primitive_attribute_matrix(kg, sd, desc); | Transform tfm = primitive_attribute_matrix(kg, sd, desc); | ||||
| P = transform_point(&tfm, P); | P = transform_point(&tfm, P); | ||||
| } | } | ||||
| return P; | return P; | ||||
| } | } | ||||
| ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float *dx, float *dy) | ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc) | ||||
| { | { | ||||
| float3 P = volume_normalized_position(kg, sd, sd->P); | float3 P = volume_normalized_position(kg, sd, sd->P); | ||||
| InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC)? INTERPOLATION_CUBIC: INTERPOLATION_NONE; | InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC)? INTERPOLATION_CUBIC: INTERPOLATION_NONE; | ||||
| float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P.x, P.y, P.z, interp); | float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P.x, P.y, P.z, interp); | ||||
| if(dx) *dx = 0.0f; | |||||
| if(dy) *dy = 0.0f; | |||||
| return average(float4_to_float3(r)); | return average(float4_to_float3(r)); | ||||
| } | } | ||||
| ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc, float3 *dx, float3 *dy) | ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *sd, const AttributeDescriptor desc) | ||||
| { | { | ||||
| float3 P = volume_normalized_position(kg, sd, sd->P); | float3 P = volume_normalized_position(kg, sd, sd->P); | ||||
| InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC)? INTERPOLATION_CUBIC: INTERPOLATION_NONE; | InterpolationType interp = (sd->flag & SD_VOLUME_CUBIC)? INTERPOLATION_CUBIC: INTERPOLATION_NONE; | ||||
| float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P.x, P.y, P.z, interp); | float4 r = kernel_tex_image_interp_3d(kg, desc.offset, P.x, P.y, P.z, interp); | ||||
| if(dx) *dx = make_float3(0.0f, 0.0f, 0.0f); | |||||
| if(dy) *dy = make_float3(0.0f, 0.0f, 0.0f); | |||||
| if(r.w > 1e-6f && r.w != 1.0f) { | if(r.w > 1e-6f && r.w != 1.0f) { | ||||
| /* For RGBA colors, unpremultiply after interpolation. */ | /* For RGBA colors, unpremultiply after interpolation. */ | ||||
| return float4_to_float3(r) / r.w; | return float4_to_float3(r) / r.w; | ||||
| } | } | ||||
| else { | else { | ||||
| return float4_to_float3(r); | return float4_to_float3(r); | ||||
| } | } | ||||
| } | } | ||||
| #endif | #endif | ||||
| CCL_NAMESPACE_END | CCL_NAMESPACE_END | ||||