Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@gmail.com>2018-03-10 18:09:22 +0300
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2018-03-10 20:05:01 +0300
commit7613ffc944ebc133f1f906ea737ab55718434cc4 (patch)
treee2c54a4b971fe955f4c7538db1fc086a997b8702 /intern/cycles/kernel
parent8a76f8dac3475b1d24956e0d384d65295f15c76a (diff)
Cycles: switch to squared roughness convention for all nodes.
This was already done for the Principled BSDF to be compatible with typical baked roughness maps in PBR workflows.
Diffstat (limited to 'intern/cycles/kernel')
-rw-r--r--intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl19
-rw-r--r--intern/cycles/kernel/shaders/node_glass_bsdf.osl11
-rw-r--r--intern/cycles/kernel/shaders/node_glossy_bsdf.osl10
-rw-r--r--intern/cycles/kernel/shaders/node_refraction_bsdf.osl5
-rw-r--r--intern/cycles/kernel/svm/svm_closure.h20
5 files changed, 37 insertions, 28 deletions
diff --git a/intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl b/intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl
index bef6d7e8809..21e28ece65d 100644
--- a/intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_anisotropic_bsdf.osl
@@ -33,27 +33,28 @@ shader node_anisotropic_bsdf(
T = rotate(T, Rotation * M_2PI, point(0.0, 0.0, 0.0), Normal);
/* compute roughness */
- float RoughnessU, RoughnessV;
+ float roughness = Roughness * Roughness;
+ float roughness_u, roughness_v;
float aniso = clamp(Anisotropy, -0.99, 0.99);
if (aniso < 0.0) {
- RoughnessU = Roughness / (1.0 + aniso);
- RoughnessV = Roughness * (1.0 + aniso);
+ roughness_u = roughness / (1.0 + aniso);
+ roughness_v = roughness * (1.0 + aniso);
}
else {
- RoughnessU = Roughness * (1.0 - aniso);
- RoughnessV = Roughness / (1.0 - aniso);
+ roughness_u = roughness * (1.0 - aniso);
+ roughness_v = roughness / (1.0 - aniso);
}
if (distribution == "sharp")
BSDF = Color * reflection(Normal);
else if (distribution == "beckmann")
- BSDF = Color * microfacet_beckmann_aniso(Normal, T, RoughnessU, RoughnessV);
+ BSDF = Color * microfacet_beckmann_aniso(Normal, T, roughness_u, roughness_v);
else if (distribution == "GGX")
- BSDF = Color * microfacet_ggx_aniso(Normal, T, RoughnessU, RoughnessV);
+ BSDF = Color * microfacet_ggx_aniso(Normal, T, roughness_u, roughness_v);
else if (distribution == "Multiscatter GGX")
- BSDF = Color * microfacet_multi_ggx_aniso(Normal, T, RoughnessU, RoughnessV, Color);
+ BSDF = Color * microfacet_multi_ggx_aniso(Normal, T, roughness_u, roughness_v, Color);
else
- BSDF = Color * ashikhmin_shirley(Normal, T, RoughnessU, RoughnessV);
+ BSDF = Color * ashikhmin_shirley(Normal, T, roughness_u, roughness_v);
}
diff --git a/intern/cycles/kernel/shaders/node_glass_bsdf.osl b/intern/cycles/kernel/shaders/node_glass_bsdf.osl
index a9723a8300a..2e713861c58 100644
--- a/intern/cycles/kernel/shaders/node_glass_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_glass_bsdf.osl
@@ -29,16 +29,17 @@ shader node_glass_bsdf(
float eta = backfacing() ? 1.0 / f : f;
float cosi = dot(I, Normal);
float Fr = fresnel_dielectric_cos(cosi, eta);
+ float roughness = Roughness * Roughness;
if (distribution == "sharp")
BSDF = Color * (Fr * reflection(Normal) + (1.0 - Fr) * refraction(Normal, eta));
else if (distribution == "beckmann")
- BSDF = Color * (Fr * microfacet_beckmann(Normal, Roughness) +
- (1.0 - Fr) * microfacet_beckmann_refraction(Normal, Roughness, eta));
+ BSDF = Color * (Fr * microfacet_beckmann(Normal, roughness) +
+ (1.0 - Fr) * microfacet_beckmann_refraction(Normal, roughness, eta));
else if (distribution == "Multiscatter GGX")
- BSDF = Color * microfacet_multi_ggx_glass(Normal, Roughness, eta, Color);
+ BSDF = Color * microfacet_multi_ggx_glass(Normal, roughness, eta, Color);
else if (distribution == "GGX")
- BSDF = Color * (Fr * microfacet_ggx(Normal, Roughness) +
- (1.0 - Fr) * microfacet_ggx_refraction(Normal, Roughness, eta));
+ BSDF = Color * (Fr * microfacet_ggx(Normal, roughness) +
+ (1.0 - Fr) * microfacet_ggx_refraction(Normal, roughness, eta));
}
diff --git a/intern/cycles/kernel/shaders/node_glossy_bsdf.osl b/intern/cycles/kernel/shaders/node_glossy_bsdf.osl
index f4ea7e7dc6a..7415211b56d 100644
--- a/intern/cycles/kernel/shaders/node_glossy_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_glossy_bsdf.osl
@@ -24,16 +24,18 @@ shader node_glossy_bsdf(
normal Normal = N,
output closure color BSDF = 0)
{
+ float roughness = Roughness * Roughness;
+
if (distribution == "sharp")
BSDF = Color * reflection(Normal);
else if (distribution == "beckmann")
- BSDF = Color * microfacet_beckmann(Normal, Roughness);
+ BSDF = Color * microfacet_beckmann(Normal, roughness);
else if (distribution == "GGX")
- BSDF = Color * microfacet_ggx(Normal, Roughness);
+ BSDF = Color * microfacet_ggx(Normal, roughness);
else if (distribution == "Multiscatter GGX")
- BSDF = Color * microfacet_multi_ggx(Normal, Roughness, Color);
+ BSDF = Color * microfacet_multi_ggx(Normal, roughness, Color);
else
- BSDF = Color * ashikhmin_shirley(Normal, vector(0, 0, 0), Roughness, Roughness);
+ BSDF = Color * ashikhmin_shirley(Normal, vector(0, 0, 0), roughness, roughness);
}
diff --git a/intern/cycles/kernel/shaders/node_refraction_bsdf.osl b/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
index 828becf1818..eaab7282243 100644
--- a/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
+++ b/intern/cycles/kernel/shaders/node_refraction_bsdf.osl
@@ -26,12 +26,13 @@ shader node_refraction_bsdf(
{
float f = max(IOR, 1e-5);
float eta = backfacing() ? 1.0 / f : f;
+ float roughness = Roughness * Roughness;
if (distribution == "sharp")
BSDF = Color * refraction(Normal, eta);
else if (distribution == "beckmann")
- BSDF = Color * microfacet_beckmann_refraction(Normal, Roughness, eta);
+ BSDF = Color * microfacet_beckmann_refraction(Normal, roughness, eta);
else if (distribution == "GGX")
- BSDF = Color * microfacet_ggx_refraction(Normal, Roughness, eta);
+ BSDF = Color * microfacet_ggx_refraction(Normal, roughness, eta);
}
diff --git a/intern/cycles/kernel/svm/svm_closure.h b/intern/cycles/kernel/svm/svm_closure.h
index a54095ed127..886a1333fa3 100644
--- a/intern/cycles/kernel/svm/svm_closure.h
+++ b/intern/cycles/kernel/svm/svm_closure.h
@@ -468,10 +468,12 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
break;
}
+ float roughness = sqr(param1);
+
bsdf->N = N;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
- bsdf->alpha_x = param1;
- bsdf->alpha_y = param1;
+ bsdf->alpha_x = roughness;
+ bsdf->alpha_y = roughness;
bsdf->ior = 0.0f;
bsdf->extra = NULL;
@@ -525,8 +527,9 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
sd->flag |= bsdf_refraction_setup(bsdf);
}
else {
- bsdf->alpha_x = param1;
- bsdf->alpha_y = param1;
+ float roughness = sqr(param1);
+ bsdf->alpha_x = roughness;
+ bsdf->alpha_y = roughness;
bsdf->ior = eta;
if(type == CLOSURE_BSDF_MICROFACET_BECKMANN_REFRACTION_ID)
@@ -557,7 +560,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
/* fresnel */
float cosNO = dot(N, sd->I);
float fresnel = fresnel_dielectric_cos(cosNO, eta);
- float roughness = param1;
+ float roughness = sqr(param1);
/* reflection */
#ifdef __CAUSTICS_TRICKS__
@@ -611,8 +614,9 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
bsdf->extra = extra;
bsdf->T = make_float3(0.0f, 0.0f, 0.0f);
- bsdf->alpha_x = param1;
- bsdf->alpha_y = param1;
+ float roughness = sqr(param1);
+ bsdf->alpha_x = roughness;
+ bsdf->alpha_y = roughness;
float eta = fmaxf(param2, 1e-5f);
bsdf->ior = (sd->flag & SD_BACKFACING)? 1.0f/eta: eta;
@@ -648,7 +652,7 @@ ccl_device void svm_node_closure_bsdf(KernelGlobals *kg, ShaderData *sd, float *
bsdf->T = rotate_around_axis(bsdf->T, bsdf->N, rotation * M_2PI_F);
/* compute roughness */
- float roughness = param1;
+ float roughness = sqr(param1);
float anisotropy = clamp(param2, -0.99f, 0.99f);
if(anisotropy < 0.0f) {