2022-02-11 13:53:21 +01:00
|
|
|
/* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
* Copyright 2011-2022 Blender Foundation */
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Object Primitive
|
|
|
|
|
*
|
|
|
|
|
* All mesh and curve primitives are part of an object. The same mesh and curves
|
|
|
|
|
* may be instanced multiple times by different objects.
|
|
|
|
|
*
|
|
|
|
|
* If the mesh is not instanced multiple times, the object will not be explicitly
|
|
|
|
|
* stored as a primitive in the BVH, rather the bare triangles are curved are
|
|
|
|
|
* directly primitives in the BVH with world space locations applied, and the object
|
|
|
|
|
* ID is looked up afterwards. */
|
|
|
|
|
|
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
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Object attributes, for now a fixed size and contents */
|
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
enum ObjectTransform {
|
|
|
|
|
OBJECT_TRANSFORM = 0,
|
2018-03-08 06:48:14 +01:00
|
|
|
OBJECT_INVERSE_TRANSFORM = 1,
|
2012-12-20 19:26:57 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum ObjectVectorTransform { OBJECT_PASS_MOTION_PRE = 0, OBJECT_PASS_MOTION_POST = 1 };
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Object to world space transformation */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline Transform object_fetch_transform(KernelGlobals kg,
|
2013-11-16 00:17:10 +01:00
|
|
|
int object,
|
|
|
|
|
enum ObjectTransform type)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2018-03-07 22:19:56 +01:00
|
|
|
if (type == OBJECT_INVERSE_TRANSFORM) {
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).itfm;
|
2018-03-07 22:19:56 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).tfm;
|
2018-03-07 22:19:56 +01:00
|
|
|
}
|
2012-10-15 21:12:58 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2016-10-29 18:54:42 +02:00
|
|
|
/* Lamp to world space transformation */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline Transform lamp_fetch_transform(KernelGlobals kg, int lamp, bool inverse)
|
2016-10-29 18:54:42 +02:00
|
|
|
{
|
2018-03-08 00:15:41 +01:00
|
|
|
if (inverse) {
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(lights, lamp).itfm;
|
2018-03-08 00:15:41 +01:00
|
|
|
}
|
|
|
|
|
else {
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(lights, lamp).tfm;
|
2018-03-08 00:15:41 +01:00
|
|
|
}
|
2016-10-29 18:54:42 +02:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Object to world space transformation for motion vectors */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline Transform object_fetch_motion_pass_transform(KernelGlobals kg,
|
2018-03-10 00:37:07 +01:00
|
|
|
int object,
|
|
|
|
|
enum ObjectVectorTransform type)
|
2012-12-20 19:26:57 +00:00
|
|
|
{
|
2018-03-10 00:37:07 +01:00
|
|
|
int offset = object * OBJECT_MOTION_PASS_SIZE + (int)type;
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(object_motion_pass, offset);
|
2012-12-20 19:26:57 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Motion blurred object transformations */
|
|
|
|
|
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __OBJECT_MOTION__
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline Transform object_fetch_transform_motion(KernelGlobals kg, int object, float time)
|
2012-10-15 21:12:58 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
const uint motion_offset = kernel_data_fetch(objects, object).motion_offset;
|
|
|
|
|
ccl_global const DecomposedTransform *motion = &kernel_data_fetch(object_motion, motion_offset);
|
|
|
|
|
const uint num_steps = kernel_data_fetch(objects, object).numsteps * 2 + 1;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-10-17 22:48:29 +00:00
|
|
|
Transform tfm;
|
2020-02-17 23:44:12 +01:00
|
|
|
transform_motion_array_interpolate(&tfm, motion, num_steps, time);
|
2012-10-15 21:12:58 +00:00
|
|
|
|
2012-10-17 22:48:29 +00:00
|
|
|
return tfm;
|
|
|
|
|
}
|
2012-04-30 12:49:26 +00:00
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline Transform object_fetch_transform_motion_test(KernelGlobals kg,
|
2013-11-16 00:17:10 +01:00
|
|
|
int object,
|
|
|
|
|
float time,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private Transform *itfm)
|
2012-10-17 22:48:29 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
int object_flag = kernel_data_fetch(object_flag, object);
|
2012-10-17 22:48:29 +00:00
|
|
|
if (object_flag & SD_OBJECT_MOTION) {
|
|
|
|
|
/* if we do motion blur */
|
|
|
|
|
Transform tfm = object_fetch_transform_motion(kg, object, time);
|
2012-04-30 12:49:26 +00:00
|
|
|
|
2012-10-15 21:12:58 +00:00
|
|
|
if (itfm)
|
|
|
|
|
*itfm = transform_quick_inverse(tfm);
|
2012-10-17 22:48:29 +00:00
|
|
|
|
|
|
|
|
return tfm;
|
2012-04-30 12:49:26 +00:00
|
|
|
}
|
2012-10-15 21:12:58 +00:00
|
|
|
else {
|
2012-10-17 22:48:29 +00:00
|
|
|
Transform tfm = object_fetch_transform(kg, object, OBJECT_TRANSFORM);
|
2012-11-04 22:31:32 +00:00
|
|
|
if (itfm)
|
|
|
|
|
*itfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2012-10-17 22:48:29 +00:00
|
|
|
return tfm;
|
2012-10-15 21:12:58 +00:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2012-10-15 21:12:58 +00:00
|
|
|
#endif
|
2011-04-27 11:58:34 +00: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
|
|
|
/* Get transform matrix for shading point. */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline Transform object_get_transform(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const ShaderData *sd)
|
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
|
|
|
{
|
|
|
|
|
#ifdef __OBJECT_MOTION__
|
|
|
|
|
return (sd->object_flag & SD_OBJECT_MOTION) ?
|
|
|
|
|
sd->ob_tfm_motion :
|
|
|
|
|
object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
|
|
|
|
|
#else
|
|
|
|
|
return object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline Transform object_get_inverse_transform(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const ShaderData *sd)
|
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
|
|
|
{
|
|
|
|
|
#ifdef __OBJECT_MOTION__
|
|
|
|
|
return (sd->object_flag & SD_OBJECT_MOTION) ?
|
|
|
|
|
sd->ob_itfm_motion :
|
|
|
|
|
object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
|
|
|
|
|
#else
|
|
|
|
|
return object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Transform position from object to world space */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void object_position_transform(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const ShaderData *sd,
|
|
|
|
|
ccl_private float3 *P)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __OBJECT_MOTION__
|
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
|
|
|
if (sd->object_flag & SD_OBJECT_MOTION) {
|
|
|
|
|
*P = transform_point_auto(&sd->ob_tfm_motion, *P);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
|
2012-04-16 08:35:21 +00:00
|
|
|
*P = transform_point(&tfm, *P);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Transform position from world to object space */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void object_inverse_position_transform(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const ShaderData *sd,
|
|
|
|
|
ccl_private float3 *P)
|
2012-05-08 23:39:31 +00:00
|
|
|
{
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __OBJECT_MOTION__
|
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
|
|
|
if (sd->object_flag & SD_OBJECT_MOTION) {
|
|
|
|
|
*P = transform_point_auto(&sd->ob_itfm_motion, *P);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
|
2012-05-08 23:39:31 +00:00
|
|
|
*P = transform_point(&tfm, *P);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Transform normal from world to object space */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void object_inverse_normal_transform(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const ShaderData *sd,
|
|
|
|
|
ccl_private float3 *N)
|
2012-05-02 09:33:45 +00:00
|
|
|
{
|
2016-11-03 12:38:00 +01:00
|
|
|
#ifdef __OBJECT_MOTION__
|
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
|
|
|
if (sd->object_flag & SD_OBJECT_MOTION) {
|
|
|
|
|
if ((sd->object != OBJECT_NONE) || (sd->type == PRIMITIVE_LAMP)) {
|
|
|
|
|
*N = normalize(transform_direction_transposed_auto(&sd->ob_tfm_motion, *N));
|
|
|
|
|
}
|
|
|
|
|
return;
|
2016-11-03 03:08:14 +01: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
|
|
|
#endif
|
|
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE) {
|
|
|
|
|
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
|
2016-11-03 03:08:14 +01:00
|
|
|
*N = normalize(transform_direction_transposed(&tfm, *N));
|
|
|
|
|
}
|
2018-01-11 08:42:57 +01:00
|
|
|
else if (sd->type == PRIMITIVE_LAMP) {
|
|
|
|
|
Transform tfm = lamp_fetch_transform(kg, sd->lamp, false);
|
|
|
|
|
*N = normalize(transform_direction_transposed(&tfm, *N));
|
|
|
|
|
}
|
2012-05-02 09:33:45 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Transform normal from object to world space */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void object_normal_transform(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const ShaderData *sd,
|
|
|
|
|
ccl_private float3 *N)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __OBJECT_MOTION__
|
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
|
|
|
if (sd->object_flag & SD_OBJECT_MOTION) {
|
|
|
|
|
*N = normalize(transform_direction_transposed_auto(&sd->ob_itfm_motion, *N));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
|
2012-04-30 12:49:26 +00:00
|
|
|
*N = normalize(transform_direction_transposed(&tfm, *N));
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Transform direction vector from object to world space */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void object_dir_transform(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const ShaderData *sd,
|
|
|
|
|
ccl_private float3 *D)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __OBJECT_MOTION__
|
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
|
|
|
if (sd->object_flag & SD_OBJECT_MOTION) {
|
|
|
|
|
*D = transform_direction_auto(&sd->ob_tfm_motion, *D);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
|
2011-04-27 11:58:34 +00:00
|
|
|
*D = transform_direction(&tfm, *D);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Transform direction vector from world to object space */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void object_inverse_dir_transform(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const ShaderData *sd,
|
|
|
|
|
ccl_private float3 *D)
|
2013-07-31 21:18:23 +00:00
|
|
|
{
|
|
|
|
|
#ifdef __OBJECT_MOTION__
|
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
|
|
|
if (sd->object_flag & SD_OBJECT_MOTION) {
|
|
|
|
|
*D = transform_direction_auto(&sd->ob_itfm_motion, *D);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2013-07-31 21:18:23 +00: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
|
|
|
|
|
|
|
|
const Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_INVERSE_TRANSFORM);
|
|
|
|
|
*D = transform_direction(&tfm, *D);
|
2013-07-31 21:18:23 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Object center position */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float3 object_location(KernelGlobals kg, ccl_private const ShaderData *sd)
|
2012-05-21 12:52:28 +00:00
|
|
|
{
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object == OBJECT_NONE)
|
2012-10-16 13:20:57 +00:00
|
|
|
return make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
2012-10-09 18:37:14 +00:00
|
|
|
#ifdef __OBJECT_MOTION__
|
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
|
|
|
if (sd->object_flag & SD_OBJECT_MOTION) {
|
|
|
|
|
return make_float3(sd->ob_tfm_motion.x.w, sd->ob_tfm_motion.y.w, sd->ob_tfm_motion.z.w);
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
Transform tfm = object_fetch_transform(kg, sd->object, OBJECT_TRANSFORM);
|
2012-05-21 12:52:28 +00:00
|
|
|
return make_float3(tfm.x.w, tfm.y.w, tfm.z.w);
|
|
|
|
|
}
|
|
|
|
|
|
2019-08-22 14:26:09 +02:00
|
|
|
/* Color of the object */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float3 object_color(KernelGlobals kg, int object)
|
2019-08-22 14:26:09 +02:00
|
|
|
{
|
|
|
|
|
if (object == OBJECT_NONE)
|
|
|
|
|
return make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
ccl_global const KernelObject *kobject = &kernel_data_fetch(objects, object);
|
2019-08-22 14:26:09 +02:00
|
|
|
return make_float3(kobject->color[0], kobject->color[1], kobject->color[2]);
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-07 17:34:52 +01:00
|
|
|
/* Alpha of the object */
|
|
|
|
|
|
|
|
|
|
ccl_device_inline float object_alpha(KernelGlobals kg, int object)
|
|
|
|
|
{
|
|
|
|
|
if (object == OBJECT_NONE)
|
|
|
|
|
return 0.0f;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).alpha;
|
2022-03-07 17:34:52 +01:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Pass ID number of object */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float object_pass_id(KernelGlobals kg, int object)
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
{
|
2014-03-29 13:03:47 +01:00
|
|
|
if (object == OBJECT_NONE)
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
return 0.0f;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).pass_id;
|
Cycles: Render Passes
Currently supported passes:
* Combined, Z, Normal, Object Index, Material Index, Emission, Environment,
Diffuse/Glossy/Transmission x Direct/Indirect/Color
Not supported yet:
* UV, Vector, Mist
Only enabled for CPU devices at the moment, will do GPU tweaks tommorrow,
also for environment importance sampling.
Documentation:
http://wiki.blender.org/index.php/Doc:2.6/Manual/Render/Cycles/Passes
2012-01-25 17:23:52 +00:00
|
|
|
}
|
|
|
|
|
|
2022-04-02 00:11:11 +02:00
|
|
|
/* Lightgroup of lamp */
|
|
|
|
|
|
|
|
|
|
ccl_device_inline int lamp_lightgroup(KernelGlobals kg, int lamp)
|
|
|
|
|
{
|
|
|
|
|
if (lamp == LAMP_NONE)
|
|
|
|
|
return LIGHTGROUP_NONE;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(lights, lamp).lightgroup;
|
2022-04-02 00:11:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Lightgroup of object */
|
|
|
|
|
|
|
|
|
|
ccl_device_inline int object_lightgroup(KernelGlobals kg, int object)
|
|
|
|
|
{
|
|
|
|
|
if (object == OBJECT_NONE)
|
|
|
|
|
return LIGHTGROUP_NONE;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).lightgroup;
|
2022-04-02 00:11:11 +02:00
|
|
|
}
|
|
|
|
|
|
2017-11-05 21:59:17 +01:00
|
|
|
/* Per lamp random number for shader variation */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float lamp_random_number(KernelGlobals kg, int lamp)
|
2017-11-05 21:59:17 +01:00
|
|
|
{
|
|
|
|
|
if (lamp == LAMP_NONE)
|
|
|
|
|
return 0.0f;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(lights, lamp).random;
|
2017-11-05 21:59:17 +01:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Per object random number for shader variation */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float object_random_number(KernelGlobals kg, int object)
|
2012-05-21 12:52:28 +00:00
|
|
|
{
|
2014-03-29 13:03:47 +01:00
|
|
|
if (object == OBJECT_NONE)
|
2012-05-21 12:52:28 +00:00
|
|
|
return 0.0f;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).random_number;
|
2012-05-21 12:52:28 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Particle ID from which this object was generated */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline int object_particle_id(KernelGlobals kg, int object)
|
2012-06-08 16:17:57 +00:00
|
|
|
{
|
2014-03-29 13:03:47 +01:00
|
|
|
if (object == OBJECT_NONE)
|
2015-03-31 19:51:55 +05:00
|
|
|
return 0;
|
2012-06-08 16:17:57 +00:00
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).particle_index;
|
2012-06-08 16:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Generated texture coordinate on surface from where object was instanced */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float3 object_dupli_generated(KernelGlobals kg, int object)
|
2012-10-04 21:40:39 +00:00
|
|
|
{
|
2014-03-29 13:03:47 +01:00
|
|
|
if (object == OBJECT_NONE)
|
2012-10-04 21:40:39 +00:00
|
|
|
return make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
ccl_global const KernelObject *kobject = &kernel_data_fetch(objects, object);
|
2018-03-07 22:19:56 +01:00
|
|
|
return make_float3(
|
|
|
|
|
kobject->dupli_generated[0], kobject->dupli_generated[1], kobject->dupli_generated[2]);
|
2012-10-04 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* UV texture coordinate on surface from where object was instanced */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float3 object_dupli_uv(KernelGlobals kg, int object)
|
2012-10-04 21:40:39 +00:00
|
|
|
{
|
2014-03-29 13:03:47 +01:00
|
|
|
if (object == OBJECT_NONE)
|
2012-10-04 21:40:39 +00:00
|
|
|
return make_float3(0.0f, 0.0f, 0.0f);
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
ccl_global const KernelObject *kobject = &kernel_data_fetch(objects, object);
|
2018-03-07 22:19:56 +01:00
|
|
|
return make_float3(kobject->dupli_uv[0], kobject->dupli_uv[1], 0.0f);
|
2012-10-04 21:40:39 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Information about mesh for motion blurred triangles and curves */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void object_motion_info(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
int object,
|
|
|
|
|
ccl_private int *numsteps,
|
|
|
|
|
ccl_private int *numverts,
|
|
|
|
|
ccl_private int *numkeys)
|
2014-03-29 13:03:46 +01:00
|
|
|
{
|
|
|
|
|
if (numkeys) {
|
2022-06-17 17:16:37 +02:00
|
|
|
*numkeys = kernel_data_fetch(objects, object).numkeys;
|
2014-03-29 13:03:46 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (numsteps)
|
2022-06-17 17:16:37 +02:00
|
|
|
*numsteps = kernel_data_fetch(objects, object).numsteps;
|
2014-03-29 13:03:46 +01:00
|
|
|
if (numverts)
|
2022-06-17 17:16:37 +02:00
|
|
|
*numverts = kernel_data_fetch(objects, object).numverts;
|
2014-03-29 13:03:46 +01:00
|
|
|
}
|
2012-10-04 21:40:39 +00:00
|
|
|
|
2016-07-16 22:57:06 -04:00
|
|
|
/* Offset to an objects patch map */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline uint object_patch_map_offset(KernelGlobals kg, int object)
|
2016-07-16 22:57:06 -04:00
|
|
|
{
|
|
|
|
|
if (object == OBJECT_NONE)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).patch_map_offset;
|
2016-07-16 22:57:06 -04:00
|
|
|
}
|
|
|
|
|
|
2020-03-07 14:38:52 +01:00
|
|
|
/* Volume step size */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float object_volume_density(KernelGlobals kg, int object)
|
2020-03-16 14:42:56 +01:00
|
|
|
{
|
|
|
|
|
if (object == OBJECT_NONE) {
|
|
|
|
|
return 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).volume_density;
|
2020-03-16 14:42:56 +01:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float object_volume_step_size(KernelGlobals kg, int object)
|
2020-03-07 14:38:52 +01:00
|
|
|
{
|
|
|
|
|
if (object == OBJECT_NONE) {
|
|
|
|
|
return kernel_data.background.volume_step_size;
|
|
|
|
|
}
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(object_volume_step, object);
|
2020-03-07 14:38:52 +01:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Pass ID for shader */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device int shader_pass_id(KernelGlobals kg, ccl_private const ShaderData *sd)
|
2012-05-21 12:52:28 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(shaders, (sd->shader & SHADER_MASK)).pass_id;
|
2012-05-21 12:52:28 +00:00
|
|
|
}
|
|
|
|
|
|
2018-10-28 05:37:41 -04:00
|
|
|
/* Cryptomatte ID */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float object_cryptomatte_id(KernelGlobals kg, int object)
|
2018-10-28 05:37:41 -04:00
|
|
|
{
|
|
|
|
|
if (object == OBJECT_NONE)
|
|
|
|
|
return 0.0f;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).cryptomatte_object;
|
2018-10-28 05:37:41 -04:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float object_cryptomatte_asset_id(KernelGlobals kg, int object)
|
2018-10-28 05:37:41 -04:00
|
|
|
{
|
|
|
|
|
if (object == OBJECT_NONE)
|
|
|
|
|
return 0;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(objects, object).cryptomatte_asset;
|
2018-10-28 05:37:41 -04:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Particle data from which object was instanced */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline uint particle_index(KernelGlobals kg, int particle)
|
2012-06-08 16:17:57 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(particles, particle).index;
|
2012-06-08 16:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device float particle_age(KernelGlobals kg, int particle)
|
2012-06-08 16:17:57 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(particles, particle).age;
|
2012-06-08 16:17:57 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device float particle_lifetime(KernelGlobals kg, int particle)
|
2012-07-26 11:40:58 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(particles, particle).lifetime;
|
2012-07-26 11:40:58 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device float particle_size(KernelGlobals kg, int particle)
|
2012-08-31 19:38:59 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(particles, particle).size;
|
2012-08-31 19:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device float4 particle_rotation(KernelGlobals kg, int particle)
|
2012-08-31 19:38:59 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
return kernel_data_fetch(particles, particle).rotation;
|
2012-08-31 19:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device float3 particle_location(KernelGlobals kg, int particle)
|
2012-08-31 19:38:59 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
return float4_to_float3(kernel_data_fetch(particles, particle).location);
|
2012-08-31 19:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device float3 particle_velocity(KernelGlobals kg, int particle)
|
2012-08-31 19:38:59 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
return float4_to_float3(kernel_data_fetch(particles, particle).velocity);
|
2012-08-31 19:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device float3 particle_angular_velocity(KernelGlobals kg, int particle)
|
2012-08-31 19:38:59 +00:00
|
|
|
{
|
2022-06-17 17:16:37 +02:00
|
|
|
return float4_to_float3(kernel_data_fetch(particles, particle).angular_velocity);
|
2012-08-31 19:38:59 +00:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Object intersection in BVH */
|
2014-03-29 13:03:45 +01:00
|
|
|
|
2014-04-03 22:08:53 +04:00
|
|
|
ccl_device_inline float3 bvh_clamp_direction(float3 dir)
|
2014-03-29 13:03:45 +01:00
|
|
|
{
|
2016-10-25 14:47:34 +02:00
|
|
|
const float ooeps = 8.271806E-25f;
|
2014-04-03 22:08:53 +04:00
|
|
|
return make_float3((fabsf(dir.x) > ooeps) ? dir.x : copysignf(ooeps, dir.x),
|
2014-05-05 02:19:08 +10:00
|
|
|
(fabsf(dir.y) > ooeps) ? dir.y : copysignf(ooeps, dir.y),
|
|
|
|
|
(fabsf(dir.z) > ooeps) ? dir.z : copysignf(ooeps, dir.z));
|
2014-04-03 22:08:53 +04:00
|
|
|
}
|
2014-03-29 13:03:45 +01:00
|
|
|
|
2014-04-03 22:08:53 +04:00
|
|
|
ccl_device_inline float3 bvh_inverse_direction(float3 dir)
|
|
|
|
|
{
|
2016-10-25 14:47:34 +02:00
|
|
|
return rcp(dir);
|
2014-03-29 13:03:45 +01:00
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Transform ray into object space to enter static object in BVH */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float bvh_instance_push(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
int object,
|
|
|
|
|
ccl_private const Ray *ray,
|
|
|
|
|
ccl_private float3 *P,
|
|
|
|
|
ccl_private float3 *dir,
|
|
|
|
|
ccl_private float3 *idir)
|
2014-03-29 13:03:45 +01:00
|
|
|
{
|
|
|
|
|
Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
|
|
|
|
|
|
|
|
|
|
*P = transform_point(&tfm, ray->P);
|
|
|
|
|
|
|
|
|
|
float len;
|
2014-04-03 22:08:53 +04:00
|
|
|
*dir = bvh_clamp_direction(normalize_len(transform_direction(&tfm, ray->D), &len));
|
|
|
|
|
*idir = bvh_inverse_direction(*dir);
|
2014-03-29 13:03:45 +01: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 len;
|
2014-03-29 13:03:45 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Transform ray to exit static object in BVH. */
|
2014-03-29 13:03:48 +01:00
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float bvh_instance_pop(KernelGlobals kg,
|
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
|
|
|
int object,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const Ray *ray,
|
|
|
|
|
ccl_private float3 *P,
|
|
|
|
|
ccl_private float3 *dir,
|
|
|
|
|
ccl_private float3 *idir,
|
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
|
|
|
float t)
|
2014-03-29 13:03:45 +01:00
|
|
|
{
|
2017-03-08 15:42:26 +01:00
|
|
|
if (t != FLT_MAX) {
|
2015-10-08 20:30:51 +05:00
|
|
|
Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
|
2017-03-08 15:42:26 +01:00
|
|
|
t /= len(transform_direction(&tfm, ray->D));
|
2014-03-29 13:03:45 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
*P = ray->P;
|
2014-04-03 22:08:53 +04:00
|
|
|
*dir = bvh_clamp_direction(ray->D);
|
|
|
|
|
*idir = bvh_inverse_direction(*dir);
|
2017-03-08 15:42:26 +01:00
|
|
|
|
|
|
|
|
return t;
|
2014-03-29 13:03:45 +01:00
|
|
|
}
|
|
|
|
|
|
2014-04-19 17:02:30 +02:00
|
|
|
/* Same as above, but returns scale factor to apply to multiple intersection distances */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void bvh_instance_pop_factor(KernelGlobals kg,
|
2014-04-19 17:02:30 +02:00
|
|
|
int object,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const Ray *ray,
|
|
|
|
|
ccl_private float3 *P,
|
|
|
|
|
ccl_private float3 *dir,
|
|
|
|
|
ccl_private float3 *idir,
|
|
|
|
|
ccl_private float *t_fac)
|
2014-04-19 17:02:30 +02:00
|
|
|
{
|
2015-10-08 20:30:51 +05:00
|
|
|
Transform tfm = object_fetch_transform(kg, object, OBJECT_INVERSE_TRANSFORM);
|
|
|
|
|
*t_fac = 1.0f / len(transform_direction(&tfm, ray->D));
|
2014-04-19 17:02:30 +02:00
|
|
|
|
|
|
|
|
*P = ray->P;
|
|
|
|
|
*dir = bvh_clamp_direction(ray->D);
|
|
|
|
|
*idir = bvh_inverse_direction(*dir);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:45 +01:00
|
|
|
#ifdef __OBJECT_MOTION__
|
2014-03-29 13:03:48 +01:00
|
|
|
/* Transform ray into object space to enter motion blurred object in BVH */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float bvh_instance_motion_push(KernelGlobals kg,
|
2015-10-08 21:24:54 +05:00
|
|
|
int object,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const Ray *ray,
|
|
|
|
|
ccl_private float3 *P,
|
|
|
|
|
ccl_private float3 *dir,
|
|
|
|
|
ccl_private float3 *idir,
|
|
|
|
|
ccl_private Transform *itfm)
|
2014-03-29 13:03:45 +01:00
|
|
|
{
|
2015-10-08 21:24:54 +05:00
|
|
|
object_fetch_transform_motion_test(kg, object, ray->time, itfm);
|
2014-03-29 13:03:45 +01:00
|
|
|
|
2015-10-08 21:24:54 +05:00
|
|
|
*P = transform_point(itfm, ray->P);
|
2014-03-29 13:03:45 +01:00
|
|
|
|
|
|
|
|
float len;
|
2015-10-08 21:24:54 +05:00
|
|
|
*dir = bvh_clamp_direction(normalize_len(transform_direction(itfm, ray->D), &len));
|
2014-04-03 22:08:53 +04:00
|
|
|
*idir = bvh_inverse_direction(*dir);
|
2014-03-29 13:03:45 +01: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 len;
|
2014-03-29 13:03:45 +01:00
|
|
|
}
|
|
|
|
|
|
2021-02-05 16:23:34 +11:00
|
|
|
/* Transform ray to exit motion blurred object in BVH. */
|
2014-03-29 13:03:48 +01:00
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline float bvh_instance_motion_pop(KernelGlobals kg,
|
2017-03-08 15:42:26 +01:00
|
|
|
int object,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const Ray *ray,
|
|
|
|
|
ccl_private float3 *P,
|
|
|
|
|
ccl_private float3 *dir,
|
|
|
|
|
ccl_private float3 *idir,
|
2017-03-08 15:42:26 +01:00
|
|
|
float t,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private Transform *itfm)
|
2017-03-08 15:42:26 +01:00
|
|
|
{
|
|
|
|
|
if (t != FLT_MAX) {
|
|
|
|
|
t /= len(transform_direction(itfm, ray->D));
|
2015-10-08 21:24:54 +05:00
|
|
|
}
|
2014-03-29 13:03:45 +01:00
|
|
|
|
|
|
|
|
*P = ray->P;
|
2014-04-03 22:08:53 +04:00
|
|
|
*dir = bvh_clamp_direction(ray->D);
|
|
|
|
|
*idir = bvh_inverse_direction(*dir);
|
2017-03-08 15:42:26 +01:00
|
|
|
|
|
|
|
|
return t;
|
2014-03-29 13:03:45 +01:00
|
|
|
}
|
2014-04-19 17:02:30 +02:00
|
|
|
|
|
|
|
|
/* Same as above, but returns scale factor to apply to multiple intersection distances */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void bvh_instance_motion_pop_factor(KernelGlobals kg,
|
2015-10-08 21:24:54 +05:00
|
|
|
int object,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private const Ray *ray,
|
|
|
|
|
ccl_private float3 *P,
|
|
|
|
|
ccl_private float3 *dir,
|
|
|
|
|
ccl_private float3 *idir,
|
|
|
|
|
ccl_private float *t_fac,
|
|
|
|
|
ccl_private Transform *itfm)
|
2014-04-19 17:02:30 +02:00
|
|
|
{
|
2016-05-04 14:46:30 +02:00
|
|
|
*t_fac = 1.0f / len(transform_direction(itfm, ray->D));
|
2014-04-19 17:02:30 +02:00
|
|
|
*P = ray->P;
|
|
|
|
|
*dir = bvh_clamp_direction(ray->D);
|
|
|
|
|
*idir = bvh_inverse_direction(*dir);
|
|
|
|
|
}
|
|
|
|
|
|
2014-03-29 13:03:45 +01: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
|
|
|
/* TODO: This can be removed when we know if no devices will require explicit
|
|
|
|
|
* address space qualifiers for this case. */
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05: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
|
|
|
#define object_position_transform_auto object_position_transform
|
|
|
|
|
#define object_dir_transform_auto object_dir_transform
|
|
|
|
|
#define object_normal_transform_auto object_normal_transform
|
Cycles: OpenCL kernel split
This commit contains all the work related on the AMD megakernel split work
which was mainly done by Varun Sundar, George Kyriazis and Lenny Wang, plus
some help from Sergey Sharybin, Martijn Berger, Thomas Dinges and likely
someone else which we're forgetting to mention.
Currently only AMD cards are enabled for the new split kernel, but it is
possible to force split opencl kernel to be used by setting the following
environment variable: CYCLES_OPENCL_SPLIT_KERNEL_TEST=1.
Not all the features are supported yet, and that being said no motion blur,
camera blur, SSS and volumetrics for now. Also transparent shadows are
disabled on AMD device because of some compiler bug.
This kernel is also only implements regular path tracing and supporting
branched one will take a bit. Branched path tracing is exposed to the
interface still, which is a bit misleading and will be hidden there soon.
More feature will be enabled once they're ported to the split kernel and
tested.
Neither regular CPU nor CUDA has any difference, they're generating the
same exact code, which means no regressions/improvements there.
Based on the research paper:
https://research.nvidia.com/sites/default/files/publications/laine2013hpg_paper.pdf
Here's the documentation:
https://docs.google.com/document/d/1LuXW-CV-sVJkQaEGZlMJ86jZ8FmoPfecaMdR-oiWbUY/edit
Design discussion of the patch:
https://developer.blender.org/T44197
Differential Revision: https://developer.blender.org/D1200
2015-05-09 19:34:30 +05:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|