From fe92fac05f0306bea83a6c113daea35acde80398 Mon Sep 17 00:00:00 2001 From: Oleksandr Shcherbina Date: Thu, 1 Oct 2015 19:08:14 +0900 Subject: [PATCH] evas_canvas3d: Unification algorithm generation shadow Summary: Change type of texdepth from GL_R(doesn't support with GLES) to GL_RGBA. Don't use useless additional framebuffers for shadows. Use same shader code for generation shadow map texture. Turn always using software alpha-test. It reduce and simplify code in general. Reviewers: cedric, Hermet Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3115 --- src/modules/evas/engines/gl_common/evas_gl_3d.c | 38 +------- .../evas/engines/gl_common/evas_gl_3d_private.h | 6 -- .../evas/engines/gl_common/evas_gl_3d_shader.c | 6 -- .../gl_common/shader_3d/evas_gl_3d_shaders.x | 100 ++------------------- .../evas/engines/gl_common/shader_3d/include.shd | 21 +---- .../gl_common/shader_3d/shadow_map_frag.shd | 5 +- 6 files changed, 16 insertions(+), 160 deletions(-) diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d.c b/src/modules/evas/engines/gl_common/evas_gl_3d.c index 69c9c54..68fc15f 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d.c +++ b/src/modules/evas/engines/gl_common/evas_gl_3d.c @@ -276,9 +276,6 @@ e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_fo GLuint depth_stencil_buf = 0; GLuint depth_buf = 0; GLuint stencil_buf = 0; -#ifdef GL_GLES - GLuint shadow_fbo, depth_render_buf; -#endif Eina_Bool depth_stencil = EINA_FALSE; glGenTextures(1, &tex); @@ -299,13 +296,7 @@ e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_fo glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); -#ifndef GL_GLES - glTexImage2D(GL_TEXTURE_2D, 0, GL_R16, w, h, 0, GL_RED, GL_UNSIGNED_SHORT, 0); -#else - glGenFramebuffers(1, &shadow_fbo); - glGenFramebuffers(1, &depth_render_buf); glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); -#endif glGenFramebuffers(1, &color_pick_fb_id); glGenTextures(1, &texcolorpick); @@ -401,10 +392,7 @@ e3d_drawable_new(int w, int h, int alpha, GLenum depth_format, GLenum stencil_fo drawable->depth_buf = depth_buf; drawable->stencil_buf = stencil_buf; drawable->texDepth = texDepth; -#ifdef GL_GLES - drawable->shadow_fbo = shadow_fbo; - drawable->depth_render_buf = depth_render_buf; -#endif + return drawable; error: @@ -437,12 +425,6 @@ error: if (stencil_buf) glDeleteRenderbuffers(1, &stencil_buf); -#ifdef GL_GLES - if (shadow_fbo) - glDeleteFramebuffers(1, &shadow_fbo); - if (depth_render_buf) - glDeleteFramebuffers(1, &depth_render_buf); -#endif return NULL; } @@ -1009,9 +991,7 @@ _mesh_draw_data_build(E3D_Draw_Data *data, data->flags |= E3D_SHADER_FLAG_SHADOWED; data->pcf_size = 1 / pdmesh->shadows_edges_size; data->pcf_step = (Evas_Real)pdmesh->shadows_edges_filtering_level; -#ifdef GL_GLES data->constant_bias = pdmesh->shadows_constant_bias; -#endif } if (pdmesh->color_pick_enabled) @@ -1186,18 +1166,10 @@ void _shadowmap_render(E3D_Drawable *drawable, E3D_Renderer *renderer, glEnable(GL_POLYGON_OFFSET_FILL); glPolygonOffset(data->depth_offset, data->depth_constant); -#ifdef GL_GLES - glBindFramebuffer(GL_FRAMEBUFFER, drawable->shadow_fbo); - glBindRenderbuffer(GL_RENDERBUFFER, drawable->depth_render_buf); -#endif + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, drawable->texDepth, 0); -#ifdef GL_GLES - glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT16, drawable->w, - drawable->h); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, - drawable->depth_render_buf); -#endif + e3d_renderer_target_set(renderer, drawable); e3d_renderer_clear(renderer, &c); @@ -1231,9 +1203,7 @@ void _shadowmap_render(E3D_Drawable *drawable, E3D_Renderer *renderer, } glDisable(GL_POLYGON_OFFSET_FILL); -#ifdef GL_GLES - glBindFramebuffer(GL_FRAMEBUFFER, drawable->fbo); -#endif + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, drawable->tex, 0); } diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d_private.h b/src/modules/evas/engines/gl_common/evas_gl_3d_private.h index 6f44456..a05eba7 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d_private.h +++ b/src/modules/evas/engines/gl_common/evas_gl_3d_private.h @@ -114,9 +114,7 @@ struct _E3D_Draw_Data /*Sets of the quality of shadow rendering*/ Evas_Real pcf_step; Evas_Real pcf_size; -#ifdef GL_GLES Evas_Real constant_bias; -#endif }; struct _E3D_Texture @@ -157,10 +155,6 @@ struct _E3D_Drawable GLuint texDepth; GLuint texcolorpick; GLuint color_pick_fb_id; -#ifdef GL_GLES - GLuint shadow_fbo; - GLuint depth_render_buf; -#endif }; /* Texture internal functions. */ diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c b/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c index 21d5d18..8beeb3d 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c +++ b/src/modules/evas/engines/gl_common/evas_gl_3d_shader.c @@ -47,9 +47,7 @@ typedef enum _E3D_Uniform E3D_UNIFORM_SHADOWMAP, E3D_UNIFORM_SHADOWS_PCF_STEP, E3D_UNIFORM_SHADOWS_PCF_SIZE, -#ifdef GL_GLES E3D_UNIFORM_SHADOWS_CONSTANT_BIAS, -#endif E3D_UNIFORM_LIGHT_POSITION, E3D_UNIFORM_LIGHT_SPOT_DIR, @@ -344,9 +342,7 @@ static const char *uniform_names[] = "uShadowMap", "uShadowsPCFStep", "uShadowsPCFSize", -#ifdef GL_GLES "uShadowsConstantBias", -#endif "uLightPosition", "uLightSpotDir", "uLightSpotExp", @@ -528,11 +524,9 @@ _uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data) case E3D_UNIFORM_SHADOWS_PCF_SIZE: glUniform1f(loc, data->pcf_size); break; -#ifdef GL_GLES case E3D_UNIFORM_SHADOWS_CONSTANT_BIAS: glUniform1f(loc, data->constant_bias); break; -#endif case E3D_UNIFORM_LIGHT_POSITION: glUniform4f(loc, data->light.position.x, data->light.position.y, data->light.position.z, data->light.position.w); diff --git a/src/modules/evas/engines/gl_common/shader_3d/evas_gl_3d_shaders.x b/src/modules/evas/engines/gl_common/shader_3d/evas_gl_3d_shaders.x index b6dbb5a..46195fe 100644 --- a/src/modules/evas/engines/gl_common/shader_3d/evas_gl_3d_shaders.x +++ b/src/modules/evas/engines/gl_common/shader_3d/evas_gl_3d_shaders.x @@ -55,15 +55,12 @@ static const char vertex_color_frag_glsl[] = "uniform float uFogFactor;\n" "uniform vec4 uFogColor;\n" "#endif //FOG_ENABLED\n" - "#ifdef GL_ES\n" "uniform int uAlphaTestComparison;\n" "uniform float uAlphaTestRefValue;\n" - "#endif //GL_ES\n" "void main()\n" "{\n" "#ifdef ALPHA_TEST_ENABLED\n" - " #ifdef GL_ES\n" - "/*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" + " /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" " const float p = 1000000.0;\n" " float acolor = floor(vColor.a * p);\n" " float refvalue = floor(uAlphaTestRefValue * p);\n" @@ -101,9 +98,6 @@ static const char vertex_color_frag_glsl[] = " else if (uAlphaTestComparison == 7) ;\n" "#else\n" " gl_FragColor = vColor;\n" - "#endif //GL_ES\n" - "#else\n" - " gl_FragColor = vColor;\n" "#endif //ALPHA_TEST_ENABLED\n" " \n" "#ifdef FOG_ENABLED\n" @@ -188,10 +182,8 @@ static const char diffuse_frag_glsl[] = " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse1;\n" "#endif //DIFFUSE_TEXTURE_BLEND\n" "#endif //DIFFUSE\n" - "#ifdef GL_ES\n" "uniform int uAlphaTestComparison;\n" "uniform float uAlphaTestRefValue;\n" - "#endif //GL_ES\n" "void main() {\n" " vec4 color;\n" " \n" @@ -207,8 +199,7 @@ static const char diffuse_frag_glsl[] = "#endif //DIFFUSE_TEXTURE\n" "#endif //DIFFUSE_TEXTURE_BLEND\n" "#ifdef ALPHA_TEST_ENABLED\n" - " #ifdef GL_ES\n" - "/*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" + " /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" " const float p = 1000000.0;\n" " float acolor = floor(color.a * p);\n" " float refvalue = floor(uAlphaTestRefValue * p);\n" @@ -246,9 +237,6 @@ static const char diffuse_frag_glsl[] = " else if (uAlphaTestComparison == 7) ;\n" "#else\n" " gl_FragColor = color;\n" - "#endif //GL_ES\n" - "#else\n" - " gl_FragColor = color;\n" "#endif //ALPHA_TEST_ENABLED\n" " \n" "#ifdef FOG_ENABLED\n" @@ -403,9 +391,7 @@ static const char flat_frag_glsl[] = "uniform sampler2D uShadowMap;\n" "uniform float uShadowsPCFStep;\n" "uniform float uShadowsPCFSize;\n" - "#ifdef GL_ES\n" "uniform float uShadowsConstantBias;\n" - "#endif //GL_ES\n" "float shadow;\n" "float pcf(vec4 lpos)\n" "{\n" @@ -414,11 +400,6 @@ static const char flat_frag_glsl[] = " q = floor(uShadowsPCFStep * 2.0);\n" " c = floor(uShadowsPCFStep * uShadowsPCFStep * 4.0);\n" " shadow = 0.0;\n" - "#ifndef GL_ES\n" - " for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0)\n" - " for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0)\n" - " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize).x);\n" - "#else\n" " const vec4 unpack = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n" " for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0)\n" " for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0)\n" @@ -426,7 +407,6 @@ static const char flat_frag_glsl[] = " vec4 zvalue = texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize);\n" " shadow += float(smcoord.z < dot(zvalue, unpack) + uShadowsConstantBias);\n" " }\n" - "#endif //GL_ES\n" " return shadow / c;\n" "}\n" "#endif //SHADOWED\n" @@ -498,10 +478,8 @@ static const char flat_frag_glsl[] = " vec3(vTexCoord, 1.0) * uTextureMatrixTransformEmission1;\n" "#endif //EMISSION_TEXTURE_BLEND\n" "#endif //EMISSION\n" - "#ifdef GL_ES\n" "uniform int uAlphaTestComparison;\n" "uniform float uAlphaTestRefValue;\n" - "#endif //GL_ES\n" "vec4 fragmentFlat()\n" "{\n" " vec4 color;\n" @@ -580,8 +558,7 @@ static const char flat_frag_glsl[] = "#endif //SHADOWED\n" " color = fragmentFlat();\n" "#ifdef ALPHA_TEST_ENABLED\n" - " #ifdef GL_ES\n" - "/*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" + " /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" " const float p = 1000000.0;\n" " float acolor = floor(color.a * p);\n" " float refvalue = floor(uAlphaTestRefValue * p);\n" @@ -619,9 +596,6 @@ static const char flat_frag_glsl[] = " else if (uAlphaTestComparison == 7) ;\n" "#else\n" " gl_FragColor = color;\n" - "#endif //GL_ES\n" - "#else\n" - " gl_FragColor = color;\n" "#endif //ALPHA_TEST_ENABLED\n" " \n" "#ifdef FOG_ENABLED\n" @@ -746,9 +720,7 @@ static const char phong_frag_glsl[] = "uniform sampler2D uShadowMap;\n" "uniform float uShadowsPCFStep;\n" "uniform float uShadowsPCFSize;\n" - "#ifdef GL_ES\n" "uniform float uShadowsConstantBias;\n" - "#endif //GL_ES\n" "float shadow;\n" "float pcf(vec4 lpos)\n" "{\n" @@ -757,11 +729,6 @@ static const char phong_frag_glsl[] = " q = floor(uShadowsPCFStep * 2.0);\n" " c = floor(uShadowsPCFStep * uShadowsPCFStep * 4.0);\n" " shadow = 0.0;\n" - "#ifndef GL_ES\n" - " for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0)\n" - " for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0)\n" - " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize).x);\n" - "#else\n" " const vec4 unpack = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n" " for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0)\n" " for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0)\n" @@ -769,7 +736,6 @@ static const char phong_frag_glsl[] = " vec4 zvalue = texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize);\n" " shadow += float(smcoord.z < dot(zvalue, unpack) + uShadowsConstantBias);\n" " }\n" - "#endif //GL_ES\n" " return shadow / c;\n" "}\n" "#endif //SHADOWED\n" @@ -849,10 +815,8 @@ static const char phong_frag_glsl[] = "#ifdef LIGHT_ATTENUATION\n" "varying float vLightDist;\n" "#endif //LIGHT_ATTENUATION\n" - "#ifdef GL_ES\n" "uniform int uAlphaTestComparison;\n" "uniform float uAlphaTestRefValue;\n" - "#endif //GL_ES\n" "vec4 fragmentPhong()\n" "{\n" " vec3 normal = normalize(vNormal);\n" @@ -959,8 +923,7 @@ static const char phong_frag_glsl[] = "#endif //SHADOWED\n" " color = fragmentPhong();\n" "#ifdef ALPHA_TEST_ENABLED\n" - " #ifdef GL_ES\n" - "/*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" + " /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" " const float p = 1000000.0;\n" " float acolor = floor(color.a * p);\n" " float refvalue = floor(uAlphaTestRefValue * p);\n" @@ -998,9 +961,6 @@ static const char phong_frag_glsl[] = " else if (uAlphaTestComparison == 7) ;\n" "#else\n" " gl_FragColor = color;\n" - "#endif //GL_ES\n" - "#else\n" - " gl_FragColor = color;\n" "#endif //ALPHA_TEST_ENABLED\n" " \n" "#ifdef FOG_ENABLED\n" @@ -1182,9 +1142,7 @@ static const char normal_map_frag_glsl[] = "uniform sampler2D uShadowMap;\n" "uniform float uShadowsPCFStep;\n" "uniform float uShadowsPCFSize;\n" - "#ifdef GL_ES\n" "uniform float uShadowsConstantBias;\n" - "#endif //GL_ES\n" "float shadow;\n" "float pcf(vec4 lpos)\n" "{\n" @@ -1193,11 +1151,6 @@ static const char normal_map_frag_glsl[] = " q = floor(uShadowsPCFStep * 2.0);\n" " c = floor(uShadowsPCFStep * uShadowsPCFStep * 4.0);\n" " shadow = 0.0;\n" - "#ifndef GL_ES\n" - " for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0)\n" - " for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0)\n" - " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize).x);\n" - "#else\n" " const vec4 unpack = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n" " for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0)\n" " for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0)\n" @@ -1205,7 +1158,6 @@ static const char normal_map_frag_glsl[] = " vec4 zvalue = texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize);\n" " shadow += float(smcoord.z < dot(zvalue, unpack) + uShadowsConstantBias);\n" " }\n" - "#endif //GL_ES\n" " return shadow / c;\n" "}\n" "#endif //SHADOWED\n" @@ -1222,10 +1174,8 @@ static const char normal_map_frag_glsl[] = "vec3 Tex1CoordNormal =\n" " vec3(vTexCoord, 1.0) * uTextureMatrixTransformNormal1;\n" "#endif //NORMAL_TEXTURE_BLEND\n" - "#ifdef GL_ES\n" "uniform int uAlphaTestComparison;\n" "uniform float uAlphaTestRefValue;\n" - "#endif //GL_ES\n" "#ifndef VERTEX_TANGENT\n" "varying vec3 vNormal;\n" "#endif //VERTEX_TANGENT\n" @@ -1439,8 +1389,7 @@ static const char normal_map_frag_glsl[] = "#endif //SHADOWED\n" " color = fragmentNormalMap();\n" "#ifdef ALPHA_TEST_ENABLED\n" - " #ifdef GL_ES\n" - "/*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" + " /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" " const float p = 1000000.0;\n" " float acolor = floor(color.a * p);\n" " float refvalue = floor(uAlphaTestRefValue * p);\n" @@ -1478,9 +1427,6 @@ static const char normal_map_frag_glsl[] = " else if (uAlphaTestComparison == 7) ;\n" "#else\n" " gl_FragColor = color;\n" - "#endif //GL_ES\n" - "#else\n" - " gl_FragColor = color;\n" "#endif //ALPHA_TEST_ENABLED\n" "#ifdef FOG_ENABLED\n" " float z = gl_FragCoord.z / gl_FragCoord.w;\n" @@ -1551,10 +1497,8 @@ static const char shadow_map_frag_glsl[] = "#ifdef NEED_TEX_COORD\n" "varying vec2 vTexCoord;\n" "#endif //TEX_COORD\n" - "#ifdef GL_ES\n" "uniform int uAlphaTestComparison;\n" "uniform float uAlphaTestRefValue;\n" - "#endif //GL_ES\n" "#ifdef DIFFUSE\n" "#ifdef DIFFUSE_TEXTURE\n" "uniform sampler2D uTextureDiffuse0;\n" @@ -1588,8 +1532,7 @@ static const char shadow_map_frag_glsl[] = " color = vec4(1);\n" "#endif //DIFFUSE_TEXTURE\n" "#endif //DIFFUSE_TEXTURE_BLEND\n" - " #ifdef GL_ES\n" - "/*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" + " /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" " const float p = 1000000.0;\n" " float acolor = floor(color.a * p);\n" " float refvalue = floor(uAlphaTestRefValue * p);\n" @@ -1625,13 +1568,7 @@ static const char shadow_map_frag_glsl[] = " else discard;\n" " }\n" " else if (uAlphaTestComparison == 7) ;\n" - "#else\n" - " gl_FragColor = color;\n" - "#endif //GL_ES\n" "#endif //ALPHA_TEST_ENABLED\n" - "#ifndef GL_ES\n" - " gl_FragColor.r = gl_FragCoord.z;\n" - "#else\n" " const vec4 pack = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0);\n" " const vec4 mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0);\n" " vec4 depthcolor;\n" @@ -1640,7 +1577,6 @@ static const char shadow_map_frag_glsl[] = " depthcolor = vec4(fract(pack * normdist));\n" " depthcolor -= depthcolor.xxyz * mask;\n" " gl_FragColor = depthcolor;\n" - "#endif\n" "}\n"; static const char color_pick_vert_glsl[] = @@ -1681,10 +1617,8 @@ static const char color_pick_frag_glsl[] = "#else\n" " uniform vec4 uColorPick;\n" "#endif\n" - "#ifdef GL_ES\n" "uniform int uAlphaTestComparison;\n" "uniform float uAlphaTestRefValue;\n" - "#endif //GL_ES\n" "void main()\n" "{\n" " vec4 color;\n" @@ -1694,8 +1628,7 @@ static const char color_pick_frag_glsl[] = " color = uColorPick;\n" "#endif\n" "#ifdef ALPHA_TEST_ENABLED\n" - " #ifdef GL_ES\n" - "/*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" + " /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" " const float p = 1000000.0;\n" " float acolor = floor(color.a * p);\n" " float refvalue = floor(uAlphaTestRefValue * p);\n" @@ -1733,9 +1666,6 @@ static const char color_pick_frag_glsl[] = " else if (uAlphaTestComparison == 7) ;\n" "#else\n" " gl_FragColor = color;\n" - "#endif //GL_ES\n" - "#else\n" - " gl_FragColor = color;\n" "#endif //ALPHA_TEST_ENABLED\n" "}\n"; @@ -1891,9 +1821,7 @@ static const char parallax_occlusion_frag_glsl[] = "uniform sampler2D uShadowMap;\n" "uniform float uShadowsPCFStep;\n" "uniform float uShadowsPCFSize;\n" - "#ifdef GL_ES\n" "uniform float uShadowsConstantBias;\n" - "#endif //GL_ES\n" "float shadow;\n" "float pcf(vec4 lpos)\n" "{\n" @@ -1902,11 +1830,6 @@ static const char parallax_occlusion_frag_glsl[] = " q = floor(uShadowsPCFStep * 2.0);\n" " c = floor(uShadowsPCFStep * uShadowsPCFStep * 4.0);\n" " shadow = 0.0;\n" - "#ifndef GL_ES\n" - " for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0)\n" - " for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0)\n" - " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize).x);\n" - "#else\n" " const vec4 unpack = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0);\n" " for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0)\n" " for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0)\n" @@ -1914,7 +1837,6 @@ static const char parallax_occlusion_frag_glsl[] = " vec4 zvalue = texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize);\n" " shadow += float(smcoord.z < dot(zvalue, unpack) + uShadowsConstantBias);\n" " }\n" - "#endif //GL_ES\n" " return shadow / c;\n" "}\n" "#endif //SHADOWED\n" @@ -1994,10 +1916,8 @@ static const char parallax_occlusion_frag_glsl[] = "#ifdef LIGHT_ATTENUATION\n" "varying float vLightDist;\n" "#endif //LIGHT_ATTENUATION\n" - "#ifdef GL_ES\n" "uniform int uAlphaTestComparison;\n" "uniform float uAlphaTestRefValue;\n" - "#endif //GL_ES\n" "const float parallaxScale = 0.2;\n" "vec2 parallaxMapping(in vec3 view, in vec2 tex, out float parallaxHeight)\n" "{\n" @@ -2147,8 +2067,7 @@ static const char parallax_occlusion_frag_glsl[] = "#endif //SHADOWED\n" " color = fragmentParallaxMap();\n" "#ifdef ALPHA_TEST_ENABLED\n" - " #ifdef GL_ES\n" - "/*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" + " /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n" " const float p = 1000000.0;\n" " float acolor = floor(color.a * p);\n" " float refvalue = floor(uAlphaTestRefValue * p);\n" @@ -2186,9 +2105,6 @@ static const char parallax_occlusion_frag_glsl[] = " else if (uAlphaTestComparison == 7) ;\n" "#else\n" " gl_FragColor = color;\n" - "#endif //GL_ES\n" - "#else\n" - " gl_FragColor = color;\n" "#endif //ALPHA_TEST_ENABLED\n" " \n" "#ifdef FOG_ENABLED\n" diff --git a/src/modules/evas/engines/gl_common/shader_3d/include.shd b/src/modules/evas/engines/gl_common/shader_3d/include.shd index 28a9955..03afe25 100644 --- a/src/modules/evas/engines/gl_common/shader_3d/include.shd +++ b/src/modules/evas/engines/gl_common/shader_3d/include.shd @@ -29,12 +29,9 @@ define(`FRAGMENT_SHADER_USE_FOG', ` uniform float uFogFactor; uniform vec4 uFogColor; #endif //FOG_ENABLED') - -define(`FRAGMENT_SHADER_USE_ALPHA_TEST_GLES', ` -#ifdef GL_ES +define(`FRAGMENT_SHADER_USE_ALPHA_TEST_GLES', uniform int uAlphaTestComparison; -uniform float uAlphaTestRefValue; -#endif //GL_ES') +uniform float uAlphaTestRefValue;) define(`FRAGMENT_SHADER_USE_SHADOWS', ` #ifdef SHADOWED @@ -42,9 +39,7 @@ varying vec4 vLightPosition; uniform sampler2D uShadowMap; uniform float uShadowsPCFStep; uniform float uShadowsPCFSize; -#ifdef GL_ES uniform float uShadowsConstantBias; -#endif //GL_ES float shadow; float pcf(vec4 lpos) { @@ -53,11 +48,6 @@ float pcf(vec4 lpos) q = floor(uShadowsPCFStep * 2.0); c = floor(uShadowsPCFStep * uShadowsPCFStep * 4.0); shadow = 0.0; -#ifndef GL_ES - for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0) - for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0) - shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize).x); -#else const vec4 unpack = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1.0); for (i = -uShadowsPCFStep; i < uShadowsPCFStep; i += 1.0) for (j = -uShadowsPCFStep; j < uShadowsPCFStep; j += 1.0) @@ -65,7 +55,6 @@ float pcf(vec4 lpos) vec4 zvalue = texture2D(uShadowMap, smcoord.xy + vec2(i / q, j / q) * uShadowsPCFSize); shadow += float(smcoord.z < dot(zvalue, unpack) + uShadowsConstantBias); } -#endif //GL_ES return shadow / c; } #endif //SHADOWED') @@ -130,7 +119,6 @@ FRAGMENT_SHADER_USE_TEXTURE(DIFFUSE, Diffuse) `#endif //DIFFUSE') define(`FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY', -`#ifdef GL_ES' /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/ const float p = 1000000.0; float acolor = floor($1.a * p); @@ -166,10 +154,7 @@ define(`FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY', if (acolor >= refvalue) gl_FragColor = $1; else discard; } - else if (uAlphaTestComparison == 7) ; -`#else' - gl_FragColor = $1; -`#endif //GL_ES') + else if (uAlphaTestComparison == 7) ;) define(`VERTEX_SHADER_NEED_TEX_COORD', diff --git a/src/modules/evas/engines/gl_common/shader_3d/shadow_map_frag.shd b/src/modules/evas/engines/gl_common/shader_3d/shadow_map_frag.shd index bdb16e5..c464730 100644 --- a/src/modules/evas/engines/gl_common/shader_3d/shadow_map_frag.shd +++ b/src/modules/evas/engines/gl_common/shader_3d/shadow_map_frag.shd @@ -50,9 +50,7 @@ void main() { FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(color) #endif //ALPHA_TEST_ENABLED -#ifndef GL_ES - gl_FragColor.r = gl_FragCoord.z; -#else + const vec4 pack = vec4(256.0 * 256.0 * 256.0, 256.0 * 256.0, 256.0, 1.0); const vec4 mask = vec4(0.0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); vec4 depthcolor; @@ -61,5 +59,4 @@ void main() { depthcolor = vec4(fract(pack * normdist)); depthcolor -= depthcolor.xxyz * mask; gl_FragColor = depthcolor; -#endif } -- 2.7.4