Blender V4.5
kernel/osl/camera.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2009-2010 Sony Pictures Imageworks Inc., et al. All Rights Reserved.
2 * SPDX-FileCopyrightText: 2011-2024 Blender Foundation
3 *
4 * SPDX-License-Identifier: BSD-3-Clause */
5
6#pragma once
7
8#include "kernel/osl/types.h"
9
11
13 const packed_float3 dSdx,
14 const packed_float3 dSdy,
15 const float2 rand_lens,
17{
18 memset(globals, 0, sizeof(ShaderGlobals));
19
20 globals->P = sensor;
21 globals->dPdx = dSdx;
22 globals->dPdy = dSdy;
23 globals->N = make_float3(rand_lens);
24}
25
26#ifndef __KERNEL_GPU__
27
29 const packed_float3 sensor,
30 const packed_float3 dSdx,
31 const packed_float3 dSdy,
32 const float2 rand_lens,
34 packed_float3 &dPdx,
35 packed_float3 &dPdy,
37 packed_float3 &dDdx,
38 packed_float3 &dDdy);
39
40#else
41
43 const packed_float3 sensor,
44 const packed_float3 dSdx,
45 const packed_float3 dSdy,
46 const float2 rand_lens,
48 packed_float3 &dPdx,
49 packed_float3 &dPdy,
51 packed_float3 &dDdx,
52 packed_float3 &dDdy)
53{
54 ShaderGlobals globals;
55 cameradata_to_shaderglobals(sensor, dSdx, dSdy, rand_lens, &globals);
56
57 float output[21] = {0.0f};
58# ifdef __KERNEL_OPTIX__
59 optixDirectCall<void>(/*NUM_CALLABLE_PROGRAM_GROUPS*/ 2,
60 /*shaderglobals_ptr*/ &globals,
61 /*groupdata_ptr*/ (void *)nullptr,
62 /*userdata_base_ptr*/ (void *)nullptr,
63 /*output_base_ptr*/ (void *)output,
64 /*shadeindex*/ 0,
65 /*interactive_params_ptr*/ (void *)nullptr);
66# endif
67
68 P = make_float3(output[0], output[1], output[2]);
69 dPdx = make_float3(output[3], output[4], output[5]);
70 dPdy = make_float3(output[6], output[7], output[8]);
71 D = make_float3(output[9], output[10], output[11]);
72 dDdx = make_float3(output[12], output[13], output[14]);
73 dDdy = make_float3(output[15], output[16], output[17]);
74 return make_float3(output[18], output[19], output[20]);
75}
76
77#endif
78
#define D
#define ccl_private
const ThreadKernelGlobalsCPU * KernelGlobals
#define ccl_device_inline
#define CCL_NAMESPACE_END
ccl_device_forceinline float3 make_float3(const float x, const float y, const float z)
#define output
CCL_NAMESPACE_BEGIN ccl_device_inline void cameradata_to_shaderglobals(const packed_float3 sensor, const packed_float3 dSdx, const packed_float3 dSdy, const float2 rand_lens, ccl_private ShaderGlobals *globals)
packed_float3 osl_eval_camera(KernelGlobals kg, const packed_float3 sensor, const packed_float3 dSdx, const packed_float3 dSdy, const float2 rand_lens, packed_float3 &P, packed_float3 &dPdx, packed_float3 &dPdy, packed_float3 &D, packed_float3 &dDdx, packed_float3 &dDdy)