shader_compiler_gles2.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*************************************************************************/
  2. /* shader_compiler_gles2.h */
  3. /*************************************************************************/
  4. /* This file is part of: */
  5. /* GODOT ENGINE */
  6. /* http://www.godotengine.org */
  7. /*************************************************************************/
  8. /* Copyright (c) 2007-2015 Juan Linietsky, Ariel Manzur. */
  9. /* */
  10. /* Permission is hereby granted, free of charge, to any person obtaining */
  11. /* a copy of this software and associated documentation files (the */
  12. /* "Software"), to deal in the Software without restriction, including */
  13. /* without limitation the rights to use, copy, modify, merge, publish, */
  14. /* distribute, sublicense, and/or sell copies of the Software, and to */
  15. /* permit persons to whom the Software is furnished to do so, subject to */
  16. /* the following conditions: */
  17. /* */
  18. /* The above copyright notice and this permission notice shall be */
  19. /* included in all copies or substantial portions of the Software. */
  20. /* */
  21. /* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
  22. /* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
  23. /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
  24. /* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
  25. /* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
  26. /* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
  27. /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  28. /*************************************************************************/
  29. #ifndef SHADER_COMPILER_GLES2_H
  30. #define SHADER_COMPILER_GLES2_H
  31. #include "servers/visual/shader_language.h"
  32. class ShaderCompilerGLES2 {
  33. class Uniform;
  34. public:
  35. class Flags;
  36. private:
  37. ShaderLanguage::ProgramNode *program_node;
  38. String dump_node_code(ShaderLanguage::Node *p_node,int p_level,bool p_assign_left=false);
  39. Error compile_node(ShaderLanguage::ProgramNode *p_program);
  40. static Error create_glsl_120_code(void *p_str,ShaderLanguage::ProgramNode *p_program);
  41. bool uses_light;
  42. bool uses_texscreen;
  43. bool uses_texpos;
  44. bool uses_alpha;
  45. bool uses_discard;
  46. bool uses_time;
  47. bool uses_screen_uv;
  48. bool uses_normalmap;
  49. bool uses_normal;
  50. bool uses_texpixel_size;
  51. bool uses_worldvec;
  52. bool vertex_code_writes_vertex;
  53. bool uses_shadow_color;
  54. bool sinh_used;
  55. bool tanh_used;
  56. bool cosh_used;
  57. bool custom_h;
  58. Flags *flags;
  59. StringName vname_discard;
  60. StringName vname_screen_uv;
  61. StringName vname_diffuse_alpha;
  62. StringName vname_color_interp;
  63. StringName vname_uv_interp;
  64. StringName vname_uv2_interp;
  65. StringName vname_tangent_interp;
  66. StringName vname_binormal_interp;
  67. StringName vname_var1_interp;
  68. StringName vname_var2_interp;
  69. StringName vname_vertex;
  70. StringName vname_light;
  71. StringName vname_time;
  72. StringName vname_normalmap;
  73. StringName vname_normalmap_depth;
  74. StringName vname_normal;
  75. StringName vname_texpixel_size;
  76. StringName vname_world_vec;
  77. StringName vname_shadow;
  78. Map<StringName,ShaderLanguage::Uniform> *uniforms;
  79. StringName out_vertex_name;
  80. String global_code;
  81. String code;
  82. ShaderLanguage::ShaderType type;
  83. String replace_string(const StringName& p_string);
  84. Map<StringName,StringName> mode_replace_table[9];
  85. Map<StringName,StringName> replace_table;
  86. public:
  87. struct Flags {
  88. bool uses_alpha;
  89. bool uses_texscreen;
  90. bool uses_texpos;
  91. bool uses_normalmap;
  92. bool vertex_code_writes_vertex;
  93. bool uses_discard;
  94. bool uses_screen_uv;
  95. bool use_color_interp;
  96. bool use_uv_interp;
  97. bool use_uv2_interp;
  98. bool use_tangent_interp;
  99. bool use_var1_interp;
  100. bool use_var2_interp;
  101. bool uses_light;
  102. bool uses_time;
  103. bool uses_normal;
  104. bool uses_texpixel_size;
  105. bool uses_worldvec;
  106. bool uses_shadow_color;
  107. };
  108. Error compile(const String& p_code, ShaderLanguage::ShaderType p_type, String& r_code_line, String& r_globals_line, Flags& r_flags, Map<StringName,ShaderLanguage::Uniform> *r_uniforms=NULL);
  109. ShaderCompilerGLES2();
  110. };
  111. #endif // SHADER_COMPILERL_GL_H