Cleanup the Disney BSDF implementation and removing unneeded files.

This commit is contained in:
2016-09-27 08:53:18 +02:00
parent 3f4fc826bd
commit d0530a8af0
10 changed files with 0 additions and 816 deletions

View File

@@ -109,8 +109,6 @@ set(SRC_CLOSURE_HEADERS
closure/volume.h
closure/bsdf_disney_diffuse.h
closure/bsdf_disney_sheen.h
closure/bsdf_disney_specular.h
closure/bsdf_disney_clearcoat.h
)
set(SRC_SVM_HEADERS

View File

@@ -29,8 +29,6 @@
#include "../closure/bsdf_hair.h"
#include "../closure/bsdf_disney_diffuse.h"
#include "../closure/bsdf_disney_sheen.h"
#include "../closure/bsdf_disney_specular.h"
#include "../closure/bsdf_disney_clearcoat.h"
#ifdef __SUBSURFACE__
# include "../closure/bssrdf.h"
#endif
@@ -144,14 +142,6 @@ ccl_device_inline int bsdf_sample(KernelGlobals *kg,
label = bsdf_disney_sheen_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
break;
/*case CLOSURE_BSDF_DISNEY_SPECULAR_ID:
label = bsdf_disney_specular_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
break;*/
case CLOSURE_BSDF_DISNEY_CLEARCOAT_ID:
label = bsdf_disney_clearcoat_sample(sc, ccl_fetch(sd, Ng), ccl_fetch(sd, I), ccl_fetch(sd, dI).dx, ccl_fetch(sd, dI).dy, randu, randv,
eval, omega_in, &domega_in->dx, &domega_in->dy, pdf);
break;
#endif
#ifdef __VOLUME__
case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
@@ -251,12 +241,6 @@ float3 bsdf_eval(KernelGlobals *kg,
case CLOSURE_BSDF_DISNEY_SHEEN_ID:
eval = bsdf_disney_sheen_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
break;
/*case CLOSURE_BSDF_DISNEY_SPECULAR_ID:
eval = bsdf_disney_specular_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
break;*/
case CLOSURE_BSDF_DISNEY_CLEARCOAT_ID:
eval = bsdf_disney_clearcoat_eval_reflect(sc, ccl_fetch(sd, I), omega_in, pdf);
break;
#endif
#ifdef __VOLUME__
case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:
@@ -333,12 +317,6 @@ float3 bsdf_eval(KernelGlobals *kg,
case CLOSURE_BSDF_DISNEY_SHEEN_ID:
eval = bsdf_disney_sheen_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
break;
/*case CLOSURE_BSDF_DISNEY_SPECULAR_ID:
eval = bsdf_disney_specular_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
break;*/
case CLOSURE_BSDF_DISNEY_CLEARCOAT_ID:
eval = bsdf_disney_clearcoat_eval_transmit(sc, ccl_fetch(sd, I), omega_in, pdf);
break;
#endif
#ifdef __VOLUME__
case CLOSURE_VOLUME_HENYEY_GREENSTEIN_ID:

View File

@@ -1,200 +0,0 @@
/*
* Adapted from Open Shading Language with this license:
*
* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
* 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.
*/
#ifndef __BSDF_DISNEY_CLEARCOAT_H__
#define __BSDF_DISNEY_CLEARCOAT_H__
CCL_NAMESPACE_BEGIN
typedef ccl_addr_space struct DisneyClearcoatBsdf {
SHADER_CLOSURE_BASE;
float clearcoat, clearcoatGloss, clearcoatRoughness;
float3 N;
} DisneyClearcoatBsdf;
ccl_device int bsdf_disney_clearcoat_setup(DisneyClearcoatBsdf *bsdf)
{
/* clearcoat roughness */
bsdf->clearcoatRoughness = 0.1f * (1.0f - bsdf->clearcoatGloss) + 0.001f * bsdf->clearcoatGloss; // lerp(0.1f, 0.001f, sc->data1/*clearcoatGloss*/); //
bsdf->type = CLOSURE_BSDF_DISNEY_CLEARCOAT_ID;
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
ccl_device float3 bsdf_disney_clearcoat_eval_reflect(const ShaderClosure *sc, const float3 I,
const float3 omega_in, float *pdf)
{
const DisneyClearcoatBsdf *bsdf = (const DisneyClearcoatBsdf *)sc;
if (bsdf->clearcoat > 0.0f) {
float alpha = bsdf->clearcoatRoughness;
float3 N = bsdf->N;
if (alpha <= 1e-4f)
return make_float3(0.0f, 0.0f, 0.0f);
float cosNO = dot(N, I);
float cosNI = dot(N, omega_in);
if (cosNI > 0 && cosNO > 0) {
/* get half vector */
float3 m = normalize(omega_in + I);
float alpha2 = alpha * alpha;
float D, G1o, G1i;
/* isotropic
* eq. 20: (F*G*D)/(4*in*on)
* eq. 33: first we calculate D(m) */
float cosThetaM = dot(N, m);
float cosThetaM2 = cosThetaM * cosThetaM;
D = (alpha2 - 1) / (M_PI_F * logf(alpha2) * (1 + (alpha2 - 1) * cosThetaM2));
/* eq. 34: now calculate G1(i,m) and G1(o,m) */
G1o = 2 / (1 + safe_sqrtf(1 + 0.0625f * (1 - cosNO * cosNO) / (cosNO * cosNO)));
G1i = 2 / (1 + safe_sqrtf(1 + 0.0625f * (1 - cosNI * cosNI) / (cosNI * cosNI)));
float G = G1o * G1i;
/* eq. 20 */
float common = D * 0.25f / cosNO;
float FH = schlick_fresnel(dot(omega_in, m));
float3 F = (0.04f * (1.0f - FH) + 1.0f * FH) * 0.25f * bsdf->clearcoat * make_float3(1.0f, 1.0f, 1.0f); // lerp(make_float3(0.04f, 0.04f, 0.04f), make_float3(1.0f, 1.0f, 1.0f), FH);
float3 out = F * G * common;
/* eq. 2 in distribution of visible normals sampling
* pm = Dw = G1o * dot(m, I) * D / dot(N, I); */
/* eq. 38 - but see also:
* eq. 17 in http://www.graphics.cornell.edu/~bjw/wardnotes.pdf
* pdf = pm * 0.25 / dot(m, I); */
*pdf = G1o * common;
return out;
}
}
return make_float3(0.0f, 0.0f, 0.0f);
}
ccl_device float3 bsdf_disney_clearcoat_eval_transmit(const ShaderClosure *sc, const float3 I, const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
ccl_device int bsdf_disney_clearcoat_sample(const ShaderClosure *sc,
float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv,
float3 *eval, float3 *omega_in, float3 *domega_in_dx,
float3 *domega_in_dy, float *pdf)
{
const DisneyClearcoatBsdf *bsdf = (const DisneyClearcoatBsdf *)sc;
if (bsdf->clearcoat > 0.0f) {
float alpha = bsdf->clearcoatRoughness;
float3 N = bsdf->N;
float cosNO = dot(N, I);
if (cosNO > 0) {
float3 X, Y, Z = N;
make_orthonormals(Z, &X, &Y);
/* importance sampling with distribution of visible normals. vectors are
* transformed to local space before and after */
float3 local_I = make_float3(dot(X, I), dot(Y, I), cosNO);
float3 local_m;
float3 m;
float G1o;
local_m = importance_sample_microfacet_stretched(local_I, alpha, alpha,
randu, randv, false, &G1o);
m = X*local_m.x + Y*local_m.y + Z*local_m.z;
float cosThetaM = local_m.z;
/* reflection or refraction? */
float cosMO = dot(m, I);
if (cosMO > 0) {
/* eq. 39 - compute actual reflected direction */
*omega_in = 2 * cosMO * m - I;
if (dot(Ng, *omega_in) > 0) {
if (alpha <= 1e-4f) {
/* some high number for MIS */
*pdf = 1e6f;
*eval = make_float3(1e6f, 1e6f, 1e6f);
}
else {
/* microfacet normal is visible to this ray */
/* eq. 33 */
float alpha2 = alpha * alpha;
float D, G1i;
float cosThetaM2 = cosThetaM * cosThetaM;
D = (alpha2 - 1) / (M_PI_F * logf(alpha2) * (1 + (alpha2 - 1) * cosThetaM2));
/* eval BRDF*cosNI */
float cosNI = dot(N, *omega_in);
/* eq. 34: now calculate G1(i,m) */
G1o = 2 / (1 + safe_sqrtf(1 + 0.0625f * (1 - cosNO * cosNO) / (cosNO * cosNO)));
G1i = 2 / (1 + safe_sqrtf(1 + 0.0625f * (1 - cosNI * cosNI) / (cosNI * cosNI)));
/* see eval function for derivation */
float common = (G1o * D) * 0.25f / cosNO;
*pdf = common;
float FH = schlick_fresnel(dot(*omega_in, m));
float3 F = make_float3(0.04f, 0.04f, 0.04f) * (1.0f - FH) + make_float3(1.0f, 1.0f, 1.0f) * FH; // lerp(make_float3(0.04f, 0.04f, 0.04f), make_float3(1.0f, 1.0f, 1.0f), FH);
*eval = G1i * common * F * 0.25f * bsdf->clearcoat;
}
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = (2 * dot(m, dIdx)) * m - dIdx;
*domega_in_dy = (2 * dot(m, dIdy)) * m - dIdy;
#endif
}
}
}
}
return LABEL_REFLECT|LABEL_GLOSSY;
}
CCL_NAMESPACE_END
#endif /* __BSDF_DISNEY_CLEARCOAT_H__ */

View File

@@ -1,286 +0,0 @@
/*
* Adapted from Open Shading Language with this license:
*
* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
* 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.
*/
#ifndef __BSDF_DISNEY_SPECULAR_H__
#define __BSDF_DISNEY_SPECULAR_H__
CCL_NAMESPACE_BEGIN
typedef ccl_addr_space struct DisneySpecularExtra {
float3 T, baseColor, cspec0;
bool alpha_x, alpha_y, rough_g, ior;
} DisneySpecularExtra;
typedef ccl_addr_space struct DisneySpecularBsdf {
SHADER_CLOSURE_BASE;
float specular, specularTint, roughness, metallic, anisotropic;
float3 N;
DisneySpecularExtra *extra;
} DisneySpecularBsdf;
ccl_device int bsdf_disney_specular_setup(DisneySpecularBsdf *bsdf)
{
float m_cdlum = 0.3f * bsdf->extra->baseColor.x + 0.6f * bsdf->extra->baseColor.y + 0.1f * bsdf->extra->baseColor.z; // luminance approx.
float3 m_ctint = m_cdlum > 0.0f ? bsdf->extra->baseColor / m_cdlum : make_float3(1.0f, 1.0f, 1.0f); // normalize lum. to isolate hue+sat
float3 tmp_col = make_float3(1.0f, 1.0f, 1.0f) * (1.0f - bsdf->specularTint) + m_ctint * bsdf->specularTint; // lerp(make_float3(1.0f, 1.0f, 1.0f), m_ctint, sc->data2/*specularTint*/);
bsdf->extra->cspec0 = (bsdf->specular * 0.08f * tmp_col) * (1.0f - bsdf->metallic) + bsdf->extra->baseColor * bsdf->metallic; // lerp(sc->data1/*specular*/ * 0.08f * tmp_col, sc->color0/*baseColor*/, sc->data0/*metallic*/);
float aspect = safe_sqrtf(1.0f - bsdf->anisotropic * 0.9f);
float r2 = sqr(bsdf->roughness);
/* ax */
bsdf->extra->alpha_x = fmaxf(0.001f, r2 / aspect);
/* ay */
bsdf->extra->alpha_y = fmaxf(0.001f, r2 * aspect);
/* rough_g */
bsdf->extra->rough_g = sqr(bsdf->roughness * 0.5f + 0.5f);
bsdf->type = CLOSURE_BSDF_DISNEY_SPECULAR_ID;
return SD_BSDF|SD_BSDF_HAS_EVAL;
}
ccl_device float3 bsdf_disney_specular_eval_reflect(const ShaderClosure *sc, const float3 I,
const float3 omega_in, float *pdf)
{
const DisneySpecularBsdf *bsdf = (const DisneySpecularBsdf *)sc;
float3 N = bsdf->N;
if (bsdf->extra->alpha_x*bsdf->extra->alpha_y <= 1e-7f)
return make_float3(0.0f, 0.0f, 0.0f);
float cosNO = dot(N, I);
float cosNI = dot(N, omega_in);
if (cosNI > 0 && cosNO > 0) {
/* get half vector */
float3 m = normalize(omega_in + I);
float alpha2 = bsdf->extra->alpha_x * bsdf->extra->alpha_y;
float D, G1o, G1i;
if (bsdf->extra->alpha_x == bsdf->extra->alpha_y) {
/* isotropic
* eq. 20: (F*G*D)/(4*in*on)
* eq. 33: first we calculate D(m) */
float cosThetaM = dot(N, m);
float cosThetaM2 = cosThetaM * cosThetaM;
float cosThetaM4 = cosThetaM2 * cosThetaM2;
float tanThetaM2 = (1 - cosThetaM2) / cosThetaM2;
D = alpha2 / (M_PI_F * cosThetaM4 * (alpha2 + tanThetaM2) * (alpha2 + tanThetaM2));
/* eq. 34: now calculate G1(i,m) and G1(o,m) */
G1o = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNO * cosNO) / (cosNO * cosNO)));
G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
}
else {
/* anisotropic */
float3 X, Y, Z = N;
make_orthonormals_tangent(Z, bsdf->extra->T, &X, &Y);
// distribution
float3 local_m = make_float3(dot(X, m), dot(Y, m), dot(Z, m));
float slope_x = -local_m.x/(local_m.z*bsdf->extra->alpha_x);
float slope_y = -local_m.y/(local_m.z*bsdf->extra->alpha_y);
float slope_len = 1 + slope_x*slope_x + slope_y*slope_y;
float cosThetaM = local_m.z;
float cosThetaM2 = cosThetaM * cosThetaM;
float cosThetaM4 = cosThetaM2 * cosThetaM2;
D = 1 / ((slope_len * slope_len) * M_PI_F * alpha2 * cosThetaM4);
/* G1(i,m) and G1(o,m) */
float tanThetaO2 = (1 - cosNO * cosNO) / (cosNO * cosNO);
float cosPhiO = dot(I, X);
float sinPhiO = dot(I, Y);
float alphaO2 = (cosPhiO*cosPhiO)*(bsdf->extra->alpha_x*bsdf->extra->alpha_x) + (sinPhiO*sinPhiO)*(bsdf->extra->alpha_y*bsdf->extra->alpha_y);
alphaO2 /= cosPhiO*cosPhiO + sinPhiO*sinPhiO;
G1o = 2 / (1 + safe_sqrtf(1 + alphaO2 * tanThetaO2));
float tanThetaI2 = (1 - cosNI * cosNI) / (cosNI * cosNI);
float cosPhiI = dot(omega_in, X);
float sinPhiI = dot(omega_in, Y);
float alphaI2 = (cosPhiI*cosPhiI)*(bsdf->extra->alpha_x*bsdf->extra->alpha_x) + (sinPhiI*sinPhiI)*(bsdf->extra->alpha_y*bsdf->extra->alpha_y);
alphaI2 /= cosPhiI*cosPhiI + sinPhiI*sinPhiI;
G1i = 2 / (1 + safe_sqrtf(1 + alphaI2 * tanThetaI2));
}
float G = G1o * G1i;
/* eq. 20 */
float common = D * 0.25f / cosNO;
float FH = schlick_fresnel(dot(omega_in, m));
float3 F = bsdf->extra->cspec0 * (1.0f - FH) + make_float3(1.0f, 1.0f, 1.0f) * FH; // lerp(sc->custom_color0, make_float3(1.0f, 1.0f, 1.0f), FH);
float3 out = F * G * common;
/* eq. 2 in distribution of visible normals sampling
* pm = Dw = G1o * dot(m, I) * D / dot(N, I); */
/* eq. 38 - but see also:
* eq. 17 in http://www.graphics.cornell.edu/~bjw/wardnotes.pdf
* pdf = pm * 0.25 / dot(m, I); */
*pdf = G1o * common;
return out;
}
return make_float3(0.0f, 0.0f, 0.0f);
}
ccl_device float3 bsdf_disney_specular_eval_transmit(const ShaderClosure *sc, const float3 I,
const float3 omega_in, float *pdf)
{
return make_float3(0.0f, 0.0f, 0.0f);
}
ccl_device int bsdf_disney_specular_sample(const ShaderClosure *sc,
float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv,
float3 *eval, float3 *omega_in, float3 *domega_in_dx,
float3 *domega_in_dy, float *pdf)
{
const DisneySpecularBsdf *bsdf = (const DisneySpecularBsdf *)sc;
float3 N = bsdf->N;
float cosNO = dot(N, I);
if(cosNO > 0) {
float3 X, Y, Z = N;
if (bsdf->extra->alpha_x == bsdf->extra->alpha_y)
make_orthonormals(Z, &X, &Y);
else
make_orthonormals_tangent(Z, bsdf->extra->T, &X, &Y);
/* importance sampling with distribution of visible normals. vectors are
* transformed to local space before and after */
float3 local_I = make_float3(dot(X, I), dot(Y, I), cosNO);
float3 local_m;
float G1o;
local_m = importance_sample_microfacet_stretched(local_I, bsdf->extra->alpha_x, bsdf->extra->alpha_y,
randu, randv, false, &G1o);
float3 m = X*local_m.x + Y*local_m.y + Z*local_m.z;
float cosThetaM = local_m.z;
float cosMO = dot(m, I);
if(cosMO > 0) {
/* eq. 39 - compute actual reflected direction */
*omega_in = 2 * cosMO * m - I;
if(dot(Ng, *omega_in) > 0) {
if (bsdf->extra->alpha_x*bsdf->extra->alpha_y <= 1e-7f) {
/* some high number for MIS */
*pdf = 1e6f;
*eval = make_float3(1e6f, 1e6f, 1e6f);
}
else {
/* microfacet normal is visible to this ray */
/* eq. 33 */
float alpha2 = bsdf->extra->alpha_x * bsdf->extra->alpha_y;
float D, G1i;
if (bsdf->extra->alpha_x == bsdf->extra->alpha_y) {
float cosThetaM2 = cosThetaM * cosThetaM;
float cosThetaM4 = cosThetaM2 * cosThetaM2;
float tanThetaM2 = 1/(cosThetaM2) - 1;
D = alpha2 / (M_PI_F * cosThetaM4 * (alpha2 + tanThetaM2) * (alpha2 + tanThetaM2));
/* eval BRDF*cosNI */
float cosNI = dot(N, *omega_in);
/* eq. 34: now calculate G1(i,m) */
G1i = 2 / (1 + safe_sqrtf(1 + alpha2 * (1 - cosNI * cosNI) / (cosNI * cosNI)));
}
else {
/* anisotropic distribution */
float slope_x = -local_m.x / (local_m.z*bsdf->extra->alpha_x);
float slope_y = -local_m.y / (local_m.z*bsdf->extra->alpha_y);
float slope_len = 1 + slope_x*slope_x + slope_y*slope_y;
float cosThetaM = local_m.z;
float cosThetaM2 = cosThetaM * cosThetaM;
float cosThetaM4 = cosThetaM2 * cosThetaM2;
D = 1 / ((slope_len * slope_len) * M_PI_F * alpha2 * cosThetaM4);
/* calculate G1(i,m) */
float cosNI = dot(N, *omega_in);
float tanThetaI2 = (1 - cosNI * cosNI) / (cosNI * cosNI);
float cosPhiI = dot(*omega_in, X);
float sinPhiI = dot(*omega_in, Y);
float alphaI2 = (cosPhiI*cosPhiI)*(bsdf->extra->alpha_x*bsdf->extra->alpha_x) + (sinPhiI*sinPhiI)*(bsdf->extra->alpha_y*bsdf->extra->alpha_y);
alphaI2 /= cosPhiI*cosPhiI + sinPhiI*sinPhiI;
G1i = 2 / (1 + safe_sqrtf(1 + alphaI2 * tanThetaI2));
}
/* see eval function for derivation */
float common = (G1o * D) * 0.25f / cosNO;
*pdf = common;
float FH = fresnel_dielectric_cos(dot(*omega_in, m), bsdf->extra->ior);
//float FH = schlick_fresnel(dot(*omega_in, m));
float3 F = bsdf->extra->cspec0 * (1.0f - FH) + make_float3(1.0f, 1.0f, 1.0f) * FH; // lerp(sc->custom_color0, make_float3(1.0f, 1.0f, 1.0f), FH);
*eval = G1i * common * F;
}
#ifdef __RAY_DIFFERENTIALS__
*domega_in_dx = (2 * dot(m, dIdx)) * m - dIdx;
*domega_in_dy = (2 * dot(m, dIdy)) * m - dIdy;
#endif
}
}
}
return LABEL_REFLECT|LABEL_GLOSSY;
}
CCL_NAMESPACE_END
#endif /* __BSDF_DISNEY_SPECULAR_H__ */

View File

@@ -1,98 +0,0 @@
/*
* Adapted from Open Shading Language with this license:
*
* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
* 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 <OpenImageIO/fmath.h>
#include <OSL/genclosure.h>
#include "kernel_compat_cpu.h"
#include "osl_closures.h"
#include "kernel_types.h"
#include "closure/bsdf_disney_clearcoat.h"
CCL_NAMESPACE_BEGIN
using namespace OSL;
class DisneyClearcoatClosure : public CBSDFClosure {
public:
DisneyClearcoatClosure() : CBSDFClosure(LABEL_REFLECT|LABEL_GLOSSY)
{}
void setup()
{
sc.prim = this;
m_shaderdata_flag = bsdf_disney_clearcoat_setup(&sc);
}
void blur(float roughness)
{
}
float3 eval_reflect(const float3 &omega_out, const float3 &omega_in, float& pdf) const
{
return bsdf_disney_clearcoat_eval_reflect(&sc, omega_out, omega_in, &pdf);
}
float3 eval_transmit(const float3 &omega_out, const float3 &omega_in, float& pdf) const
{
return bsdf_disney_clearcoat_eval_transmit(&sc, omega_out, omega_in, &pdf);
}
int sample(const float3 &Ng,
const float3 &omega_out, const float3 &domega_out_dx, const float3 &domega_out_dy,
float randu, float randv,
float3 &omega_in, float3 &domega_in_dx, float3 &domega_in_dy,
float &pdf, float3 &eval) const
{
return bsdf_disney_clearcoat_sample(&sc, Ng, omega_out, domega_out_dx, domega_out_dy,
randu, randv, &eval, &omega_in, &domega_in_dx, &domega_in_dy, &pdf);
}
};
ClosureParam *closure_bsdf_disney_clearcoat_params()
{
static ClosureParam params[] = {
CLOSURE_FLOAT3_PARAM(DisneyClearcoatClosure, sc.N),
CLOSURE_FLOAT_PARAM(DisneyClearcoatClosure, sc.data0), // clearcoat
CLOSURE_FLOAT_PARAM(DisneyClearcoatClosure, sc.data1), // clearcoatGloss
CLOSURE_STRING_KEYPARAM(DisneyClearcoatClosure, label, "label"),
CLOSURE_FINISH_PARAM(DisneyClearcoatClosure)
};
return params;
}
CCLOSURE_PREPARE(closure_bsdf_disney_clearcoat_prepare, DisneyClearcoatClosure)
CCL_NAMESPACE_END*/

View File

@@ -1,100 +0,0 @@
/*
* Adapted from Open Shading Language with this license:
*
* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
* 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 <OpenImageIO/fmath.h>
#include <OSL/genclosure.h>
#include "kernel_compat_cpu.h"
#include "osl_closures.h"
#include "kernel_types.h"
#include "kernel_montecarlo.h"
#include "closure/bsdf_disney_diffuse.h"
CCL_NAMESPACE_BEGIN
using namespace OSL;
class DisneyDiffuseClosure : public CBSDFClosure {
public:
DisneyDiffuseClosure() : CBSDFClosure(LABEL_DIFFUSE)
{}
void setup()
{
sc.prim = this;
m_shaderdata_flag = bsdf_disney_diffuse_setup(&sc);
}
void blur(float roughness)
{
}
float3 eval_reflect(const float3 &omega_out, const float3 &omega_in, float& pdf) const
{
return bsdf_disney_diffuse_eval_reflect(&sc, omega_out, omega_in, &pdf);
}
float3 eval_transmit(const float3 &omega_out, const float3 &omega_in, float& pdf) const
{
return bsdf_disney_diffuse_eval_transmit(&sc, omega_out, omega_in, &pdf);
}
int sample(const float3 &Ng, const float3 &omega_out, const float3 &domega_out_dx,
const float3 &domega_out_dy, float randu, float randv, float3 &omega_in,
float3 &domega_in_dx, float3 &domega_in_dy, float &pdf, float3 &eval) const
{
return bsdf_disney_diffuse_sample(&sc, Ng, omega_out, domega_out_dx, domega_out_dy,
randu, randv, &eval, &omega_in, &domega_in_dx, &domega_in_dy, &pdf);
}
};
ClosureParam *closure_bsdf_disney_diffuse_params()
{
static ClosureParam params[] = {
CLOSURE_FLOAT3_PARAM(DisneyDiffuseClosure, sc.N),
CLOSURE_FLOAT3_PARAM(DisneyDiffuseClosure, sc.color0), // base color
CLOSURE_FLOAT_PARAM(DisneyDiffuseClosure, sc.data0), // subsurface
CLOSURE_FLOAT_PARAM(DisneyDiffuseClosure, sc.data1), // roughness
CLOSURE_FLOAT_PARAM(DisneyDiffuseClosure, sc.data2), // sheen
CLOSURE_FLOAT_PARAM(DisneyDiffuseClosure, sc.data3), // sheenTint
CLOSURE_STRING_KEYPARAM(DisneyDiffuseClosure, label, "label"),
CLOSURE_FINISH_PARAM(DisneyDiffuseClosure)
};
return params;
}
CCLOSURE_PREPARE(closure_bsdf_disney_diffuse_prepare, DisneyDiffuseClosure)
CCL_NAMESPACE_END*/

View File

@@ -1,102 +0,0 @@
/*
* Adapted from Open Shading Language with this license:
*
* Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
* 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 <OpenImageIO/fmath.h>
#include <OSL/genclosure.h>
#include "kernel_compat_cpu.h"
#include "osl_closures.h"
#include "kernel_types.h"
#include "kernel_montecarlo.h"
#include "closure/bsdf_disney_specular.h"
CCL_NAMESPACE_BEGIN
using namespace OSL;
class DisneySpecularClosure : public CBSDFClosure {
public:
DisneySpecularClosure() : CBSDFClosure(LABEL_REFLECT|LABEL_GLOSSY)
{}
void setup()
{
sc.prim = this;
m_shaderdata_flag = bsdf_disney_specular_setup(&sc);
}
void blur(float roughness)
{
}
float3 eval_reflect(const float3 &omega_out, const float3 &omega_in, float& pdf) const
{
return bsdf_disney_specular_eval_reflect(&sc, omega_out, omega_in, &pdf);
}
float3 eval_transmit(const float3 &omega_out, const float3 &omega_in, float& pdf) const
{
return bsdf_disney_specular_eval_transmit(&sc, omega_out, omega_in, &pdf);
}
int sample(const float3 &Ng, const float3 &omega_out, const float3 &domega_out_dx,
const float3 &domega_out_dy, float randu, float randv, float3 &omega_in,
float3 &domega_in_dx, float3 &domega_in_dy, float &pdf, float3 &eval) const
{
return bsdf_disney_specular_sample(&sc, Ng, omega_out, domega_out_dx, domega_out_dy,
randu, randv, &eval, &omega_in, &domega_in_dx, &domega_in_dy, &pdf);
}
};
ClosureParam *closure_bsdf_disney_specular_params()
{
static ClosureParam params[] = {
CLOSURE_FLOAT3_PARAM(DisneySpecularClosure, sc.N),
CLOSURE_FLOAT3_PARAM(DisneySpecularClosure, sc.T),
CLOSURE_FLOAT3_PARAM(DisneySpecularClosure, sc.color0), // base color
CLOSURE_FLOAT_PARAM(DisneySpecularClosure, sc.data0), // metallic
CLOSURE_FLOAT_PARAM(DisneySpecularClosure, sc.data1), // specular
CLOSURE_FLOAT_PARAM(DisneySpecularClosure, sc.data2), // specularTint
CLOSURE_FLOAT_PARAM(DisneySpecularClosure, sc.data3), // roughness
CLOSURE_FLOAT_PARAM(DisneySpecularClosure, sc.data4), // anisotropic
CLOSURE_STRING_KEYPARAM(DisneySpecularClosure, label, "label"),
CLOSURE_FINISH_PARAM(DisneySpecularClosure)
};
return params;
}
CCLOSURE_PREPARE(closure_bsdf_disney_specular_prepare, DisneySpecularClosure)
CCL_NAMESPACE_END*/

View File

@@ -61,8 +61,6 @@
#include "closure/bsdf_hair.h"
#include "closure/bsdf_disney_diffuse.h"
#include "closure/bsdf_disney_sheen.h"
#include "closure/bsdf_disney_specular.h"
#include "closure/bsdf_disney_clearcoat.h"
#include "closure/volume.h"
CCL_NAMESPACE_BEGIN

View File

@@ -62,7 +62,6 @@ OSL::ClosureParam *closure_bsdf_microfacet_ggx_aniso_fresnel_params();
OSL::ClosureParam *closure_bsdf_microfacet_multi_ggx_fresnel_params();
OSL::ClosureParam *closure_bsdf_microfacet_multi_ggx_glass_fresnel_params();
OSL::ClosureParam *closure_bsdf_microfacet_multi_ggx_aniso_fresnel_params();
OSL::ClosureParam *closure_bsdf_disney_specular_params();
void closure_emission_prepare(OSL::RendererServices *, int id, void *data);
void closure_background_prepare(OSL::RendererServices *, int id, void *data);
@@ -84,7 +83,6 @@ void closure_bsdf_microfacet_ggx_aniso_fresnel_prepare(OSL::RendererServices *,
void closure_bsdf_microfacet_multi_ggx_fresnel_prepare(OSL::RendererServices *, int id, void *data);
void closure_bsdf_microfacet_multi_ggx_glass_fresnel_prepare(OSL::RendererServices *, int id, void *data);
void closure_bsdf_microfacet_multi_ggx_aniso_fresnel_prepare(OSL::RendererServices *, int id, void *data);
void closure_bsdf_disney_specular_prepare(OSL::RendererServices *, int id, void *data);
#define CCLOSURE_PREPARE(name, classname) \
void name(RendererServices *, int id, void *data) \

View File

@@ -547,8 +547,6 @@ closure color holdout() BUILTIN;
closure color ambient_occlusion() BUILTIN;
closure color disney_diffuse(normal N, color baseColor, float roughness) BUILTIN;
closure color disney_sheen(normal N, color baseColor, float sheen, float sheenTint) BUILTIN;
closure color disney_specular(normal N, normal T, color baseColor, float metallic, float specular, float specularTint,
float roughness, float anisotropic) BUILTIN;
closure color disney_clearcoat(normal N, float clearcoat, float clearcoatGloss) BUILTIN;
// BSSRDF