Welcome to mirror list, hosted at ThFree Co, Russian Federation.

osl_services.h « osl « kernel « cycles « intern - git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: b5a7bbae7e51c4533278819d332975fc47dcf4e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/*
 * Copyright 2011, Blender Foundation.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 */

#ifndef __OSL_SERVICES_H__
#define __OSL_SERVICES_H__

/* OSL Render Services
 *
 * Implementation of OSL render services, to retriever matrices, attributes,
 * textures and point clouds. In principle this should only be accessing
 * kernel data, but currently we also reach back into the Scene to retrieve
 * attributes.
 */

#include <OSL/oslexec.h>
#include <OSL/oslclosure.h>

CCL_NAMESPACE_BEGIN

class Object;
class Scene;
class Shader;
struct ShaderData;
struct float3;
struct KernelGlobals;

class OSLRenderServices : public OSL::RendererServices
{
public:
	OSLRenderServices();
	~OSLRenderServices();
	
	void thread_init(KernelGlobals *kernel_globals);

	bool get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
	bool get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform, float time);
	
	bool get_matrix(OSL::Matrix44 &result, ustring from, float time);
	bool get_inverse_matrix(OSL::Matrix44 &result, ustring to, float time);
	
	bool get_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform);
	bool get_inverse_matrix(OSL::Matrix44 &result, OSL::TransformationPtr xform);
	
	bool get_matrix(OSL::Matrix44 &result, ustring from);
	bool get_inverse_matrix(OSL::Matrix44 &result, ustring from);

	bool get_array_attribute(void *renderstate, bool derivatives,
	                         ustring object, TypeDesc type, ustring name,
	                         int index, void *val);
	bool get_attribute(void *renderstate, bool derivatives, ustring object,
	                   TypeDesc type, ustring name, void *val);

	bool get_userdata(bool derivatives, ustring name, TypeDesc type,
	                  void *renderstate, void *val);
	bool has_userdata(ustring name, TypeDesc type, void *renderstate);

	int pointcloud_search(OSL::ShaderGlobals *sg, ustring filename, const OSL::Vec3 &center,
	                      float radius, int max_points, bool sort, size_t *out_indices,
	                      float *out_distances, int derivs_offset);

	int pointcloud_get(ustring filename, size_t *indices, int count, ustring attr_name,
	                   TypeDesc attr_type, void *out_data);

	bool trace(TraceOpt &options, OSL::ShaderGlobals *sg,
	           const OSL::Vec3 &P, const OSL::Vec3 &dPdx,
	           const OSL::Vec3 &dPdy, const OSL::Vec3 &R,
	           const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy);

	bool getmessage(OSL::ShaderGlobals *sg, ustring source, ustring name,
	                TypeDesc type, void *val, bool derivatives);

	bool texture(ustring filename, TextureOpt &options,
	             OSL::ShaderGlobals *sg,
	             float s, float t, float dsdx, float dtdx,
	             float dsdy, float dtdy, float *result);

	bool texture3d(ustring filename, TextureOpt &options,
	               OSL::ShaderGlobals *sg, const OSL::Vec3 &P,
	               const OSL::Vec3 &dPdx, const OSL::Vec3 &dPdy,
	               const OSL::Vec3 &dPdz, float *result);

	bool environment(ustring filename, TextureOpt &options,
	                 OSL::ShaderGlobals *sg, const OSL::Vec3 &R,
	                 const OSL::Vec3 &dRdx, const OSL::Vec3 &dRdy, float *result);

	bool get_texture_info(ustring filename, int subimage,
	                      ustring dataname, TypeDesc datatype, void *data);

	struct TraceData {
		Ray ray;
		Intersection isect;
		ShaderData sd;
		bool setup;
	};

	static ustring u_distance;
	static ustring u_index;
	static ustring u_camera;
	static ustring u_screen;
	static ustring u_raster;
	static ustring u_ndc;
	static ustring u_empty;

private:
	KernelGlobals *kernel_globals;
};

CCL_NAMESPACE_END

#endif /* __OSL_SERVICES_H__  */