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
|
|
|
{
|
2019-04-17 06:17:24 +02:00
|
|
|
float3 data;
|
|
|
|
uint type = node.y;
|
|
|
|
uint out_offset = node.z;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case NODE_TEXCO_OBJECT: {
|
|
|
|
data = sd->P;
|
|
|
|
if (node.w == 0) {
|
|
|
|
if (sd->object != OBJECT_NONE) {
|
|
|
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
data = transform_point(&tfm, data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_NORMAL: {
|
|
|
|
data = sd->N;
|
|
|
|
object_inverse_normal_transform(kg, sd, &data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_CAMERA: {
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
|
|
|
|
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = transform_point(&tfm, sd->P);
|
|
|
|
else
|
|
|
|
data = transform_point(&tfm, sd->P + camera_position(kg));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_WINDOW: {
|
|
|
|
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);
|
|
|
|
else
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->P);
|
|
|
|
data.z = 0.0f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_REFLECTION: {
|
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = 2.0f * dot(sd->N, sd->I) * sd->N - sd->I;
|
|
|
|
else
|
|
|
|
data = sd->I;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_GENERATED: {
|
|
|
|
data = object_dupli_generated(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_UV: {
|
|
|
|
data = object_dupli_uv(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_VOLUME_GENERATED: {
|
|
|
|
data = sd->P;
|
2013-12-31 17:33:55 +01:00
|
|
|
|
2014-03-29 13:03:48 +01:00
|
|
|
#ifdef __VOLUME__
|
2019-04-17 06:17:24 +02:00
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = volume_normalized_position(kg, sd, data);
|
2014-03-29 13:03:48 +01:00
|
|
|
#endif
|
2019-04-17 06:17:24 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
|
2019-04-17 06:17:24 +02: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__
|
2019-04-17 06:17:24 +02:00
|
|
|
float3 data;
|
|
|
|
uint type = node.y;
|
|
|
|
uint out_offset = node.z;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case NODE_TEXCO_OBJECT: {
|
|
|
|
data = sd->P + sd->dP.dx;
|
|
|
|
if (node.w == 0) {
|
|
|
|
if (sd->object != OBJECT_NONE) {
|
|
|
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
data = transform_point(&tfm, data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_NORMAL: {
|
|
|
|
data = sd->N;
|
|
|
|
object_inverse_normal_transform(kg, sd, &data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_CAMERA: {
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
|
|
|
|
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dx);
|
|
|
|
else
|
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dx + camera_position(kg));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_WINDOW: {
|
|
|
|
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));
|
2019-04-17 06:17:24 +02:00
|
|
|
else
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->P + sd->dP.dx);
|
|
|
|
data.z = 0.0f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_REFLECTION: {
|
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = 2.0f * dot(sd->N, sd->I) * sd->N - sd->I;
|
|
|
|
else
|
|
|
|
data = sd->I;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_GENERATED: {
|
|
|
|
data = object_dupli_generated(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_UV: {
|
|
|
|
data = object_dupli_uv(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_VOLUME_GENERATED: {
|
|
|
|
data = sd->P + sd->dP.dx;
|
|
|
|
|
|
|
|
# ifdef __VOLUME__
|
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = volume_normalized_position(kg, sd, data);
|
|
|
|
# endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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__
|
2019-04-17 06:17:24 +02:00
|
|
|
float3 data;
|
|
|
|
uint type = node.y;
|
|
|
|
uint out_offset = node.z;
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
case NODE_TEXCO_OBJECT: {
|
|
|
|
data = sd->P + sd->dP.dy;
|
|
|
|
if (node.w == 0) {
|
|
|
|
if (sd->object != OBJECT_NONE) {
|
|
|
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
data = transform_point(&tfm, data);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_NORMAL: {
|
|
|
|
data = sd->N;
|
|
|
|
object_inverse_normal_transform(kg, sd, &data);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_CAMERA: {
|
|
|
|
Transform tfm = kernel_data.cam.worldtocamera;
|
|
|
|
|
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dy);
|
|
|
|
else
|
|
|
|
data = transform_point(&tfm, sd->P + sd->dP.dy + camera_position(kg));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_WINDOW: {
|
|
|
|
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));
|
2019-04-17 06:17:24 +02:00
|
|
|
else
|
|
|
|
data = camera_world_to_ndc(kg, sd, sd->P + sd->dP.dy);
|
|
|
|
data.z = 0.0f;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_REFLECTION: {
|
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = 2.0f * dot(sd->N, sd->I) * sd->N - sd->I;
|
|
|
|
else
|
|
|
|
data = sd->I;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_GENERATED: {
|
|
|
|
data = object_dupli_generated(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_DUPLI_UV: {
|
|
|
|
data = object_dupli_uv(kg, sd->object);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case NODE_TEXCO_VOLUME_GENERATED: {
|
|
|
|
data = sd->P + sd->dP.dy;
|
|
|
|
|
|
|
|
# ifdef __VOLUME__
|
|
|
|
if (sd->object != OBJECT_NONE)
|
|
|
|
data = volume_normalized_position(kg, sd, data);
|
|
|
|
# endif
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02: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
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
bool is_backfacing = (sd->flag & SD_BACKFACING) != 0;
|
|
|
|
float3 N;
|
|
|
|
|
|
|
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* first try to get tangent attribute */
|
|
|
|
const AttributeDescriptor attr = find_attribute(kg, sd, node.z);
|
|
|
|
const AttributeDescriptor attr_sign = find_attribute(kg, sd, node.w);
|
|
|
|
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* get _unnormalized_ interpolated normal and tangent */
|
|
|
|
float3 tangent = primitive_surface_attribute_float3(kg, sd, attr, NULL, NULL);
|
|
|
|
float sign = primitive_surface_attribute_float(kg, sd, attr_sign, NULL, NULL);
|
|
|
|
float3 normal;
|
|
|
|
|
|
|
|
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);
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
normal = sd->Ng;
|
|
|
|
|
|
|
|
/* the normal is already inverted, which is too soon for the math here */
|
|
|
|
if (is_backfacing) {
|
|
|
|
normal = -normal;
|
|
|
|
}
|
|
|
|
|
|
|
|
object_inverse_normal_transform(kg, sd, &normal);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* apply normal map */
|
|
|
|
float3 B = sign * cross(normal, tangent);
|
|
|
|
N = safe_normalize(color.x * tangent + color.y * B + color.z * normal);
|
|
|
|
|
|
|
|
/* transform to world space */
|
|
|
|
object_normal_transform(kg, sd, &N);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* strange blender convention */
|
|
|
|
if (space == NODE_NORMAL_MAP_BLENDER_OBJECT || space == NODE_NORMAL_MAP_BLENDER_WORLD) {
|
|
|
|
color.y = -color.y;
|
|
|
|
color.z = -color.z;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* object, world space */
|
|
|
|
N = color;
|
|
|
|
|
|
|
|
if (space == NODE_NORMAL_MAP_OBJECT || space == NODE_NORMAL_MAP_BLENDER_OBJECT)
|
|
|
|
object_normal_transform(kg, sd, &N);
|
|
|
|
else
|
|
|
|
N = safe_normalize(N);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* invert normal for backfacing polygons */
|
|
|
|
if (is_backfacing) {
|
|
|
|
N = -N;
|
|
|
|
}
|
|
|
|
|
|
|
|
float strength = stack_load_float(stack, strength_offset);
|
|
|
|
|
|
|
|
if (strength != 1.0f) {
|
|
|
|
strength = max(strength, 0.0f);
|
|
|
|
N = safe_normalize(sd->N + (N - sd->N) * strength);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_zero(N)) {
|
|
|
|
N = sd->N;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
2019-04-17 06:17:24 +02: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
|
|
|
|
|
|
|
float3 tangent;
|
|
|
|
float3 attribute_value;
|
|
|
|
const AttributeDescriptor desc = find_attribute(kg, sd, node.z);
|
|
|
|
if (desc.offset != ATTR_STD_NOT_FOUND) {
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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-04-17 06:17:24 +02:00
|
|
|
tangent = attribute_value;
|
2021-05-11 20:36:15 +02:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* radial */
|
|
|
|
float3 generated;
|
|
|
|
|
|
|
|
if (desc.offset == ATTR_STD_NOT_FOUND)
|
|
|
|
generated = sd->P;
|
|
|
|
else
|
|
|
|
generated = attribute_value;
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
|
|
|
|
object_normal_transform(kg, sd, &tangent);
|
|
|
|
tangent = cross(sd->N, normalize(cross(tangent, sd->N)));
|
|
|
|
stack_store_float3(stack, tangent_offset, tangent);
|
2012-11-06 19:59:02 +00:00
|
|
|
}
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|