2022-02-11 13:53:21 +01:00
|
|
|
/* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
* Copyright 2011-2022 Blender Foundation */
|
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
|
|
|
|
|
|
|
|
/* Functions to initialize ShaderData given.
|
|
|
|
|
*
|
|
|
|
|
* Could be from an incoming ray, intersection or sampled position. */
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
|
|
/* ShaderData setup from incoming ray */
|
|
|
|
|
|
|
|
|
|
#ifdef __OBJECT_MOTION__
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device void shader_setup_object_transforms(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 ShaderData *ccl_restrict 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
|
|
|
float time)
|
|
|
|
|
{
|
|
|
|
|
if (sd->object_flag & SD_OBJECT_MOTION) {
|
|
|
|
|
sd->ob_tfm_motion = object_fetch_transform_motion(kg, sd->object, time);
|
|
|
|
|
sd->ob_itfm_motion = transform_quick_inverse(sd->ob_tfm_motion);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* TODO: break this up if it helps reduce register pressure to load data from
|
2021-10-06 14:44:27 +11:00
|
|
|
* global memory as we write it to shader-data. */
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void shader_setup_from_ray(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 ShaderData *ccl_restrict sd,
|
|
|
|
|
ccl_private const Ray *ccl_restrict ray,
|
|
|
|
|
ccl_private const Intersection *ccl_restrict isect)
|
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
|
|
|
{
|
|
|
|
|
/* Read intersection data into shader globals.
|
|
|
|
|
*
|
|
|
|
|
* TODO: this is redundant, could potentially remove some of this from
|
|
|
|
|
* ShaderData but would need to ensure that it also works for shadow
|
|
|
|
|
* shader evaluation. */
|
|
|
|
|
sd->u = isect->u;
|
|
|
|
|
sd->v = isect->v;
|
|
|
|
|
sd->ray_length = isect->t;
|
|
|
|
|
sd->type = isect->type;
|
2021-02-28 23:23:24 +01:00
|
|
|
sd->object = isect->object;
|
2022-06-17 17:16:37 +02:00
|
|
|
sd->object_flag = kernel_data_fetch(object_flag, sd->object);
|
2021-02-28 23:23:24 +01:00
|
|
|
sd->prim = isect->prim;
|
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
|
|
|
sd->lamp = LAMP_NONE;
|
|
|
|
|
sd->flag = 0;
|
|
|
|
|
|
|
|
|
|
/* Read matrices and time. */
|
|
|
|
|
sd->time = ray->time;
|
|
|
|
|
|
|
|
|
|
#ifdef __OBJECT_MOTION__
|
|
|
|
|
shader_setup_object_transforms(kg, sd, ray->time);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Read ray data into shader globals. */
|
|
|
|
|
sd->I = -ray->D;
|
|
|
|
|
|
|
|
|
|
#ifdef __HAIR__
|
2021-12-20 02:52:56 +01:00
|
|
|
if (sd->type & PRIMITIVE_CURVE) {
|
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
|
|
|
/* curve */
|
|
|
|
|
curve_shader_setup(kg, sd, ray->P, ray->D, isect->t, isect->object, isect->prim);
|
|
|
|
|
}
|
|
|
|
|
else
|
2021-12-01 17:30:46 +01:00
|
|
|
#endif
|
|
|
|
|
#ifdef __POINTCLOUD__
|
2021-12-20 02:52:56 +01:00
|
|
|
if (sd->type & PRIMITIVE_POINT) {
|
2021-12-01 17:30:46 +01:00
|
|
|
/* point */
|
|
|
|
|
point_shader_setup(kg, sd, isect, ray);
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
#endif
|
2021-12-20 06:00:38 +01:00
|
|
|
{
|
|
|
|
|
if (sd->type == PRIMITIVE_TRIANGLE) {
|
|
|
|
|
/* static triangle */
|
|
|
|
|
float3 Ng = triangle_normal(kg, sd);
|
2022-06-17 17:16:37 +02:00
|
|
|
sd->shader = kernel_data_fetch(tri_shader, sd->prim);
|
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
|
|
|
|
2021-12-20 06:00:38 +01:00
|
|
|
/* vectors */
|
2022-01-13 17:12:03 +01:00
|
|
|
sd->P = triangle_point_from_uv(kg, sd, isect->object, isect->prim, isect->u, isect->v);
|
2021-12-20 06:00:38 +01:00
|
|
|
sd->Ng = Ng;
|
|
|
|
|
sd->N = Ng;
|
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
|
|
|
|
2021-12-20 06:00:38 +01:00
|
|
|
/* smooth normal */
|
|
|
|
|
if (sd->shader & SHADER_SMOOTH_NORMAL)
|
|
|
|
|
sd->N = triangle_smooth_normal(kg, Ng, sd->prim, sd->u, sd->v);
|
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 __DPDU__
|
2021-12-20 06:00:38 +01:00
|
|
|
/* dPdu/dPdv */
|
|
|
|
|
triangle_dPdudv(kg, sd->prim, &sd->dPdu, &sd->dPdv);
|
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
|
2021-12-20 06:00:38 +01:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
/* motion triangle */
|
|
|
|
|
motion_triangle_shader_setup(
|
|
|
|
|
kg, sd, ray->P, ray->D, isect->t, isect->object, isect->prim, false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
|
|
|
|
|
/* instance transform */
|
|
|
|
|
object_normal_transform_auto(kg, sd, &sd->N);
|
|
|
|
|
object_normal_transform_auto(kg, sd, &sd->Ng);
|
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 __DPDU__
|
2021-12-20 06:00:38 +01:00
|
|
|
object_dir_transform_auto(kg, sd, &sd->dPdu);
|
|
|
|
|
object_dir_transform_auto(kg, sd, &sd->dPdv);
|
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
|
2021-12-20 06:00:38 +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
|
|
|
}
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
sd->flag = kernel_data_fetch(shaders, (sd->shader & SHADER_MASK)).flags;
|
2021-12-20 06:00:38 +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
|
|
|
/* backfacing test */
|
|
|
|
|
bool backfacing = (dot(sd->Ng, sd->I) < 0.0f);
|
|
|
|
|
|
|
|
|
|
if (backfacing) {
|
|
|
|
|
sd->flag |= SD_BACKFACING;
|
|
|
|
|
sd->Ng = -sd->Ng;
|
|
|
|
|
sd->N = -sd->N;
|
|
|
|
|
#ifdef __DPDU__
|
|
|
|
|
sd->dPdu = -sd->dPdu;
|
|
|
|
|
sd->dPdv = -sd->dPdv;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
|
/* differentials */
|
|
|
|
|
differential_transfer_compact(&sd->dP, ray->dP, ray->D, ray->dD, sd->Ng, sd->ray_length);
|
|
|
|
|
differential_incoming_compact(&sd->dI, ray->D, ray->dD);
|
|
|
|
|
differential_dudv(&sd->du, &sd->dv, sd->dPdu, sd->dPdv, sd->dP, sd->Ng);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ShaderData setup from position sampled on mesh */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void shader_setup_from_sample(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 ShaderData *ccl_restrict 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
|
|
|
const float3 P,
|
|
|
|
|
const float3 Ng,
|
|
|
|
|
const float3 I,
|
|
|
|
|
int shader,
|
|
|
|
|
int object,
|
|
|
|
|
int prim,
|
|
|
|
|
float u,
|
|
|
|
|
float v,
|
|
|
|
|
float t,
|
|
|
|
|
float time,
|
|
|
|
|
bool object_space,
|
|
|
|
|
int lamp)
|
|
|
|
|
{
|
|
|
|
|
/* vectors */
|
|
|
|
|
sd->P = P;
|
|
|
|
|
sd->N = Ng;
|
|
|
|
|
sd->Ng = Ng;
|
|
|
|
|
sd->I = I;
|
|
|
|
|
sd->shader = shader;
|
|
|
|
|
if (prim != PRIM_NONE)
|
|
|
|
|
sd->type = PRIMITIVE_TRIANGLE;
|
|
|
|
|
else if (lamp != LAMP_NONE)
|
|
|
|
|
sd->type = PRIMITIVE_LAMP;
|
|
|
|
|
else
|
|
|
|
|
sd->type = PRIMITIVE_NONE;
|
|
|
|
|
|
|
|
|
|
/* primitive */
|
|
|
|
|
sd->object = object;
|
|
|
|
|
sd->lamp = LAMP_NONE;
|
|
|
|
|
/* Currently no access to bvh prim index for strand sd->prim. */
|
|
|
|
|
sd->prim = prim;
|
|
|
|
|
sd->u = u;
|
|
|
|
|
sd->v = v;
|
|
|
|
|
sd->time = time;
|
|
|
|
|
sd->ray_length = t;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
sd->flag = kernel_data_fetch(shaders, (sd->shader & SHADER_MASK)).flags;
|
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
|
|
|
sd->object_flag = 0;
|
|
|
|
|
if (sd->object != OBJECT_NONE) {
|
2022-06-17 17:16:37 +02:00
|
|
|
sd->object_flag |= kernel_data_fetch(object_flag, sd->object);
|
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__
|
|
|
|
|
shader_setup_object_transforms(kg, sd, time);
|
|
|
|
|
#endif
|
|
|
|
|
|
2022-01-28 14:16:06 +01:00
|
|
|
/* transform into world space */
|
|
|
|
|
if (object_space) {
|
|
|
|
|
object_position_transform_auto(kg, sd, &sd->P);
|
|
|
|
|
object_normal_transform_auto(kg, sd, &sd->Ng);
|
|
|
|
|
sd->N = sd->Ng;
|
|
|
|
|
object_dir_transform_auto(kg, sd, &sd->I);
|
|
|
|
|
}
|
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
|
|
|
|
2022-01-28 14:16:06 +01:00
|
|
|
if (sd->type == PRIMITIVE_TRIANGLE) {
|
|
|
|
|
/* smooth normal */
|
|
|
|
|
if (sd->shader & SHADER_SMOOTH_NORMAL) {
|
|
|
|
|
sd->N = triangle_smooth_normal(kg, Ng, sd->prim, sd->u, sd->v);
|
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
|
|
|
|
2022-01-28 14:16:06 +01:00
|
|
|
if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
|
|
|
|
|
object_normal_transform_auto(kg, sd, &sd->N);
|
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
|
2022-01-28 14:16:06 +01:00
|
|
|
/* dPdu/dPdv */
|
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 __DPDU__
|
2022-01-28 14:16:06 +01:00
|
|
|
triangle_dPdudv(kg, sd->prim, &sd->dPdu, &sd->dPdv);
|
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
|
|
|
|
2022-01-28 14:16:06 +01:00
|
|
|
if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
|
|
|
|
|
object_dir_transform_auto(kg, sd, &sd->dPdu);
|
|
|
|
|
object_dir_transform_auto(kg, sd, &sd->dPdv);
|
|
|
|
|
}
|
|
|
|
|
#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
|
|
|
}
|
2022-01-28 14:16:06 +01:00
|
|
|
else {
|
|
|
|
|
#ifdef __DPDU__
|
|
|
|
|
sd->dPdu = zero_float3();
|
|
|
|
|
sd->dPdv = zero_float3();
|
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
|
2022-01-28 14:16:06 +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
|
|
|
}
|
|
|
|
|
else {
|
2022-01-28 14:16:06 +01:00
|
|
|
if (lamp != LAMP_NONE) {
|
|
|
|
|
sd->lamp = lamp;
|
|
|
|
|
}
|
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 __DPDU__
|
|
|
|
|
sd->dPdu = zero_float3();
|
|
|
|
|
sd->dPdv = zero_float3();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* backfacing test */
|
|
|
|
|
if (sd->prim != PRIM_NONE) {
|
|
|
|
|
bool backfacing = (dot(sd->Ng, sd->I) < 0.0f);
|
|
|
|
|
|
|
|
|
|
if (backfacing) {
|
|
|
|
|
sd->flag |= SD_BACKFACING;
|
|
|
|
|
sd->Ng = -sd->Ng;
|
|
|
|
|
sd->N = -sd->N;
|
|
|
|
|
#ifdef __DPDU__
|
|
|
|
|
sd->dPdu = -sd->dPdu;
|
|
|
|
|
sd->dPdv = -sd->dPdv;
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
|
/* no ray differentials here yet */
|
|
|
|
|
sd->dP = differential3_zero();
|
|
|
|
|
sd->dI = differential3_zero();
|
|
|
|
|
sd->du = differential_zero();
|
|
|
|
|
sd->dv = differential_zero();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ShaderData setup for displacement */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device void shader_setup_from_displace(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 ShaderData *ccl_restrict 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
|
|
|
int object,
|
|
|
|
|
int prim,
|
|
|
|
|
float u,
|
|
|
|
|
float v)
|
|
|
|
|
{
|
|
|
|
|
float3 P, Ng, I = zero_float3();
|
|
|
|
|
int shader;
|
|
|
|
|
|
|
|
|
|
triangle_point_normal(kg, object, prim, u, v, &P, &Ng, &shader);
|
|
|
|
|
|
|
|
|
|
/* force smooth shading for displacement */
|
|
|
|
|
shader |= SHADER_SMOOTH_NORMAL;
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
shader_setup_from_sample(kg,
|
|
|
|
|
sd,
|
|
|
|
|
P,
|
|
|
|
|
Ng,
|
|
|
|
|
I,
|
|
|
|
|
shader,
|
|
|
|
|
object,
|
|
|
|
|
prim,
|
|
|
|
|
u,
|
|
|
|
|
v,
|
|
|
|
|
0.0f,
|
|
|
|
|
0.5f,
|
|
|
|
|
!(kernel_data_fetch(object_flag, object) & SD_OBJECT_TRANSFORM_APPLIED),
|
|
|
|
|
LAMP_NONE);
|
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
|
|
|
}
|
|
|
|
|
|
2021-09-20 16:16:11 +02:00
|
|
|
/* ShaderData setup for point on curve. */
|
|
|
|
|
|
|
|
|
|
ccl_device void shader_setup_from_curve(KernelGlobals kg,
|
|
|
|
|
ccl_private ShaderData *ccl_restrict sd,
|
|
|
|
|
int object,
|
|
|
|
|
int prim,
|
|
|
|
|
int segment,
|
|
|
|
|
float u)
|
|
|
|
|
{
|
|
|
|
|
/* Primitive */
|
|
|
|
|
sd->type = PRIMITIVE_PACK_SEGMENT(PRIMITIVE_CURVE_THICK, segment);
|
|
|
|
|
sd->lamp = LAMP_NONE;
|
|
|
|
|
sd->prim = prim;
|
|
|
|
|
sd->u = u;
|
|
|
|
|
sd->v = 0.0f;
|
|
|
|
|
sd->time = 0.5f;
|
|
|
|
|
sd->ray_length = 0.0f;
|
|
|
|
|
|
|
|
|
|
/* Shader */
|
2022-06-17 17:16:37 +02:00
|
|
|
sd->shader = kernel_data_fetch(curves, prim).shader_id;
|
|
|
|
|
sd->flag = kernel_data_fetch(shaders, (sd->shader & SHADER_MASK)).flags;
|
2021-09-20 16:16:11 +02:00
|
|
|
|
|
|
|
|
/* Object */
|
|
|
|
|
sd->object = object;
|
2022-06-17 17:16:37 +02:00
|
|
|
sd->object_flag = kernel_data_fetch(object_flag, sd->object);
|
2021-09-20 16:16:11 +02:00
|
|
|
#ifdef __OBJECT_MOTION__
|
|
|
|
|
shader_setup_object_transforms(kg, sd, sd->time);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Get control points. */
|
2022-06-17 17:16:37 +02:00
|
|
|
KernelCurve kcurve = kernel_data_fetch(curves, prim);
|
2021-09-20 16:16:11 +02:00
|
|
|
|
|
|
|
|
int k0 = kcurve.first_key + PRIMITIVE_UNPACK_SEGMENT(sd->type);
|
|
|
|
|
int k1 = k0 + 1;
|
|
|
|
|
int ka = max(k0 - 1, kcurve.first_key);
|
|
|
|
|
int kb = min(k1 + 1, kcurve.first_key + kcurve.num_keys - 1);
|
|
|
|
|
|
|
|
|
|
float4 P_curve[4];
|
|
|
|
|
|
2022-06-17 17:16:37 +02:00
|
|
|
P_curve[0] = kernel_data_fetch(curve_keys, ka);
|
|
|
|
|
P_curve[1] = kernel_data_fetch(curve_keys, k0);
|
|
|
|
|
P_curve[2] = kernel_data_fetch(curve_keys, k1);
|
|
|
|
|
P_curve[3] = kernel_data_fetch(curve_keys, kb);
|
2021-09-20 16:16:11 +02:00
|
|
|
|
|
|
|
|
/* Interpolate position and tangent. */
|
|
|
|
|
sd->P = float4_to_float3(catmull_rom_basis_derivative(P_curve, sd->u));
|
|
|
|
|
#ifdef __DPDU__
|
|
|
|
|
sd->dPdu = float4_to_float3(catmull_rom_basis_derivative(P_curve, sd->u));
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* Transform into world space */
|
|
|
|
|
if (!(sd->object_flag & SD_OBJECT_TRANSFORM_APPLIED)) {
|
|
|
|
|
object_position_transform_auto(kg, sd, &sd->P);
|
|
|
|
|
#ifdef __DPDU__
|
|
|
|
|
object_dir_transform_auto(kg, sd, &sd->dPdu);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* No view direction, normals or bitangent. */
|
|
|
|
|
sd->I = zero_float3();
|
|
|
|
|
sd->N = zero_float3();
|
|
|
|
|
sd->Ng = zero_float3();
|
|
|
|
|
#ifdef __DPDU__
|
|
|
|
|
sd->dPdv = zero_float3();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/* No ray differentials currently. */
|
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
|
sd->dP = differential3_zero();
|
|
|
|
|
sd->dI = differential3_zero();
|
|
|
|
|
sd->du = differential_zero();
|
|
|
|
|
sd->dv = differential_zero();
|
|
|
|
|
#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
|
|
|
/* ShaderData setup from ray into background */
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void shader_setup_from_background(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 ShaderData *ccl_restrict 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
|
|
|
const float3 ray_P,
|
|
|
|
|
const float3 ray_D,
|
|
|
|
|
const float ray_time)
|
|
|
|
|
{
|
|
|
|
|
/* for NDC coordinates */
|
|
|
|
|
sd->ray_P = ray_P;
|
|
|
|
|
|
|
|
|
|
/* vectors */
|
|
|
|
|
sd->P = ray_D;
|
|
|
|
|
sd->N = -ray_D;
|
|
|
|
|
sd->Ng = -ray_D;
|
|
|
|
|
sd->I = -ray_D;
|
|
|
|
|
sd->shader = kernel_data.background.surface_shader;
|
2022-06-17 17:16:37 +02:00
|
|
|
sd->flag = kernel_data_fetch(shaders, (sd->shader & SHADER_MASK)).flags;
|
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
|
|
|
sd->object_flag = 0;
|
|
|
|
|
sd->time = ray_time;
|
|
|
|
|
sd->ray_length = 0.0f;
|
|
|
|
|
|
|
|
|
|
sd->object = OBJECT_NONE;
|
|
|
|
|
sd->lamp = LAMP_NONE;
|
|
|
|
|
sd->prim = PRIM_NONE;
|
|
|
|
|
sd->u = 0.0f;
|
|
|
|
|
sd->v = 0.0f;
|
|
|
|
|
|
|
|
|
|
#ifdef __DPDU__
|
|
|
|
|
/* dPdu/dPdv */
|
|
|
|
|
sd->dPdu = zero_float3();
|
|
|
|
|
sd->dPdv = zero_float3();
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
|
/* differentials */
|
|
|
|
|
sd->dP = differential3_zero(); /* TODO: ray->dP */
|
|
|
|
|
differential_incoming(&sd->dI, sd->dP);
|
|
|
|
|
sd->du = differential_zero();
|
|
|
|
|
sd->dv = differential_zero();
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ShaderData setup from point inside volume */
|
|
|
|
|
|
|
|
|
|
#ifdef __VOLUME__
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline void shader_setup_from_volume(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 ShaderData *ccl_restrict sd,
|
|
|
|
|
ccl_private const Ray *ccl_restrict ray)
|
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
|
|
|
{
|
|
|
|
|
|
|
|
|
|
/* vectors */
|
|
|
|
|
sd->P = ray->P;
|
|
|
|
|
sd->N = -ray->D;
|
|
|
|
|
sd->Ng = -ray->D;
|
|
|
|
|
sd->I = -ray->D;
|
|
|
|
|
sd->shader = SHADER_NONE;
|
|
|
|
|
sd->flag = 0;
|
|
|
|
|
sd->object_flag = 0;
|
|
|
|
|
sd->time = ray->time;
|
|
|
|
|
sd->ray_length = 0.0f; /* todo: can we set this to some useful value? */
|
|
|
|
|
|
|
|
|
|
sd->object = OBJECT_NONE; /* todo: fill this for texture coordinates */
|
|
|
|
|
sd->lamp = LAMP_NONE;
|
|
|
|
|
sd->prim = PRIM_NONE;
|
|
|
|
|
sd->type = PRIMITIVE_VOLUME;
|
|
|
|
|
|
|
|
|
|
sd->u = 0.0f;
|
|
|
|
|
sd->v = 0.0f;
|
|
|
|
|
|
|
|
|
|
# ifdef __DPDU__
|
|
|
|
|
/* dPdu/dPdv */
|
|
|
|
|
sd->dPdu = zero_float3();
|
|
|
|
|
sd->dPdv = zero_float3();
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
# ifdef __RAY_DIFFERENTIALS__
|
|
|
|
|
/* differentials */
|
|
|
|
|
sd->dP = differential3_zero(); /* TODO ray->dD */
|
|
|
|
|
differential_incoming(&sd->dI, sd->dP);
|
|
|
|
|
sd->du = differential_zero();
|
|
|
|
|
sd->dv = differential_zero();
|
|
|
|
|
# endif
|
|
|
|
|
|
|
|
|
|
/* for NDC coordinates */
|
|
|
|
|
sd->ray_P = ray->P;
|
|
|
|
|
sd->ray_dP = ray->dP;
|
|
|
|
|
}
|
|
|
|
|
#endif /* __VOLUME__ */
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|