forked from enlightenment/efl
evas: unification of color pick mechanism.
Summary: Use same way using color pick under GLES and not: Use GL_RGBA texture insted of GL_RED Generate and pass to engine 3 components color of mesh See T2761 Reviewers: cedric, Hermet Subscribers: cedric Differential Revision: https://phab.enlightenment.org/D3135 Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
This commit is contained in:
parent
fb75f6df5a
commit
3af65dd4e2
|
@ -124,14 +124,12 @@ _mesh_init(Evas_Canvas3D_Mesh_Data *pd)
|
|||
pd->alpha_comparison = EVAS_CANVAS3D_COMPARISON_ALWAYS;
|
||||
pd->alpha_ref_value = 0.0f;
|
||||
pd->alpha_test_enabled = EINA_FALSE;
|
||||
#ifndef GL_GLES
|
||||
pd->color_pick_key = -1.0;
|
||||
#else
|
||||
|
||||
pd->color_pick_key.r = 0.0;
|
||||
pd->color_pick_key.g = 0.0;
|
||||
pd->color_pick_key.b = 0.0;
|
||||
#endif
|
||||
pd->color_pick_enabled = EINA_FALSE;
|
||||
|
||||
pd->shadows_edges_filtering_level = 4;
|
||||
pd->shadows_edges_size = 300.0;
|
||||
pd->shadows_constant_bias = 0.00015;
|
||||
|
|
|
@ -14,26 +14,6 @@ static Eina_Stringshare *
|
|||
_generate_unic_color_key(Evas_Color *color, Evas_Color *bg_color, Evas_Canvas3D_Node *node, Evas_Canvas3D_Mesh *mesh,
|
||||
Eina_Bool init)
|
||||
{
|
||||
#ifndef GL_GLES
|
||||
static unsigned short red = USHRT_MAX;
|
||||
|
||||
if (init) red = USHRT_MAX;
|
||||
|
||||
if (fabs(bg_color->r - (double)red) <= DBL_EPSILON) red--;
|
||||
|
||||
color->r = (double)red / USHRT_MAX;
|
||||
color->g = 0.0;
|
||||
color->b = 0.0;
|
||||
|
||||
red--;
|
||||
|
||||
if (red == 0)
|
||||
{
|
||||
ERR("Overfill number of color. %d %s", __LINE__, __FILE__);
|
||||
red = USHRT_MAX;
|
||||
}
|
||||
|
||||
#else
|
||||
static unsigned char red = 0;
|
||||
static unsigned char green = 0;
|
||||
static unsigned char blue = 0;
|
||||
|
@ -72,7 +52,7 @@ _generate_unic_color_key(Evas_Color *color, Evas_Color *bg_color, Evas_Canvas3D_
|
|||
color->b = (double)blue / 255;
|
||||
|
||||
#undef GET_NEXT_COLOR
|
||||
#endif
|
||||
|
||||
return eina_stringshare_printf("%p %p", node, mesh);
|
||||
}
|
||||
|
||||
|
|
|
@ -384,11 +384,7 @@ struct _Evas_Canvas3D_Mesh
|
|||
|
||||
Evas_Color fog_color;
|
||||
Eina_Bool fog_enabled :1;
|
||||
#ifndef GL_GLES
|
||||
double color_pick_key;
|
||||
#else
|
||||
Evas_Color color_pick_key;
|
||||
#endif
|
||||
Eina_Bool color_pick_enabled :1;
|
||||
/*sets of the quality and offsets for shadow rendering*/
|
||||
int shadows_edges_filtering_level;
|
||||
|
|
|
@ -305,11 +305,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_REPEAT);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
#ifndef GL_GLES
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_R16, w, h, 0, GL_RED, GL_UNSIGNED_SHORT, 0);
|
||||
#else
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, w, h, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL);
|
||||
#endif
|
||||
|
||||
glGenFramebuffers(1, &fbo);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
|
||||
|
@ -1345,13 +1341,9 @@ e3d_drawable_scene_render_to_texture(E3D_Drawable *drawable, E3D_Renderer *rende
|
|||
unic_color = (Evas_Color *)eina_hash_find(data->node_mesh_colors, tmp);
|
||||
if (unic_color)
|
||||
{
|
||||
#ifndef GL_GLES
|
||||
pdmesh->color_pick_key = unic_color->r;
|
||||
#else
|
||||
pdmesh->color_pick_key.r = unic_color->r;
|
||||
pdmesh->color_pick_key.g = unic_color->g;
|
||||
pdmesh->color_pick_key.b = unic_color->b;
|
||||
#endif
|
||||
shade_mode = pdmesh->shade_mode;
|
||||
pdmesh->shade_mode = EVAS_CANVAS3D_SHADE_MODE_COLOR_PICK;
|
||||
_mesh_draw(renderer, nm->mesh, nm->frame, NULL, matrix_eye, &matrix_mv,
|
||||
|
@ -1377,17 +1369,12 @@ e3d_drawable_texture_pixel_color_get(GLuint tex EINA_UNUSED, int x, int y,
|
|||
E3D_Drawable *d = (E3D_Drawable *)drawable;
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, d->color_pick_fb_id);
|
||||
#ifndef GL_GLES
|
||||
GLuint pixel = 0;
|
||||
glReadPixels(x, y, 1, 1, GL_RED, GL_UNSIGNED_SHORT, &pixel);
|
||||
color->r = (double)pixel / USHRT_MAX;
|
||||
#else
|
||||
|
||||
GLubyte pixel[4] = {0, 0, 0, 0};
|
||||
glReadPixels(x, y, 1, 1, GL_RGBA, GL_UNSIGNED_BYTE, pixel);
|
||||
color->r = (double)pixel[0] / 255;
|
||||
color->g = (double)pixel[1] / 255;
|
||||
color->b = (double)pixel[2] / 255;
|
||||
#endif
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, d->fbo);
|
||||
}
|
||||
|
|
|
@ -106,11 +106,7 @@ struct _E3D_Draw_Data
|
|||
Evas_Color specular;
|
||||
} light;
|
||||
Evas_Color fog_color;
|
||||
#ifndef GL_GLES
|
||||
double color_pick_key;
|
||||
#else
|
||||
Evas_Color color_pick_key;
|
||||
#endif
|
||||
/*Sets of the quality of shadow rendering*/
|
||||
Evas_Real pcf_step;
|
||||
Evas_Real pcf_size;
|
||||
|
|
|
@ -619,16 +619,10 @@ _uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data)
|
|||
case E3D_UNIFORM_FOG_COLOR:
|
||||
glUniform4f(loc, data->fog_color.r, data->fog_color.g, data->fog_color.b, 1);
|
||||
break;
|
||||
#ifndef GL_GLES
|
||||
case E3D_UNIFORM_COLOR_PICK:
|
||||
glUniform1f(loc, data->color_pick_key);
|
||||
break;
|
||||
#else
|
||||
case E3D_UNIFORM_COLOR_PICK:
|
||||
glUniform4f(loc, data->color_pick_key.r, data->color_pick_key.g,
|
||||
data->color_pick_key.b, 1.0);
|
||||
break;
|
||||
#endif
|
||||
case E3D_UNIFORM_ALPHATEST_COMPARISON:
|
||||
glUniform1i(loc,
|
||||
(data->alpha_comparison ? data->alpha_comparison : EVAS_CANVAS3D_COMPARISON_GREATER));
|
||||
|
|
|
@ -1,19 +1,10 @@
|
|||
#ifndef GL_ES
|
||||
uniform float uColorPick;
|
||||
#else
|
||||
uniform vec4 uColorPick;
|
||||
#endif
|
||||
uniform vec4 uColorPick;
|
||||
|
||||
FRAGMENT_SHADER_USE_ALPHA_TEST_GLES
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color;
|
||||
|
||||
#ifndef GL_ES
|
||||
color = vec4(uColorPick);
|
||||
#else
|
||||
color = uColorPick;
|
||||
#endif
|
||||
vec4 color = uColorPick;
|
||||
|
||||
#ifdef ALPHA_TEST_ENABLED
|
||||
FRAGMENT_SHADER_ALPHA_TEST_GLES_APPLY(color)
|
||||
|
|
|
@ -1612,21 +1612,12 @@ static const char color_pick_frag_glsl[] =
|
|||
"precision mediump int;\n"
|
||||
"precision lowp sampler2D;\n"
|
||||
"#endif\n"
|
||||
"#ifndef GL_ES\n"
|
||||
" uniform float uColorPick;\n"
|
||||
"#else\n"
|
||||
" uniform vec4 uColorPick;\n"
|
||||
"#endif\n"
|
||||
"uniform vec4 uColorPick;\n"
|
||||
"uniform int uAlphaTestComparison;\n"
|
||||
"uniform float uAlphaTestRefValue;\n"
|
||||
"void main()\n"
|
||||
"{\n"
|
||||
" vec4 color;\n"
|
||||
"#ifndef GL_ES\n"
|
||||
" color = vec4(uColorPick);\n"
|
||||
"#else\n"
|
||||
" color = uColorPick;\n"
|
||||
"#endif\n"
|
||||
" vec4 color = uColorPick;\n"
|
||||
"#ifdef ALPHA_TEST_ENABLED\n"
|
||||
" /*uAlphaTestComparison is value of the Evas_3D_Comparison type*/\n"
|
||||
" const float p = 1000000.0;\n"
|
||||
|
|
Loading…
Reference in New Issue