C++ SDK Reference  12.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyGraphicsShaderTechnique.h
Go to the documentation of this file.
1 
2 /*
3  * Copyright (C) 1992-2013 Boston Dynamics
4  * ALL RIGHTS RESERVED.
5  *
6  * These coded instructions, statements, and computer Techniques
7  * contain unpublished proprietary information of Boston Dynamics
8  * and are protected by Copyright Laws of the United States.
9  * They may not be used, duplicated, or disclosed in any form, in
10  * whole or in part, without the prior written consent from Boston
11  * Dynamics.
12  *
13  * RESTRICTED RIGHTS LEGEND
14  * Use, duplication, or disclosure by the government is subject
15  * to restrictions as set forth in FAR 52.227.19(c)(2) or
16  * subparagraph (c)(1)(ii) of the Rights in Technical Data and
17  * Computer Software clause at DFARS 252.227-7013 and/or in
18  * similar or successor clauses in the FAR, or the DOD or NASA
19  * FAR Supplement, or to subparagraphs (c)(1) and (c)(2) of the
20  * Commercial Computer Software--Restricted Rights at 48 CFR
21  * 52.227-19, as applicable. Unpublished-rights reserved under
22  * the Copyright Laws of the United States.
23  * Contractor/Manufacturer is:
24  * Boston Dynamics/78 Fourth Avenue/Waltham MA 02451.
25  */
26 
27 /*********************************************************************/
34 #ifndef __diguyGraphicsShaderTechnique_H
35 #define __diguyGraphicsShaderTechnique_H
36 
37 
38 #ifdef SWIG
40 #else
41 #define CPLUSPLUS_ONLY
42 #endif
43 
44 #ifdef CPLUSPLUS_ONLY
45 
46 #include <diguy_constants.h>
47 #include <declspec_diguy.h>
48 
49 class diguyGraphicsLink;
52 class bdiShaderTechnique;
53 
54 #endif
55 
56 /****************************************************************************/
62 {
64  m_shader_instance(NULL),
67  m_shader_lod(-1),
71  {
72  ;
73  }
74 
78 
81 
84  int m_shader_lod;
85 
87  float m_render_distance;
88 
90  float m_shader_lod_bias;
91 
96 
99 
103 };
104 
105 /****************************************************************************/
117 class BDI_DECLSPEC_diguy diguyGraphicsShaderTechnique
118 {
119 
120 public:
121 
122 /*****************************************************************************/
135  /*l
136  *b Returns:
137  **
138  ** the name of the shader technique. This pointer will
139  ** never be NULL.
140  */
141  const char* get_name();
142 
143  /*l
144  *b Description:
145  **
146  ** Returns the number of lod shaders the technique has.
147  */
148  int get_num_shader_lod_programs();
149 
150  /*l
151  *b Description:
152  **
153  ** Returns the shader program at a lod index.
154  */
155  diguyGraphicsShaderProgram* get_shader_lod_program_at_index(int index);
156 
157  /*l
158  *b Description:
159  **
160  ** Returns the distance that a shader lod switches out at.
161  */
162  float get_shader_lod_range_at_index(int index);
163 
164  /*l
165  *b Description:
166  **
167  ** Returns a shader based on the rendering distance.
168  */
169  diguyGraphicsShaderProgram * get_shader_by_distance(float distance, int max_quality_level);
170 
171  /*l
172  *b Description:
173  **
174  ** Returns the shader index based on the rendering distance.
175  */
176  int get_program_index_by_distance(float distance, int max_quality_level);
177 
178  /*l
179  *b Description:
180  **
181  ** Returns the shader specified for intersections.
182  */
183  diguyGraphicsShaderProgram* get_intersection_shader();
184 
185  /*l
186  *b Description:
187  **
188  ** Returns the shader specified for shadow map generation.
189  */
190  diguyGraphicsShaderProgram* get_shadow_pass_shader();
191 
192 /*****************************************************************************/
197  /*l
198  *b Description:
199  **
200  ** This function allows you create a new shader that uses the same
201  ** vertex and pixel files as the one passed in. The user is then able
202  ** modify the subclassed shader before calling load().
203  ** This function should allow end users to create an arbitrary number of
204  ** shader permutations and then return them via overriding pick_shader_program().
205  ** See diguyOglGraphicsShaderTechnique::build() for an example of it's usage.
206  ** Override pick_shader_program() to return a procedurally created shader.
207  */
208  diguyGraphicsShaderProgram * find_or_create_shader_variation(diguyGraphicsShaderProgram * program, const char * new_name);
209 
210  /*l
211  *b Description:
212  **
213  ** Adds an additional shader program to the technique these will get
214  ** automatically updated if any of the shader uniform functions are used.
215  ** These are mostly for convenience. Users will probably want their own
216  ** data structures to store shader lookup tables.
217  **/
218  void add_additional_shader(diguyGraphicsShaderProgram* program);
219 
220  /*l
221  *b Returns:
222  ** The number of shaders that have been procedurally added to the technique.
223  */
224  int get_num_additional_shaders();
225 
226  /*l
227  *b Returns:
228  ** A pointer to the procedural shaders that has been procedurally added to
229  ** the technique.
230  */
231  diguyGraphicsShaderProgram* get_additional_shader_at_index(int index);
232 
233 /*****************************************************************************/
237  /*l
238  *b Description:
239  **
240  ** Convenience functions. Loops through all shaders in this technique
241  ** and sets uniform variables if they exist.
242  **
243  *b Callable From:
244  **
245  *- - C++
246  *- - Script
247  */
248  int set_variable_float(const char* name, float value, int set_current = 1, int set_initial = 0);
249  int set_variable_vec2(const char* name, float x, float y, int set_current = 1, int set_initial = 0);
250  int set_variable_vec3(const char* name, float x, float y, float z, int set_current = 1, int set_initial = 0);
251  int set_variable_vec4(const char* name, float x, float y, float z, float w, int set_current = 1, int set_initial = 0);
252  int set_variable_int(const char* name, int value, int set_current = 1, int set_initial = 0);
253 
254 /*****************************************************************************/
266  /*l
267  *b Description:
268  **
269  ** Allows users to use a subclass to override the default shader LOD system
270  ** see diguyOglGraphicsShaderTechnique::pick_shader_program() for an example
271  ** of it's usage.
272  **/
273  virtual diguyGraphicsShaderProgram * pick_shader_program(const diguyShaderPickDescription & desc);
274 
275 
276  /*l
277  *b Description:
278  **
279  ** Allows users to do their own post shader load behavior.
280  **/
281  virtual void build();
282 
288 #ifdef CPLUSPLUS_ONLY
289 
290  bdiShaderTechnique* get_internal_data() {return m_internal_data;}
291 
292 protected:
293 
294  /*l
295  ** A protected constructor. Constructors are called automatically
296  ** by DI-Guy.
297  */
298  diguyGraphicsShaderTechnique(void* internal_data);
299 
300  /*l
301  ** A protected destructor. Destructors are called automatically
302  ** by DI-Guy.
303  */
304  virtual ~diguyGraphicsShaderTechnique();
305 
306 private:
307 
308  /*l
309  ** A pointer to internal data.
310  */
311  bdiShaderTechnique* m_internal_data;
312 
313  friend class bdiShaderTechnique;
314  friend class bdiGeometryFactory;
315 #endif
316 };
319 #endif /* __diguyGraphicsShaderTechnique_H */
320