Blender  V2.93
osl_shader.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011-2013 Blender Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __OSL_SHADER_H__
18 #define __OSL_SHADER_H__
19 
20 #ifdef WITH_OSL
21 
22 /* OSL Shader Engine
23  *
24  * Holds all variables to execute and use OSL shaders from the kernel. These
25  * are initialized externally by OSLShaderManager before rendering starts.
26  *
27  * Before/after a thread starts rendering, thread_init/thread_free must be
28  * called, which will store any per thread OSL state in thread local storage.
29  * This means no thread state must be passed along in the kernel itself.
30  */
31 
32 # include "kernel/kernel_types.h"
33 
35 
36 class Scene;
37 
38 struct ShaderClosure;
39 struct ShaderData;
40 struct differential3;
41 struct KernelGlobals;
42 
43 struct OSLGlobals;
44 struct OSLShadingSystem;
45 
46 class OSLShader {
47  public:
48  /* init */
49  static void register_closures(OSLShadingSystem *ss);
50 
51  /* per thread data */
52  static void thread_init(KernelGlobals *kg,
53  KernelGlobals *kernel_globals,
54  OSLGlobals *osl_globals);
55  static void thread_free(KernelGlobals *kg);
56 
57  /* eval */
58  static void eval_surface(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag);
59  static void eval_background(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag);
60  static void eval_volume(KernelGlobals *kg, ShaderData *sd, PathState *state, int path_flag);
61  static void eval_displacement(KernelGlobals *kg, ShaderData *sd, PathState *state);
62 
63  /* attributes */
64  static int find_attribute(KernelGlobals *kg,
65  const ShaderData *sd,
66  uint id,
67  AttributeDescriptor *desc);
68 };
69 
71 
72 #endif
73 
74 #endif /* __OSL_SHADER_H__ */
unsigned int uint
Definition: BLI_sys_types.h:83
ccl_device_inline AttributeDescriptor find_attribute(KernelGlobals *kg, const ShaderData *sd, uint id)
#define CCL_NAMESPACE_END
ShaderData
ShaderClosure
Definition: kernel_types.h:831
static ulong state[N]
static void eval_displacement(SubdivDisplacement *displacement, const int ptex_face_index, const float u, const float v, const float dPdu[3], const float dPdv[3], float r_D[3])