diff --git a/src/examples/evas/Makefile.am b/src/examples/evas/Makefile.am index 98a4a7f831..5e27afa438 100644 --- a/src/examples/evas/Makefile.am +++ b/src/examples/evas/Makefile.am @@ -338,6 +338,8 @@ resources/images/wood.jpg \ resources/images/rocks.jpg \ resources/images/four_NM_height.tga \ resources/images/rocks_NM_height.tga \ +resources/images/grid.png \ +resources/images/grid_n.png \ resources/models/mesh_for_mmap.eet \ resources/models/mesh_for_mmap.md2 \ resources/models/mesh_for_mmap.obj \ diff --git a/src/examples/evas/evas-3d-shadows.c b/src/examples/evas/evas-3d-shadows.c index f58e8b8a7d..d53f435127 100644 --- a/src/examples/evas/evas-3d-shadows.c +++ b/src/examples/evas/evas-3d-shadows.c @@ -6,7 +6,7 @@ * @see evas_3d_object_callback_register * * @verbatim - * gcc -o gcc -o evas-3d-shadows evas-3d-shadows.c evas-3d-primitives.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo eina` -lm + * gcc -o evas-3d-shadows evas-3d-shadows.c evas-3d-primitives.c `pkg-config --libs --cflags efl evas ecore ecore-evas eo eina` -lm * @endverbatim */ @@ -37,8 +37,9 @@ #define SPECULAR_LIGHT 1.0, 1.0, 1.0 static const char *model_path = PACKAGE_EXAMPLES_DIR EVAS_MODEL_FOLDER "/sonic.md2"; -static const char *image_path = PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/sonic.png"; + static const vec2 tex_scale = {1, 1}; +static const vec2 fence_tex_scale = {80, 6}; Ecore_Evas *ecore_evas = NULL; Evas *evas = NULL; @@ -46,30 +47,6 @@ Eo *background = NULL; Eo *image = NULL; Evas_3D_Node *choosed_node = NULL; -typedef struct _Body_3D -{ - Eo *material; - Eo *mesh; - Eo *node; -} Body_3D; - -typedef struct _Scene_Data -{ - Eo *scene; - Eo *root_node; - Eo *camera_node; - Eo *camera; - Eo *light_node; - Eo *light; - - Body_3D sphere; - Body_3D cube; - Body_3D square; - Body_3D cylinder; - Body_3D model; - Body_3D cone; -} Scene_Data; - Eina_Bool _cb_clicked(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Description *desc EINA_UNUSED, void *event_info) { @@ -107,6 +84,31 @@ _cb_collision(void *data EINA_UNUSED, Eo *obj EINA_UNUSED, const Eo_Event_Descri return EINA_TRUE; } +typedef struct _Body_3D +{ + Eo *material; + Eo *mesh; + Eo *node; +} Body_3D; + +typedef struct _Scene_Data +{ + Eo *scene; + Eo *root_node; + Eo *camera_node; + Eo *camera; + Eo *light_node; + Eo *light; + + Body_3D sphere; + Body_3D cube; + Body_3D square; + Body_3D cylinder; + Body_3D model; + Body_3D cone; + Body_3D fence; +} Scene_Data; + static void _show_help() { @@ -211,6 +213,51 @@ _cylinder_setup(Body_3D *cylinder) evas_3d_node_position_set(-2.0, 3.0, 1.0)); } +static void +_fence_setup(Body_3D *fence) +{ + + Eo *texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas); + eo_do(texture, + evas_3d_texture_file_set(PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/grid.png", NULL), + evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, + EVAS_3D_TEXTURE_FILTER_NEAREST), + evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, + EVAS_3D_WRAP_MODE_REPEAT)); + Eo *texture1 = eo_add(EVAS_3D_TEXTURE_CLASS, evas); + eo_do(texture1, + evas_3d_texture_file_set(PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/grid_n.png", NULL), + evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, + EVAS_3D_TEXTURE_FILTER_NEAREST), + evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, + EVAS_3D_WRAP_MODE_REPEAT)); + fence->material = eo_add(EVAS_3D_MATERIAL_CLASS, evas); + + eo_do(fence->material, + evas_3d_material_texture_set(EVAS_3D_MATERIAL_DIFFUSE, texture), + evas_3d_material_texture_set(EVAS_3D_MATERIAL_AMBIENT, texture), + evas_3d_material_enable_set(EVAS_3D_MATERIAL_AMBIENT, EINA_TRUE), + evas_3d_material_enable_set(EVAS_3D_MATERIAL_DIFFUSE, EINA_TRUE), + evas_3d_material_enable_set(EVAS_3D_MATERIAL_SPECULAR, EINA_TRUE), + evas_3d_material_enable_set(EVAS_3D_MATERIAL_NORMAL, EINA_TRUE), + evas_3d_material_texture_set(EVAS_3D_MATERIAL_NORMAL, texture1), + evas_3d_material_shininess_set(100.0)); + fence->mesh = eo_add(EVAS_3D_MESH_CLASS, evas); + evas_3d_add_cylinder_frame(fence->mesh, 0, 50, fence_tex_scale); + + eo_do(fence->mesh, + evas_3d_mesh_frame_material_set(0, fence->material), + evas_3d_mesh_alpha_func_set(EVAS_3D_COMPARISON_GREATER, 0), + evas_3d_mesh_alpha_test_enable_set(EINA_TRUE), + evas_3d_mesh_shade_mode_set(EVAS_3D_SHADE_MODE_NORMAL_MAP)); + fence->node = + eo_add(EVAS_3D_NODE_CLASS, evas, + evas_3d_node_constructor(EVAS_3D_NODE_TYPE_MESH)); + eo_do(fence->node, evas_3d_node_mesh_add(fence->mesh), + evas_3d_node_scale_set(7.0, 3.0, 7.0), + evas_3d_node_position_set(0.0, 0.5, -5.0)); +} + static void _square_setup(Body_3D *square) { @@ -247,7 +294,7 @@ _model_setup(Body_3D *model) { Eo *texture = eo_add(EVAS_3D_TEXTURE_CLASS, evas); eo_do(texture, - evas_3d_texture_file_set(image_path, NULL), + evas_3d_texture_file_set(PACKAGE_EXAMPLES_DIR EVAS_IMAGE_FOLDER "/sonic.png", NULL), evas_3d_texture_filter_set(EVAS_3D_TEXTURE_FILTER_NEAREST, EVAS_3D_TEXTURE_FILTER_NEAREST), evas_3d_texture_wrap_set(EVAS_3D_WRAP_MODE_REPEAT, @@ -307,7 +354,8 @@ _light_setup(Scene_Data *data) evas_3d_light_ambient_set(AMBIENT_LIGHT, 1.0), evas_3d_light_diffuse_set(DIFFUSE_LIGHT, 1.0), evas_3d_light_specular_set(SPECULAR_LIGHT, 1.0), - evas_3d_light_projection_perspective_set(45.0, 1.0, 2.0, 1000.0)); + evas_3d_light_spot_cutoff_set(20), + evas_3d_light_projection_perspective_set(40.0, 1.0, 2.0, 1000.0)); data->light_node = eo_add(EVAS_3D_NODE_CLASS, evas, @@ -315,7 +363,7 @@ _light_setup(Scene_Data *data) eo_do(data->light_node, evas_3d_node_light_set(data->light), evas_3d_node_position_set(50.0, 50.0, 20.0), - evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 0.0, 0.0, 20.0, + evas_3d_node_look_at_set(EVAS_3D_SPACE_PARENT, 15.0, 0.0, -5.0, EVAS_3D_SPACE_PARENT, 0.0, 0.0, 1.0)); eo_do(data->root_node, evas_3d_node_member_add(data->light_node)); } @@ -343,13 +391,16 @@ _scene_setup(Scene_Data *data) _square_setup(&data->square); _model_setup(&data->model); _cone_setup(&data->cone); + _fence_setup(&data->fence); - eo_do(data->root_node, evas_3d_node_member_add(data->sphere.node)); - eo_do(data->root_node, evas_3d_node_member_add(data->cube.node)); - eo_do(data->root_node, evas_3d_node_member_add(data->cylinder.node)); - eo_do(data->root_node, evas_3d_node_member_add(data->square.node)); - eo_do(data->root_node, evas_3d_node_member_add(data->model.node)); - eo_do(data->root_node, evas_3d_node_member_add(data->cone.node)); + eo_do(data->root_node, + evas_3d_node_member_add(data->sphere.node), + evas_3d_node_member_add(data->cube.node), + evas_3d_node_member_add(data->cylinder.node), + evas_3d_node_member_add(data->square.node), + evas_3d_node_member_add(data->model.node), + evas_3d_node_member_add(data->cone.node), + evas_3d_node_member_add(data->fence.node)); eo_do(data->scene, evas_3d_scene_root_node_set(data->root_node), diff --git a/src/examples/evas/resources/images/grid.png b/src/examples/evas/resources/images/grid.png new file mode 100644 index 0000000000..60d103629d Binary files /dev/null and b/src/examples/evas/resources/images/grid.png differ diff --git a/src/examples/evas/resources/images/grid_n.png b/src/examples/evas/resources/images/grid_n.png new file mode 100644 index 0000000000..7b9236ef30 Binary files /dev/null and b/src/examples/evas/resources/images/grid_n.png differ diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index f82dbed26d..34ab6a486b 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h @@ -488,6 +488,7 @@ typedef enum _Evas_3D_State EVAS_3D_STATE_MESH_SHADE_MODE, EVAS_3D_STATE_MESH_FOG, EVAS_3D_STATE_MESH_BLENDING, + EVAS_3D_STATE_MESH_ALPHA_TEST, EVAS_3D_STATE_MESH_COLOR_PICK, EVAS_3D_STATE_CAMERA_PROJECTION = 1, @@ -669,6 +670,32 @@ typedef enum _Evas_3D_Blend_Func EVAS_3D_BLEND_SRC_ALPHA_SATURATE, } Evas_3D_Blend_Func; +/** + * Comparsion functions for testing(alpha, depth, stencil) in fragment shader. + * + * @since 1.14 + * @ingroup Evas_3D_Types + */ +typedef enum _Evas_3D_Comparison +{ + /**< Never passes.*/ + EVAS_3D_COMPARISON_NEVER, + /**< Passes if the incoming value is less than the reference value.*/ + EVAS_3D_COMPARISON_LESS, + /**< Passes if the incoming value is equal to the reference value.*/ + EVAS_3D_COMPARISON_EQUAL, + /**< Passes if the incoming value is less than or equal to the reference value.*/ + EVAS_3D_COMPARISON_LEQUAL, + /**< Passes if the incoming value is greater than the reference value.*/ + EVAS_3D_COMPARISON_GREATER, + /**< Passes if the incoming value is not equal to the reference value.*/ + EVAS_3D_COMPARISON_NOTEQUAL, + /**< Passes if the incoming value is greater than or equal to the reference value.*/ + EVAS_3D_COMPARISON_GEQUAL, + /**< Always passes (initial value).*/ + EVAS_3D_COMPARISON_ALWAYS, +} Evas_3D_Comparison; + /** * Color formats of pixel data * diff --git a/src/lib/evas/canvas/evas_3d_mesh.c b/src/lib/evas/canvas/evas_3d_mesh.c index 5e6253f7d3..52a71f2d66 100644 --- a/src/lib/evas/canvas/evas_3d_mesh.c +++ b/src/lib/evas/canvas/evas_3d_mesh.c @@ -121,6 +121,10 @@ _mesh_init(Evas_3D_Mesh_Data *pd) pd->blend_dfactor = EVAS_3D_BLEND_ZERO; pd->blending = EINA_FALSE; + pd->alpha_comparison = EVAS_3D_COMPARISON_ALWAYS; + pd->alpha_ref_value = 0.0f; + pd->alpha_test_enabled = EINA_FALSE; + pd->color_pick_key = -1.0; pd->color_pick_enabled = EINA_FALSE; } @@ -803,6 +807,39 @@ _evas_3d_mesh_blending_func_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, if (dfactor) *dfactor = pd->blend_dfactor; } +EOLIAN static void +_evas_3d_mesh_alpha_func_set(Eo *obj, Evas_3D_Mesh_Data *pd, Evas_3D_Comparison comparison, + Evas_Real ref_value) +{ + if (pd->alpha_comparison == comparison && pd->alpha_ref_value == ref_value) + return; + pd->alpha_comparison = comparison; + pd->alpha_ref_value = ref_value; + eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_MESH_ALPHA_TEST, NULL)); +} + +EOLIAN static void +_evas_3d_mesh_alpha_func_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd, + Evas_3D_Comparison *comparison, + Evas_Real *ref_value) +{ + if (comparison) *comparison = pd->alpha_comparison; + if (ref_value) *ref_value = pd->alpha_ref_value; +} + +EOLIAN static void +_evas_3d_mesh_alpha_test_enable_set(Eo *obj, Evas_3D_Mesh_Data *pd, Eina_Bool enabled) +{ + pd->alpha_test_enabled = enabled; + eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_MESH_ALPHA_TEST, NULL)); +} + +EOLIAN static Eina_Bool +_evas_3d_mesh_alpha_test_enable_get(Eo *obj EINA_UNUSED, Evas_3D_Mesh_Data *pd) +{ + return pd->alpha_test_enabled; +} + EOLIAN static void _evas_3d_mesh_mmap_set(Eo *obj, Evas_3D_Mesh_Data *pd, Eina_File *file, const char *key EINA_UNUSED) diff --git a/src/lib/evas/canvas/evas_3d_mesh.eo b/src/lib/evas/canvas/evas_3d_mesh.eo index 7965cd647d..784f91a257 100644 --- a/src/lib/evas/canvas/evas_3d_mesh.eo +++ b/src/lib/evas/canvas/evas_3d_mesh.eo @@ -402,6 +402,56 @@ class Evas_3D_Mesh (Evas_3D_Object, Evas.Common_Interface, Efl.File) Eina_Bool enabled; /*@ Fog enabled status.*/ } } + + alpha_test_enable { + set { + /** + * Get the enable status of alpha test for given mesh + * + * Default alpha test disabled. + * + * @ingroup Evas_3D_Mesh + */ + } + get { + /** + * Get the enable status of alpha test for given mesh + * + * @see alpha_test_enable_set() + * + * @ingroup Evas_3D_Mesh + */ + } + values { + Eina_Bool enabled; /*@ Alpha test status.*/ + } + } + + alpha_func { + set { + /* + * The alpha test discards fragments depending on the outcome of a comparison + * between an incoming fragment's alpha value and a constant reference value + * This func specifies the reference value and the comparison function. + * + * @ingroup Evas_3D_Mesh + */ + } + get { + /* + * Get the reference value and the comparison function for alpha testing + * + * @see eavs_3d_mesh_alpha_test_param_set() + * + * @ingroup Evas_3D_Mesh + */ + } + values { + Evas_3D_Comparison comparison_func; /*@ Specifies the alpha comparison function.*/ + Evas_Real ref_value; /*@ Specifies the reference value that incoming alpha values are compared to.*/ + } + } + blending_enable { set { /** diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index 7471ae6a42..a3f06e1dae 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -344,6 +344,10 @@ struct _Evas_3D_Mesh Evas_3D_Blend_Func blend_sfactor; Evas_3D_Blend_Func blend_dfactor; + Evas_3D_Comparison alpha_comparison; + Evas_Real alpha_ref_value; + Eina_Bool alpha_test_enabled :1; + Evas_Color fog_color; Eina_Bool fog_enabled :1; 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 9e7dfd02f8..6ee269721f 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d.c +++ b/src/modules/evas/engines/gl_common/evas_gl_3d.c @@ -1142,6 +1142,8 @@ _mesh_draw_data_build(E3D_Draw_Data *data, data->flags |= E3D_SHADER_FLAG_FOG_ENABLED; data->fog_color = pdmesh->fog_color; } + if (pdmesh->alpha_test_enabled) + data->flags |= E3D_SHADER_FLAG_ALPHA_TEST_ENABLED; if (pdmesh->shadowed) data->flags |= E3D_SHADER_FLAG_SHADOWED; @@ -1149,6 +1151,10 @@ _mesh_draw_data_build(E3D_Draw_Data *data, if (pdmesh->color_pick_enabled) data->color_pick_key = pdmesh->color_pick_key; + data->alpha_comparison = pdmesh->alpha_comparison; + data->alpha_ref_value = pdmesh->alpha_ref_value; + data->alpha_test_enabled =pdmesh->alpha_test_enabled; + data->blending = pdmesh->blending; data->blend_sfactor = pdmesh->blend_sfactor; data->blend_dfactor = pdmesh->blend_dfactor; @@ -1184,6 +1190,13 @@ _mesh_draw_data_build(E3D_Draw_Data *data, else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_SHADOW_MAP_RENDER) { BUILD(vertex_attrib, VERTEX_POSITION, EINA_TRUE); + if (pdmesh->alpha_test_enabled) + { + BUILD(material_texture, MATERIAL_DIFFUSE, EINA_FALSE); + + if (_flags_need_tex_coord(data->flags)) + BUILD(vertex_attrib, VERTEX_TEXCOORD, EINA_FALSE); + } } else if (pdmesh->shade_mode == EVAS_3D_SHADE_MODE_COLOR_PICK) { 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 78ddc429f0..948ec7ba37 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 @@ -37,8 +37,9 @@ typedef unsigned long E3D_Shader_Flag; #define E3D_SHADER_FLAG_EMISSION_TEXTURE_BLEND (1 << 26) #define E3D_SHADER_FLAG_NORMAL_TEXTURE_BLEND (1 << 27) #define E3D_SHADER_FLAG_FOG_ENABLED (1 << 28) -#define E3D_SHADER_FLAG_SHADOWED (1 << 29) -#define E3D_SHADER_FLAG_COUNT 30 +#define E3D_SHADER_FLAG_ALPHA_TEST_ENABLED (1 << 29) +#define E3D_SHADER_FLAG_SHADOWED (1 << 30) +#define E3D_SHADER_FLAG_COUNT 31 static inline Eina_Bool _flags_need_tex_coord(E3D_Shader_Flag flags) @@ -90,6 +91,10 @@ struct _E3D_Draw_Data Evas_3D_Blend_Func blend_dfactor; Eina_Bool blending : 1; + Evas_3D_Comparison alpha_comparison; + Evas_Real alpha_ref_value; + Eina_Bool alpha_test_enabled :1; + struct { Evas_Vec4 position; Evas_Vec3 spot_dir; diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d_renderer.c b/src/modules/evas/engines/gl_common/evas_gl_3d_renderer.c index f5228819fb..0c8410e08f 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d_renderer.c +++ b/src/modules/evas/engines/gl_common/evas_gl_3d_renderer.c @@ -82,6 +82,32 @@ _gl_blend_func_get(Evas_3D_Blend_Func blend_func) } } +static inline GLenum +_gl_comparison_func_get(Evas_3D_Comparison comparison_func) +{ + switch (comparison_func) + { + case EVAS_3D_COMPARISON_NEVER: + return GL_NEVER; + case EVAS_3D_COMPARISON_LESS: + return GL_LESS; + case EVAS_3D_COMPARISON_EQUAL: + return GL_EQUAL; + case EVAS_3D_COMPARISON_LEQUAL: + return GL_LEQUAL; + case EVAS_3D_COMPARISON_GREATER: + return GL_GREATER; + case EVAS_3D_COMPARISON_NOTEQUAL: + return GL_NOTEQUAL; + case EVAS_3D_COMPARISON_GEQUAL: + return GL_GEQUAL; + case EVAS_3D_COMPARISON_ALWAYS: + return GL_ALWAYS; + default: + return GL_ALWAYS; + } +} + static inline void _renderer_vertex_attrib_array_enable(E3D_Renderer *renderer, int index) { @@ -284,7 +310,6 @@ e3d_renderer_draw(E3D_Renderer *renderer, E3D_Draw_Data *data) _renderer_program_use(renderer, program); e3d_program_uniform_upload(program, data); - if (data->mode != EVAS_3D_SHADE_MODE_SHADOW_MAP_RENDER) _renderer_texture_bind(renderer, data); /* Set up vertex attrib pointers. */ @@ -323,6 +348,14 @@ e3d_renderer_draw(E3D_Renderer *renderer, E3D_Draw_Data *data) } else glDisable(GL_BLEND); + if (data->alpha_test_enabled) + { + glEnable(GL_ALPHA_TEST); + glAlphaFunc(_gl_comparison_func_get(data->alpha_comparison), + (GLclampf)data->alpha_ref_value); + } + else glDisable(GL_ALPHA_TEST); + if (data->indices) { _renderer_elements_draw(renderer, data->assembly, data->index_count, 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 4f8fcedbc7..9d858aa54b 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 @@ -86,6 +86,7 @@ static const char *shader_flag_names[] = "EMISSION_TEXTURE_BLEND", "NORMAL_TEXTURE_BLEND", "FOG_ENABLED", + "ALPHA_TEST_ENABLED", "SHADOWED" }; 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 cae8825e39..12476733e6 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 @@ -1055,6 +1055,18 @@ static const char const shadow_map_vert_glsl[] = "attribute vec4 aPosition1;\n" "uniform float uPositionWeight;\n" "#endif //VERTEX_POSITION_BLEND\n" + "#ifdef ALPHA_TEST_ENABLED\n" + "#ifdef VERTEX_TEXCOORD\n" + "attribute vec4 aTexCoord0;\n" + "#endif //VERTEX_TEXCOORD\n" + "#ifdef VERTEX_TEXCOORD_BLEND\n" + "attribute vec4 aTexCoord1;\n" + "uniform float uTexCoordWeight;\n" + "#endif //VERTEX_TEXCOORD_BLEND\n" + "#ifdef NEED_TEX_COORD\n" + "varying vec2 vTexCoord;\n" + "#endif //TEX_COORD\n" + "#endif //ALPHA_TEST_ENABLED\n" "void main()\n" "{\n" "#ifdef VERTEX_POSITION_BLEND\n" @@ -1066,12 +1078,48 @@ static const char const shadow_map_vert_glsl[] = " vec4 position = vec4(aPosition0.xyz, 1.0);\n" "#endif // VERTEX_POSITION\n" "#endif //VERTEX_POSITION_BLEND\n" + "#ifdef ALPHA_TEST_ENABLED\n" + "#ifdef VERTEX_TEXCOORD_BLEND\n" + " vTexCoord = aTexCoord0.st * uTexCoordWeight +\n" + " aTexCoord1.st * (1.0 - uTexCoordWeight);\n" + "#else\n" + "#ifdef VERTEX_TEXCOORD\n" + " vTexCoord = aTexCoord0.st;\n" + "#endif //VERTEX_TEXCOORD\n" + "#endif //VERTEX_TEXCOORD_BLEND\n" + "#endif //ALPHA_TEST_ENABLED\n" " gl_Position = uMatrixMvp * position;\n" "}\n"; static const char const shadow_map_frag_glsl[] = - "void main()\n" - "{\n" + "#ifdef ALPHA_TEST_ENABLED\n" + "#ifdef NEED_TEX_COORD\n" + "varying vec2 vTexCoord;\n" + "#endif //TEX_COORD\n" + "#ifdef DIFFUSE\n" + "#ifdef DIFFUSE_TEXTURE\n" + "uniform sampler2D uTextureDiffuse0;\n" + "#endif //DIFFUSE_TEXTURE\n" + "#ifdef DIFFUSE_TEXTURE_BLEND\n" + "uniform sampler2D uTextureDiffuse1;\n" + "uniform float uTextureDiffuseWeight;\n" + "#endif //DIFFUSE_TEXTURE_BLEND\n" + "#endif //DIFFUSE\n" + "#endif //ALPHA_TEST_ENABLED\n" + "void main() {\n" + "#ifdef ALPHA_TEST_ENABLED\n" + "#ifdef DIFFUSE_TEXTURE_BLEND\n" + " gl_FragColor = (texture2D(uTextureDiffuse0, vTexCoord) *\n" + " uTextureDiffuseWeight + texture2D(uTextureDiffuse1, vTexCoord) *\n" + " (1.0 - uTextureDiffuseWeight));\n" + "#else\n" + "#ifdef DIFFUSE_TEXTURE\n" + " gl_FragColor = texture2D(uTextureDiffuse0, vTexCoord) ;\n" + "#else\n" + " gl_FragColor = vec4(1);\n" + "#endif //DIFFUSE_TEXTURE\n" + "#endif //DIFFUSE_TEXTURE_BLEND\n" + "#endif //ALPHA_TEST_ENABLED\n" " gl_FragColor.r = gl_FragCoord.z;\n" "}\n"; 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 84a586ac7b..6bfbcc7104 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 @@ -1,4 +1,43 @@ -void main() -{ +#ifdef ALPHA_TEST_ENABLED + +#ifdef NEED_TEX_COORD +varying vec2 vTexCoord; +#endif //TEX_COORD + +#ifdef DIFFUSE + +#ifdef DIFFUSE_TEXTURE +uniform sampler2D uTextureDiffuse0; +#endif //DIFFUSE_TEXTURE + +#ifdef DIFFUSE_TEXTURE_BLEND +uniform sampler2D uTextureDiffuse1; +uniform float uTextureDiffuseWeight; +#endif //DIFFUSE_TEXTURE_BLEND + +#endif //DIFFUSE + +#endif //ALPHA_TEST_ENABLED + +void main() { + +#ifdef ALPHA_TEST_ENABLED + +#ifdef DIFFUSE_TEXTURE_BLEND + gl_FragColor = (texture2D(uTextureDiffuse0, vTexCoord) * + uTextureDiffuseWeight + texture2D(uTextureDiffuse1, vTexCoord) * + (1.0 - uTextureDiffuseWeight)); +#else + +#ifdef DIFFUSE_TEXTURE + gl_FragColor = texture2D(uTextureDiffuse0, vTexCoord) ; +#else + gl_FragColor = vec4(1); +#endif //DIFFUSE_TEXTURE + +#endif //DIFFUSE_TEXTURE_BLEND + +#endif //ALPHA_TEST_ENABLED + gl_FragColor.r = gl_FragCoord.z; } diff --git a/src/modules/evas/engines/gl_common/shader_3d/shadow_map_vert.shd b/src/modules/evas/engines/gl_common/shader_3d/shadow_map_vert.shd index 3f12a69b2b..be92999e7b 100644 --- a/src/modules/evas/engines/gl_common/shader_3d/shadow_map_vert.shd +++ b/src/modules/evas/engines/gl_common/shader_3d/shadow_map_vert.shd @@ -9,6 +9,23 @@ attribute vec4 aPosition1; uniform float uPositionWeight; #endif //VERTEX_POSITION_BLEND +#ifdef ALPHA_TEST_ENABLED + +#ifdef VERTEX_TEXCOORD +attribute vec4 aTexCoord0; +#endif //VERTEX_TEXCOORD + +#ifdef VERTEX_TEXCOORD_BLEND +attribute vec4 aTexCoord1; +uniform float uTexCoordWeight; +#endif //VERTEX_TEXCOORD_BLEND + +#ifdef NEED_TEX_COORD +varying vec2 vTexCoord; +#endif //TEX_COORD + +#endif //ALPHA_TEST_ENABLED + void main() { @@ -24,5 +41,20 @@ void main() #endif //VERTEX_POSITION_BLEND +#ifdef ALPHA_TEST_ENABLED + +#ifdef VERTEX_TEXCOORD_BLEND + vTexCoord = aTexCoord0.st * uTexCoordWeight + + aTexCoord1.st * (1.0 - uTexCoordWeight); +#else + +#ifdef VERTEX_TEXCOORD + vTexCoord = aTexCoord0.st; +#endif //VERTEX_TEXCOORD + +#endif //VERTEX_TEXCOORD_BLEND + +#endif //ALPHA_TEST_ENABLED + gl_Position = uMatrixMvp * position; }