diff options
author | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-15 17:40:39 +0300 |
---|---|---|
committer | Sergey Sharybin <sergey.vfx@gmail.com> | 2016-02-15 23:26:29 +0300 |
commit | 1c4f21f85e17ac557c9867a7764a31d5ebe74eb0 (patch) | |
tree | 72ea537d6624e43e452ce7465f25f92832b88e4f /intern/cycles/kernel/geom | |
parent | b5171e250c6816ecce26227615d53cf6f6339892 (diff) |
Cycles: Initial support of 3D textures for CUDA rendering
Supports both smoke/fire and point density textures now.
Reduces number of textures available for sm_20 and sm_21, but you have
to compromise somewhere on such a limited hardware.
Currently limited to linear interpolation only, and decoupled ray
marching is not supported yet. Think those could be considered just a
further improvement.
Some quick example:
https://developer.blender.org/F282934
Code is minimal and we can fully consider it a fix for missing
support of 3D textures with CUDA.
Reviewers: lukasstockner97, brecht, juicyfruit, dingto
Reviewed By: brecht, juicyfruit, dingto
Subscribers: mib2berlin
Differential Revision: https://developer.blender.org/D1806
Diffstat (limited to 'intern/cycles/kernel/geom')
-rw-r--r-- | intern/cycles/kernel/geom/geom_volume.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/intern/cycles/kernel/geom/geom_volume.h b/intern/cycles/kernel/geom/geom_volume.h index c72afa2a3a4..14b6738b23e 100644 --- a/intern/cycles/kernel/geom/geom_volume.h +++ b/intern/cycles/kernel/geom/geom_volume.h @@ -29,6 +29,21 @@ CCL_NAMESPACE_BEGIN /* Return position normalized to 0..1 in mesh bounds */ +#ifdef __KERNEL_GPU__ +ccl_device float4 volume_image_texture_3d(int id, float x, float y, float z) +{ + float4 r; + switch(id) { + case 0: r = kernel_tex_image_interp_3d(__tex_image_float3d_000, x, y, z); break; + case 1: r = kernel_tex_image_interp_3d(__tex_image_float3d_001, x, y, z); break; + case 2: r = kernel_tex_image_interp_3d(__tex_image_float3d_002, x, y, z); break; + case 3: r = kernel_tex_image_interp_3d(__tex_image_float3d_003, x, y, z); break; + case 4: r = kernel_tex_image_interp_3d(__tex_image_float3d_004, x, y, z); break; + } + return r; +} +#endif /* __KERNEL_GPU__ */ + ccl_device float3 volume_normalized_position(KernelGlobals *kg, const ShaderData *sd, float3 P) { /* todo: optimize this so it's just a single matrix multiplication when @@ -50,7 +65,7 @@ ccl_device float volume_attribute_float(KernelGlobals *kg, const ShaderData *sd, { float3 P = volume_normalized_position(kg, sd, sd->P); #ifdef __KERNEL_GPU__ - float4 r = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + float4 r = volume_image_texture_3d(id, P.x, P.y, P.z); #else float4 r; if(sd->flag & SD_VOLUME_CUBIC) @@ -70,7 +85,7 @@ ccl_device float3 volume_attribute_float3(KernelGlobals *kg, const ShaderData *s { float3 P = volume_normalized_position(kg, sd, sd->P); #ifdef __KERNEL_GPU__ - float4 r = make_float4(0.0f, 0.0f, 0.0f, 0.0f); + float4 r = volume_image_texture_3d(id, P.x, P.y, P.z); #else float4 r; if(sd->flag & SD_VOLUME_CUBIC) |