Blender V4.3
osl/globals.h
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
2 *
3 * SPDX-License-Identifier: Apache-2.0 */
4
5#ifndef __OSL_GLOBALS_H__
6#define __OSL_GLOBALS_H__
7
8#ifdef WITH_OSL
9
10# include <OSL/oslexec.h>
11
12# include <OpenImageIO/refcnt.h>
13# include <OpenImageIO/unordered_map_concurrent.h>
14
15# include "kernel/osl/compat.h"
16
17# include "util/map.h"
18# include "util/param.h"
19# include "util/thread.h"
20# include "util/unique_ptr.h"
21# include "util/vector.h"
22
23# ifndef WIN32
24using std::isfinite;
25# endif
26
28
30class ColorSpaceProcessor;
31
32/* OSL Globals
33 *
34 * Data needed by OSL render services, that is global to a rendering session.
35 * This includes all OSL shaders, name to attribute mapping and texture handles.
36 */
37
38struct OSLGlobals {
39 OSLGlobals()
40 {
41 ss = NULL;
42 ts = NULL;
43 services = NULL;
44 use = false;
45 }
46
47 /* per thread data */
48 static void thread_init(struct KernelGlobalsCPU *kg,
49 OSLGlobals *osl_globals,
50 const int thread_init);
51 static void thread_free(struct KernelGlobalsCPU *kg);
52
53 bool use;
54
55 /* shading system */
56 OSL::ShadingSystem *ss;
57 OSL::TextureSystem *ts;
58 OSLRenderServices *services;
59
60 /* shader states */
61 vector<OSL::ShaderGroupRef> surface_state;
62 vector<OSL::ShaderGroupRef> volume_state;
63 vector<OSL::ShaderGroupRef> displacement_state;
65 OSL::ShaderGroupRef background_state;
66
67 /* attributes */
68 typedef unordered_map<OSLUStringHash, int> ObjectNameMap;
69
70 ObjectNameMap object_name_map;
71 vector<ustring> object_names;
72};
73
74/* trace() call result */
75struct OSLTraceData {
76 Ray ray;
77 Intersection isect;
78 ShaderData sd;
79 bool setup;
80 bool init;
81 bool hit;
82};
83
84/* thread key for thread specific data lookup */
85struct OSLThreadData {
86 OSL::ShaderGlobals globals;
87 OSL::PerThreadInfo *osl_thread_info;
88 OSLTraceData tracedata;
89 OSL::ShadingContext *context;
90 OIIO::TextureSystem::Perthread *oiio_thread_info;
91};
92
94
95#endif
96
97#endif /* __OSL_GLOBALS_H__ */
in reality light always falls off quadratically Particle Retrieve the data of the particle that spawned the object for example to give variation to multiple instances of an object Point Retrieve information about points in a point cloud Retrieve the edges of an object as it appears to Cycles topology will always appear triangulated Convert a blackbody temperature to an RGB value Normal Generate a perturbed normal from an RGB normal map image Typically used for faking highly detailed surfaces Generate an OSL shader from a file or text data block Image Sample an image file as a texture Gabor Generate Gabor noise Gradient Generate interpolated color and intensity values based on the input vector Magic Generate a psychedelic color texture Voronoi Generate Worley noise based on the distance to random points Typically used to generate textures such as or biological cells Brick Generate a procedural texture producing bricks Texture Retrieve multiple types of texture coordinates nTypically used as inputs for texture nodes Vector Convert a vector
void init()
struct KernelGlobalsCPU KernelGlobalsCPU
#define CCL_NAMESPACE_END
#define NULL
struct Intersection Intersection
struct Ray Ray
ShaderData
int context(const bContext *C, const char *member, bContextDataResult *result)