~siretart/ubuntu/utopic/blender/libav10

« back to all changes in this revision

Viewing changes to intern/cycles/render/shader.h

  • Committer: Package Import Robot
  • Author(s): Matteo F. Vescovi
  • Date: 2012-07-23 08:54:18 UTC
  • mfrom: (14.2.16 sid)
  • mto: (14.2.19 sid)
  • mto: This revision was merged to the branch mainline in revision 42.
  • Revision ID: package-import@ubuntu.com-20120723085418-9foz30v6afaf5ffs
Tags: 2.63a-2
* debian/: Cycles support added (Closes: #658075)
  For now, this top feature has been enabled only
  on [any-amd64 any-i386] architectures because
  of OpenImageIO failing on all others
* debian/: scripts installation path changed
  from /usr/lib to /usr/share:
  + debian/patches/: patchset re-worked for path changing
  + debian/control: "Breaks" field added on yafaray-exporter

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright 2011, Blender Foundation.
 
3
 *
 
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.
 
8
 *
 
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.
 
13
 *
 
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.
 
17
 */
 
18
 
 
19
#ifndef __SHADER_H__
 
20
#define __SHADER_H__
 
21
 
 
22
#include "attribute.h"
 
23
#include "kernel_types.h"
 
24
 
 
25
#include "util_map.h"
 
26
#include "util_param.h"
 
27
#include "util_string.h"
 
28
#include "util_types.h"
 
29
 
 
30
CCL_NAMESPACE_BEGIN
 
31
 
 
32
class Device;
 
33
class DeviceScene;
 
34
class Mesh;
 
35
class Progress;
 
36
class Scene;
 
37
class ShaderGraph;
 
38
struct float3;
 
39
 
 
40
/* Shader describing the appearance of a Mesh, Light or Background.
 
41
 *
 
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
 
44
 * separately. */
 
45
 
 
46
class Shader {
 
47
public:
 
48
        /* name */
 
49
        string name;
 
50
        int pass_id;
 
51
 
 
52
        /* shader graph */
 
53
        ShaderGraph *graph;
 
54
 
 
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;
 
59
 
 
60
        /* sampling */
 
61
        bool sample_as_light;
 
62
        bool homogeneous_volume;
 
63
 
 
64
        /* synchronization */
 
65
        bool need_update;
 
66
        bool need_update_attributes;
 
67
 
 
68
        /* information about shader after compiling */
 
69
        bool has_surface;
 
70
        bool has_surface_emission;
 
71
        bool has_surface_transparent;
 
72
        bool has_volume;
 
73
        bool has_displacement;
 
74
 
 
75
        /* requested mesh attributes */
 
76
        AttributeRequestSet attributes;
 
77
 
 
78
        Shader();
 
79
        ~Shader();
 
80
 
 
81
        void set_graph(ShaderGraph *graph);
 
82
        void tag_update(Scene *scene);
 
83
};
 
84
 
 
85
/* Shader Manager virtual base class
 
86
 * 
 
87
 * From this the SVM and OSL shader managers are derived, that do the actual
 
88
 * shader compiling and device updating. */
 
89
 
 
90
class ShaderManager {
 
91
public:
 
92
        bool need_update;
 
93
 
 
94
        static ShaderManager *create(Scene *scene);
 
95
        virtual ~ShaderManager();
 
96
 
 
97
        /* device update */
 
98
        virtual void device_update(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress) = 0;
 
99
        virtual void device_free(Device *device, DeviceScene *dscene) = 0;
 
100
 
 
101
        void device_update_common(Device *device, DeviceScene *dscene, Scene *scene, Progress& progress);
 
102
        void device_free_common(Device *device, DeviceScene *dscene);
 
103
 
 
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);
 
107
 
 
108
        /* get shader id for mesh faces */
 
109
        int get_shader_id(uint shader, Mesh *mesh = NULL, bool smooth = false);
 
110
 
 
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);
 
114
 
 
115
protected:
 
116
        ShaderManager();
 
117
 
 
118
        typedef unordered_map<ustring, uint, ustringHash> AttributeIDMap;
 
119
        AttributeIDMap unique_attribute_id;
 
120
};
 
121
 
 
122
CCL_NAMESPACE_END
 
123
 
 
124
#endif /* __SHADER_H__ */
 
125