Blender V5.0
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 float3 position,
25 float3 direction)
26{
27 /* Check cutoff weight. */
28 const float sample_weight = fabsf(average(weight));
29 if (!(sample_weight >= CLOSURE_WEIGHT_CUTOFF)) {
30 return;
31 }
32
33 sd->closure_transparent_extinction += weight;
34
36 sd, sizeof(RayPortalClosure), CLOSURE_BSDF_RAY_PORTAL_ID, weight);
37
38 if (pc) {
39 sd->flag |= SD_BSDF | SD_RAY_PORTAL;
40 if (is_zero(direction)) {
41 direction = -sd->wi;
42 }
43 pc->sample_weight = sample_weight;
44 pc->N = sd->N;
45 pc->P = position;
46 pc->D = direction;
47 }
48}
49
51 const float3 /*wi*/,
52 const float3 /*wo*/,
53 ccl_private float *pdf)
54{
55 *pdf = 0.0f;
56 return zero_spectrum();
57}
58
CCL_NAMESPACE_BEGIN ccl_device ccl_private ShaderClosure * closure_alloc(ccl_private ShaderData *sd, const uint size, ClosureType type, Spectrum weight)
Definition alloc.h:11
ccl_device void bsdf_ray_portal_setup(ccl_private ShaderData *sd, const Spectrum weight, const float3 position, float3 direction)
ccl_device Spectrum bsdf_ray_portal_eval(const ccl_private ShaderClosure *, const float3, const float3, ccl_private float *pdf)
#define zero_spectrum
#define ccl_private
#define CCL_NAMESPACE_END
#define CLOSURE_WEIGHT_CUTOFF
@ CLOSURE_BSDF_RAY_PORTAL_ID
@ SD_BSDF
@ SD_RAY_PORTAL
ccl_device_inline bool is_zero(const float2 a)
float average(point a)
Definition node_math.h:144
#define fabsf
#define ccl_device
float3 Spectrum