Blender V4.5
bsdf_ray_portal.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#pragma once
6
7#include "kernel/types.h"
8
10
12
19
20static_assert(sizeof(ShaderClosure) >= sizeof(RayPortalClosure), "RayPortalClosure is too large!");
21
23 const Spectrum weight,
24 const uint32_t path_flag,
25 const float3 position,
26 float3 direction)
27{
28 /* Check cutoff weight. */
29 const float sample_weight = fabsf(average(weight));
30 if (!(sample_weight >= CLOSURE_WEIGHT_CUTOFF)) {
31 return;
32 }
33
34 sd->closure_transparent_extinction += weight;
35
37 sd, sizeof(RayPortalClosure), CLOSURE_BSDF_RAY_PORTAL_ID, weight);
38
39 if (pc) {
40 sd->flag |= SD_BSDF | SD_RAY_PORTAL;
41 if (is_zero(direction)) {
42 direction = -sd->wi;
43 }
44 pc->sample_weight = sample_weight;
45 pc->N = sd->N;
46 pc->P = position;
47 pc->D = direction;
48 }
49}
50
52 const float3 wi,
53 const float3 wo,
54 ccl_private float *pdf)
55{
56 *pdf = 0.0f;
57 return zero_spectrum();
58}
59
CCL_NAMESPACE_BEGIN ccl_device ccl_private ShaderClosure * closure_alloc(ccl_private ShaderData *sd, const int size, ClosureType type, Spectrum weight)
Definition alloc.h:11
ccl_device Spectrum bsdf_ray_portal_eval(const ccl_private ShaderClosure *sc, const float3 wi, const float3 wo, ccl_private float *pdf)
ccl_device void bsdf_ray_portal_setup(ccl_private ShaderData *sd, const Spectrum weight, const uint32_t path_flag, const float3 position, float3 direction)
#define ccl_device
#define zero_spectrum
#define ccl_private
#define CLOSURE_WEIGHT_CUTOFF
#define CCL_NAMESPACE_END
#define fabsf(x)
@ CLOSURE_BSDF_RAY_PORTAL_ID
@ SD_BSDF
@ SD_RAY_PORTAL
ccl_device_inline bool is_zero(const float2 a)
ccl_device_inline float average(const float2 a)
float3 Spectrum