2011-04-27 11:58:34 +00:00
|
|
|
/*
|
|
|
|
* Adapted from Open Shading Language with this license:
|
|
|
|
*
|
2013-05-20 00:26:48 +00:00
|
|
|
* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
|
2011-04-27 11:58:34 +00:00
|
|
|
* All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Modifications Copyright 2011, Blender Foundation.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions are
|
|
|
|
* met:
|
|
|
|
* * Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* * Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* * Neither the name of Sony Pictures Imageworks nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived from
|
|
|
|
* this software without specific prior written permission.
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
|
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
|
|
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
|
|
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
|
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
|
|
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
|
|
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
|
|
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
|
|
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
|
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <OSL/genclosure.h>
|
|
|
|
#include <OSL/oslclosure.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/osl/osl_closures.h"
|
|
|
|
#include "kernel/osl/osl_shader.h"
|
2011-04-27 11:58:34 +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 "util/util_debug.h"
|
|
|
|
#include "util/util_math.h"
|
|
|
|
#include "util/util_param.h"
|
2011-04-27 11:58:34 +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/kernel_types.h"
|
|
|
|
#include "kernel/kernel_compat_cpu.h"
|
|
|
|
#include "kernel/split/kernel_split_data_types.h"
|
|
|
|
#include "kernel/kernel_globals.h"
|
|
|
|
#include "kernel/kernel_montecarlo.h"
|
|
|
|
#include "kernel/kernel_random.h"
|
2012-10-20 12:18:00 +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"
|
|
|
|
#include "kernel/closure/bsdf_util.h"
|
|
|
|
#include "kernel/closure/bsdf_ashikhmin_velvet.h"
|
|
|
|
#include "kernel/closure/bsdf_diffuse.h"
|
|
|
|
#include "kernel/closure/bsdf_microfacet.h"
|
|
|
|
#include "kernel/closure/bsdf_microfacet_multi.h"
|
|
|
|
#include "kernel/closure/bsdf_oren_nayar.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"
|
|
|
|
#include "kernel/closure/volume.h"
|
2012-10-20 12:18:00 +00:00
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_BEGIN
|
|
|
|
|
2012-10-20 12:18:00 +00:00
|
|
|
using namespace OSL;
|
|
|
|
|
|
|
|
/* BSDF class definitions */
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(Diffuse, diffuse, DiffuseBsdf, LABEL_DIFFUSE)
|
|
|
|
CLOSURE_FLOAT3_PARAM(DiffuseClosure, params.N),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(Diffuse, diffuse)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(Translucent, translucent, DiffuseBsdf, LABEL_DIFFUSE)
|
|
|
|
CLOSURE_FLOAT3_PARAM(TranslucentClosure, params.N),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(Translucent, translucent)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(OrenNayar, oren_nayar, OrenNayarBsdf, LABEL_DIFFUSE)
|
|
|
|
CLOSURE_FLOAT3_PARAM(OrenNayarClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(OrenNayarClosure, params.roughness),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(OrenNayar, oren_nayar)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(Reflection, reflection, MicrofacetBsdf, LABEL_SINGULAR)
|
|
|
|
CLOSURE_FLOAT3_PARAM(ReflectionClosure, params.N),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(Reflection, reflection)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(Refraction, refraction, MicrofacetBsdf, LABEL_SINGULAR)
|
|
|
|
CLOSURE_FLOAT3_PARAM(RefractionClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(RefractionClosure, params.ior),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(Refraction, refraction)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(Transparent, transparent, ShaderClosure, LABEL_SINGULAR)
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(Transparent, transparent)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(AshikhminVelvet, ashikhmin_velvet, VelvetBsdf, LABEL_DIFFUSE)
|
|
|
|
CLOSURE_FLOAT3_PARAM(AshikhminVelvetClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(AshikhminVelvetClosure, params.sigma),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(AshikhminVelvet, ashikhmin_velvet)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(AshikhminShirley, ashikhmin_shirley_aniso, MicrofacetBsdf, LABEL_GLOSSY|LABEL_REFLECT)
|
|
|
|
CLOSURE_FLOAT3_PARAM(AshikhminShirleyClosure, params.N),
|
|
|
|
CLOSURE_FLOAT3_PARAM(AshikhminShirleyClosure, params.T),
|
|
|
|
CLOSURE_FLOAT_PARAM(AshikhminShirleyClosure, params.alpha_x),
|
|
|
|
CLOSURE_FLOAT_PARAM(AshikhminShirleyClosure, params.alpha_y),
|
2014-06-08 12:46:12 +02:00
|
|
|
BSDF_CLOSURE_CLASS_END(AshikhminShirley, ashikhmin_shirley_aniso)
|
2014-06-08 12:16:28 +02:00
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(DiffuseToon, diffuse_toon, ToonBsdf, LABEL_DIFFUSE)
|
|
|
|
CLOSURE_FLOAT3_PARAM(DiffuseToonClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(DiffuseToonClosure, params.size),
|
|
|
|
CLOSURE_FLOAT_PARAM(DiffuseToonClosure, params.smooth),
|
2013-05-23 17:45:20 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(DiffuseToon, diffuse_toon)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(GlossyToon, glossy_toon, ToonBsdf, LABEL_GLOSSY)
|
|
|
|
CLOSURE_FLOAT3_PARAM(GlossyToonClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(GlossyToonClosure, params.size),
|
|
|
|
CLOSURE_FLOAT_PARAM(GlossyToonClosure, params.smooth),
|
2013-05-23 17:45:20 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(GlossyToon, glossy_toon)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetGGX, microfacet_ggx, MicrofacetBsdf, LABEL_GLOSSY|LABEL_REFLECT)
|
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetGGXClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetGGXClosure, params.alpha_x),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(MicrofacetGGX, microfacet_ggx)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetGGXAniso, microfacet_ggx_aniso, MicrofacetBsdf, LABEL_GLOSSY|LABEL_REFLECT)
|
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetGGXAnisoClosure, params.N),
|
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetGGXAnisoClosure, params.T),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetGGXAnisoClosure, params.alpha_x),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetGGXAnisoClosure, params.alpha_y),
|
2014-06-08 12:46:12 +02:00
|
|
|
BSDF_CLOSURE_CLASS_END(MicrofacetGGXAniso, microfacet_ggx_aniso)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetBeckmann, microfacet_beckmann, MicrofacetBsdf, LABEL_GLOSSY|LABEL_REFLECT)
|
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetBeckmannClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannClosure, params.alpha_x),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(MicrofacetBeckmann, microfacet_beckmann)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetBeckmannAniso, microfacet_beckmann_aniso, MicrofacetBsdf, LABEL_GLOSSY|LABEL_REFLECT)
|
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetBeckmannAnisoClosure, params.N),
|
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetBeckmannAnisoClosure, params.T),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannAnisoClosure, params.alpha_x),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannAnisoClosure, params.alpha_y),
|
2014-06-08 12:46:12 +02:00
|
|
|
BSDF_CLOSURE_CLASS_END(MicrofacetBeckmannAniso, microfacet_beckmann_aniso)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetGGXRefraction, microfacet_ggx_refraction, MicrofacetBsdf, LABEL_GLOSSY|LABEL_TRANSMIT)
|
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetGGXRefractionClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetGGXRefractionClosure, params.alpha_x),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetGGXRefractionClosure, params.ior),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(MicrofacetGGXRefraction, microfacet_ggx_refraction)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(MicrofacetBeckmannRefraction, microfacet_beckmann_refraction, MicrofacetBsdf, LABEL_GLOSSY|LABEL_TRANSMIT)
|
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetBeckmannRefractionClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannRefractionClosure, params.alpha_x),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetBeckmannRefractionClosure, params.ior),
|
2012-10-20 12:18:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(MicrofacetBeckmannRefraction, microfacet_beckmann_refraction)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(HairReflection, hair_reflection, HairBsdf, LABEL_GLOSSY)
|
|
|
|
CLOSURE_FLOAT3_PARAM(HairReflectionClosure, unused),
|
|
|
|
CLOSURE_FLOAT_PARAM(HairReflectionClosure, params.roughness1),
|
|
|
|
CLOSURE_FLOAT_PARAM(HairReflectionClosure, params.roughness2),
|
|
|
|
CLOSURE_FLOAT3_PARAM(HairReflectionClosure, params.T),
|
|
|
|
CLOSURE_FLOAT_PARAM(HairReflectionClosure, params.offset),
|
2013-09-15 23:58:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(HairReflection, hair_reflection)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
BSDF_CLOSURE_CLASS_BEGIN(HairTransmission, hair_transmission, HairBsdf, LABEL_GLOSSY)
|
|
|
|
CLOSURE_FLOAT3_PARAM(HairTransmissionClosure, unused),
|
|
|
|
CLOSURE_FLOAT_PARAM(HairTransmissionClosure, params.roughness1),
|
|
|
|
CLOSURE_FLOAT_PARAM(HairTransmissionClosure, params.roughness2),
|
|
|
|
CLOSURE_FLOAT3_PARAM(HairReflectionClosure, params.T),
|
|
|
|
CLOSURE_FLOAT_PARAM(HairReflectionClosure, params.offset),
|
2013-09-15 23:58:00 +00:00
|
|
|
BSDF_CLOSURE_CLASS_END(HairTransmission, hair_transmission)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
VOLUME_CLOSURE_CLASS_BEGIN(VolumeHenyeyGreenstein, henyey_greenstein, HenyeyGreensteinVolume, LABEL_VOLUME_SCATTER)
|
|
|
|
CLOSURE_FLOAT_PARAM(VolumeHenyeyGreensteinClosure, params.g),
|
2013-12-28 01:54:44 +01:00
|
|
|
VOLUME_CLOSURE_CLASS_END(VolumeHenyeyGreenstein, henyey_greenstein)
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
VOLUME_CLOSURE_CLASS_BEGIN(VolumeAbsorption, absorption, ShaderClosure, LABEL_SINGULAR)
|
2013-12-28 01:54:44 +01:00
|
|
|
VOLUME_CLOSURE_CLASS_END(VolumeAbsorption, absorption)
|
|
|
|
|
2012-10-20 12:18:00 +00:00
|
|
|
/* Registration */
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
static void register_closure(OSL::ShadingSystem *ss, const char *name, int id, OSL::ClosureParam *params, OSL::PrepareClosureFunc prepare)
|
|
|
|
{
|
2013-11-29 02:09:24 +01:00
|
|
|
/* optimization: it's possible to not use a prepare function at all and
|
|
|
|
* only initialize the actual class when accessing the closure component
|
|
|
|
* data, but then we need to map the id to the class somehow */
|
2014-12-03 20:34:03 +05:00
|
|
|
ss->register_closure(name, id, params, prepare, NULL, 16);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2012-12-01 19:15:05 +00:00
|
|
|
void OSLShader::register_closures(OSLShadingSystem *ss_)
|
2011-04-27 11:58:34 +00:00
|
|
|
{
|
2012-12-01 19:15:05 +00:00
|
|
|
OSL::ShadingSystem *ss = (OSL::ShadingSystem*)ss_;
|
2012-10-20 12:18:00 +00:00
|
|
|
int id = 0;
|
|
|
|
|
|
|
|
register_closure(ss, "diffuse", id++,
|
|
|
|
bsdf_diffuse_params(), bsdf_diffuse_prepare);
|
|
|
|
register_closure(ss, "oren_nayar", id++,
|
|
|
|
bsdf_oren_nayar_params(), bsdf_oren_nayar_prepare);
|
|
|
|
register_closure(ss, "translucent", id++,
|
|
|
|
bsdf_translucent_params(), bsdf_translucent_prepare);
|
|
|
|
register_closure(ss, "reflection", id++,
|
|
|
|
bsdf_reflection_params(), bsdf_reflection_prepare);
|
|
|
|
register_closure(ss, "refraction", id++,
|
|
|
|
bsdf_refraction_params(), bsdf_refraction_prepare);
|
|
|
|
register_closure(ss, "transparent", id++,
|
|
|
|
bsdf_transparent_params(), bsdf_transparent_prepare);
|
|
|
|
register_closure(ss, "microfacet_ggx", id++,
|
|
|
|
bsdf_microfacet_ggx_params(), bsdf_microfacet_ggx_prepare);
|
2014-06-08 12:46:12 +02:00
|
|
|
register_closure(ss, "microfacet_ggx_aniso", id++,
|
|
|
|
bsdf_microfacet_ggx_aniso_params(), bsdf_microfacet_ggx_aniso_prepare);
|
2012-10-20 12:18:00 +00:00
|
|
|
register_closure(ss, "microfacet_ggx_refraction", id++,
|
|
|
|
bsdf_microfacet_ggx_refraction_params(), bsdf_microfacet_ggx_refraction_prepare);
|
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
|
|
|
register_closure(ss, "microfacet_multi_ggx", id++,
|
|
|
|
closure_bsdf_microfacet_multi_ggx_params(), closure_bsdf_microfacet_multi_ggx_prepare);
|
|
|
|
register_closure(ss, "microfacet_multi_ggx_glass", id++,
|
|
|
|
closure_bsdf_microfacet_multi_ggx_glass_params(), closure_bsdf_microfacet_multi_ggx_glass_prepare);
|
|
|
|
register_closure(ss, "microfacet_multi_ggx_aniso", id++,
|
|
|
|
closure_bsdf_microfacet_multi_ggx_aniso_params(), closure_bsdf_microfacet_multi_ggx_aniso_prepare);
|
2012-10-20 12:18:00 +00:00
|
|
|
register_closure(ss, "microfacet_beckmann", id++,
|
|
|
|
bsdf_microfacet_beckmann_params(), bsdf_microfacet_beckmann_prepare);
|
2014-06-08 12:46:12 +02:00
|
|
|
register_closure(ss, "microfacet_beckmann_aniso", id++,
|
|
|
|
bsdf_microfacet_beckmann_aniso_params(), bsdf_microfacet_beckmann_aniso_prepare);
|
2012-10-20 12:18:00 +00:00
|
|
|
register_closure(ss, "microfacet_beckmann_refraction", id++,
|
|
|
|
bsdf_microfacet_beckmann_refraction_params(), bsdf_microfacet_beckmann_refraction_prepare);
|
2014-06-08 12:16:28 +02:00
|
|
|
register_closure(ss, "ashikhmin_shirley", id++,
|
2014-06-08 12:46:12 +02:00
|
|
|
bsdf_ashikhmin_shirley_aniso_params(), bsdf_ashikhmin_shirley_aniso_prepare);
|
2012-10-20 12:18:00 +00:00
|
|
|
register_closure(ss, "ashikhmin_velvet", id++,
|
|
|
|
bsdf_ashikhmin_velvet_params(), bsdf_ashikhmin_velvet_prepare);
|
2013-05-23 17:45:20 +00:00
|
|
|
register_closure(ss, "diffuse_toon", id++,
|
|
|
|
bsdf_diffuse_toon_params(), bsdf_diffuse_toon_prepare);
|
|
|
|
register_closure(ss, "glossy_toon", id++,
|
|
|
|
bsdf_glossy_toon_params(), bsdf_glossy_toon_prepare);
|
2013-05-21 10:13:47 +00:00
|
|
|
|
2012-10-20 12:18:00 +00:00
|
|
|
register_closure(ss, "emission", id++,
|
|
|
|
closure_emission_params(), closure_emission_prepare);
|
|
|
|
register_closure(ss, "background", id++,
|
|
|
|
closure_background_params(), closure_background_prepare);
|
|
|
|
register_closure(ss, "holdout", id++,
|
|
|
|
closure_holdout_params(), closure_holdout_prepare);
|
2012-11-06 19:59:02 +00:00
|
|
|
register_closure(ss, "ambient_occlusion", id++,
|
|
|
|
closure_ambient_occlusion_params(), closure_ambient_occlusion_prepare);
|
2012-12-11 14:39:41 +00:00
|
|
|
register_closure(ss, "diffuse_ramp", id++,
|
|
|
|
closure_bsdf_diffuse_ramp_params(), closure_bsdf_diffuse_ramp_prepare);
|
2012-12-19 21:17:16 +00:00
|
|
|
register_closure(ss, "phong_ramp", id++,
|
|
|
|
closure_bsdf_phong_ramp_params(), closure_bsdf_phong_ramp_prepare);
|
2013-04-01 20:26:52 +00:00
|
|
|
register_closure(ss, "bssrdf_cubic", id++,
|
2013-08-18 14:15:57 +00:00
|
|
|
closure_bssrdf_cubic_params(), closure_bssrdf_cubic_prepare);
|
|
|
|
register_closure(ss, "bssrdf_gaussian", id++,
|
|
|
|
closure_bssrdf_gaussian_params(), closure_bssrdf_gaussian_prepare);
|
2016-02-04 03:34:49 +05:00
|
|
|
register_closure(ss, "bssrdf_burley", id++,
|
|
|
|
closure_bssrdf_burley_params(), closure_bssrdf_burley_prepare);
|
2013-09-15 23:58:00 +00:00
|
|
|
|
|
|
|
register_closure(ss, "hair_reflection", id++,
|
|
|
|
bsdf_hair_reflection_params(), bsdf_hair_reflection_prepare);
|
|
|
|
register_closure(ss, "hair_transmission", id++,
|
|
|
|
bsdf_hair_transmission_params(), bsdf_hair_transmission_prepare);
|
2013-12-28 01:54:44 +01:00
|
|
|
|
|
|
|
register_closure(ss, "henyey_greenstein", id++,
|
|
|
|
volume_henyey_greenstein_params(), volume_henyey_greenstein_prepare);
|
|
|
|
register_closure(ss, "absorption", id++,
|
|
|
|
volume_absorption_params(), volume_absorption_prepare);
|
2011-04-27 11:58:34 +00:00
|
|
|
}
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
/* BSDF Closure */
|
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
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
bool CBSDFClosure::skip(const ShaderData *sd, int path_flag, int scattering)
|
|
|
|
{
|
|
|
|
/* caustic options */
|
|
|
|
if((scattering & LABEL_GLOSSY) && (path_flag & PATH_RAY_DIFFUSE)) {
|
|
|
|
KernelGlobals *kg = sd->osl_globals;
|
|
|
|
|
|
|
|
if((!kernel_data.integrator.caustics_reflective && (scattering & LABEL_REFLECT)) ||
|
|
|
|
(!kernel_data.integrator.caustics_refractive && (scattering & LABEL_TRANSMIT)))
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
return false;
|
|
|
|
}
|
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
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
/* Multiscattering GGX closures */
|
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
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
class MicrofacetMultiClosure : public CBSDFClosure {
|
|
|
|
public:
|
|
|
|
MicrofacetBsdf params;
|
|
|
|
float3 color;
|
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
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
MicrofacetBsdf *alloc(ShaderData *sd, int path_flag, float3 weight)
|
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
|
|
|
{
|
2016-07-25 03:03:23 +02:00
|
|
|
/* Technically, the MultiGGX Glass closure may also transmit. However,
|
|
|
|
* since this is set statically and only used for caustic flags, this
|
|
|
|
* is probably as good as it gets. */
|
|
|
|
if(!skip(sd, path_flag, LABEL_GLOSSY|LABEL_REFLECT)) {
|
|
|
|
MicrofacetBsdf *bsdf = (MicrofacetBsdf*)bsdf_alloc_osl(sd, sizeof(MicrofacetBsdf), weight, ¶ms);
|
|
|
|
MicrofacetExtra *extra = (MicrofacetExtra*)closure_alloc_extra(sd, sizeof(MicrofacetExtra));
|
|
|
|
if(bsdf && extra) {
|
|
|
|
bsdf->extra = extra;
|
|
|
|
bsdf->extra->color = color;
|
|
|
|
return bsdf;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
class MicrofacetMultiGGXClosure : public MicrofacetMultiClosure {
|
|
|
|
public:
|
2016-07-25 03:03:23 +02:00
|
|
|
void setup(ShaderData *sd, int path_flag, float3 weight)
|
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
|
|
|
{
|
2016-07-25 03:03:23 +02:00
|
|
|
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
|
|
|
|
sd->flag |= (bsdf) ? bsdf_microfacet_multi_ggx_setup(bsdf) : 0;
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ClosureParam *closure_bsdf_microfacet_multi_ggx_params()
|
|
|
|
{
|
|
|
|
static ClosureParam params[] = {
|
2016-07-25 03:03:23 +02:00
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetMultiGGXClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetMultiGGXClosure, params.alpha_x),
|
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
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetMultiGGXClosure, color),
|
|
|
|
CLOSURE_STRING_KEYPARAM(MicrofacetMultiGGXClosure, label, "label"),
|
|
|
|
CLOSURE_FINISH_PARAM(MicrofacetMultiGGXClosure)
|
|
|
|
};
|
|
|
|
return params;
|
|
|
|
}
|
|
|
|
CCLOSURE_PREPARE(closure_bsdf_microfacet_multi_ggx_prepare, MicrofacetMultiGGXClosure);
|
|
|
|
|
|
|
|
class MicrofacetMultiGGXAnisoClosure : public MicrofacetMultiClosure {
|
|
|
|
public:
|
2016-07-25 03:03:23 +02:00
|
|
|
void setup(ShaderData *sd, int path_flag, float3 weight)
|
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
|
|
|
{
|
2016-07-25 03:03:23 +02:00
|
|
|
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
|
|
|
|
sd->flag |= (bsdf) ? bsdf_microfacet_multi_ggx_aniso_setup(bsdf) : 0;
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ClosureParam *closure_bsdf_microfacet_multi_ggx_aniso_params()
|
|
|
|
{
|
|
|
|
static ClosureParam params[] = {
|
2016-07-25 03:03:23 +02:00
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetMultiGGXClosure, params.N),
|
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetMultiGGXClosure, params.T),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetMultiGGXClosure, params.alpha_x),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetMultiGGXClosure, params.alpha_y),
|
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
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetMultiGGXClosure, color),
|
|
|
|
CLOSURE_STRING_KEYPARAM(MicrofacetMultiGGXClosure, label, "label"),
|
|
|
|
CLOSURE_FINISH_PARAM(MicrofacetMultiGGXClosure)
|
|
|
|
};
|
|
|
|
return params;
|
|
|
|
}
|
|
|
|
CCLOSURE_PREPARE(closure_bsdf_microfacet_multi_ggx_aniso_prepare, MicrofacetMultiGGXAnisoClosure);
|
|
|
|
|
|
|
|
class MicrofacetMultiGGXGlassClosure : public MicrofacetMultiClosure {
|
|
|
|
public:
|
|
|
|
MicrofacetMultiGGXGlassClosure() : MicrofacetMultiClosure() {}
|
|
|
|
|
2016-07-25 03:03:23 +02:00
|
|
|
void setup(ShaderData *sd, int path_flag, float3 weight)
|
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
|
|
|
{
|
2016-07-25 03:03:23 +02:00
|
|
|
MicrofacetBsdf *bsdf = alloc(sd, path_flag, weight);
|
|
|
|
sd->flag |= (bsdf) ? bsdf_microfacet_multi_ggx_glass_setup(bsdf) : 0;
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
ClosureParam *closure_bsdf_microfacet_multi_ggx_glass_params()
|
|
|
|
{
|
|
|
|
static ClosureParam params[] = {
|
2016-07-25 03:03:23 +02:00
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetMultiGGXClosure, params.N),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetMultiGGXClosure, params.alpha_x),
|
|
|
|
CLOSURE_FLOAT_PARAM(MicrofacetMultiGGXClosure, params.ior),
|
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
|
|
|
CLOSURE_FLOAT3_PARAM(MicrofacetMultiGGXClosure, color),
|
|
|
|
CLOSURE_STRING_KEYPARAM(MicrofacetMultiGGXClosure, label, "label"),
|
|
|
|
CLOSURE_FINISH_PARAM(MicrofacetMultiGGXClosure)
|
|
|
|
};
|
|
|
|
return params;
|
|
|
|
}
|
|
|
|
CCLOSURE_PREPARE(closure_bsdf_microfacet_multi_ggx_glass_prepare, MicrofacetMultiGGXGlassClosure);
|
|
|
|
|
2011-04-27 11:58:34 +00:00
|
|
|
CCL_NAMESPACE_END
|
|
|
|
|