Blender V2.61 - r43446
|
00001 /* 00002 * Copyright 2011, Blender Foundation. 00003 * 00004 * This program is free software; you can redistribute it and/or 00005 * modify it under the terms of the GNU General Public License 00006 * as published by the Free Software Foundation; either version 2 00007 * of the License, or (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program; if not, write to the Free Software Foundation, 00016 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #ifndef __OSL_H__ 00020 #define __OSL_H__ 00021 00022 #include "util_set.h" 00023 00024 #include "shader.h" 00025 00026 #ifdef WITH_OSL 00027 #include <OSL/oslexec.h> 00028 #endif 00029 00030 CCL_NAMESPACE_BEGIN 00031 00032 class Device; 00033 class DeviceScene; 00034 class ImageManager; 00035 class OSLRenderServices; 00036 class OSLGlobals; 00037 class Scene; 00038 class ShaderGraph; 00039 class ShaderNode; 00040 class ShaderOutput; 00041 00042 #ifdef WITH_OSL 00043 00044 /* Shader Manage */ 00045 00046 class OSLShaderManager : public ShaderManager { 00047 public: 00048 OSLShaderManager(); 00049 ~OSLShaderManager(); 00050 00051 void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress); 00052 void device_free(Device *device, DeviceScene *dscene); 00053 00054 private: 00055 OSL::ShadingSystem *ss; 00056 OSL::TextureSystem *ts; 00057 OSLRenderServices *services; 00058 OSL::ErrorHandler errhandler; 00059 }; 00060 00061 #endif 00062 00063 /* Graph Compiler */ 00064 00065 class OSLCompiler { 00066 public: 00067 OSLCompiler(void *shadingsys); 00068 void compile(OSLGlobals *og, Shader *shader); 00069 00070 void add(ShaderNode *node, const char *name); 00071 00072 void parameter(const char *name, float f); 00073 void parameter_color(const char *name, float3 f); 00074 void parameter_vector(const char *name, float3 f); 00075 void parameter_normal(const char *name, float3 f); 00076 void parameter_point(const char *name, float3 f); 00077 void parameter(const char *name, int f); 00078 void parameter(const char *name, const char *s); 00079 void parameter(const char *name, ustring str); 00080 void parameter(const char *name, const Transform& tfm); 00081 00082 ShaderType output_type() { return current_type; } 00083 00084 bool background; 00085 00086 private: 00087 string id(ShaderNode *node); 00088 void compile_type(Shader *shader, ShaderGraph *graph, ShaderType type); 00089 bool node_skip_input(ShaderNode *node, ShaderInput *input); 00090 string compatible_name(const char *name); 00091 00092 void find_dependencies(set<ShaderNode*>& dependencies, ShaderInput *input); 00093 void generate_nodes(const set<ShaderNode*>& nodes); 00094 00095 void *shadingsys; 00096 ShaderType current_type; 00097 Shader *current_shader; 00098 }; 00099 00100 CCL_NAMESPACE_END 00101 00102 #endif /* __OSL_H__ */ 00103