Blender V5.0
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/globals.h"
9
10#include "kernel/osl/types.h"
11
13
15 const packed_float3 dSdx,
16 const packed_float3 dSdy,
17 const float2 rand_lens,
19{
20 memset(globals, 0, sizeof(ShaderGlobals));
21
22 globals->P = sensor;
23 globals->dPdx = dSdx;
24 globals->dPdy = dSdy;
25 globals->N = make_float3(rand_lens);
26}
27
28#ifndef __KERNEL_GPU__
29
31 const packed_float3 sensor,
32 const packed_float3 dSdx,
33 const packed_float3 dSdy,
34 const float2 rand_lens,
39 packed_float3 &dDdx,
40 packed_float3 &dDdy);
41
42#else
43
45 const packed_float3 sensor,
46 const packed_float3 dSdx,
47 const packed_float3 dSdy,
48 const float2 rand_lens,
53 packed_float3 &dDdx,
54 packed_float3 &dDdy)
55{
56 ShaderGlobals globals;
57 cameradata_to_shaderglobals(sensor, dSdx, dSdy, rand_lens, &globals);
58
59 float output[21] = {0.0f};
60# ifdef __KERNEL_OPTIX__
61 optixDirectCall<void>(/*NUM_CALLABLE_PROGRAM_GROUPS*/ 2,
62 /*shaderglobals_ptr*/ &globals,
63 /*groupdata_ptr*/ (void *)nullptr,
64 /*userdata_base_ptr*/ (void *)nullptr,
65 /*output_base_ptr*/ (void *)output,
66 /*shadeindex*/ 0,
67 /*interactive_params_ptr*/ (void *)nullptr);
68# endif
69
70 P = make_float3(output[0], output[1], output[2]);
71 dPdx = make_float3(output[3], output[4], output[5]);
72 dPdy = make_float3(output[6], output[7], output[8]);
73 D = make_float3(output[9], output[10], output[11]);
74 dDdx = make_float3(output[12], output[13], output[14]);
75 dDdy = make_float3(output[15], output[16], output[17]);
76 return make_float3(output[18], output[19], output[20]);
77}
78
79#endif
80
#define D
ccl_device_forceinline float3 dPdx(const ccl_private ShaderData *sd)
ccl_device_forceinline float3 dPdy(const ccl_private ShaderData *sd)
#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)