diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2019-07-29 22:43:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-07-29 22:43:26 +0200 |
commit | b697121d75aad486f658daa864535a1d2ae8ad96 (patch) | |
tree | a3dc4355a1d26311245fbff1dc5ea1e1d1460795 /drivers/gles2 | |
parent | 961b9b30e3b941032b355decaa7171f2612b1f34 (diff) | |
parent | 3f25dde6b4c46bec1fd25a3dd8f65c774b0fef94 (diff) |
Merge pull request #30895 from clayjohn/gles2-shader-funcs
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 b9b5818e8d..fa0b315e29 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) { |