diff options
author | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2017-08-11 19:09:55 +0200 |
---|---|---|
committer | Fabio Alessandrelli <fabio.alessandrelli@gmail.com> | 2017-08-11 23:26:24 +0200 |
commit | 9b9a723c771a0146cb16e23c3dac744af312bad7 (patch) | |
tree | 39deb91751445abf65b875a2b569bea16403abeb | |
parent | f863c0ca14111d4bab06604fb4e2bf42fc83f0da (diff) |
Some fixes for shaders and WebGL2
Add padding to UBO data to be multiple of 16 bytes
Add precision definition for samplers
Replace texture2D (deprecated) with texture in shaders
-rw-r--r-- | drivers/gles3/rasterizer_canvas_gles3.h | 2 | ||||
-rw-r--r-- | drivers/gles3/rasterizer_scene_gles3.h | 2 | ||||
-rw-r--r-- | drivers/gles3/shader_gles3.cpp | 6 | ||||
-rw-r--r-- | drivers/gles3/shaders/canvas.glsl | 4 |
4 files changed, 12 insertions, 2 deletions
diff --git a/drivers/gles3/rasterizer_canvas_gles3.h b/drivers/gles3/rasterizer_canvas_gles3.h index 26003f543f..29f889cc88 100644 --- a/drivers/gles3/rasterizer_canvas_gles3.h +++ b/drivers/gles3/rasterizer_canvas_gles3.h @@ -42,6 +42,7 @@ public: float projection_matrix[16]; float time; + uint8_t padding[12]; }; RasterizerSceneGLES3 *scene_render; @@ -102,6 +103,7 @@ public: float light_height; float light_outside_alpha; float shadow_distance_mult; + uint8_t padding[4]; } ubo_data; GLuint ubo; diff --git a/drivers/gles3/rasterizer_scene_gles3.h b/drivers/gles3/rasterizer_scene_gles3.h index f6509e0041..0cdaef44a9 100644 --- a/drivers/gles3/rasterizer_scene_gles3.h +++ b/drivers/gles3/rasterizer_scene_gles3.h @@ -141,6 +141,7 @@ public: float fog_height_min; float fog_height_max; float fog_height_curve; + uint8_t padding[8]; } ubo_data; @@ -150,6 +151,7 @@ public: float transform[16]; float ambient_contribution; + uint8_t padding[12]; } env_radiance_data; diff --git a/drivers/gles3/shader_gles3.cpp b/drivers/gles3/shader_gles3.cpp index f1077e2d20..77e257dfc8 100644 --- a/drivers/gles3/shader_gles3.cpp +++ b/drivers/gles3/shader_gles3.cpp @@ -273,6 +273,9 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { //vertex precision is high strings.push_back("precision highp float;\n"); strings.push_back("precision highp int;\n"); + strings.push_back("precision highp sampler2D;\n"); + strings.push_back("precision highp samplerCube;\n"); + strings.push_back("precision highp sampler2DArray;\n"); #if 0 if (cc) { @@ -371,6 +374,9 @@ ShaderGLES3::Version *ShaderGLES3::get_current_version() { //fragment precision is medium strings.push_back("precision highp float;\n"); strings.push_back("precision highp int;\n"); + strings.push_back("precision highp sampler2D;\n"); + strings.push_back("precision highp samplerCube;\n"); + strings.push_back("precision highp sampler2DArray;\n"); #if 0 if (cc) { diff --git a/drivers/gles3/shaders/canvas.glsl b/drivers/gles3/shaders/canvas.glsl index 1c950c82d9..f0dc14c35a 100644 --- a/drivers/gles3/shaders/canvas.glsl +++ b/drivers/gles3/shaders/canvas.glsl @@ -532,11 +532,11 @@ FRAGMENT_SHADER_CODE #ifdef USE_RGBA_SHADOWS -#define SHADOW_DEPTH(m_tex,m_uv) dot(texture2D((m_tex),(m_uv)),vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) ) +#define SHADOW_DEPTH(m_tex,m_uv) dot(texture((m_tex),(m_uv)),vec4(1.0 / (256.0 * 256.0 * 256.0),1.0 / (256.0 * 256.0),1.0 / 256.0,1) ) #else -#define SHADOW_DEPTH(m_tex,m_uv) (texture2D((m_tex),(m_uv)).r) +#define SHADOW_DEPTH(m_tex,m_uv) (texture((m_tex),(m_uv)).r) #endif |