Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_volume.h
| Show All 25 Lines | |||||
| #pragma once | #pragma once | ||||
| CCL_NAMESPACE_BEGIN | CCL_NAMESPACE_BEGIN | ||||
| #ifdef __VOLUME__ | #ifdef __VOLUME__ | ||||
| /* Return position normalized to 0..1 in mesh bounds */ | /* Return position normalized to 0..1 in mesh bounds */ | ||||
| ccl_device_inline float3 volume_normalized_position(ccl_global const KernelGlobals *kg, | ccl_device_inline float3 volume_normalized_position(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| float3 P) | float3 P) | ||||
| { | { | ||||
| /* todo: optimize this so it's just a single matrix multiplication when | /* todo: optimize this so it's just a single matrix multiplication when | ||||
| * possible (not motion blur), or perhaps even just translation + scale */ | * possible (not motion blur), or perhaps even just translation + scale */ | ||||
| const AttributeDescriptor desc = find_attribute(kg, sd, ATTR_STD_GENERATED_TRANSFORM); | const AttributeDescriptor desc = find_attribute(kg, sd, ATTR_STD_GENERATED_TRANSFORM); | ||||
| object_inverse_position_transform(kg, sd, &P); | object_inverse_position_transform(kg, sd, &P); | ||||
| Show All 22 Lines | if (value.w > 1e-6f && value.w != 1.0f) { | ||||
| /* For RGBA colors, unpremultiply after interpolation. */ | /* For RGBA colors, unpremultiply after interpolation. */ | ||||
| return float4_to_float3(value) / value.w; | return float4_to_float3(value) / value.w; | ||||
| } | } | ||||
| else { | else { | ||||
| return float4_to_float3(value); | return float4_to_float3(value); | ||||
| } | } | ||||
| } | } | ||||
| ccl_device float4 volume_attribute_float4(ccl_global const KernelGlobals *kg, | ccl_device float4 volume_attribute_float4(KernelGlobals kg, | ||||
| ccl_private const ShaderData *sd, | ccl_private const ShaderData *sd, | ||||
| const AttributeDescriptor desc) | const AttributeDescriptor desc) | ||||
| { | { | ||||
| if (desc.element & (ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) { | if (desc.element & (ATTR_ELEMENT_OBJECT | ATTR_ELEMENT_MESH)) { | ||||
| return kernel_tex_fetch(__attributes_float3, desc.offset); | return kernel_tex_fetch(__attributes_float3, desc.offset); | ||||
| } | } | ||||
| else if (desc.element == ATTR_ELEMENT_VOXEL) { | else if (desc.element == ATTR_ELEMENT_VOXEL) { | ||||
| /* todo: optimize this so we don't have to transform both here and in | /* todo: optimize this so we don't have to transform both here and in | ||||
| Show All 16 Lines | |||||