Blender V5.3
eevee_bxdf_oren_nayar.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2024 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
5#pragma once
6
10
11#if 0 /* Unfinished. */
12
13/* -------------------------------------------------------------------- */
16
22BsdfSample bxdf_oren_nayar_sample(float3 random_point_cos_hemisphere)
23{
24 /* Bias the rays so we never get really high energy rays almost parallel to the surface.
25 * Also reduces shadow terminator artifacts. */
26 constexpr float bias = 0.05f;
27 random_point_cos_hemisphere = normalize(random_point_cos_hemisphere + float3(0.0f, 0.0f, bias));
28
29 float cos_theta = random_point_cos_hemisphere.z;
30 BsdfSample samp;
31 samp.direction = random_point_cos_hemisphere;
32 samp.pdf = cos_theta * M_1_PI;
33 return samp;
34}
35
37{
38 OrenNayarBsdf *bsdf = (OrenNayarBsdf *)sc;
39 float NL = max(dot(n, l), 0.0f);
40 float NV = max(dot(n, v), 0.0f);
41 float t = dot(l, v) - NL * NV;
42
43 if (t > 0.0f) {
44 t /= max(NL, NV) + FLT_MIN;
45 }
46
47 float single_scatter = bsdf->a + bsdf->b * t;
48
49 float El = bsdf->a * M_PI_F + bsdf->b * bsdf_oren_nayar_G(NL);
50 Spectrum multi_scatter = bsdf->multiscatter_term * (1.0f - El);
51
52 return NL * (make_spectrum(single_scatter) + multi_scatter);
53}
54
55BsdfEval bxdf_oren_nayar_eval(float3 N, float3 L)
56{
58 eval.throughput = eval.pdf = saturate(dot(N, L));
59 return eval;
60}
61
62float bxdf_oren_nayar_perceived_roughness()
63{
64 return 1.0f;
65}
66
67LightProbeRay bxdf_oren_nayar_lightprobe(float3 N)
68{
69 LightProbeRay probe;
70 probe.perceptual_roughness = bxdf_oren_nayar_perceived_roughness();
71 probe.dominant_direction = N;
72 return probe;
73}
74
75ClosureLight bxdf_oren_nayar_light(ClosureUndetermined cl, float3 V)
76{
77 ClosureLight light;
78 /* TODO(fclem): LTC fit. */
79 light.N = cl.N;
80 light.type = LIGHT_DIFFUSE;
81 eevee::LTCData::pack_identity(light, light.N, V);
82 return light;
83}
84
86
87#endif
#define M_1_PI
ccl_device Spectrum bsdf_oren_nayar_get_intensity(const ccl_private OrenNayarBsdf *bsdf, const float3 n, const float3 v, const float3 l)
ccl_device_inline float bsdf_oren_nayar_G(const float cosTheta)
ccl_device_inline float cos_theta(const float3 w)
btScalar max
#define NL
#define make_spectrum(f)
#define FLT_MIN
VecBase< float, D > normalize(VecOp< float, D >) RET
float dot(VecOp< float, D >, VecOp< float, D >) RET
#define N
#define L
ResultT eval(const Uniform &uni, const ViewMatrices view, ScreenThicknessParameters thickness_params, sampler2D hiz_tx, sampler2D screen_radiance_tx, sampler2D screen_normal_tx, float3 vP, float3 vN, float4 noise, float2 pixel_size, float search_distance, float angle_bias, const int slice_count, const int sample_count, const bool reversed, const bool ao_only)
#define M_PI_F
#define saturate(a)
Definition smaa.cc:319
packed_float3 direction
packed_float3 dominant_direction
static void pack_identity(ClosureLight &cl, float3 N, float3 V)
float z
Definition sky_math.h:136
float3 Spectrum
CCL_NAMESPACE_BEGIN struct Window V