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:
Diffstat (limited to 'intern/cycles/kernel/closure/bsdf_principled_sheen.h')
-rw-r--r--intern/cycles/kernel/closure/bsdf_principled_sheen.h55
1 files changed, 19 insertions, 36 deletions
diff --git a/intern/cycles/kernel/closure/bsdf_principled_sheen.h b/intern/cycles/kernel/closure/bsdf_principled_sheen.h
index 5f4677cba3d..949a6f8f567 100644
--- a/intern/cycles/kernel/closure/bsdf_principled_sheen.h
+++ b/intern/cycles/kernel/closure/bsdf_principled_sheen.h
@@ -33,7 +33,7 @@ ccl_device_inline float calculate_avg_principled_sheen_brdf(float3 N, float3 I)
return schlick_fresnel(NdotI) * NdotI;
}
-ccl_device float3
+ccl_device Spectrum
calculate_principled_sheen_brdf(float3 N, float3 V, float3 L, float3 H, ccl_private float *pdf)
{
float NdotL = dot(N, L);
@@ -41,14 +41,14 @@ calculate_principled_sheen_brdf(float3 N, float3 V, float3 L, float3 H, ccl_priv
if (NdotL < 0 || NdotV < 0) {
*pdf = 0.0f;
- return make_float3(0.0f, 0.0f, 0.0f);
+ return zero_spectrum();
}
float LdotH = dot(L, H);
float value = schlick_fresnel(LdotH) * NdotL;
- return make_float3(value, value, value);
+ return make_spectrum(value);
}
/* Based on
@@ -72,11 +72,13 @@ ccl_device_inline float sheen_v2_lambda(float mu, float w)
return expf(exponent);
}
-ccl_device_inline float3 sheen_v2_eval(float3 N, float3 V, float3 L, float3 H, float r, float *pdf)
+ccl_device_inline Spectrum
+sheen_v2_eval(float3 N, float3 V, float3 L, float3 H, float r, float *pdf)
{
float cosNH = dot(N, H), cosNV = dot(N, V), cosNL = dot(N, L);
if (cosNH < 0 || cosNV < 0 || cosNL < 0) {
+ *pdf = 0.0f;
return zero_float3();
}
@@ -99,7 +101,7 @@ ccl_device_inline float3 sheen_v2_eval(float3 N, float3 V, float3 L, float3 H, f
* term G=1/(1+lambdaV+lambdaL).
*/
float val = D / (4 * cosNV * (1 + lambdaV + lambdaL));
- return make_float3(val, val, val);
+ return make_spectrum(val);
}
ccl_device_forceinline float sheen_v2_E(KernelGlobals kg, float mu, float rough)
@@ -131,19 +133,19 @@ ccl_device int bsdf_principled_sheen_v2_setup(KernelGlobals kg,
return SD_BSDF | SD_BSDF_HAS_EVAL;
}
-ccl_device float3 bsdf_principled_sheen_eval_reflect(ccl_private const ShaderClosure *sc,
- const float3 I,
- const float3 omega_in,
- ccl_private float *pdf)
+ccl_device Spectrum bsdf_principled_sheen_eval(ccl_private const ShaderClosure *sc,
+ const float3 I,
+ const float3 omega_in,
+ ccl_private float *pdf)
{
ccl_private const PrincipledSheenBsdf *bsdf = (ccl_private const PrincipledSheenBsdf *)sc;
-
- float3 N = bsdf->N;
- float3 V = I; // outgoing
- float3 L = omega_in; // incoming
- float3 H = normalize(L + V);
+ const float3 N = bsdf->N;
if (dot(N, omega_in) > 0.0f) {
+ const float3 V = I; // outgoing
+ const float3 L = omega_in; // incoming
+ const float3 H = normalize(L + V);
+
*pdf = M_1_2PI_F;
if (bsdf->type == CLOSURE_BSDF_PRINCIPLED_SHEEN_V2_ID) {
return sheen_v2_eval(N, V, L, H, bsdf->roughness, pdf);
@@ -154,30 +156,17 @@ ccl_device float3 bsdf_principled_sheen_eval_reflect(ccl_private const ShaderClo
}
else {
*pdf = 0.0f;
- return make_float3(0.0f, 0.0f, 0.0f);
+ return zero_spectrum();
}
}
-ccl_device float3 bsdf_principled_sheen_eval_transmit(ccl_private const ShaderClosure *sc,
- const float3 I,
- const float3 omega_in,
- ccl_private float *pdf)
-{
- *pdf = 0.0f;
- return make_float3(0.0f, 0.0f, 0.0f);
-}
-
ccl_device int bsdf_principled_sheen_sample(ccl_private const ShaderClosure *sc,
float3 Ng,
float3 I,
- float3 dIdx,
- float3 dIdy,
float randu,
float randv,
- ccl_private float3 *eval,
+ ccl_private Spectrum *eval,
ccl_private float3 *omega_in,
- ccl_private float3 *domega_in_dx,
- ccl_private float3 *domega_in_dy,
ccl_private float *pdf)
{
ccl_private const PrincipledSheenBsdf *bsdf = (ccl_private const PrincipledSheenBsdf *)sc;
@@ -195,15 +184,9 @@ ccl_device int bsdf_principled_sheen_sample(ccl_private const ShaderClosure *sc,
else {
*eval = calculate_principled_sheen_brdf(N, I, *omega_in, H, pdf);
}
-
-#ifdef __RAY_DIFFERENTIALS__
- // TODO: find a better approximation for the diffuse bounce
- *domega_in_dx = -((2 * dot(N, dIdx)) * N - dIdx);
- *domega_in_dy = -((2 * dot(N, dIdy)) * N - dIdy);
-#endif
}
else {
- *eval = make_float3(0.0f, 0.0f, 0.0f);
+ *eval = zero_spectrum();
*pdf = 0.0f;
}
return LABEL_REFLECT | LABEL_DIFFUSE;