2017-10-06 21:47:41 +02:00
|
|
|
/*
|
|
|
|
|
* Copyright 2017 Blender Foundation
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2020-10-02 17:40:28 +02:00
|
|
|
#ifdef WITH_NANOVDB
|
2020-12-03 15:20:50 +01:00
|
|
|
# define NDEBUG /* Disable "assert" in device code */
|
|
|
|
|
# define NANOVDB_USE_INTRINSICS
|
2020-10-02 17:40:28 +02:00
|
|
|
# include "nanovdb/NanoVDB.h"
|
|
|
|
|
# include "nanovdb/util/SampleFromVoxels.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-10-07 02:15:12 +02:00
|
|
|
/* w0, w1, w2, and w3 are the four cubic B-spline basis functions. */
|
|
|
|
|
ccl_device float cubic_w0(float a)
|
|
|
|
|
{
|
|
|
|
|
return (1.0f / 6.0f) * (a * (a * (-a + 3.0f) - 3.0f) + 1.0f);
|
|
|
|
|
}
|
|
|
|
|
ccl_device float cubic_w1(float a)
|
|
|
|
|
{
|
|
|
|
|
return (1.0f / 6.0f) * (a * a * (3.0f * a - 6.0f) + 4.0f);
|
|
|
|
|
}
|
|
|
|
|
ccl_device float cubic_w2(float a)
|
|
|
|
|
{
|
|
|
|
|
return (1.0f / 6.0f) * (a * (a * (-3.0f * a + 3.0f) + 3.0f) + 1.0f);
|
|
|
|
|
}
|
|
|
|
|
ccl_device float cubic_w3(float a)
|
|
|
|
|
{
|
|
|
|
|
return (1.0f / 6.0f) * (a * a * a);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* g0 and g1 are the two amplitude functions. */
|
|
|
|
|
ccl_device float cubic_g0(float a)
|
|
|
|
|
{
|
|
|
|
|
return cubic_w0(a) + cubic_w1(a);
|
|
|
|
|
}
|
|
|
|
|
ccl_device float cubic_g1(float a)
|
|
|
|
|
{
|
|
|
|
|
return cubic_w2(a) + cubic_w3(a);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* h0 and h1 are the two offset functions */
|
|
|
|
|
ccl_device float cubic_h0(float a)
|
|
|
|
|
{
|
2020-11-06 15:19:58 +01:00
|
|
|
return (cubic_w1(a) / cubic_g0(a)) - 1.0f;
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
|
|
|
|
ccl_device float cubic_h1(float a)
|
|
|
|
|
{
|
2020-11-06 15:19:58 +01:00
|
|
|
return (cubic_w3(a) / cubic_g1(a)) + 1.0f;
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Fast bicubic texture lookup using 4 bilinear lookups, adapted from CUDA samples. */
|
|
|
|
|
template<typename T>
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_device_noinline T kernel_tex_image_interp_bicubic(const TextureInfo &info, float x, float y)
|
2017-10-07 02:15:12 +02:00
|
|
|
{
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
|
2020-10-02 17:40:28 +02:00
|
|
|
|
2017-10-07 02:15:12 +02:00
|
|
|
x = (x * info.width) - 0.5f;
|
|
|
|
|
y = (y * info.height) - 0.5f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-08 13:59:16 +01:00
|
|
|
float px = floorf(x);
|
|
|
|
|
float py = floorf(y);
|
2017-10-07 02:15:12 +02:00
|
|
|
float fx = x - px;
|
|
|
|
|
float fy = y - py;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-07 02:15:12 +02:00
|
|
|
float g0x = cubic_g0(fx);
|
|
|
|
|
float g1x = cubic_g1(fx);
|
2020-11-06 15:19:58 +01:00
|
|
|
/* Note +0.5 offset to compensate for CUDA linear filtering convention. */
|
|
|
|
|
float x0 = (px + cubic_h0(fx) + 0.5f) / info.width;
|
|
|
|
|
float x1 = (px + cubic_h1(fx) + 0.5f) / info.width;
|
|
|
|
|
float y0 = (py + cubic_h0(fy) + 0.5f) / info.height;
|
|
|
|
|
float y1 = (py + cubic_h1(fy) + 0.5f) / info.height;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return cubic_g0(fy) * (g0x * ccl_gpu_tex_object_read_2D<T>(tex, x0, y0) +
|
|
|
|
|
g1x * ccl_gpu_tex_object_read_2D<T>(tex, x1, y0)) +
|
|
|
|
|
cubic_g1(fy) * (g0x * ccl_gpu_tex_object_read_2D<T>(tex, x0, y1) +
|
|
|
|
|
g1x * ccl_gpu_tex_object_read_2D<T>(tex, x1, y1));
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
|
|
|
|
|
2017-10-15 17:40:01 +02:00
|
|
|
/* Fast tricubic texture lookup using 8 trilinear lookups. */
|
2017-10-07 02:15:12 +02:00
|
|
|
template<typename T>
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_device_noinline T
|
|
|
|
|
kernel_tex_image_interp_tricubic(const TextureInfo &info, float x, float y, float z)
|
2017-10-07 02:15:12 +02:00
|
|
|
{
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
|
2020-10-02 17:40:28 +02:00
|
|
|
|
2017-10-07 02:15:12 +02:00
|
|
|
x = (x * info.width) - 0.5f;
|
|
|
|
|
y = (y * info.height) - 0.5f;
|
|
|
|
|
z = (z * info.depth) - 0.5f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-03-08 13:59:16 +01:00
|
|
|
float px = floorf(x);
|
|
|
|
|
float py = floorf(y);
|
|
|
|
|
float pz = floorf(z);
|
2017-10-07 02:15:12 +02:00
|
|
|
float fx = x - px;
|
|
|
|
|
float fy = y - py;
|
|
|
|
|
float fz = z - pz;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-07 02:15:12 +02:00
|
|
|
float g0x = cubic_g0(fx);
|
|
|
|
|
float g1x = cubic_g1(fx);
|
|
|
|
|
float g0y = cubic_g0(fy);
|
|
|
|
|
float g1y = cubic_g1(fy);
|
|
|
|
|
float g0z = cubic_g0(fz);
|
|
|
|
|
float g1z = cubic_g1(fz);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2020-11-06 15:19:58 +01:00
|
|
|
/* Note +0.5 offset to compensate for CUDA linear filtering convention. */
|
|
|
|
|
float x0 = (px + cubic_h0(fx) + 0.5f) / info.width;
|
|
|
|
|
float x1 = (px + cubic_h1(fx) + 0.5f) / info.width;
|
|
|
|
|
float y0 = (py + cubic_h0(fy) + 0.5f) / info.height;
|
|
|
|
|
float y1 = (py + cubic_h1(fy) + 0.5f) / info.height;
|
|
|
|
|
float z0 = (pz + cubic_h0(fz) + 0.5f) / info.depth;
|
|
|
|
|
float z1 = (pz + cubic_h1(fz) + 0.5f) / info.depth;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return g0z * (g0y * (g0x * ccl_gpu_tex_object_read_3D<T>(tex, x0, y0, z0) +
|
|
|
|
|
g1x * ccl_gpu_tex_object_read_3D<T>(tex, x1, y0, z0)) +
|
|
|
|
|
g1y * (g0x * ccl_gpu_tex_object_read_3D<T>(tex, x0, y1, z0) +
|
|
|
|
|
g1x * ccl_gpu_tex_object_read_3D<T>(tex, x1, y1, z0))) +
|
|
|
|
|
g1z * (g0y * (g0x * ccl_gpu_tex_object_read_3D<T>(tex, x0, y0, z1) +
|
|
|
|
|
g1x * ccl_gpu_tex_object_read_3D<T>(tex, x1, y0, z1)) +
|
|
|
|
|
g1y * (g0x * ccl_gpu_tex_object_read_3D<T>(tex, x0, y1, z1) +
|
|
|
|
|
g1x * ccl_gpu_tex_object_read_3D<T>(tex, x1, y1, z1)));
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
|
|
|
|
|
2020-10-02 17:40:28 +02:00
|
|
|
#ifdef WITH_NANOVDB
|
2020-11-06 15:19:58 +01:00
|
|
|
template<typename T, typename S>
|
|
|
|
|
ccl_device T kernel_tex_image_interp_tricubic_nanovdb(S &s, float x, float y, float z)
|
|
|
|
|
{
|
2021-03-08 13:59:16 +01:00
|
|
|
float px = floorf(x);
|
|
|
|
|
float py = floorf(y);
|
|
|
|
|
float pz = floorf(z);
|
2020-11-06 15:19:58 +01:00
|
|
|
float fx = x - px;
|
|
|
|
|
float fy = y - py;
|
|
|
|
|
float fz = z - pz;
|
|
|
|
|
|
|
|
|
|
float g0x = cubic_g0(fx);
|
|
|
|
|
float g1x = cubic_g1(fx);
|
|
|
|
|
float g0y = cubic_g0(fy);
|
|
|
|
|
float g1y = cubic_g1(fy);
|
|
|
|
|
float g0z = cubic_g0(fz);
|
|
|
|
|
float g1z = cubic_g1(fz);
|
|
|
|
|
|
|
|
|
|
float x0 = px + cubic_h0(fx);
|
|
|
|
|
float x1 = px + cubic_h1(fx);
|
|
|
|
|
float y0 = py + cubic_h0(fy);
|
|
|
|
|
float y1 = py + cubic_h1(fy);
|
|
|
|
|
float z0 = pz + cubic_h0(fz);
|
|
|
|
|
float z1 = pz + cubic_h1(fz);
|
|
|
|
|
|
|
|
|
|
using namespace nanovdb;
|
|
|
|
|
|
|
|
|
|
return g0z * (g0y * (g0x * s(Vec3f(x0, y0, z0)) + g1x * s(Vec3f(x1, y0, z0))) +
|
|
|
|
|
g1y * (g0x * s(Vec3f(x0, y1, z0)) + g1x * s(Vec3f(x1, y1, z0)))) +
|
|
|
|
|
g1z * (g0y * (g0x * s(Vec3f(x0, y0, z1)) + g1x * s(Vec3f(x1, y0, z1))) +
|
|
|
|
|
g1y * (g0x * s(Vec3f(x0, y1, z1)) + g1x * s(Vec3f(x1, y1, z1))));
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-02 17:40:28 +02:00
|
|
|
template<typename T>
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_device_noinline T kernel_tex_image_interp_nanovdb(
|
2020-10-02 17:40:28 +02:00
|
|
|
const TextureInfo &info, float x, float y, float z, uint interpolation)
|
|
|
|
|
{
|
2020-11-06 15:19:58 +01:00
|
|
|
using namespace nanovdb;
|
|
|
|
|
|
|
|
|
|
NanoGrid<T> *const grid = (NanoGrid<T> *)info.data;
|
2020-11-10 18:28:14 +01:00
|
|
|
typedef typename nanovdb::NanoGrid<T>::AccessorType AccessorType;
|
|
|
|
|
AccessorType acc = grid->getAccessor();
|
2020-10-02 17:40:28 +02:00
|
|
|
|
|
|
|
|
switch (interpolation) {
|
|
|
|
|
case INTERPOLATION_CLOSEST:
|
2020-11-10 18:28:14 +01:00
|
|
|
return SampleFromVoxels<AccessorType, 0, false>(acc)(Vec3f(x, y, z));
|
2020-11-04 15:09:06 +01:00
|
|
|
case INTERPOLATION_LINEAR:
|
2020-11-10 18:28:14 +01:00
|
|
|
return SampleFromVoxels<AccessorType, 1, false>(acc)(Vec3f(x - 0.5f, y - 0.5f, z - 0.5f));
|
2020-11-04 15:09:06 +01:00
|
|
|
default:
|
2020-11-10 18:28:14 +01:00
|
|
|
SampleFromVoxels<AccessorType, 1, false> s(acc);
|
2020-11-06 15:19:58 +01:00
|
|
|
return kernel_tex_image_interp_tricubic_nanovdb<T>(s, x - 0.5f, y - 0.5f, z - 0.5f);
|
2020-10-02 17:40:28 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_device float4 kernel_tex_image_interp(const KernelGlobals *kg, int id, float x, float y)
|
2017-10-06 21:47:41 +02:00
|
|
|
{
|
|
|
|
|
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-07-05 12:37:52 +02:00
|
|
|
/* float4, byte4, ushort4 and half4 */
|
2020-02-26 17:31:33 +01:00
|
|
|
const int texture_type = info.data_type;
|
2017-10-06 21:47:41 +02:00
|
|
|
if (texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 ||
|
2018-07-05 12:37:52 +02:00
|
|
|
texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) {
|
2017-10-07 02:15:12 +02:00
|
|
|
if (info.interpolation == INTERPOLATION_CUBIC) {
|
2020-10-02 17:40:28 +02:00
|
|
|
return kernel_tex_image_interp_bicubic<float4>(info, x, y);
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
|
|
|
|
else {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
|
|
|
|
|
return ccl_gpu_tex_object_read_2D<float4>(tex, x, y);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
2017-10-06 21:47:41 +02:00
|
|
|
/* float, byte and half */
|
|
|
|
|
else {
|
2017-10-07 02:15:12 +02:00
|
|
|
float f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-07 02:15:12 +02:00
|
|
|
if (info.interpolation == INTERPOLATION_CUBIC) {
|
2020-10-02 17:40:28 +02:00
|
|
|
f = kernel_tex_image_interp_bicubic<float>(info, x, y);
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
|
|
|
|
else {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
|
|
|
|
|
f = ccl_gpu_tex_object_read_2D<float>(tex, x, y);
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-06 21:47:41 +02:00
|
|
|
return make_float4(f, f, f, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_device float4 kernel_tex_image_interp_3d(const KernelGlobals *kg,
|
2020-03-17 16:48:00 +01:00
|
|
|
int id,
|
|
|
|
|
float3 P,
|
|
|
|
|
InterpolationType interp)
|
2017-10-06 21:47:41 +02:00
|
|
|
{
|
|
|
|
|
const TextureInfo &info = kernel_tex_fetch(__texture_info, id);
|
2020-03-17 16:48:00 +01:00
|
|
|
|
|
|
|
|
if (info.use_transform_3d) {
|
|
|
|
|
P = transform_point(&info.transform_3d, P);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const float x = P.x;
|
|
|
|
|
const float y = P.y;
|
|
|
|
|
const float z = P.z;
|
|
|
|
|
|
2017-10-07 02:15:12 +02:00
|
|
|
uint interpolation = (interp == INTERPOLATION_NONE) ? info.interpolation : interp;
|
2020-02-26 17:31:33 +01:00
|
|
|
const int texture_type = info.data_type;
|
2020-10-02 17:40:28 +02:00
|
|
|
|
|
|
|
|
#ifdef WITH_NANOVDB
|
|
|
|
|
if (texture_type == IMAGE_DATA_TYPE_NANOVDB_FLOAT) {
|
|
|
|
|
float f = kernel_tex_image_interp_nanovdb<float>(info, x, y, z, interpolation);
|
|
|
|
|
return make_float4(f, f, f, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
if (texture_type == IMAGE_DATA_TYPE_NANOVDB_FLOAT3) {
|
|
|
|
|
nanovdb::Vec3f f = kernel_tex_image_interp_nanovdb<nanovdb::Vec3f>(
|
|
|
|
|
info, x, y, z, interpolation);
|
|
|
|
|
return make_float4(f[0], f[1], f[2], 1.0f);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
2017-10-06 21:47:41 +02:00
|
|
|
if (texture_type == IMAGE_DATA_TYPE_FLOAT4 || texture_type == IMAGE_DATA_TYPE_BYTE4 ||
|
2018-07-05 12:37:52 +02:00
|
|
|
texture_type == IMAGE_DATA_TYPE_HALF4 || texture_type == IMAGE_DATA_TYPE_USHORT4) {
|
2017-10-07 02:15:12 +02:00
|
|
|
if (interpolation == INTERPOLATION_CUBIC) {
|
2020-11-06 15:19:58 +01:00
|
|
|
return kernel_tex_image_interp_tricubic<float4>(info, x, y, z);
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
|
|
|
|
else {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
|
|
|
|
|
return ccl_gpu_tex_object_read_3D<float4>(tex, x, y, z);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
2017-10-06 21:47:41 +02:00
|
|
|
else {
|
2017-10-07 02:15:12 +02:00
|
|
|
float f;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-07 02:15:12 +02:00
|
|
|
if (interpolation == INTERPOLATION_CUBIC) {
|
2020-11-06 15:19:58 +01:00
|
|
|
f = kernel_tex_image_interp_tricubic<float>(info, x, y, z);
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
|
|
|
|
else {
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
ccl_gpu_tex_object tex = (ccl_gpu_tex_object)info.data;
|
|
|
|
|
f = ccl_gpu_tex_object_read_3D<float>(tex, x, y, z);
|
2017-10-07 02:15:12 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-10-06 21:47:41 +02:00
|
|
|
return make_float4(f, f, f, 1.0f);
|
|
|
|
|
}
|
|
|
|
|
}
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|