diff options
author | clayjohn <claynjohn@gmail.com> | 2019-07-28 11:06:05 -0700 |
---|---|---|
committer | clayjohn <claynjohn@gmail.com> | 2019-07-29 11:17:08 -0700 |
commit | 3f25dde6b4c46bec1fd25a3dd8f65c774b0fef94 (patch) | |
tree | b9ccae49176d3ef73ea3167f46f1f1ee4c6d583b /drivers/gles2 | |
parent | 5dae2ea777da5395cf1b1e9a8bc6abc93f6ae6bb (diff) |
added round function to gles2
Diffstat (limited to 'drivers/gles2')
-rw-r--r-- | drivers/gles2/shader_compiler_gles2.cpp | 12 | ||||
-rw-r--r-- | drivers/gles2/shaders/canvas.glsl | 2 | ||||
-rw-r--r-- | drivers/gles2/shaders/stdlib.glsl | 17 |
3 files changed, 31 insertions, 0 deletions
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index df7eee2301..630a5ed6c6 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -733,6 +733,17 @@ String ShaderCompilerGLES2::_dump_node_code(SL::Node *p_node, int p_level, Gener code += ")"; + if (p_default_actions.usage_defines.has(var_node->name) && !used_name_defines.has(var_node->name)) { + String define = p_default_actions.usage_defines[var_node->name]; + + if (define.begins_with("@")) { + define = p_default_actions.usage_defines[define.substr(1, define.length())]; + } + + r_gen_code.custom_defines.push_back(define.utf8()); + used_name_defines.insert(var_node->name); + } + } break; case SL::OP_INDEX: { @@ -917,6 +928,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMAL"] = "#define NORMAL_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["NORMALMAP"] = "#define NORMALMAP_USED\n"; actions[VS::SHADER_CANVAS_ITEM].usage_defines["LIGHT"] = "#define USE_LIGHT_SHADER_CODE\n"; + actions[VS::SHADER_CANVAS_ITEM].usage_defines["round"] = "#define ROUND_USED\n"; actions[VS::SHADER_CANVAS_ITEM].render_mode_defines["skip_vertex_transform"] = "#define SKIP_TRANSFORM_USED\n"; /** SPATIAL SHADER **/ diff --git a/drivers/gles2/shaders/canvas.glsl b/drivers/gles2/shaders/canvas.glsl index 0818942b0a..55ee50f66d 100644 --- a/drivers/gles2/shaders/canvas.glsl +++ b/drivers/gles2/shaders/canvas.glsl @@ -258,6 +258,8 @@ precision mediump int; #endif #endif +#include "stdlib.glsl" + uniform sampler2D color_texture; // texunit:-1 /* clang-format on */ uniform highp vec2 color_texpixel_size; diff --git a/drivers/gles2/shaders/stdlib.glsl b/drivers/gles2/shaders/stdlib.glsl index 3674d70c9f..b9ecfec65e 100644 --- a/drivers/gles2/shaders/stdlib.glsl +++ b/drivers/gles2/shaders/stdlib.glsl @@ -35,6 +35,23 @@ highp vec4 texel2DFetch(highp sampler2D tex, ivec2 size, ivec2 coord) { return texture2DLod(tex, vec2(x_coord, y_coord), 0.0); } +#ifdef ROUND_USED +highp float round(highp float x) { + return floor(x + 0.5); +} + +highp vec2 round(highp vec2 x) { + return floor(x + vec2(0.5)); +} + +highp vec3 round(highp vec3 x) { + return floor(x + vec3(0.5)); +} + +highp vec4 round(highp vec4 x) { + return floor(x + vec4(0.5)); +} +#endif #ifndef USE_GLES_OVER_GL highp mat4 transpose(highp mat4 src) { |