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
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#pragma once
|
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "kernel/camera/camera.h"
|
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
|
|
|
#include "kernel/geom/geom.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "kernel/sample/mapping.h"
|
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
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
/* Texture Coordinate Node */
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_noinline int svm_node_tex_coord(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 *sd,
|
2021-10-17 20:09:45 +02:00
|
|
|
uint32_t path_flag,
|
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 float *stack,
|
|
|
|
uint4 node,
|
|
|
|
int offset)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
float3 data;
|
2015-01-21 22:19:31 +05:00
|
|
|
uint type = node.y;
|
|
|
|
uint out_offset = node.z;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
switch (type) {
|
|
|
|
case NODE_TEXCO_OBJECT: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->P;
|
2015-01-21 22:19:31 +05:00
|
|
|
if (node.w == 0) {
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE) {
|
2015-01-21 22:19:31 +05:00
|
|
|
object_inverse_position_transform(kg, sd, &data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Transform tfm;
|
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
|
|
|
tfm.x = read_node_float(kg, &offset);
|
|
|
|
tfm.y = read_node_float(kg, &offset);
|
|
|
|
tfm.z = read_node_float(kg, &offset);
|
2015-01-21 22:19:31 +05:00
|
|
|
data = transform_point(&tfm, data);
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
case NODE_TEXCO_NORMAL: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->N;
|
2016-11-03 03:08:14 +01:00
|
|
|
object_inverse_normal_transform(kg, sd, &data);
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
case NODE_TEXCO_CAMERA: {
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = transform_point(&tfm, sd->P);
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2017-02-16 06:24:13 -05:00
|
|
|
data = transform_point(&tfm, sd->P + camera_position(kg));
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_WINDOW: {
|
2017-02-16 06:24:13 -05:00
|
|
|
if ((path_flag & PATH_RAY_CAMERA) && sd->object == OBJECT_NONE &&
|
|
|
|
kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->ray_P);
|
2013-06-08 10:51:33 +00:00
|
|
|
else
|
2017-02-16 06:24:13 -05:00
|
|
|
data = camera_world_to_ndc(kg, sd, sd->P);
|
2012-11-21 13:00:57 +00:00
|
|
|
data.z = 0.0f;
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_REFLECTION: {
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = 2.0f * dot(sd->N, sd->I) * sd->N - sd->I;
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->I;
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-10-04 21:40:39 +00:00
|
|
|
case NODE_TEXCO_DUPLI_GENERATED: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = object_dupli_generated(kg, sd->object);
|
2012-10-04 21:40:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_UV: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = object_dupli_uv(kg, sd->object);
|
2012-10-04 21:40:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-12-31 17:33:55 +01:00
|
|
|
case NODE_TEXCO_VOLUME_GENERATED: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->P;
|
2013-12-31 17:33:55 +01:00
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
#ifdef __VOLUME__
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE)
|
2014-03-29 13:03:48 +01:00
|
|
|
data = volume_normalized_position(kg, sd, data);
|
|
|
|
#endif
|
2013-12-31 17:33:55 +01:00
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
stack_store_float3(stack, out_offset, data);
|
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 offset;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_noinline int svm_node_tex_coord_bump_dx(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 *sd,
|
2021-10-17 20:09:45 +02:00
|
|
|
uint32_t path_flag,
|
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 float *stack,
|
|
|
|
uint4 node,
|
|
|
|
int offset)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
float3 data;
|
2015-01-29 21:47:02 +05:00
|
|
|
uint type = node.y;
|
|
|
|
uint out_offset = node.z;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
switch (type) {
|
|
|
|
case NODE_TEXCO_OBJECT: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->P + sd->dP.dx;
|
2015-01-29 21:47:02 +05:00
|
|
|
if (node.w == 0) {
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE) {
|
2015-01-29 21:47:02 +05:00
|
|
|
object_inverse_position_transform(kg, sd, &data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Transform tfm;
|
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
|
|
|
tfm.x = read_node_float(kg, &offset);
|
|
|
|
tfm.y = read_node_float(kg, &offset);
|
|
|
|
tfm.z = read_node_float(kg, &offset);
|
2015-01-29 21:47:02 +05:00
|
|
|
data = transform_point(&tfm, data);
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
case NODE_TEXCO_NORMAL: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->N;
|
2016-11-03 03:08:14 +01:00
|
|
|
object_inverse_normal_transform(kg, sd, &data);
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
case NODE_TEXCO_CAMERA: {
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dx);
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2017-02-16 06:24:13 -05:00
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dx + camera_position(kg));
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_WINDOW: {
|
2017-02-16 06:24:13 -05:00
|
|
|
if ((path_flag & PATH_RAY_CAMERA) && sd->object == OBJECT_NONE &&
|
|
|
|
kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
|
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
|
|
|
data = camera_world_to_ndc(kg, sd, sd->ray_P + make_float3(sd->ray_dP, 0.0f, 0.0f));
|
2013-06-08 10:51:33 +00:00
|
|
|
else
|
2017-02-16 06:24:13 -05:00
|
|
|
data = camera_world_to_ndc(kg, sd, sd->P + sd->dP.dx);
|
2012-11-21 13:00:57 +00:00
|
|
|
data.z = 0.0f;
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_REFLECTION: {
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = 2.0f * dot(sd->N, sd->I) * sd->N - sd->I;
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->I;
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-10-04 21:40:39 +00:00
|
|
|
case NODE_TEXCO_DUPLI_GENERATED: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = object_dupli_generated(kg, sd->object);
|
2012-10-04 21:40:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_UV: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = object_dupli_uv(kg, sd->object);
|
2012-10-04 21:40:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-12-31 17:33:55 +01:00
|
|
|
case NODE_TEXCO_VOLUME_GENERATED: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->P + sd->dP.dx;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
# ifdef __VOLUME__
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE)
|
2014-03-29 13:03:48 +01:00
|
|
|
data = volume_normalized_position(kg, sd, data);
|
|
|
|
# endif
|
2013-12-31 17:33:55 +01:00
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
stack_store_float3(stack, out_offset, data);
|
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 offset;
|
2011-04-27 11:58:34 +00:00
|
|
|
#else
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return svm_node_tex_coord(kg, sd, path_flag, stack, node, offset);
|
2011-04-27 11:58:34 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_noinline int svm_node_tex_coord_bump_dy(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 *sd,
|
2021-10-17 20:09:45 +02:00
|
|
|
uint32_t path_flag,
|
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 float *stack,
|
|
|
|
uint4 node,
|
|
|
|
int offset)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
|
|
|
#ifdef __RAY_DIFFERENTIALS__
|
|
|
|
float3 data;
|
2015-01-29 21:47:02 +05:00
|
|
|
uint type = node.y;
|
|
|
|
uint out_offset = node.z;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
switch (type) {
|
|
|
|
case NODE_TEXCO_OBJECT: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->P + sd->dP.dy;
|
2015-01-29 21:47:02 +05:00
|
|
|
if (node.w == 0) {
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE) {
|
2015-01-29 21:47:02 +05:00
|
|
|
object_inverse_position_transform(kg, sd, &data);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
Transform tfm;
|
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
|
|
|
tfm.x = read_node_float(kg, &offset);
|
|
|
|
tfm.y = read_node_float(kg, &offset);
|
|
|
|
tfm.z = read_node_float(kg, &offset);
|
2015-01-29 21:47:02 +05:00
|
|
|
data = transform_point(&tfm, data);
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
case NODE_TEXCO_NORMAL: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->N;
|
2016-11-03 03:08:14 +01:00
|
|
|
object_inverse_normal_transform(kg, sd, &data);
|
Cycles: merging features from tomato branch.
=== BVH build time optimizations ===
* BVH building was multithreaded. Not all building is multithreaded, packing
and the initial bounding/splitting is still single threaded, but recursive
splitting is, which was the main bottleneck.
* Object splitting now uses binning rather than sorting of all elements, using
code from the Embree raytracer from Intel.
http://software.intel.com/en-us/articles/embree-photo-realistic-ray-tracing-kernels/
* Other small changes to avoid allocations, pack memory more tightly, avoid
some unnecessary operations, ...
These optimizations do not work yet when Spatial Splits are enabled, for that
more work is needed. There's also other optimizations still needed, in
particular for the case of many low poly objects, the packing step and node
memory allocation.
BVH raytracing time should remain about the same, but BVH build time should be
significantly reduced, test here show speedup of about 5x to 10x on a dual core
and 5x to 25x on an 8-core machine, depending on the scene.
=== Threads ===
Centralized task scheduler for multithreading, which is basically the
CPU device threading code wrapped into something reusable.
Basic idea is that there is a single TaskScheduler that keeps a pool of threads,
one for each core. Other places in the code can then create a TaskPool that they
can drop Tasks in to be executed by the scheduler, and wait for them to complete
or cancel them early.
=== Normal ====
Added a Normal output to the texture coordinate node. This currently
gives the object space normal, which is the same under object animation.
In the future this might become a "generated" normal so it's also stable for
deforming objects, but for now it's already useful for non-deforming objects.
=== Render Layers ===
Per render layer Samples control, leaving it to 0 will use the common scene
setting.
Environment pass will now render environment even if film is set to transparent.
Exclude Layers" added. Scene layers (all object that influence the render,
directly or indirectly) are shared between all render layers. However sometimes
it's useful to leave out some object influence for a particular render layer.
That's what this option allows you to do.
=== Filter Glossy ===
When using a value higher than 0.0, this will blur glossy reflections after
blurry bounces, to reduce noise at the cost of accuracy. 1.0 is a good
starting value to tweak.
Some light paths have a low probability of being found while contributing much
light to the pixel. As a result these light paths will be found in some pixels
and not in others, causing fireflies. An example of such a difficult path might
be a small light that is causing a small specular highlight on a sharp glossy
material, which we are seeing through a rough glossy material. With path tracing
it is difficult to find the specular highlight, but if we increase the roughness
on the material the highlight gets bigger and softer, and so easier to find.
Often this blurring will be hardly noticeable, because we are seeing it through
a blurry material anyway, but there are also cases where this will lead to a
loss of detail in lighting.
2012-04-28 08:53:59 +00:00
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
case NODE_TEXCO_CAMERA: {
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dy);
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2017-02-16 06:24:13 -05:00
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dy + camera_position(kg));
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_WINDOW: {
|
2017-02-16 06:24:13 -05:00
|
|
|
if ((path_flag & PATH_RAY_CAMERA) && sd->object == OBJECT_NONE &&
|
|
|
|
kernel_data.cam.type == CAMERA_ORTHOGRAPHIC)
|
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
|
|
|
data = camera_world_to_ndc(kg, sd, sd->ray_P + make_float3(0.0f, sd->ray_dP, 0.0f));
|
2013-06-08 10:51:33 +00:00
|
|
|
else
|
2017-02-16 06:24:13 -05:00
|
|
|
data = camera_world_to_ndc(kg, sd, sd->P + sd->dP.dy);
|
2012-11-21 13:00:57 +00:00
|
|
|
data.z = 0.0f;
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_REFLECTION: {
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = 2.0f * dot(sd->N, sd->I) * sd->N - sd->I;
|
2011-04-27 11:58:34 +00:00
|
|
|
else
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->I;
|
2011-04-27 11:58:34 +00:00
|
|
|
break;
|
|
|
|
}
|
2012-10-04 21:40:39 +00:00
|
|
|
case NODE_TEXCO_DUPLI_GENERATED: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = object_dupli_generated(kg, sd->object);
|
2012-10-04 21:40:39 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_UV: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = object_dupli_uv(kg, sd->object);
|
2012-10-04 21:40:39 +00:00
|
|
|
break;
|
|
|
|
}
|
2013-12-31 17:33:55 +01:00
|
|
|
case NODE_TEXCO_VOLUME_GENERATED: {
|
2017-02-16 06:24:13 -05:00
|
|
|
data = sd->P + sd->dP.dy;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
# ifdef __VOLUME__
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->object != OBJECT_NONE)
|
2014-03-29 13:03:48 +01:00
|
|
|
data = volume_normalized_position(kg, sd, data);
|
|
|
|
# endif
|
2013-12-31 17:33:55 +01:00
|
|
|
break;
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
stack_store_float3(stack, out_offset, data);
|
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 offset;
|
2011-04-27 11:58:34 +00:00
|
|
|
#else
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
return svm_node_tex_coord(kg, sd, path_flag, stack, node, offset);
|
2011-04-27 11:58:34 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_noinline void svm_node_normal_map(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 *sd,
|
|
|
|
ccl_private float *stack,
|
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
|
|
|
uint4 node)
|
2012-11-06 19:59:02 +00:00
|
|
|
{
|
2012-11-08 16:35:20 +00:00
|
|
|
uint color_offset, strength_offset, normal_offset, space;
|
2019-08-21 11:59:57 +02:00
|
|
|
svm_unpack_node_uchar4(node.y, &color_offset, &strength_offset, &normal_offset, &space);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
float3 color = stack_load_float3(stack, color_offset);
|
|
|
|
color = 2.0f * make_float3(color.x - 0.5f, color.y - 0.5f, color.z - 0.5f);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
bool is_backfacing = (sd->flag & SD_BACKFACING) != 0;
|
2012-11-08 16:35:20 +00:00
|
|
|
float3 N;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
if (space == NODE_NORMAL_MAP_TANGENT) {
|
|
|
|
/* tangent space */
|
2021-12-20 02:52:56 +01:00
|
|
|
if (sd->object == OBJECT_NONE || (sd->type & PRIMITIVE_TRIANGLE) == 0) {
|
2020-11-19 23:15:09 +01:00
|
|
|
/* Fallback to unperturbed normal. */
|
|
|
|
stack_store_float3(stack, normal_offset, sd->N);
|
2012-11-06 19:59:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
/* first try to get tangent attribute */
|
2016-07-01 17:36:27 -04:00
|
|
|
const AttributeDescriptor attr = find_attribute(kg, sd, node.z);
|
|
|
|
const AttributeDescriptor attr_sign = find_attribute(kg, sd, node.w);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-08-17 23:24:46 +02:00
|
|
|
if (attr.offset == ATTR_STD_NOT_FOUND || attr_sign.offset == ATTR_STD_NOT_FOUND) {
|
2020-11-19 23:15:09 +01:00
|
|
|
/* Fallback to unperturbed normal. */
|
|
|
|
stack_store_float3(stack, normal_offset, sd->N);
|
2012-11-06 19:59:02 +00:00
|
|
|
return;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-15 16:35:05 +00:00
|
|
|
/* get _unnormalized_ interpolated normal and tangent */
|
2019-02-19 15:41:22 +01:00
|
|
|
float3 tangent = primitive_surface_attribute_float3(kg, sd, attr, NULL, NULL);
|
|
|
|
float sign = primitive_surface_attribute_float(kg, sd, attr_sign, NULL, NULL);
|
2013-05-11 09:31:58 +00:00
|
|
|
float3 normal;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2017-02-16 06:24:13 -05:00
|
|
|
if (sd->shader & SHADER_SMOOTH_NORMAL) {
|
2021-08-24 01:42:45 +02:00
|
|
|
normal = triangle_smooth_normal_unnormalized(kg, sd, sd->Ng, sd->prim, sd->u, sd->v);
|
2013-06-13 13:55:05 +00:00
|
|
|
}
|
|
|
|
else {
|
2017-02-16 06:24:13 -05:00
|
|
|
normal = sd->Ng;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-08-30 12:48:59 +03:00
|
|
|
/* the normal is already inverted, which is too soon for the math here */
|
|
|
|
if (is_backfacing) {
|
|
|
|
normal = -normal;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-06-13 13:55:05 +00:00
|
|
|
object_inverse_normal_transform(kg, sd, &normal);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-15 16:35:05 +00:00
|
|
|
/* apply normal map */
|
|
|
|
float3 B = sign * cross(normal, tangent);
|
2016-07-16 20:48:12 +02:00
|
|
|
N = safe_normalize(color.x * tangent + color.y * B + color.z * normal);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-01-15 16:35:05 +00:00
|
|
|
/* transform to world space */
|
|
|
|
object_normal_transform(kg, sd, &N);
|
2012-11-06 19:59:02 +00:00
|
|
|
}
|
|
|
|
else {
|
2013-05-27 17:48:02 +00:00
|
|
|
/* strange blender convention */
|
2013-05-28 14:24:03 +00:00
|
|
|
if (space == NODE_NORMAL_MAP_BLENDER_OBJECT || space == NODE_NORMAL_MAP_BLENDER_WORLD) {
|
|
|
|
color.y = -color.y;
|
|
|
|
color.z = -color.z;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
/* object, world space */
|
2012-11-08 16:35:20 +00:00
|
|
|
N = color;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2013-05-28 14:24:03 +00:00
|
|
|
if (space == NODE_NORMAL_MAP_OBJECT || space == NODE_NORMAL_MAP_BLENDER_OBJECT)
|
2012-11-06 19:59:02 +00:00
|
|
|
object_normal_transform(kg, sd, &N);
|
2013-05-27 17:48:02 +00:00
|
|
|
else
|
2016-07-16 20:48:12 +02:00
|
|
|
N = safe_normalize(N);
|
2012-11-08 16:35:20 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-08-30 12:48:59 +03:00
|
|
|
/* invert normal for backfacing polygons */
|
|
|
|
if (is_backfacing) {
|
|
|
|
N = -N;
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-08 16:35:20 +00:00
|
|
|
float strength = stack_load_float(stack, strength_offset);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-08 16:35:20 +00:00
|
|
|
if (strength != 1.0f) {
|
|
|
|
strength = max(strength, 0.0f);
|
2017-02-16 06:24:13 -05:00
|
|
|
N = safe_normalize(sd->N + (N - sd->N) * strength);
|
2016-07-16 20:48:12 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-07-17 19:24:53 +02:00
|
|
|
if (is_zero(N)) {
|
2017-02-16 06:24:13 -05:00
|
|
|
N = sd->N;
|
2012-11-06 19:59:02 +00:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-22 16:08:18 +00:00
|
|
|
stack_store_float3(stack, normal_offset, N);
|
2012-11-06 19:59:02 +00:00
|
|
|
}
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_noinline void svm_node_tangent(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 *sd,
|
|
|
|
ccl_private float *stack,
|
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
|
|
|
uint4 node)
|
2012-11-06 19:59:02 +00:00
|
|
|
{
|
|
|
|
uint tangent_offset, direction_type, axis;
|
2019-08-21 11:59:57 +02:00
|
|
|
svm_unpack_node_uchar3(node.y, &tangent_offset, &direction_type, &axis);
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
float3 tangent;
|
2019-02-19 15:41:22 +01:00
|
|
|
float3 attribute_value;
|
|
|
|
const AttributeDescriptor desc = find_attribute(kg, sd, node.z);
|
|
|
|
if (desc.offset != ATTR_STD_NOT_FOUND) {
|
2019-03-05 14:54:54 +01:00
|
|
|
if (desc.type == NODE_ATTR_FLOAT2) {
|
|
|
|
float2 value = primitive_surface_attribute_float2(kg, sd, desc, NULL, NULL);
|
|
|
|
attribute_value.x = value.x;
|
|
|
|
attribute_value.y = value.y;
|
|
|
|
attribute_value.z = 0.0f;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
attribute_value = primitive_surface_attribute_float3(kg, sd, desc, NULL, NULL);
|
|
|
|
}
|
2019-02-19 15:41:22 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
if (direction_type == NODE_TANGENT_UVMAP) {
|
|
|
|
/* UV map */
|
2021-05-11 20:36:15 +02:00
|
|
|
if (desc.offset == ATTR_STD_NOT_FOUND) {
|
|
|
|
stack_store_float3(stack, tangent_offset, zero_float3());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
else {
|
2019-02-19 15:41:22 +01:00
|
|
|
tangent = attribute_value;
|
2021-05-11 20:36:15 +02:00
|
|
|
}
|
2012-11-06 19:59:02 +00:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* radial */
|
|
|
|
float3 generated;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-07-01 17:36:27 -04:00
|
|
|
if (desc.offset == ATTR_STD_NOT_FOUND)
|
2017-02-16 06:24:13 -05:00
|
|
|
generated = sd->P;
|
2012-11-06 19:59:02 +00:00
|
|
|
else
|
2019-02-19 15:41:22 +01:00
|
|
|
generated = attribute_value;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
if (axis == NODE_TANGENT_AXIS_X)
|
|
|
|
tangent = make_float3(0.0f, -(generated.z - 0.5f), (generated.y - 0.5f));
|
|
|
|
else if (axis == NODE_TANGENT_AXIS_Y)
|
|
|
|
tangent = make_float3(-(generated.z - 0.5f), 0.0f, (generated.x - 0.5f));
|
|
|
|
else
|
|
|
|
tangent = make_float3(-(generated.y - 0.5f), (generated.x - 0.5f), 0.0f);
|
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2012-11-06 19:59:02 +00:00
|
|
|
object_normal_transform(kg, sd, &tangent);
|
2017-02-16 06:24:13 -05:00
|
|
|
tangent = cross(sd->N, normalize(cross(tangent, sd->N)));
|
2012-11-06 19:59:02 +00:00
|
|
|
stack_store_float3(stack, tangent_offset, tangent);
|
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|