Changeset View
Changeset View
Standalone View
Standalone View
intern/cycles/kernel/geom/geom_volume.h
| Show All 23 Lines | |||||
| * same shader can be used for volume objects with different densities, etc. */ | * same shader can be used for volume objects with different densities, etc. */ | ||||
| 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 */ | ||||
| #ifdef __KERNEL_GPU__ | #if defined(__KERNEL_GPU__) && __CUDA_ARCH__ < 300 | ||||
| ccl_device float4 volume_image_texture_3d(int id, float x, float y, float z) | ccl_device float4 volume_image_texture_3d(int id, float x, float y, float z) | ||||
| { | { | ||||
| float4 r; | float4 r; | ||||
| switch(id) { | switch(id) { | ||||
| case 0: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_000, x, y, z); break; | case 0: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_000, x, y, z); break; | ||||
| case 1: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_001, x, y, z); break; | case 1: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_001, x, y, z); break; | ||||
| case 2: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_002, x, y, z); break; | case 2: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_002, x, y, z); break; | ||||
| case 3: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_003, x, y, z); break; | case 3: r = kernel_tex_image_interp_3d(__tex_image_float4_3d_003, x, y, z); break; | ||||
| Show All 19 Lines | ccl_device float3 volume_normalized_position(KernelGlobals *kg, const ShaderData *sd, float3 P) | ||||
| return P; | return P; | ||||
| } | } | ||||
| ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int id, float *dx, float *dy) | ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int id, float *dx, float *dy) | ||||
| { | { | ||||
| float3 P = volume_normalized_position(kg, sd, sd->P); | float3 P = volume_normalized_position(kg, sd, sd->P); | ||||
| #ifdef __KERNEL_GPU__ | #ifdef __KERNEL_GPU__ | ||||
| # if __CUDA_ARCH__ >= 300 | |||||
| CUtexObject tex = kernel_tex_fetch(__bindless_mapping, id); | |||||
| float f = kernel_tex_image_interp_3d_float(tex, P.x, P.y, P.z); | |||||
| float4 r = make_float4(f, f, f, 1.0); | |||||
| # else | |||||
| float4 r = volume_image_texture_3d(id, P.x, P.y, P.z); | float4 r = volume_image_texture_3d(id, P.x, P.y, P.z); | ||||
| # endif | |||||
| #else | #else | ||||
| float4 r; | float4 r; | ||||
| if(sd->flag & SD_VOLUME_CUBIC) | if(sd->flag & SD_VOLUME_CUBIC) | ||||
| r = kernel_tex_image_interp_3d_ex(id, P.x, P.y, P.z, INTERPOLATION_CUBIC); | r = kernel_tex_image_interp_3d_ex(id, P.x, P.y, P.z, INTERPOLATION_CUBIC); | ||||
| else | else | ||||
| r = kernel_tex_image_interp_3d(id, P.x, P.y, P.z); | r = kernel_tex_image_interp_3d(id, P.x, P.y, P.z); | ||||
| #endif | #endif | ||||
| if(dx) *dx = 0.0f; | if(dx) *dx = 0.0f; | ||||
| if(dy) *dy = 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, AttributeElement elem, int id, float3 *dx, float3 *dy) | ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *sd, AttributeElement elem, int id, float3 *dx, float3 *dy) | ||||
| { | { | ||||
| float3 P = volume_normalized_position(kg, sd, sd->P); | float3 P = volume_normalized_position(kg, sd, sd->P); | ||||
| #ifdef __KERNEL_GPU__ | #ifdef __KERNEL_GPU__ | ||||
| # if __CUDA_ARCH__ >= 300 | |||||
| CUtexObject tex = kernel_tex_fetch(__bindless_mapping, id); | |||||
| float4 r = kernel_tex_image_interp_3d_float4(tex, P.x, P.y, P.z); | |||||
| # else | |||||
| float4 r = volume_image_texture_3d(id, P.x, P.y, P.z); | float4 r = volume_image_texture_3d(id, P.x, P.y, P.z); | ||||
| # endif | |||||
| #else | #else | ||||
| float4 r; | float4 r; | ||||
| if(sd->flag & SD_VOLUME_CUBIC) | if(sd->flag & SD_VOLUME_CUBIC) | ||||
| r = kernel_tex_image_interp_3d_ex(id, P.x, P.y, P.z, INTERPOLATION_CUBIC); | r = kernel_tex_image_interp_3d_ex(id, P.x, P.y, P.z, INTERPOLATION_CUBIC); | ||||
| else | else | ||||
| r = kernel_tex_image_interp_3d(id, P.x, P.y, P.z); | r = kernel_tex_image_interp_3d(id, P.x, P.y, P.z); | ||||
| #endif | #endif | ||||
| Show All 10 Lines | |||||