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

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTon Roosendaal <ton@blender.org>2011-04-27 15:58:34 +0400
committerTon Roosendaal <ton@blender.org>2011-04-27 15:58:34 +0400
commitda376e0237517543aa21740ee2363234ee1c20ae (patch)
tree014a513ed8d0eccc5e54fef42347781e85bae56a /intern/cycles/kernel/osl/osl_services.h
parent693780074388111e7b9ef1c3825e462f398dc6c4 (diff)
Cycles render engine, initial commit. This is the engine itself, blender modifications and build instructions will follow later.
Cycles uses code from some great open source projects, many thanks them: * BVH building and traversal code from NVidia's "Understanding the Efficiency of Ray Traversal on GPUs": http://code.google.com/p/understanding-the-efficiency-of-ray-traversal-on-gpus/ * Open Shading Language for a large part of the shading system: http://code.google.com/p/openshadinglanguage/ * Blender for procedural textures and a few other nodes. * Approximate Catmull Clark subdivision from NVidia Mesh tools: http://code.google.com/p/nvidia-mesh-tools/ * Sobol direction vectors from: http://web.maths.unsw.edu.au/~fkuo/sobol/ * Film response functions from: http://www.cs.columbia.edu/CAVE/software/softlib/dorf.php
Diffstat (limited to 'intern/cycles/kernel/osl/osl_services.h')
-rw-r--r--intern/cycles/kernel/osl/osl_services.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/intern/cycles/kernel/osl/osl_services.h b/intern/cycles/kernel/osl/osl_services.h
new file mode 100644
index 00000000000..e5003074822
--- /dev/null
+++ b/intern/cycles/kernel/osl/osl_services.h
@@ -0,0 +1,111 @@
+/*
+ * 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>
+
+#ifdef WITH_PARTIO
+#include <Partio.h>
+#endif
+
+CCL_NAMESPACE_BEGIN
+
+class Object;
+class Scene;
+class Shader;
+class ShaderData;
+class float3;
+class 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_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);
+
+ void *get_pointcloud_attr_query(ustring *attr_names,
+ TypeDesc *attr_types, int nattrs);
+ int pointcloud(ustring filename, const OSL::Vec3 &center, float radius,
+ int max_points, void *attr_query, void **attr_outdata);
+
+private:
+ KernelGlobals *kernel_globals;
+
+#ifdef WITH_PARTIO
+ /* OSL gets pointers to this but its definition is private.
+ right now it only caches the types already converted to
+ Partio constants. this is what get_pointcloud_attr_query
+ returns */
+ struct AttrQuery
+ {
+ /* names of the attributes to query */
+ std::vector<ustring> attr_names;
+ /* types as (enum Partio::ParticleAttributeType) of the
+ attributes in the query */
+ std::vector<int> attr_partio_types;
+ /* for sanity checks, capacity of the output arrays */
+ int capacity;
+ };
+
+ Partio::ParticlesData *get_pointcloud(ustring filename);
+
+ /* keep a list so adding elements doesn't invalidate pointers */
+ std::list<AttrQuery> m_attr_queries;
+#endif
+
+ 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;
+};
+
+CCL_NAMESPACE_END
+
+#endif /* __OSL_SERVICES_H__ */
+