Blender  V3.3
bsdf_reflection.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  *
3  * Adapted from Open Shading Language
4  * Copyright (c) 2009-2010 Sony Pictures Imageworks Inc., et al.
5  * All Rights Reserved.
6  *
7  * Modifications Copyright 2011-2022 Blender Foundation. */
8 
9 #pragma once
10 
12 
13 /* REFLECTION */
14 
16 {
17  bsdf->type = CLOSURE_BSDF_REFLECTION_ID;
18  return SD_BSDF;
19 }
20 
22  const float3 I,
23  const float3 omega_in,
24  ccl_private float *pdf)
25 {
26  *pdf = 0.0f;
27  return make_float3(0.0f, 0.0f, 0.0f);
28 }
29 
31  const float3 I,
32  const float3 omega_in,
33  ccl_private float *pdf)
34 {
35  *pdf = 0.0f;
36  return make_float3(0.0f, 0.0f, 0.0f);
37 }
38 
40  float3 Ng,
41  float3 I,
42  float3 dIdx,
43  float3 dIdy,
44  float randu,
45  float randv,
46  ccl_private float3 *eval,
47  ccl_private float3 *omega_in,
48  ccl_private float3 *domega_in_dx,
49  ccl_private float3 *domega_in_dy,
50  ccl_private float *pdf)
51 {
52  ccl_private const MicrofacetBsdf *bsdf = (ccl_private const MicrofacetBsdf *)sc;
53  float3 N = bsdf->N;
54 
55  // only one direction is possible
56  float cosNO = dot(N, I);
57  if (cosNO > 0) {
58  *omega_in = (2 * cosNO) * N - I;
59  if (dot(Ng, *omega_in) > 0) {
60 #ifdef __RAY_DIFFERENTIALS__
61  *domega_in_dx = 2 * dot(N, dIdx) * N - dIdx;
62  *domega_in_dy = 2 * dot(N, dIdy) * N - dIdy;
63 #endif
64  /* Some high number for MIS. */
65  *pdf = 1e6f;
66  *eval = make_float3(1e6f, 1e6f, 1e6f);
67  }
68  }
69  else {
70  *pdf = 0.0f;
71  *eval = make_float3(0.0f, 0.0f, 0.0f);
72  }
74 }
75 
ccl_device float3 bsdf_reflection_eval_transmit(ccl_private const ShaderClosure *sc, const float3 I, const float3 omega_in, ccl_private float *pdf)
CCL_NAMESPACE_BEGIN ccl_device int bsdf_reflection_setup(ccl_private MicrofacetBsdf *bsdf)
ccl_device float3 bsdf_reflection_eval_reflect(ccl_private const ShaderClosure *sc, const float3 I, const float3 omega_in, ccl_private float *pdf)
ccl_device int bsdf_reflection_sample(ccl_private const ShaderClosure *sc, float3 Ng, float3 I, float3 dIdx, float3 dIdy, float randu, float randv, ccl_private float3 *eval, ccl_private float3 *omega_in, ccl_private float3 *domega_in_dx, ccl_private float3 *domega_in_dy, ccl_private float *pdf)
#define ccl_device
Definition: cuda/compat.h:32
#define ccl_private
Definition: cuda/compat.h:48
#define CCL_NAMESPACE_END
Definition: cuda/compat.h:9
@ CLOSURE_BSDF_REFLECTION_ID
@ SD_BSDF
Definition: kernel/types.h:742
@ LABEL_SINGULAR
Definition: kernel/types.h:321
@ LABEL_REFLECT
Definition: kernel/types.h:318
ShaderClosure
Definition: kernel/types.h:726
#define N
#define make_float3(x, y, z)
Definition: metal/compat.h:204
T dot(const vec_base< T, Size > &a, const vec_base< T, Size > &b)
#define I