2022-02-11 13:53:21 +01:00
|
|
|
/* SPDX-License-Identifier: BSD-3-Clause
|
2013-04-01 20:26:52 +00:00
|
|
|
*
|
2022-02-11 13:53:21 +01:00
|
|
|
* Adapted from Open Shading Language
|
2013-04-01 20:26:52 +00:00
|
|
|
* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
|
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
2022-02-11 13:53:21 +01:00
|
|
|
* Modifications Copyright 2011-2022 Blender Foundation. */
|
2013-04-01 20:26:52 +00:00
|
|
|
|
|
|
|
#include <OSL/genclosure.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/device/cpu/compat.h"
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "kernel/osl/closures.h"
|
2013-04-01 20:26:52 +00:00
|
|
|
|
2020-03-06 14:15:21 +01:00
|
|
|
// clang-format off
|
2022-07-29 13:41:37 +02:00
|
|
|
#include "kernel/device/cpu/compat.h"
|
|
|
|
#include "kernel/device/cpu/globals.h"
|
|
|
|
|
2021-10-24 14:19:19 +02:00
|
|
|
#include "kernel/types.h"
|
2013-04-01 20:26:52 +00:00
|
|
|
|
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/alloc.h"
|
2017-04-18 11:43:09 +02:00
|
|
|
#include "kernel/closure/bsdf_util.h"
|
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_diffuse.h"
|
2017-04-18 11:43:09 +02:00
|
|
|
#include "kernel/closure/bsdf_principled_diffuse.h"
|
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/bssrdf.h"
|
2022-07-29 13:41:37 +02:00
|
|
|
|
|
|
|
#include "kernel/util/color.h"
|
2020-03-06 14:15:21 +01:00
|
|
|
// clang-format on
|
2013-04-01 20:26:52 +00:00
|
|
|
|
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
|
|
|
using namespace OSL;
|
|
|
|
|
2021-10-07 17:27:22 +02:00
|
|
|
static ustring u_burley("burley");
|
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
|
|
|
static ustring u_random_walk_fixed_radius("random_walk_fixed_radius");
|
2018-01-21 14:04:22 +01:00
|
|
|
static ustring u_random_walk("random_walk");
|
2018-02-08 16:14:04 +01:00
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
class CBSSRDFClosure : public CClosurePrimitive {
|
|
|
|
public:
|
|
|
|
Bssrdf params;
|
Cycles: merge of cycles-x branch, a major update to the renderer
This includes much improved GPU rendering performance, viewport interactivity,
new shadow catcher, revamped sampling settings, subsurface scattering anisotropy,
new GPU volume sampling, improved PMJ sampling pattern, and more.
Some features have also been removed or changed, breaking backwards compatibility.
Including the removal of the OpenCL backend, for which alternatives are under
development.
Release notes and code docs:
https://wiki.blender.org/wiki/Reference/Release_Notes/3.0/Cycles
https://wiki.blender.org/wiki/Source/Render/Cycles
Credits:
* Sergey Sharybin
* Brecht Van Lommel
* Patrick Mours (OptiX backend)
* Christophe Hery (subsurface scattering anisotropy)
* William Leeson (PMJ sampling pattern)
* Alaska (various fixes and tweaks)
* Thomas Dinges (various fixes)
For the full commit history, see the cycles-x branch. This squashes together
all the changes since intermediate changes would often fail building or tests.
Ref T87839, T87837, T87836
Fixes T90734, T89353, T80267, T80267, T77185, T69800
2021-09-20 17:59:20 +02:00
|
|
|
float ior;
|
2018-02-08 16:14:04 +01:00
|
|
|
ustring method;
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-02-08 16:14:04 +01:00
|
|
|
CBSSRDFClosure()
|
|
|
|
{
|
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
|
|
|
params.roughness = FLT_MAX;
|
|
|
|
params.anisotropy = 1.0f;
|
|
|
|
ior = 1.4f;
|
2018-02-08 16:14:04 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-17 20:09:45 +02:00
|
|
|
void setup(ShaderData *sd, uint32_t path_flag, float3 weight)
|
2018-02-08 16:14:04 +01:00
|
|
|
{
|
2022-05-17 16:27:37 +02:00
|
|
|
params.N = ensure_valid_reflection(sd->Ng, sd->I, params.N);
|
|
|
|
|
2021-10-07 17:27:22 +02:00
|
|
|
if (method == u_burley) {
|
|
|
|
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_BURLEY_ID);
|
|
|
|
}
|
|
|
|
else if (method == u_random_walk_fixed_radius) {
|
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
|
|
|
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_RANDOM_WALK_FIXED_RADIUS_ID);
|
2018-02-08 16:14:04 +01:00
|
|
|
}
|
2018-08-24 14:36:18 +02:00
|
|
|
else if (method == u_random_walk) {
|
2018-01-21 14:04:22 +01:00
|
|
|
alloc(sd, path_flag, weight, CLOSURE_BSSRDF_RANDOM_WALK_ID);
|
|
|
|
}
|
2018-02-08 16:14:04 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2021-10-17 20:09:45 +02:00
|
|
|
void alloc(ShaderData *sd, uint32_t path_flag, float3 weight, ClosureType type)
|
2016-07-25 03:03:23 +02:00
|
|
|
{
|
2022-07-29 13:41:37 +02:00
|
|
|
Bssrdf *bssrdf = bssrdf_alloc(sd, rgb_to_spectrum(weight));
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2018-01-26 22:11:28 +01:00
|
|
|
if (bssrdf) {
|
|
|
|
/* disable in case of diffuse ancestor, can't see it well then and
|
|
|
|
* adds considerably noise due to probabilities of continuing path
|
|
|
|
* getting lower and lower */
|
|
|
|
if (path_flag & PATH_RAY_DIFFUSE_ANCESTOR) {
|
2022-07-29 13:41:37 +02:00
|
|
|
params.radius = zero_spectrum();
|
2018-01-26 22:11:28 +01:00
|
|
|
}
|
2019-04-17 06:17:24 +02:00
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
/* create one closure per color channel */
|
2018-01-26 22:11:28 +01:00
|
|
|
bssrdf->radius = params.radius;
|
|
|
|
bssrdf->albedo = params.albedo;
|
|
|
|
bssrdf->N = params.N;
|
|
|
|
bssrdf->roughness = params.roughness;
|
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
|
|
|
bssrdf->anisotropy = clamp(params.anisotropy, 0.0f, 0.9f);
|
|
|
|
sd->flag |= bssrdf_setup(sd, bssrdf, (ClosureType)type, clamp(ior, 1.01f, 3.8f));
|
2016-07-25 03:03:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2018-02-08 16:14:04 +01:00
|
|
|
ClosureParam *closure_bssrdf_params()
|
2017-04-18 11:43:09 +02:00
|
|
|
{
|
|
|
|
static ClosureParam params[] = {
|
2018-02-08 16:14:04 +01:00
|
|
|
CLOSURE_STRING_PARAM(CBSSRDFClosure, method),
|
|
|
|
CLOSURE_FLOAT3_PARAM(CBSSRDFClosure, params.N),
|
|
|
|
CLOSURE_FLOAT3_PARAM(CBSSRDFClosure, params.radius),
|
|
|
|
CLOSURE_FLOAT3_PARAM(CBSSRDFClosure, params.albedo),
|
|
|
|
CLOSURE_FLOAT_KEYPARAM(CBSSRDFClosure, params.roughness, "roughness"),
|
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
|
|
|
CLOSURE_FLOAT_KEYPARAM(CBSSRDFClosure, ior, "ior"),
|
|
|
|
CLOSURE_FLOAT_KEYPARAM(CBSSRDFClosure, params.anisotropy, "anisotropy"),
|
2018-02-08 16:14:04 +01:00
|
|
|
CLOSURE_STRING_KEYPARAM(CBSSRDFClosure, label, "label"),
|
|
|
|
CLOSURE_FINISH_PARAM(CBSSRDFClosure)};
|
2017-04-18 11:43:09 +02:00
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
2018-02-08 16:14:04 +01:00
|
|
|
CCLOSURE_PREPARE(closure_bssrdf_prepare, CBSSRDFClosure)
|
2017-04-18 11:43:09 +02:00
|
|
|
|
2013-04-01 20:26:52 +00:00
|
|
|
CCL_NAMESPACE_END
|