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
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
2020-03-06 14:15:21 +01:00
|
|
|
// clang-format off
|
Cycles: Make all #include statements relative to cycles source directory
The idea is to make include statements more explicit and obvious where the
file is coming from, additionally reducing chance of wrong header being
picked up.
For example, it was not obvious whether bvh.h was refferring to builder
or traversal, whenter node.h is a generic graph node or a shader node
and cases like that.
Surely this might look obvious for the active developers, but after some
time of not touching the code it becomes less obvious where file is coming
from.
This was briefly mentioned in T50824 and seems @brecht is fine with such
explicitness, but need to agree with all active developers before committing
this.
Please note that this patch is lacking changes related on GPU/OpenCL
support. This will be solved if/when we all agree this is a good idea to move
forward.
Reviewers: brecht, lukasstockner97, maiself, nirved, dingto, juicyfruit, swerner
Reviewed By: lukasstockner97, maiself, nirved, dingto
Subscribers: brecht
Differential Revision: https://developer.blender.org/D2586
2017-03-28 20:39:14 +02:00
|
|
|
#include "kernel/closure/bsdf_ashikhmin_velvet.h"
|
|
|
|
|
#include "kernel/closure/bsdf_diffuse.h"
|
|
|
|
|
#include "kernel/closure/bsdf_oren_nayar.h"
|
|
|
|
|
#include "kernel/closure/bsdf_phong_ramp.h"
|
|
|
|
|
#include "kernel/closure/bsdf_diffuse_ramp.h"
|
|
|
|
|
#include "kernel/closure/bsdf_microfacet.h"
|
|
|
|
|
#include "kernel/closure/bsdf_microfacet_multi.h"
|
|
|
|
|
#include "kernel/closure/bsdf_reflection.h"
|
|
|
|
|
#include "kernel/closure/bsdf_refraction.h"
|
|
|
|
|
#include "kernel/closure/bsdf_transparent.h"
|
|
|
|
|
#include "kernel/closure/bsdf_ashikhmin_shirley.h"
|
|
|
|
|
#include "kernel/closure/bsdf_toon.h"
|
|
|
|
|
#include "kernel/closure/bsdf_hair.h"
|
2018-07-18 11:14:43 +02:00
|
|
|
#include "kernel/closure/bsdf_hair_principled.h"
|
2017-04-18 11:43:09 +02:00
|
|
|
#include "kernel/closure/bsdf_principled_diffuse.h"
|
|
|
|
|
#include "kernel/closure/bsdf_principled_sheen.h"
|
2017-08-18 18:37:05 +02:00
|
|
|
#include "kernel/closure/bssrdf.h"
|
2018-01-21 14:04:22 +01:00
|
|
|
#include "kernel/closure/volume.h"
|
2020-03-06 14:15:21 +01:00
|
|
|
// clang-format on
|
2011-04-27 11:58:34 +00:00
|
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
2017-11-05 21:43:23 +01:00
|
|
|
/* Returns the square of the roughness of the closure if it has roughness,
|
|
|
|
|
* 0 for singular closures and 1 otherwise. */
|
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_device_inline float bsdf_get_specular_roughness_squared(ccl_private const ShaderClosure *sc)
|
2017-11-05 21:43:23 +01:00
|
|
|
{
|
|
|
|
|
if (CLOSURE_IS_BSDF_SINGULAR(sc->type)) {
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CLOSURE_IS_BSDF_MICROFACET(sc->type)) {
|
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 MicrofacetBsdf *bsdf = (ccl_private MicrofacetBsdf *)sc;
|
2017-11-05 21:43:23 +01:00
|
|
|
return bsdf->alpha_x * bsdf->alpha_y;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
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_device_inline float bsdf_get_roughness_squared(ccl_private const ShaderClosure *sc)
|
2018-03-28 23:18:46 +02:00
|
|
|
{
|
|
|
|
|
/* This version includes diffuse, mainly for baking Principled BSDF
|
|
|
|
|
* where specular and metallic zero otherwise does not bake the
|
|
|
|
|
* specified roughness parameter. */
|
|
|
|
|
if (sc->type == CLOSURE_BSDF_OREN_NAYAR_ID) {
|
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 OrenNayarBsdf *bsdf = (ccl_private OrenNayarBsdf *)sc;
|
2018-03-28 23:18:46 +02:00
|
|
|
return sqr(sqr(bsdf->roughness));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (sc->type == CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID) {
|
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 PrincipledDiffuseBsdf *bsdf = (ccl_private PrincipledDiffuseBsdf *)sc;
|
2018-03-28 23:18:46 +02:00
|
|
|
return sqr(sqr(bsdf->roughness));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return bsdf_get_specular_roughness_squared(sc);
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-08 15:26:45 +02:00
|
|
|
/* An additional term to smooth illumination on grazing angles when using bump mapping.
|
|
|
|
|
* Based on "Taming the Shadow Terminator" by Matt Jen-Yuan Chiang,
|
|
|
|
|
* Yining Karl Li and Brent Burley. */
|
|
|
|
|
ccl_device_inline float bump_shadowing_term(float3 Ng, float3 N, float3 I)
|
|
|
|
|
{
|
|
|
|
|
float g = safe_divide(dot(Ng, I), dot(N, I) * dot(Ng, N));
|
|
|
|
|
|
|
|
|
|
/* If the incoming light is on the unshadowed side, return full brightness. */
|
|
|
|
|
if (g >= 1.0f) {
|
|
|
|
|
return 1.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If the incoming light points away from the surface, return black. */
|
|
|
|
|
if (g < 0.0f) {
|
|
|
|
|
return 0.0f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Return smoothed value to avoid discontinuity at perpendicular angle. */
|
|
|
|
|
float g2 = sqr(g);
|
|
|
|
|
return -g2 * g + g2 + g;
|
|
|
|
|
}
|
|
|
|
|
|
2020-05-05 13:55:24 +02:00
|
|
|
ccl_device_inline float shift_cos_in(float cos_in, const float frequency_multiplier)
|
|
|
|
|
{
|
2022-02-11 13:53:21 +01:00
|
|
|
/* Shadow terminator workaround, taken from Appleseed.
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
* Copyright (c) 2019 Francois Beaune, The appleseedhq Organization */
|
2020-05-05 13:55:24 +02:00
|
|
|
cos_in = min(cos_in, 1.0f);
|
|
|
|
|
|
|
|
|
|
const float angle = fast_acosf(cos_in);
|
|
|
|
|
const float val = max(cosf(angle * frequency_multiplier), 0.0f) / cos_in;
|
|
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device_inline int bsdf_sample(KernelGlobals kg,
|
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation.
MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness.
The vast majority of deltas in this patch fall into one of two cases:
- Ensuring ccl_private is specified for thread-local pointer types
- Ensuring ccl_global is specified for device-wide pointer types
Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant.
In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture.
The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation.
Ref T92212
Reviewed By: brecht
Maniphest Tasks: T92212
Differential Revision: https://developer.blender.org/D12864
2021-10-14 13:53:40 +01:00
|
|
|
ccl_private ShaderData *sd,
|
|
|
|
|
ccl_private const ShaderClosure *sc,
|
2018-06-21 11:29:09 +02:00
|
|
|
float randu,
|
|
|
|
|
float randv,
|
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 float3 *eval,
|
|
|
|
|
ccl_private float3 *omega_in,
|
|
|
|
|
ccl_private differential3 *domega_in,
|
|
|
|
|
ccl_private float *pdf)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2020-02-18 20:54:41 +01:00
|
|
|
/* For curves use the smooth normal, particularly for ribbons the geometric
|
|
|
|
|
* normal gives too much darkening otherwise. */
|
2012-12-15 10:18:42 +00:00
|
|
|
int label;
|
2021-12-20 02:52:56 +01:00
|
|
|
const float3 Ng = (sd->type & PRIMITIVE_CURVE) ? sc->N : sd->Ng;
|
2012-12-15 10:18:42 +00:00
|
|
|
|
|
|
|
|
switch (sc->type) {
|
|
|
|
|
case CLOSURE_BSDF_DIFFUSE_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_diffuse_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
|
|
|
|
#ifdef __SVM__
|
|
|
|
|
case CLOSURE_BSDF_OREN_NAYAR_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_oren_nayar_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
2016-07-25 03:03:23 +02:00
|
|
|
# ifdef __OSL__
|
|
|
|
|
case CLOSURE_BSDF_PHONG_RAMP_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_phong_ramp_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_DIFFUSE_RAMP_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_diffuse_ramp_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
2016-07-25 03:03:23 +02:00
|
|
|
break;
|
|
|
|
|
# endif
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_TRANSLUCENT_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_translucent_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_REFLECTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_reflection_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_REFRACTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_refraction_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_TRANSPARENT_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_transparent_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_microfacet_ggx_sample(kg,
|
|
|
|
|
sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_microfacet_multi_ggx_sample(kg,
|
|
|
|
|
sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
|
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf,
|
|
|
|
|
&sd->lcg_state);
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_microfacet_multi_ggx_glass_sample(kg,
|
|
|
|
|
sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
|
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf,
|
|
|
|
|
&sd->lcg_state);
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
break;
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_microfacet_beckmann_sample(kg,
|
|
|
|
|
sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
2014-06-08 12:16:28 +02:00
|
|
|
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_ashikhmin_shirley_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2014-06-08 12:16:28 +02:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_ashikhmin_velvet_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2012-12-15 10:18:42 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
2013-05-23 17:45:20 +00:00
|
|
|
case CLOSURE_BSDF_DIFFUSE_TOON_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_diffuse_toon_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2013-05-23 17:45:20 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_GLOSSY_TOON_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_glossy_toon_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2013-05-23 17:45:20 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
2013-09-15 23:58:00 +00:00
|
|
|
case CLOSURE_BSDF_HAIR_REFLECTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_hair_reflection_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2013-09-15 23:58:00 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
label = bsdf_hair_transmission_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-02-16 06:24:13 -05:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
2013-09-15 23:58:00 +00:00
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
2018-07-18 11:14:43 +02:00
|
|
|
case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
|
|
|
|
|
label = bsdf_principled_hair_sample(
|
|
|
|
|
kg, sc, sd, randu, randv, eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
|
|
|
|
|
break;
|
2017-04-21 12:56:54 +02:00
|
|
|
# ifdef __PRINCIPLED__
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
|
|
|
|
|
label = bsdf_principled_diffuse_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-04-18 11:43:09 +02:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
|
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID:
|
|
|
|
|
label = bsdf_principled_sheen_sample(sc,
|
2020-02-18 20:54:41 +01:00
|
|
|
Ng,
|
2017-04-18 11:43:09 +02:00
|
|
|
sd->I,
|
|
|
|
|
sd->dI.dx,
|
|
|
|
|
sd->dI.dy,
|
|
|
|
|
randu,
|
|
|
|
|
randv,
|
|
|
|
|
eval,
|
|
|
|
|
omega_in,
|
|
|
|
|
&domega_in->dx,
|
|
|
|
|
&domega_in->dy,
|
|
|
|
|
pdf);
|
|
|
|
|
break;
|
2017-04-21 12:56:54 +02:00
|
|
|
# endif /* __PRINCIPLED__ */
|
2014-01-07 15:48:04 +01:00
|
|
|
#endif
|
2012-12-15 10:18:42 +00:00
|
|
|
default:
|
|
|
|
|
label = LABEL_NONE;
|
|
|
|
|
break;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2012-12-15 10:18:42 +00:00
|
|
|
|
2018-01-11 20:03:31 +01:00
|
|
|
/* Test if BSDF sample should be treated as transparent for background. */
|
|
|
|
|
if (label & LABEL_TRANSMIT) {
|
|
|
|
|
float threshold_squared = kernel_data.background.transparent_roughness_squared_threshold;
|
|
|
|
|
|
2021-11-22 19:07:03 +01:00
|
|
|
if (threshold_squared >= 0.0f && !(label & LABEL_DIFFUSE)) {
|
2018-03-28 23:18:46 +02:00
|
|
|
if (bsdf_get_specular_roughness_squared(sc) <= threshold_squared) {
|
2018-01-11 20:03:31 +01:00
|
|
|
label |= LABEL_TRANSMIT_TRANSPARENT;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-05-05 13:55:24 +02:00
|
|
|
else {
|
|
|
|
|
/* Shadow terminator offset. */
|
2020-06-04 01:18:14 +10:00
|
|
|
const float frequency_multiplier =
|
2022-06-17 17:16:37 +02:00
|
|
|
kernel_data_fetch(objects, sd->object).shadow_terminator_shading_offset;
|
2020-05-05 13:55:24 +02:00
|
|
|
if (frequency_multiplier > 1.0f) {
|
|
|
|
|
*eval *= shift_cos_in(dot(*omega_in, sc->N), frequency_multiplier);
|
|
|
|
|
}
|
|
|
|
|
if (label & LABEL_DIFFUSE) {
|
2022-06-23 14:29:17 +02:00
|
|
|
if (!isequal(sc->N, sd->N)) {
|
2020-05-05 13:55:24 +02:00
|
|
|
*eval *= bump_shadowing_term((label & LABEL_TRANSMIT) ? -sd->N : sd->N, sc->N, *omega_in);
|
|
|
|
|
}
|
2019-09-08 15:26:45 +02:00
|
|
|
}
|
|
|
|
|
}
|
2018-01-11 20:03:31 +01:00
|
|
|
|
2022-04-28 18:03:24 +02:00
|
|
|
#ifdef WITH_CYCLES_DEBUG
|
|
|
|
|
kernel_assert(*pdf >= 0.0f);
|
|
|
|
|
kernel_assert(eval->x >= 0.0f && eval->y >= 0.0f && eval->z >= 0.0f);
|
|
|
|
|
#endif
|
|
|
|
|
|
2012-12-15 10:18:42 +00:00
|
|
|
return label;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2016-08-05 14:45:54 +02:00
|
|
|
#ifndef __KERNEL_CUDA__
|
2016-08-02 15:04:34 +02:00
|
|
|
ccl_device
|
|
|
|
|
#else
|
2018-06-21 11:29:09 +02:00
|
|
|
ccl_device_inline
|
2016-08-02 15:04:34 +02:00
|
|
|
#endif
|
|
|
|
|
float3
|
2021-10-17 16:10:10 +02:00
|
|
|
bsdf_eval(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 const ShaderClosure *sc,
|
2016-08-02 15:04:34 +02:00
|
|
|
const float3 omega_in,
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
const bool is_transmission,
|
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 *pdf)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
float3 eval = zero_float3();
|
2012-12-15 10:18:42 +00:00
|
|
|
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
if (!is_transmission) {
|
2012-12-15 10:18:42 +00:00
|
|
|
switch (sc->type) {
|
|
|
|
|
case CLOSURE_BSDF_DIFFUSE_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_diffuse_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
#ifdef __SVM__
|
|
|
|
|
case CLOSURE_BSDF_OREN_NAYAR_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_oren_nayar_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
2016-07-25 03:03:23 +02:00
|
|
|
# ifdef __OSL__
|
|
|
|
|
case CLOSURE_BSDF_PHONG_RAMP_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_phong_ramp_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_DIFFUSE_RAMP_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_diffuse_ramp_eval_reflect(sc, sd->I, omega_in, pdf);
|
2016-07-25 03:03:23 +02:00
|
|
|
break;
|
|
|
|
|
# endif
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_TRANSLUCENT_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_translucent_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_REFLECTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_reflection_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_REFRACTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_refraction_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_TRANSPARENT_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_transparent_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_microfacet_ggx_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_microfacet_multi_ggx_eval_reflect(sc, sd->I, omega_in, pdf, &sd->lcg_state);
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_microfacet_multi_ggx_glass_eval_reflect(
|
|
|
|
|
sc, sd->I, omega_in, pdf, &sd->lcg_state);
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
break;
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_microfacet_beckmann_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
2014-06-08 12:16:28 +02:00
|
|
|
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_ashikhmin_shirley_eval_reflect(sc, sd->I, omega_in, pdf);
|
2014-06-08 12:16:28 +02:00
|
|
|
break;
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_ashikhmin_velvet_eval_reflect(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
2013-05-23 17:45:20 +00:00
|
|
|
case CLOSURE_BSDF_DIFFUSE_TOON_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_diffuse_toon_eval_reflect(sc, sd->I, omega_in, pdf);
|
2013-05-23 17:45:20 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_GLOSSY_TOON_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_glossy_toon_eval_reflect(sc, sd->I, omega_in, pdf);
|
2013-05-23 17:45:20 +00:00
|
|
|
break;
|
2018-07-18 11:14:43 +02:00
|
|
|
case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
|
|
|
|
|
eval = bsdf_principled_hair_eval(kg, sd, sc, omega_in, pdf);
|
|
|
|
|
break;
|
2013-09-15 23:58:00 +00:00
|
|
|
case CLOSURE_BSDF_HAIR_REFLECTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_hair_reflection_eval_reflect(sc, sd->I, omega_in, pdf);
|
2013-09-15 23:58:00 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_hair_transmission_eval_reflect(sc, sd->I, omega_in, pdf);
|
2013-09-15 23:58:00 +00:00
|
|
|
break;
|
2017-04-21 12:56:54 +02:00
|
|
|
# ifdef __PRINCIPLED__
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
|
|
|
|
|
eval = bsdf_principled_diffuse_eval_reflect(sc, sd->I, omega_in, pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID:
|
|
|
|
|
eval = bsdf_principled_sheen_eval_reflect(sc, sd->I, omega_in, pdf);
|
|
|
|
|
break;
|
2017-04-21 12:56:54 +02:00
|
|
|
# endif /* __PRINCIPLED__ */
|
2012-12-15 10:18:42 +00:00
|
|
|
#endif
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-09-08 15:26:45 +02:00
|
|
|
if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
|
2022-06-23 14:29:17 +02:00
|
|
|
if (!isequal(sc->N, sd->N)) {
|
2019-09-09 21:03:37 +02:00
|
|
|
eval *= bump_shadowing_term(sd->N, sc->N, omega_in);
|
|
|
|
|
}
|
2019-09-08 15:26:45 +02:00
|
|
|
}
|
2020-05-05 13:55:24 +02:00
|
|
|
/* Shadow terminator offset. */
|
2020-06-04 01:18:14 +10:00
|
|
|
const float frequency_multiplier =
|
2022-06-17 17:16:37 +02:00
|
|
|
kernel_data_fetch(objects, sd->object).shadow_terminator_shading_offset;
|
2020-05-05 13:55:24 +02:00
|
|
|
if (frequency_multiplier > 1.0f) {
|
|
|
|
|
eval *= shift_cos_in(dot(omega_in, sc->N), frequency_multiplier);
|
|
|
|
|
}
|
2012-12-15 10:18:42 +00:00
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
switch (sc->type) {
|
|
|
|
|
case CLOSURE_BSDF_DIFFUSE_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_diffuse_eval_transmit(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
#ifdef __SVM__
|
|
|
|
|
case CLOSURE_BSDF_OREN_NAYAR_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_oren_nayar_eval_transmit(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_TRANSLUCENT_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_translucent_eval_transmit(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_REFLECTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_reflection_eval_transmit(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_REFRACTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_refraction_eval_transmit(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_TRANSPARENT_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_transparent_eval_transmit(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_microfacet_ggx_eval_transmit(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_microfacet_multi_ggx_eval_transmit(sc, sd->I, omega_in, pdf, &sd->lcg_state);
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_microfacet_multi_ggx_glass_eval_transmit(
|
|
|
|
|
sc, sd->I, omega_in, pdf, &sd->lcg_state);
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
break;
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_microfacet_beckmann_eval_transmit(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
2014-06-08 12:16:28 +02:00
|
|
|
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_ashikhmin_shirley_eval_transmit(sc, sd->I, omega_in, pdf);
|
2014-06-08 12:16:28 +02:00
|
|
|
break;
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_ASHIKHMIN_VELVET_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_ashikhmin_velvet_eval_transmit(sc, sd->I, omega_in, pdf);
|
2012-12-15 10:18:42 +00:00
|
|
|
break;
|
2013-05-23 17:45:20 +00:00
|
|
|
case CLOSURE_BSDF_DIFFUSE_TOON_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_diffuse_toon_eval_transmit(sc, sd->I, omega_in, pdf);
|
2013-05-23 17:45:20 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_GLOSSY_TOON_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_glossy_toon_eval_transmit(sc, sd->I, omega_in, pdf);
|
2013-05-23 17:45:20 +00:00
|
|
|
break;
|
2018-07-18 11:14:43 +02:00
|
|
|
case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
|
|
|
|
|
eval = bsdf_principled_hair_eval(kg, sd, sc, omega_in, pdf);
|
|
|
|
|
break;
|
2013-09-15 23:58:00 +00:00
|
|
|
case CLOSURE_BSDF_HAIR_REFLECTION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_hair_reflection_eval_transmit(sc, sd->I, omega_in, pdf);
|
2013-09-15 23:58:00 +00:00
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_HAIR_TRANSMISSION_ID:
|
2017-02-16 06:24:13 -05:00
|
|
|
eval = bsdf_hair_transmission_eval_transmit(sc, sd->I, omega_in, pdf);
|
2013-09-15 23:58:00 +00:00
|
|
|
break;
|
2017-04-21 12:56:54 +02:00
|
|
|
# ifdef __PRINCIPLED__
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_PRINCIPLED_DIFFUSE_ID:
|
|
|
|
|
eval = bsdf_principled_diffuse_eval_transmit(sc, sd->I, omega_in, pdf);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_PRINCIPLED_SHEEN_ID:
|
|
|
|
|
eval = bsdf_principled_sheen_eval_transmit(sc, sd->I, omega_in, pdf);
|
|
|
|
|
break;
|
2017-04-21 12:56:54 +02:00
|
|
|
# endif /* __PRINCIPLED__ */
|
2012-12-15 10:18:42 +00:00
|
|
|
#endif
|
|
|
|
|
default:
|
|
|
|
|
break;
|
|
|
|
|
}
|
2019-09-08 15:26:45 +02:00
|
|
|
if (CLOSURE_IS_BSDF_DIFFUSE(sc->type)) {
|
2022-06-23 14:29:17 +02:00
|
|
|
if (!isequal(sc->N, sd->N)) {
|
2019-09-09 21:03:37 +02:00
|
|
|
eval *= bump_shadowing_term(-sd->N, sc->N, omega_in);
|
|
|
|
|
}
|
2019-09-08 15:26:45 +02:00
|
|
|
}
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2022-04-28 18:03:24 +02:00
|
|
|
#ifdef WITH_CYCLES_DEBUG
|
|
|
|
|
kernel_assert(*pdf >= 0.0f);
|
|
|
|
|
kernel_assert(eval.x >= 0.0f && eval.y >= 0.0f && eval.z >= 0.0f);
|
|
|
|
|
#endif
|
2012-12-15 10:18:42 +00:00
|
|
|
return eval;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
2021-10-17 16:10:10 +02:00
|
|
|
ccl_device void bsdf_blur(KernelGlobals kg, ccl_private ShaderClosure *sc, float roughness)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2021-10-12 17:52:35 +11:00
|
|
|
/* TODO: do we want to blur volume closures? */
|
2012-12-15 10:18:42 +00:00
|
|
|
#ifdef __SVM__
|
2015-02-17 13:43:12 +01:00
|
|
|
switch (sc->type) {
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_FRESNEL_ID:
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_MULTI_GGX_GLASS_FRESNEL_ID:
|
Cycles: Add multi-scattering, energy-conserving GGX as an option to the Glossy, Anisotropic and Glass BSDFs
This commit adds a new distribution to the Glossy, Anisotropic and Glass BSDFs that implements the
multiple-scattering microfacet model described in the paper "Multiple-Scattering Microfacet BSDFs with the Smith Model".
Essentially, the improvement is that unlike classical GGX, which only models single scattering and assumes
the contribution of multiple bounces to be zero, this new model performs a random walk on the microsurface until
the ray leaves it again, which ensures perfect energy conservation.
In practise, this means that the "darkening problem" - GGX materials becoming darker with increasing
roughness - is solved in a physically correct and efficient way.
The downside of this model is that it has no (known) analytic expression for evalation. However, it can be
evaluated stochastically, and although the correct PDF isn't known either, the properties of MIS and the
balance heuristic guarantee an unbiased result at the cost of slightly higher noise.
Reviewers: dingto, #cycles, brecht
Reviewed By: dingto, #cycles, brecht
Subscribers: bliblubli, ace_dragon, gregzaal, brecht, harvester, dingto, marcog, swerner, jtheninja, Blendify, nutel
Differential Revision: https://developer.blender.org/D2002
2016-06-23 22:56:43 +02:00
|
|
|
bsdf_microfacet_multi_ggx_blur(sc, roughness);
|
|
|
|
|
break;
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_ID:
|
2017-04-18 11:43:09 +02:00
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_FRESNEL_ID:
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_CLEARCOAT_ID:
|
2012-12-15 10:18:42 +00:00
|
|
|
case CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID:
|
|
|
|
|
bsdf_microfacet_ggx_blur(sc, roughness);
|
|
|
|
|
break;
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_BECKMANN_ID:
|
|
|
|
|
case CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID:
|
|
|
|
|
bsdf_microfacet_beckmann_blur(sc, roughness);
|
|
|
|
|
break;
|
2014-06-08 12:16:28 +02:00
|
|
|
case CLOSURE_BSDF_ASHIKHMIN_SHIRLEY_ID:
|
|
|
|
|
bsdf_ashikhmin_shirley_blur(sc, roughness);
|
|
|
|
|
break;
|
2018-07-18 11:14:43 +02:00
|
|
|
case CLOSURE_BSDF_HAIR_PRINCIPLED_ID:
|
|
|
|
|
bsdf_principled_hair_blur(sc, roughness);
|
|
|
|
|
break;
|
2012-12-15 10:18:42 +00:00
|
|
|
default:
|
|
|
|
|
break;
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
2015-02-17 13:43:12 +01:00
|
|
|
#endif
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CCL_NAMESPACE_END
|