2
* Copyright 2011, Blender Foundation.
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
#include "attribute.h"
23
#include "kernel_types.h"
26
#include "util_param.h"
27
#include "util_string.h"
28
#include "util_types.h"
40
/* Shader describing the appearance of a Mesh, Light or Background.
42
* While there is only a single shader graph, it has three outputs: surface,
43
* volume and displacement, that the shader manager will compile and execute
55
/* shader graph with auto bump mapping included, we compile two shaders,
56
with and without bump, because the displacement method is a mesh
57
level setting, so we need to handle both */
58
ShaderGraph *graph_bump;
62
bool homogeneous_volume;
66
bool need_update_attributes;
68
/* information about shader after compiling */
70
bool has_surface_emission;
71
bool has_surface_transparent;
73
bool has_displacement;
75
/* requested mesh attributes */
76
AttributeRequestSet attributes;
81
void set_graph(ShaderGraph *graph);
82
void tag_update(Scene *scene);
85
/* Shader Manager virtual base class
87
* From this the SVM and OSL shader managers are derived, that do the actual
88
* shader compiling and device updating. */
94
static ShaderManager *create(Scene *scene);
95
virtual ~ShaderManager();
98
virtual void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) = 0;
99
virtual void device_free(Device *device, DeviceScene *dscene) = 0;
101
void device_update_common(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
102
void device_free_common(Device *device, DeviceScene *dscene);
104
/* get globally unique id for a type of attribute */
105
uint get_attribute_id(ustring name);
106
uint get_attribute_id(Attribute::Standard std);
108
/* get shader id for mesh faces */
109
int get_shader_id(uint shader, Mesh *mesh = NULL, bool smooth = false);
111
/* add default shaders to scene, to use as default for things that don't
112
have any shader assigned explicitly */
113
static void add_default(Scene *scene);
118
typedef unordered_map<ustring, uint, ustringHash> AttributeIDMap;
119
AttributeIDMap unique_attribute_id;
124
#endif /* __SHADER_H__ */