diff options
author | Oleksandr Shcherbina <o.shcherbina@samsung.com> | 2015-04-22 15:19:02 +0200 |
---|---|---|
committer | Cedric BAIL <cedric@osg.samsung.com> | 2015-05-07 09:53:09 +0200 |
commit | d88ccf06a5f6ebcfc68dcc21e55a241f64ff9aa9 (patch) | |
tree | c161bdf705243e99217f689e42458a0de2edb9f9 | |
parent | 0f6d101ad5ec8327088e448c347e1f4054a5c8d7 (diff) |
evas: use Evas_GL_image for generate texture unit for Evas_3D_Texture.
Summary:
Used engine function for load image/data and use texture unit through
Evas_GL_Image object
Used Evas_ColorSpace format instead Evas_3D_Color/Pixel format
Added transformation matrix for adjusting texture unit coordinates in shader
Added property in Evas_3D_Texture for mark possibility get texture without atlas
(see https://phab.enlightenment.org/conpherence/54/, I suppose it will done
after this patch)
Reviewers: Hermet, cedric
Reviewed By: cedric
Subscribers: cedric
Differential Revision: https://phab.enlightenment.org/D2371
Signed-off-by: Cedric BAIL <cedric@osg.samsung.com>
Diffstat (limited to '')
-rw-r--r-- | src/lib/evas/Evas_Eo.h | 38 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_3d_texture.c | 84 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_3d_texture.eo | 30 | ||||
-rw-r--r-- | src/lib/evas/include/evas_3d_utils.h | 30 | ||||
-rw-r--r-- | src/lib/evas/include/evas_private.h | 12 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/evas_gl_3d.c | 230 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/evas_gl_3d_common.h | 7 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/evas_gl_3d_private.h | 26 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/evas_gl_3d_shader.c | 72 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/shader_3d/evas_gl_3d_shaders.x | 214 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/shader_3d/include.shd | 14 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/shader_3d/parallax_occlusion_frag.shd | 14 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_common/shader_3d/shadow_map_frag.shd | 12 | ||||
-rw-r--r-- | src/modules/evas/engines/gl_generic/evas_engine.c | 60 | ||||
-rw-r--r-- | src/modules/evas/engines/software_generic/evas_engine.c | 4 |
15 files changed, 467 insertions, 380 deletions
diff --git a/src/lib/evas/Evas_Eo.h b/src/lib/evas/Evas_Eo.h index 1e1fb5945b..296444268f 100644 --- a/src/lib/evas/Evas_Eo.h +++ b/src/lib/evas/Evas_Eo.h | |||
@@ -698,44 +698,6 @@ typedef enum _Evas_3D_Comparison | |||
698 | } Evas_3D_Comparison; | 698 | } Evas_3D_Comparison; |
699 | 699 | ||
700 | /** | 700 | /** |
701 | * Color formats of pixel data | ||
702 | * | ||
703 | * @since 1.10 | ||
704 | * @ingroup Evas_3D_Types | ||
705 | */ | ||
706 | typedef enum _Evas_3D_Color_Format | ||
707 | { | ||
708 | /**< Color contains full components, red, green, blue and alpha */ | ||
709 | EVAS_3D_COLOR_FORMAT_RGBA = 0, | ||
710 | /**< Color contains only red, green and blue components */ | ||
711 | EVAS_3D_COLOR_FORMAT_RGB, | ||
712 | /**< Color contains only alpha component */ | ||
713 | EVAS_3D_COLOR_FORMAT_ALPHA | ||
714 | } Evas_3D_Color_Format; | ||
715 | |||
716 | /** | ||
717 | * Pixel formats | ||
718 | * | ||
719 | * @since 1.10 | ||
720 | * @ingroup Evas_3D_Types | ||
721 | */ | ||
722 | typedef enum _Evas_3D_Pixel_Format | ||
723 | { | ||
724 | /**< 8-bit pixel with single component */ | ||
725 | EVAS_3D_PIXEL_FORMAT_8 = 0, | ||
726 | /**< 16-bit pixel with three components (5-6-5 bit) */ | ||
727 | EVAS_3D_PIXEL_FORMAT_565, | ||
728 | /**< 24-bit pixel with three 8-bit components */ | ||
729 | EVAS_3D_PIXEL_FORMAT_888, | ||
730 | /**< 32-bit pixel with four 8-bit components */ | ||
731 | EVAS_3D_PIXEL_FORMAT_8888, | ||
732 | /**< 16-bit pixel with four 4-bit components */ | ||
733 | EVAS_3D_PIXEL_FORMAT_4444, | ||
734 | /**< 16-bit pixel with four components (5-5-5-1 bit) */ | ||
735 | EVAS_3D_PIXEL_FORMAT_5551 | ||
736 | } Evas_3D_Pixel_Format; | ||
737 | |||
738 | /** | ||
739 | * Wrap modes | 701 | * Wrap modes |
740 | * | 702 | * |
741 | * @since 1.10 | 703 | * @since 1.10 |
diff --git a/src/lib/evas/canvas/evas_3d_texture.c b/src/lib/evas/canvas/evas_3d_texture.c index 314450cddf..8b68d818d6 100644 --- a/src/lib/evas/canvas/evas_3d_texture.c +++ b/src/lib/evas/canvas/evas_3d_texture.c | |||
@@ -234,7 +234,7 @@ _evas_3d_texture_evas_3d_object_update_notify(Eo *obj, Evas_3D_Texture_Data *pd) | |||
234 | if (e->engine.func->texture_new) | 234 | if (e->engine.func->texture_new) |
235 | { | 235 | { |
236 | pd->engine_data = | 236 | pd->engine_data = |
237 | e->engine.func->texture_new(e->engine.data.output); | 237 | e->engine.func->texture_new(e->engine.data.output, pd->atlas_enable); |
238 | } | 238 | } |
239 | 239 | ||
240 | if (pd->engine_data == NULL) | 240 | if (pd->engine_data == NULL) |
@@ -308,7 +308,6 @@ evas_3d_texture_material_del(Evas_3D_Texture *texture, Evas_3D_Material *materia | |||
308 | eina_hash_set(pd->materials, &material, (const void *)(uintptr_t)(count - 1)); | 308 | eina_hash_set(pd->materials, &material, (const void *)(uintptr_t)(count - 1)); |
309 | } | 309 | } |
310 | 310 | ||
311 | |||
312 | EAPI Evas_3D_Texture * | 311 | EAPI Evas_3D_Texture * |
313 | evas_3d_texture_add(Evas *e) | 312 | evas_3d_texture_add(Evas *e) |
314 | { | 313 | { |
@@ -324,6 +323,8 @@ EOLIAN static void | |||
324 | _evas_3d_texture_eo_base_constructor(Eo *obj, Evas_3D_Texture_Data *pd EINA_UNUSED) | 323 | _evas_3d_texture_eo_base_constructor(Eo *obj, Evas_3D_Texture_Data *pd EINA_UNUSED) |
325 | { | 324 | { |
326 | eo_do_super(obj, MY_CLASS, eo_constructor()); | 325 | eo_do_super(obj, MY_CLASS, eo_constructor()); |
326 | pd->atlas_enable = EINA_TRUE; | ||
327 | |||
327 | eo_do(obj, evas_3d_object_type_set(EVAS_3D_OBJECT_TYPE_TEXTURE)); | 328 | eo_do(obj, evas_3d_object_type_set(EVAS_3D_OBJECT_TYPE_TEXTURE)); |
328 | } | 329 | } |
329 | 330 | ||
@@ -335,37 +336,68 @@ _evas_3d_texture_eo_base_destructor(Eo *obj, Evas_3D_Texture_Data *pd EINA_UNUS | |||
335 | } | 336 | } |
336 | 337 | ||
337 | EOLIAN static void | 338 | EOLIAN static void |
338 | _evas_3d_texture_data_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_3D_Color_Format color_format, | 339 | _evas_3d_texture_data_set(Eo *obj, Evas_3D_Texture_Data *pd, |
339 | Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data) | 340 | Evas_Colorspace color_format, |
341 | int w, int h, const void *data) | ||
340 | { | 342 | { |
341 | Eo *evas = NULL; | 343 | Eo *evas = NULL; |
344 | void *image = NULL; | ||
342 | eo_do(obj, evas = evas_common_evas_get()); | 345 | eo_do(obj, evas = evas_common_evas_get()); |
343 | Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); | 346 | Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); |
344 | 347 | ||
345 | if (!pd->engine_data && e->engine.func->texture_new) | 348 | if (!pd->engine_data && e->engine.func->texture_new) |
346 | pd->engine_data = e->engine.func->texture_new(e->engine.data.output); | 349 | pd->engine_data = e->engine.func->texture_new(e->engine.data.output, pd->atlas_enable); |
350 | if (!data) | ||
351 | { | ||
352 | ERR("Failure, image data is empty"); | ||
353 | return; | ||
354 | } | ||
347 | 355 | ||
348 | if (e->engine.func->texture_data_set) | 356 | image = e->engine.func->image_new_from_data(e->engine.data.output, w, h, (DATA32 *)data, EINA_TRUE, color_format); |
349 | e->engine.func->texture_data_set(e->engine.data.output, pd->engine_data, | 357 | if (!image) |
350 | color_format, pixel_format, w, h, data); | 358 | { |
359 | ERR("Can't load image from data"); | ||
360 | return; | ||
361 | } | ||
351 | 362 | ||
363 | if (e->engine.func->texture_image_set) | ||
364 | e->engine.func->texture_image_set(e->engine.data.output, | ||
365 | pd->engine_data, | ||
366 | image); | ||
367 | e->engine.func->image_free(e->engine.data.output, image); | ||
352 | eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL)); | 368 | eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL)); |
353 | } | 369 | } |
354 | 370 | ||
355 | EOLIAN static void | 371 | EOLIAN static void |
356 | _evas_3d_texture_file_set(Eo *obj, Evas_3D_Texture_Data *pd, const char *file, const char *key) | 372 | _evas_3d_texture_file_set(Eo *obj, Evas_3D_Texture_Data *pd, const char *file, const char *key) |
357 | { | 373 | { |
374 | |||
375 | Evas_Image_Load_Opts lo; | ||
376 | int load_error; | ||
358 | Eo *evas = NULL; | 377 | Eo *evas = NULL; |
378 | void *image; | ||
379 | |||
359 | eo_do(obj, evas = evas_common_evas_get()); | 380 | eo_do(obj, evas = evas_common_evas_get()); |
360 | Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); | 381 | Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); |
361 | 382 | ||
362 | if (!pd->engine_data && e->engine.func->texture_new) | 383 | if (!pd->engine_data && e->engine.func->texture_new) |
363 | pd->engine_data = e->engine.func->texture_new(e->engine.data.output); | 384 | pd->engine_data = e->engine.func->texture_new(e->engine.data.output, pd->atlas_enable); |
385 | |||
386 | memset(&lo, 0x0, sizeof(Evas_Image_Load_Opts)); | ||
387 | image = e->engine.func->image_load(e->engine.data.output, | ||
388 | file, key, &load_error, &lo); | ||
389 | if (!image) | ||
390 | { | ||
391 | ERR("Can't load image from file"); | ||
392 | return; | ||
393 | } | ||
364 | 394 | ||
365 | if (e->engine.func->texture_file_set) | 395 | if (e->engine.func->texture_image_set) |
366 | e->engine.func->texture_file_set(e->engine.data.output, pd->engine_data, | 396 | e->engine.func->texture_image_set(e->engine.data.output, |
367 | file, key); | 397 | pd->engine_data, |
398 | image); | ||
368 | 399 | ||
400 | e->engine.func->image_free(e->engine.data.output, image); | ||
369 | eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL)); | 401 | eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL)); |
370 | } | 402 | } |
371 | 403 | ||
@@ -374,6 +406,7 @@ _evas_3d_texture_source_set(Eo *obj , Evas_3D_Texture_Data *pd, Evas_Object *sou | |||
374 | { | 406 | { |
375 | Eo *evas = NULL; | 407 | Eo *evas = NULL; |
376 | eo_do(obj, evas = evas_common_evas_get()); | 408 | eo_do(obj, evas = evas_common_evas_get()); |
409 | Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); | ||
377 | Evas_Object_Protected_Data *src; | 410 | Evas_Object_Protected_Data *src; |
378 | 411 | ||
379 | if (source == pd->source) | 412 | if (source == pd->source) |
@@ -403,6 +436,8 @@ _evas_3d_texture_source_set(Eo *obj , Evas_3D_Texture_Data *pd, Evas_Object *sou | |||
403 | ERR("No evas surface associated with the source object."); | 436 | ERR("No evas surface associated with the source object."); |
404 | return; | 437 | return; |
405 | } | 438 | } |
439 | if (!pd->engine_data && e->engine.func->texture_new) | ||
440 | pd->engine_data = e->engine.func->texture_new(e->engine.data.output, pd->atlas_enable); | ||
406 | 441 | ||
407 | _texture_proxy_set(obj, source, src); | 442 | _texture_proxy_set(obj, source, src); |
408 | eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL)); | 443 | eo_do(obj, evas_3d_object_change(EVAS_3D_STATE_TEXTURE_DATA, NULL)); |
@@ -442,19 +477,21 @@ _evas_3d_texture_source_visible_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *p | |||
442 | return !src_obj->proxy->src_invisible; | 477 | return !src_obj->proxy->src_invisible; |
443 | } | 478 | } |
444 | 479 | ||
445 | EOLIAN static Evas_3D_Color_Format | 480 | EOLIAN static Evas_Colorspace |
446 | _evas_3d_texture_color_format_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd) | 481 | _evas_3d_texture_color_format_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd) |
447 | { | 482 | { |
448 | // FIXME: we need an unknown color format and unify that with Evas color space to | 483 | Evas_Colorspace format = -1; |
449 | Evas_3D_Color_Format format = -1; | ||
450 | Eo *evas = NULL; | 484 | Eo *evas = NULL; |
451 | eo_do(obj, evas = evas_common_evas_get()); | 485 | eo_do(obj, evas = evas_common_evas_get()); |
452 | Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); | 486 | Evas_Public_Data *e = eo_data_scope_get(evas, EVAS_CANVAS_CLASS); |
453 | 487 | ||
454 | if (e->engine.func->texture_color_format_get) | 488 | if (e->engine.func->image_colorspace_get && |
489 | e->engine.func->texture_image_get) | ||
455 | { | 490 | { |
456 | e->engine.func->texture_color_format_get(e->engine.data.output, | 491 | void *image; |
457 | pd->engine_data, &format); | 492 | |
493 | image = e->engine.func->texture_image_get(e->engine.data.output, pd->engine_data); | ||
494 | format = e->engine.func->image_colorspace_get(e->engine.data.output, image); | ||
458 | } | 495 | } |
459 | 496 | ||
460 | return format; | 497 | return format; |
@@ -527,4 +564,15 @@ _evas_3d_texture_filter_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Evas_ | |||
527 | } | 564 | } |
528 | } | 565 | } |
529 | 566 | ||
567 | EOLIAN static void | ||
568 | _evas_3d_texture_atlas_enable_set(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd, Eina_Bool use_atlas) | ||
569 | { | ||
570 | if (pd->atlas_enable != use_atlas) pd->atlas_enable = use_atlas; | ||
571 | } | ||
572 | |||
573 | EOLIAN static Eina_Bool | ||
574 | _evas_3d_texture_atlas_enable_get(Eo *obj EINA_UNUSED, Evas_3D_Texture_Data *pd) | ||
575 | { | ||
576 | return pd->atlas_enable; | ||
577 | } | ||
530 | #include "canvas/evas_3d_texture.eo.c" | 578 | #include "canvas/evas_3d_texture.eo.c" |
diff --git a/src/lib/evas/canvas/evas_3d_texture.eo b/src/lib/evas/canvas/evas_3d_texture.eo index 83ab29a9d6..39efb61e23 100644 --- a/src/lib/evas/canvas/evas_3d_texture.eo +++ b/src/lib/evas/canvas/evas_3d_texture.eo | |||
@@ -31,6 +31,29 @@ class Evas_3D_Texture (Evas_3D_Object, Evas.Common_Interface) | |||
31 | bool visible; /*@ @c EINA_TRUE for visible, @c EINA_FALSE for invisible.*/ | 31 | bool visible; /*@ @c EINA_TRUE for visible, @c EINA_FALSE for invisible.*/ |
32 | } | 32 | } |
33 | } | 33 | } |
34 | atlas_enable { | ||
35 | set { | ||
36 | /* | ||
37 | Set enable flag to generation texture unit with support atlas. | ||
38 | |||
39 | Use this flag only in case not normalize texture coordinates. | ||
40 | |||
41 | By default, is enabled. | ||
42 | |||
43 | @ingroup Evas_3D_Texture | ||
44 | */ | ||
45 | } | ||
46 | get { | ||
47 | /* | ||
48 | Get enable flag of generation texture unit with support atlas. | ||
49 | |||
50 | @ingroup Evas_3D_Texture | ||
51 | */ | ||
52 | } | ||
53 | values { | ||
54 | bool use_atlas; /*@ @c EINA_TRUE for enable, @c EINA_FALSE for disable.*/ | ||
55 | } | ||
56 | } | ||
34 | } | 57 | } |
35 | methods { | 58 | methods { |
36 | data_set { | 59 | data_set { |
@@ -43,8 +66,7 @@ class Evas_3D_Texture (Evas_3D_Object, Evas.Common_Interface) | |||
43 | */ | 66 | */ |
44 | 67 | ||
45 | params { | 68 | params { |
46 | @in Evas_3D_Color_Format color_format; /*@ Color format of the texture. */ | 69 | @in Evas_Colorspace color_format; /*@ Color format of the texture. */ |
47 | @in Evas_3D_Pixel_Format pixel_format; /*@ Pixel format of the data. */ | ||
48 | @in int w; /*@ Width of the data. */ | 70 | @in int w; /*@ Width of the data. */ |
49 | @in int h; /*@ Height of the data. */ | 71 | @in int h; /*@ Height of the data. */ |
50 | @in const(void)* data; /*@ Pointer to the data. */ | 72 | @in const(void)* data; /*@ Pointer to the data. */ |
@@ -55,8 +77,6 @@ class Evas_3D_Texture (Evas_3D_Object, Evas.Common_Interface) | |||
55 | /* | 77 | /* |
56 | Set the data of the given texture from file. | 78 | Set the data of the given texture from file. |
57 | 79 | ||
58 | Only PNG format is supported. | ||
59 | |||
60 | @ingroup Evas_3D_Texture | 80 | @ingroup Evas_3D_Texture |
61 | */ | 81 | */ |
62 | 82 | ||
@@ -96,7 +116,7 @@ class Evas_3D_Texture (Evas_3D_Object, Evas.Common_Interface) | |||
96 | 116 | ||
97 | @ingroup Evas_3D_Texture | 117 | @ingroup Evas_3D_Texture |
98 | */ | 118 | */ |
99 | return: Evas_3D_Color_Format; | 119 | return: Evas_Colorspace; |
100 | } | 120 | } |
101 | 121 | ||
102 | size_get @const { | 122 | size_get @const { |
diff --git a/src/lib/evas/include/evas_3d_utils.h b/src/lib/evas/include/evas_3d_utils.h index d11533ff6e..87bf70867d 100644 --- a/src/lib/evas/include/evas_3d_utils.h +++ b/src/lib/evas/include/evas_3d_utils.h | |||
@@ -1150,6 +1150,36 @@ evas_mat3_invserse(Evas_Mat3 *out, const Evas_Mat3 *mat) | |||
1150 | } | 1150 | } |
1151 | } | 1151 | } |
1152 | 1152 | ||
1153 | static inline void | ||
1154 | evas_mat3_set_position_transform(Evas_Mat3 *out, const Evas_Real p_x, const Evas_Real p_y) | ||
1155 | { | ||
1156 | Evas_Real *d = &out->m[0]; | ||
1157 | memset(d, 0x00, sizeof(Evas_Mat3)); | ||
1158 | d[0] = 1; | ||
1159 | d[2] = p_x; | ||
1160 | d[4] = 1; | ||
1161 | d[5] = p_y; | ||
1162 | d[8] = 1; | ||
1163 | if (p_x || p_y) | ||
1164 | out->flags = 0; | ||
1165 | else | ||
1166 | out->flags = EVAS_MATRIX_IS_IDENTITY; | ||
1167 | } | ||
1168 | |||
1169 | static inline void | ||
1170 | evas_mat3_set_scale_transform(Evas_Mat3 *out, Evas_Real s_x, Evas_Real s_y) | ||
1171 | { | ||
1172 | Evas_Real *d = &out->m[0]; | ||
1173 | memset(d, 0x00, sizeof(Evas_Mat3)); | ||
1174 | d[0] = s_x; | ||
1175 | d[4] = s_y; | ||
1176 | d[8] = 1; | ||
1177 | if (s_x != 1.0 || s_y != 1.0) | ||
1178 | out->flags = 0; | ||
1179 | else | ||
1180 | out->flags = EVAS_MATRIX_IS_IDENTITY; | ||
1181 | } | ||
1182 | |||
1153 | /* 2x2 matrix */ | 1183 | /* 2x2 matrix */ |
1154 | static inline void | 1184 | static inline void |
1155 | evas_mat2_identity_set(Evas_Mat2 *m) | 1185 | evas_mat2_identity_set(Evas_Mat2 *m) |
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index af2592bc1a..427a71de0d 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h | |||
@@ -369,9 +369,11 @@ struct _Evas_3D_Texture | |||
369 | Evas_Object *source; | 369 | Evas_Object *source; |
370 | Eina_Bool proxy_rendering; | 370 | Eina_Bool proxy_rendering; |
371 | void *proxy_surface; | 371 | void *proxy_surface; |
372 | |||
373 | /* Engine-side object. */ | 372 | /* Engine-side object. */ |
374 | void *engine_data; | 373 | void *engine_data; |
374 | |||
375 | /*Use atlases, @EINA_TRUE by default*/ | ||
376 | Eina_Bool atlas_enable :1; | ||
375 | }; | 377 | }; |
376 | 378 | ||
377 | struct _Evas_3D_Material | 379 | struct _Evas_3D_Material |
@@ -389,7 +391,7 @@ struct _Evas_3D_Material | |||
389 | 391 | ||
390 | struct _Evas_3D_Scene_Public_Data | 392 | struct _Evas_3D_Scene_Public_Data |
391 | { | 393 | { |
392 | Evas_Color bg_color; | 394 | Evas_Color bg_color; |
393 | Evas_3D_Node *camera_node; | 395 | Evas_3D_Node *camera_node; |
394 | Eina_List *light_nodes; | 396 | Eina_List *light_nodes; |
395 | Eina_List *mesh_nodes; | 397 | Eina_List *mesh_nodes; |
@@ -1360,17 +1362,15 @@ struct _Evas_Func | |||
1360 | int (*drawable_texture_color_pick_id_get) (void *drawable); | 1362 | int (*drawable_texture_color_pick_id_get) (void *drawable); |
1361 | double (*drawable_texture_pixel_color_get) (unsigned int tex EINA_UNUSED, int x, int y, void *drawable); | 1363 | double (*drawable_texture_pixel_color_get) (unsigned int tex EINA_UNUSED, int x, int y, void *drawable); |
1362 | 1364 | ||
1363 | void *(*texture_new) (void *data); | 1365 | void *(*texture_new) (void *data, Eina_Bool use_atlas); |
1364 | void (*texture_free) (void *data, void *texture); | 1366 | void (*texture_free) (void *data, void *texture); |
1365 | void (*texture_data_set) (void *data, void *texture, Evas_3D_Color_Format format, Evas_3D_Pixel_Format pixel_format, int w, int h, const void *pixels); | ||
1366 | void (*texture_file_set) (void *data, void *texture, const char *file, const char *key); | ||
1367 | void (*texture_color_format_get) (void *data, void *texture, Evas_3D_Color_Format *format); | ||
1368 | void (*texture_size_get) (void *data, void *texture, int *w, int *h); | 1367 | void (*texture_size_get) (void *data, void *texture, int *w, int *h); |
1369 | void (*texture_wrap_set) (void *data, void *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t); | 1368 | void (*texture_wrap_set) (void *data, void *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mode t); |
1370 | void (*texture_wrap_get) (void *data, void *texture, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t); | 1369 | void (*texture_wrap_get) (void *data, void *texture, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t); |
1371 | void (*texture_filter_set) (void *data, void *texture, Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag); | 1370 | void (*texture_filter_set) (void *data, void *texture, Evas_3D_Texture_Filter min, Evas_3D_Texture_Filter mag); |
1372 | void (*texture_filter_get) (void *data, void *texture, Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag); | 1371 | void (*texture_filter_get) (void *data, void *texture, Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag); |
1373 | void (*texture_image_set) (void *data, void *texture, void *image); | 1372 | void (*texture_image_set) (void *data, void *texture, void *image); |
1373 | void *(*texture_image_get) (void *data, void *texture); | ||
1374 | 1374 | ||
1375 | Ector_Surface *(*ector_get) (void *data); | 1375 | Ector_Surface *(*ector_get) (void *data); |
1376 | void (*ector_begin) (void *data, void *context, void *surface, int x, int y, Eina_Bool do_async); | 1376 | void (*ector_begin) (void *data, void *context, void *surface, int x, int y, Eina_Bool do_async); |
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 1de2c64ecb..9f8e742f5a 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d.c +++ b/src/modules/evas/engines/gl_common/evas_gl_3d.c | |||
@@ -21,9 +21,6 @@ | |||
21 | void | 21 | void |
22 | e3d_texture_param_update(E3D_Texture *texture) | 22 | e3d_texture_param_update(E3D_Texture *texture) |
23 | { | 23 | { |
24 | if (texture->is_imported) | ||
25 | return; | ||
26 | |||
27 | if (texture->wrap_dirty) | 24 | if (texture->wrap_dirty) |
28 | { | 25 | { |
29 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->wrap_s); | 26 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->wrap_s); |
@@ -40,7 +37,7 @@ e3d_texture_param_update(E3D_Texture *texture) | |||
40 | } | 37 | } |
41 | 38 | ||
42 | E3D_Texture * | 39 | E3D_Texture * |
43 | e3d_texture_new(void) | 40 | e3d_texture_new(Eina_Bool use_atlas) |
44 | { | 41 | { |
45 | E3D_Texture *texture = NULL; | 42 | E3D_Texture *texture = NULL; |
46 | 43 | ||
@@ -52,12 +49,14 @@ e3d_texture_new(void) | |||
52 | return NULL; | 49 | return NULL; |
53 | } | 50 | } |
54 | 51 | ||
52 | evas_mat3_identity_set(&texture->trans); | ||
53 | |||
55 | texture->w = 0; | 54 | texture->w = 0; |
56 | texture->h = 0; | 55 | texture->h = 0; |
56 | texture->x = 0; | ||
57 | texture->y = 0; | ||
57 | 58 | ||
58 | texture->is_imported = EINA_FALSE; | ||
59 | texture->tex = 0; | 59 | texture->tex = 0; |
60 | texture->format = GL_RGBA; | ||
61 | 60 | ||
62 | texture->wrap_dirty = EINA_TRUE; | 61 | texture->wrap_dirty = EINA_TRUE; |
63 | texture->wrap_s = GL_CLAMP_TO_EDGE; | 62 | texture->wrap_s = GL_CLAMP_TO_EDGE; |
@@ -67,192 +66,63 @@ e3d_texture_new(void) | |||
67 | texture->filter_min = GL_NEAREST; | 66 | texture->filter_min = GL_NEAREST; |
68 | texture->filter_mag = GL_NEAREST; | 67 | texture->filter_mag = GL_NEAREST; |
69 | 68 | ||
69 | texture->atlas_enable = use_atlas; | ||
70 | |||
70 | return texture; | 71 | return texture; |
71 | } | 72 | } |
72 | 73 | ||
73 | void | 74 | void |
74 | e3d_texture_free(E3D_Texture *texture) | 75 | e3d_texture_free(E3D_Texture *texture) |
75 | { | 76 | { |
76 | if (texture->tex && !texture->is_imported) | 77 | if (texture) |
77 | glDeleteTextures(1, &texture->tex); | ||
78 | |||
79 | free(texture); | ||
80 | } | ||
81 | |||
82 | void | ||
83 | e3d_texture_data_set(E3D_Texture *texture, | ||
84 | Evas_3D_Color_Format color_format, Evas_3D_Pixel_Format pixel_format, | ||
85 | int w, int h, const void *data) | ||
86 | { | ||
87 | GLenum format; | ||
88 | GLenum iformat; | ||
89 | GLenum type; | ||
90 | |||
91 | if (color_format == EVAS_3D_COLOR_FORMAT_RGBA) | ||
92 | { | ||
93 | format = GL_RGBA; | ||
94 | iformat = GL_BGRA; | ||
95 | |||
96 | if (pixel_format == EVAS_3D_PIXEL_FORMAT_8888) | ||
97 | type = GL_UNSIGNED_BYTE; | ||
98 | else if (pixel_format == EVAS_3D_PIXEL_FORMAT_4444) | ||
99 | type = GL_UNSIGNED_SHORT_4_4_4_4; | ||
100 | else if (pixel_format == EVAS_3D_PIXEL_FORMAT_5551) | ||
101 | type = GL_UNSIGNED_SHORT_5_5_5_1; | ||
102 | else | ||
103 | { | ||
104 | ERR("Texture data format mismatch."); | ||
105 | return; | ||
106 | } | ||
107 | } | ||
108 | else if (color_format == EVAS_3D_COLOR_FORMAT_RGB) | ||
109 | { | ||
110 | format = GL_RGB; | ||
111 | iformat = GL_BGR; | ||
112 | |||
113 | if (pixel_format == EVAS_3D_PIXEL_FORMAT_565) | ||
114 | type = GL_UNSIGNED_SHORT_5_6_5; | ||
115 | else if (pixel_format == EVAS_3D_PIXEL_FORMAT_888) | ||
116 | type = GL_UNSIGNED_BYTE; | ||
117 | else | ||
118 | { | ||
119 | ERR("Texture data format mismatch."); | ||
120 | return; | ||
121 | } | ||
122 | } | ||
123 | else if (color_format == EVAS_3D_COLOR_FORMAT_ALPHA) | ||
124 | { | ||
125 | format = GL_LUMINANCE; | ||
126 | iformat = GL_LUMINANCE; | ||
127 | |||
128 | if (pixel_format == EVAS_3D_PIXEL_FORMAT_8) | ||
129 | type = GL_UNSIGNED_BYTE; | ||
130 | else | ||
131 | { | ||
132 | ERR("Texture data format mismatch."); | ||
133 | return; | ||
134 | } | ||
135 | } | ||
136 | else | ||
137 | { | 78 | { |
138 | ERR("Invalid texture color format"); | 79 | if (texture->surface) |
139 | return; | 80 | evas_gl_common_image_unref(texture->surface); |
140 | } | 81 | } |
141 | 82 | free(texture); | |
142 | if (texture->tex == 0 || texture->is_imported) | ||
143 | { | ||
144 | glGenTextures(1, &texture->tex); | ||
145 | texture->wrap_dirty = EINA_TRUE; | ||
146 | texture->filter_dirty = EINA_TRUE; | ||
147 | } | ||
148 | |||
149 | glBindTexture(GL_TEXTURE_2D, texture->tex); | ||
150 | glTexImage2D(GL_TEXTURE_2D, 0, format, w, h, 0, iformat, type, data); | ||
151 | |||
152 | if (texture->wrap_dirty) | ||
153 | { | ||
154 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, texture->wrap_s); | ||
155 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, texture->wrap_t); | ||
156 | texture->wrap_dirty = EINA_FALSE; | ||
157 | } | ||
158 | |||
159 | if (texture->filter_dirty) | ||
160 | { | ||
161 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texture->filter_min); | ||
162 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texture->filter_mag); | ||
163 | texture->filter_dirty = EINA_FALSE; | ||
164 | } | ||
165 | |||
166 | texture->is_imported = EINA_FALSE; | ||
167 | texture->format = format; | ||
168 | } | ||
169 | |||
170 | void | ||
171 | e3d_texture_file_set(E3D_Texture *texture, const char *file, const char *key) | ||
172 | { | ||
173 | Evas_Image_Load_Opts lo; | ||
174 | int error; | ||
175 | Evas_3D_Color_Format color_format; | ||
176 | Evas_3D_Pixel_Format pixel_format; | ||
177 | |||
178 | memset(&lo, 0x0, sizeof(Evas_Image_Load_Opts)); | ||
179 | RGBA_Image *im = evas_common_load_image_from_file(file, key, &lo, &error); | ||
180 | if (!im) return; | ||
181 | |||
182 | error = evas_cache_image_load_data(&im->cache_entry); | ||
183 | |||
184 | switch(im->cache_entry.space) | ||
185 | { | ||
186 | case EVAS_COLORSPACE_ARGB8888: | ||
187 | pixel_format = EVAS_3D_PIXEL_FORMAT_8888; | ||
188 | color_format = EVAS_3D_COLOR_FORMAT_RGBA; | ||
189 | break; | ||
190 | default: | ||
191 | return; | ||
192 | } | ||
193 | e3d_texture_data_set(texture, color_format, pixel_format, im->cache_entry.w, | ||
194 | im->cache_entry.h, im->image.data); | ||
195 | evas_cache_image_unload_data(&im->cache_entry); | ||
196 | } | ||
197 | |||
198 | Evas_3D_Color_Format | ||
199 | e3d_texture_color_format_get(E3D_Texture *texture) | ||
200 | { | ||
201 | if (texture->is_imported) | ||
202 | { | ||
203 | ERR("Cannot get the size of an imported texture."); | ||
204 | return EVAS_3D_COLOR_FORMAT_RGBA; | ||
205 | } | ||
206 | |||
207 | switch (texture->format) | ||
208 | { | ||
209 | case GL_RGBA: | ||
210 | return EVAS_3D_COLOR_FORMAT_RGBA; | ||
211 | case GL_RGB: | ||
212 | return EVAS_3D_COLOR_FORMAT_RGB; | ||
213 | case GL_ALPHA: | ||
214 | return EVAS_3D_COLOR_FORMAT_ALPHA; | ||
215 | default: | ||
216 | break; | ||
217 | } | ||
218 | |||
219 | ERR("Invalid texture format."); | ||
220 | return EVAS_3D_COLOR_FORMAT_RGBA; | ||
221 | } | 83 | } |
222 | 84 | ||
223 | void | 85 | void |
224 | e3d_texture_size_get(const E3D_Texture *texture, int *w, int *h) | 86 | e3d_texture_size_get(const E3D_Texture *texture, int *w, int *h) |
225 | { | 87 | { |
226 | if (texture->is_imported) | ||
227 | { | ||
228 | ERR("Invalid operation on an imported texture resource."); | ||
229 | return; | ||
230 | } | ||
231 | |||
232 | if (w) *w = texture->w; | 88 | if (w) *w = texture->w; |
233 | if (h) *h = texture->h; | 89 | if (h) *h = texture->h; |
234 | } | 90 | } |
235 | 91 | ||
236 | void | 92 | void |
237 | e3d_texture_import(E3D_Texture *texture, GLuint tex) | 93 | e3d_texture_set(Evas_Engine_GL_Context *gc, |
94 | E3D_Texture *texture, | ||
95 | Evas_GL_Image *im) | ||
238 | { | 96 | { |
239 | if (tex == 0) | 97 | Evas_Mat3 pt,st; |
240 | { | 98 | Evas_Real pt_x, pt_y, st_x, st_y; |
241 | ERR("Cannot import an invalid texture ID."); | ||
242 | return; | ||
243 | } | ||
244 | 99 | ||
245 | if (texture->tex && !texture->is_imported) | 100 | texture->surface = im; |
246 | glDeleteTextures(1, &texture->tex); | 101 | evas_gl_common_image_ref(im); |
247 | 102 | ||
248 | texture->tex = tex; | 103 | evas_gl_common_image_update(gc, im); |
249 | texture->is_imported = EINA_TRUE; | 104 | |
105 | texture->tex = im->tex->pt->texture; | ||
106 | texture->w = im->w; | ||
107 | texture->h = im->h; | ||
108 | texture->x = im->tex->x; | ||
109 | texture->y = im->tex->y; | ||
110 | |||
111 | pt_x = im->tex->pt->w ? (im->tex->x/(Evas_Real)im->tex->pt->w) : 0; | ||
112 | pt_y = im->tex->pt->h ? (im->tex->y/(Evas_Real)im->tex->pt->h) : 0; | ||
113 | |||
114 | st_x = im->tex->pt->w ? (im->w/(Evas_Real)im->tex->pt->w) : 1.0; | ||
115 | st_y = im->tex->pt->h ? (im->h/(Evas_Real)im->tex->pt->h) : 1.0; | ||
116 | /*Build adjusting matrix for texture unit coordinates*/ | ||
117 | evas_mat3_set_position_transform(&pt, pt_x, pt_y); | ||
118 | evas_mat3_set_scale_transform(&st, st_x, st_y); | ||
119 | evas_mat3_multiply(&texture->trans, &st, &pt); | ||
250 | } | 120 | } |
251 | 121 | ||
252 | Eina_Bool | 122 | Evas_GL_Image * |
253 | e3d_texture_is_imported_get(const E3D_Texture *texture) | 123 | e3d_texture_get(E3D_Texture *texture) |
254 | { | 124 | { |
255 | return texture->is_imported; | 125 | return texture ? texture->surface : NULL; |
256 | } | 126 | } |
257 | 127 | ||
258 | static inline GLenum | 128 | static inline GLenum |
@@ -348,12 +218,6 @@ e3d_texture_wrap_set(E3D_Texture *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mod | |||
348 | { | 218 | { |
349 | GLenum gl_s, gl_t; | 219 | GLenum gl_s, gl_t; |
350 | 220 | ||
351 | if (texture->is_imported) | ||
352 | { | ||
353 | ERR("Invalid operation on an imported texture resource."); | ||
354 | return; | ||
355 | } | ||
356 | |||
357 | gl_s = _to_gl_texture_wrap(s); | 221 | gl_s = _to_gl_texture_wrap(s); |
358 | gl_t = _to_gl_texture_wrap(t); | 222 | gl_t = _to_gl_texture_wrap(t); |
359 | 223 | ||
@@ -368,12 +232,6 @@ e3d_texture_wrap_set(E3D_Texture *texture, Evas_3D_Wrap_Mode s, Evas_3D_Wrap_Mod | |||
368 | void | 232 | void |
369 | e3d_texture_wrap_get(const E3D_Texture *texture, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t) | 233 | e3d_texture_wrap_get(const E3D_Texture *texture, Evas_3D_Wrap_Mode *s, Evas_3D_Wrap_Mode *t) |
370 | { | 234 | { |
371 | if (texture->is_imported) | ||
372 | { | ||
373 | ERR("Invalid operation on an imported texture resource."); | ||
374 | return; | ||
375 | } | ||
376 | |||
377 | if (s) | 235 | if (s) |
378 | *s = _to_e3d_texture_wrap(texture->wrap_s); | 236 | *s = _to_e3d_texture_wrap(texture->wrap_s); |
379 | 237 | ||
@@ -386,12 +244,6 @@ e3d_texture_filter_set(E3D_Texture *texture, Evas_3D_Texture_Filter min, Evas_3D | |||
386 | { | 244 | { |
387 | GLenum gl_min, gl_mag; | 245 | GLenum gl_min, gl_mag; |
388 | 246 | ||
389 | if (texture->is_imported) | ||
390 | { | ||
391 | ERR("Invalid operation on an imported texture resource."); | ||
392 | return; | ||
393 | } | ||
394 | |||
395 | gl_min = _to_gl_texture_filter(min); | 247 | gl_min = _to_gl_texture_filter(min); |
396 | gl_mag = _to_gl_texture_filter(mag); | 248 | gl_mag = _to_gl_texture_filter(mag); |
397 | 249 | ||
@@ -407,12 +259,6 @@ void | |||
407 | e3d_texture_filter_get(const E3D_Texture *texture, | 259 | e3d_texture_filter_get(const E3D_Texture *texture, |
408 | Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag) | 260 | Evas_3D_Texture_Filter *min, Evas_3D_Texture_Filter *mag) |
409 | { | 261 | { |
410 | if (texture->is_imported) | ||
411 | { | ||
412 | ERR("Invalid operation on an imported texture resource."); | ||
413 | return; | ||
414 | } | ||
415 | |||
416 | if (min) | 262 | if (min) |
417 | *min = _to_e3d_texture_filter(texture->filter_min); | 263 | *min = _to_e3d_texture_filter(texture->filter_min); |
418 | 264 | ||
diff --git a/src/modules/evas/engines/gl_common/evas_gl_3d_common.h b/src/modules/evas/engines/gl_common/evas_gl_3d_common.h index f119b40c46..fdb47843a2 100644 --- a/src/modules/evas/engines/gl_common/evas_gl_3d_common.h +++ b/src/modules/evas/engines/gl_common/evas_gl_3d_common.h | |||
@@ -7,13 +7,12 @@ typedef struct _E3D_Drawable E3D_Drawable; | |||
7 | typedef struct _E3D_Renderer E3D_Renderer; | 7 | typedef struct _E3D_Renderer E3D_Renderer; |
8 | 8 | ||
9 | /* Texture */ | 9 | /* Texture */ |
10 | E3D_Texture *e3d_texture_new(void); | 10 | E3D_Texture *e3d_texture_new(Eina_Bool use_atlas); |
11 | void e3d_texture_free(E3D_Texture *texture); | 11 | void e3d_texture_free(E3D_Texture *texture); |
12 | 12 | ||
13 | void e3d_texture_data_set(E3D_Texture *texture, Evas_3D_Color_Format format, Evas_3D_Pixel_Format pixel_format, int w, int h, const void *data); | ||
14 | void e3d_texture_file_set(E3D_Texture *texture, const char *file, const char *key); | ||
15 | Evas_3D_Color_Format e3d_texture_color_format_get(E3D_Texture *texture); | ||
16 | void e3d_texture_size_get(const E3D_Texture *texture, int *w, int *h); | 13 | void e3d_texture_size_get(const E3D_Texture *texture, int *w, int *h); |
14 | void e3d_texture_set(Evas_Engine_GL_Context *gc, E3D_Texture *texture, Evas_GL_Image *im); | ||
15 | Evas_GL_Image *e3d_texture_get(E3D_Texture *texture); | ||
17 | 16 | ||
18 | void e3d_texture_import(E3D_Texture *texture, GLuint tex); | 17 | void e3d_texture_import(E3D_Texture *texture, GLuint tex); |
19 | Eina_Bool e3d_texture_is_imported_get(const E3D_Texture *texture); | 18 | Eina_Bool e3d_texture_is_imported_get(const E3D_Texture *texture); |
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 948ec7ba37..87fbb8a31c 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 | |||
@@ -111,19 +111,25 @@ struct _E3D_Draw_Data | |||
111 | 111 | ||
112 | struct _E3D_Texture | 112 | struct _E3D_Texture |
113 | { | 113 | { |
114 | int w, h; | 114 | /*Offset for atlasses*/ |
115 | int x, y; | ||
116 | int w, h; | ||
115 | 117 | ||
116 | Eina_Bool is_imported; | 118 | Evas_GL_Image *surface; |
117 | GLuint tex; | 119 | /*Tranformation matrix, use it for adjusting texture unit coordinates*/ |
118 | GLenum format; | 120 | Evas_Mat3 trans; |
119 | 121 | ||
120 | Eina_Bool wrap_dirty; | 122 | GLuint tex; |
121 | GLenum wrap_s; | ||
122 | GLenum wrap_t; | ||
123 | 123 | ||
124 | Eina_Bool filter_dirty; | 124 | Eina_Bool wrap_dirty; |
125 | GLenum filter_min; | 125 | GLenum wrap_s; |
126 | GLenum filter_mag; | 126 | GLenum wrap_t; |
127 | |||
128 | Eina_Bool filter_dirty; | ||
129 | GLenum filter_min; | ||
130 | GLenum filter_mag; | ||
131 | /*Use atlas for generation texture unit, @EINA_TRUE by default*/ | ||
132 | Eina_Bool atlas_enable; | ||
127 | }; | 133 | }; |
128 | 134 | ||
129 | struct _E3D_Drawable | 135 | struct _E3D_Drawable |
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 9d858aa54b..59d68a04d1 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 | |||
@@ -32,6 +32,18 @@ typedef enum _E3D_Uniform | |||
32 | E3D_UNIFORM_TEXTURE_EMISSION1, | 32 | E3D_UNIFORM_TEXTURE_EMISSION1, |
33 | E3D_UNIFORM_TEXTURE_NORMAL1, | 33 | E3D_UNIFORM_TEXTURE_NORMAL1, |
34 | 34 | ||
35 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_AMBIENT0, | ||
36 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_DIFFUSE0, | ||
37 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_SPECULAR0, | ||
38 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_EMISSION0, | ||
39 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_NORMAL0, | ||
40 | |||
41 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_AMBIENT1, | ||
42 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_DIFFUSE1, | ||
43 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_SPECULAR1, | ||
44 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_EMISSION1, | ||
45 | E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_NORMAL1, | ||
46 | |||
35 | E3D_UNIFORM_SHADOWMAP, | 47 | E3D_UNIFORM_SHADOWMAP, |
36 | 48 | ||
37 | E3D_UNIFORM_LIGHT_POSITION, | 49 | E3D_UNIFORM_LIGHT_POSITION, |
@@ -312,6 +324,16 @@ static const char *uniform_names[] = | |||
312 | "uTextureSpecular1", | 324 | "uTextureSpecular1", |
313 | "uTextureEmission1", | 325 | "uTextureEmission1", |
314 | "uTextureNormal1", | 326 | "uTextureNormal1", |
327 | "uTextureMatrixTransformAmbient0", | ||
328 | "uTextureMatrixTransformDiffuse0", | ||
329 | "uTextureMatrixTransformSpecular0", | ||
330 | "uTextureMatrixTransformEmission0", | ||
331 | "uTextureMatrixTransformNormal0", | ||
332 | "uTextureMatrixTransformAmbient1", | ||
333 | "uTextureMatrixTransformDiffuse1", | ||
334 | "uTextureMatrixTransformSpecular1", | ||
335 | "uTextureMatrixTransformEmission1", | ||
336 | "uTextureMatrixTransformNormal1", | ||
315 | "uShadowMap", | 337 | "uShadowMap", |
316 | "uLightPosition", | 338 | "uLightPosition", |
317 | "uLightSpotDir", | 339 | "uLightSpotDir", |
@@ -344,6 +366,15 @@ _program_uniform_init(E3D_Program *program) | |||
344 | static inline void | 366 | static inline void |
345 | _uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data) | 367 | _uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data) |
346 | { | 368 | { |
369 | #define SET_TEX_COORD_TRANSFORM_MATRIX(attrib, tn) \ | ||
370 | if (data->materials[attrib].tex##tn) \ | ||
371 | { \ | ||
372 | float m[9]; \ | ||
373 | for(int i = 0 ; i < 9 ; i++) \ | ||
374 | m[i] = data->materials[attrib].tex##tn->trans.m[i]; \ | ||
375 | glUniformMatrix3fv(loc, 1, EINA_FALSE, &m[0]); \ | ||
376 | } | ||
377 | |||
347 | switch (u) | 378 | switch (u) |
348 | { | 379 | { |
349 | case E3D_UNIFORM_MATRIX_MVP: { | 380 | case E3D_UNIFORM_MATRIX_MVP: { |
@@ -434,6 +465,46 @@ _uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data) | |||
434 | case E3D_UNIFORM_TEXTURE_NORMAL1: | 465 | case E3D_UNIFORM_TEXTURE_NORMAL1: |
435 | glUniform1i(loc, data->materials[EVAS_3D_MATERIAL_NORMAL].sampler1); | 466 | glUniform1i(loc, data->materials[EVAS_3D_MATERIAL_NORMAL].sampler1); |
436 | break; | 467 | break; |
468 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_AMBIENT0: { | ||
469 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_AMBIENT, 0) | ||
470 | break; | ||
471 | } | ||
472 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_DIFFUSE0: { | ||
473 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_DIFFUSE, 0) | ||
474 | break; | ||
475 | } | ||
476 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_SPECULAR0: { | ||
477 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_SPECULAR, 0) | ||
478 | break; | ||
479 | } | ||
480 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_EMISSION0: { | ||
481 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_EMISSION, 0) | ||
482 | break; | ||
483 | } | ||
484 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_NORMAL0: { | ||
485 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_NORMAL, 0) | ||
486 | break; | ||
487 | } | ||
488 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_AMBIENT1: { | ||
489 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_AMBIENT, 1) | ||
490 | break; | ||
491 | } | ||
492 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_DIFFUSE1: { | ||
493 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_DIFFUSE, 1) | ||
494 | break; | ||
495 | } | ||
496 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_SPECULAR1: { | ||
497 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_SPECULAR, 1) | ||
498 | break; | ||
499 | } | ||
500 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_EMISSION1: { | ||
501 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_EMISSION, 1) | ||
502 | break; | ||
503 | } | ||
504 | case E3D_UNIFORM_TEXTURE_MATRIX_TRANSFORM_NORMAL1: { | ||
505 | SET_TEX_COORD_TRANSFORM_MATRIX(EVAS_3D_MATERIAL_NORMAL, 1) | ||
506 | break; | ||
507 | } | ||
437 | case E3D_UNIFORM_SHADOWMAP: | 508 | case E3D_UNIFORM_SHADOWMAP: |
438 | glUniform1i(loc, data->smap_sampler); | 509 | glUniform1i(loc, data->smap_sampler); |
439 | break; | 510 | break; |
@@ -512,6 +583,7 @@ _uniform_upload(E3D_Uniform u, GLint loc, const E3D_Draw_Data *data) | |||
512 | ERR("Invalid uniform ID."); | 583 | ERR("Invalid uniform ID."); |
513 | break; | 584 | break; |
514 | } | 585 | } |
586 | #undef SET_TEX_SHIFT | ||
515 | } | 587 | } |
516 | 588 | ||
517 | void | 589 | void |
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 62e26265da..75cbec2f35 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 | |||
@@ -129,22 +129,28 @@ static const char diffuse_frag_glsl[] = | |||
129 | "uniform vec4 uLightDiffuse;\n" | 129 | "uniform vec4 uLightDiffuse;\n" |
130 | "#ifdef DIFFUSE_TEXTURE\n" | 130 | "#ifdef DIFFUSE_TEXTURE\n" |
131 | "uniform sampler2D uTextureDiffuse0;\n" | 131 | "uniform sampler2D uTextureDiffuse0;\n" |
132 | "uniform mat3 uTextureMatrixTransformDiffuse0;\n" | ||
133 | "vec3 Tex0CoordDiffuse = \n" | ||
134 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse0;\n" | ||
132 | "#endif //DIFFUSE_TEXTURE\n" | 135 | "#endif //DIFFUSE_TEXTURE\n" |
133 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 136 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
134 | "uniform sampler2D uTextureDiffuse1;\n" | 137 | "uniform sampler2D uTextureDiffuse1;\n" |
135 | "uniform float uTextureDiffuseWeight;\n" | 138 | "uniform float uTextureDiffuseWeight;\n" |
139 | "uniform mat3 uTextureMatrixTransformDiffuse1;\n" | ||
140 | "vec3 Tex1CoordDiffuse = \n" | ||
141 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse1;\n" | ||
136 | "#endif //DIFFUSE_TEXTURE_BLEND\n" | 142 | "#endif //DIFFUSE_TEXTURE_BLEND\n" |
137 | "#endif //DIFFUSE\n" | 143 | "#endif //DIFFUSE\n" |
138 | "void main() {\n" | 144 | "void main() {\n" |
139 | " vec4 color;\n" | 145 | " vec4 color;\n" |
140 | " \n" | 146 | " \n" |
141 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 147 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
142 | " color = mix(texture2D(uTextureDiffuse1, vTexCoord),\n" | 148 | " color = mix(texture2D(uTextureDiffuse1, vec2(Tex1CoordDiffuse)),\n" |
143 | " texture2D(uTextureDiffuse0, vTexCoord), uTextureDiffuseWeight);\n" | 149 | " texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)), uTextureDiffuseWeight);\n" |
144 | " color *= uMaterialDiffuse;\n" | 150 | " color *= uMaterialDiffuse;\n" |
145 | "#else\n" | 151 | "#else\n" |
146 | "#ifdef DIFFUSE_TEXTURE\n" | 152 | "#ifdef DIFFUSE_TEXTURE\n" |
147 | " color = texture2D(uTextureDiffuse0, vTexCoord) * uMaterialDiffuse;\n" | 153 | " color = texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)) * uMaterialDiffuse;\n" |
148 | "#else\n" | 154 | "#else\n" |
149 | " color = uMaterialDiffuse;\n" | 155 | " color = uMaterialDiffuse;\n" |
150 | "#endif //DIFFUSE_TEXTURE\n" | 156 | "#endif //DIFFUSE_TEXTURE\n" |
@@ -309,7 +315,7 @@ static const char flat_frag_glsl[] = | |||
309 | " shadow = 0.0;\n" | 315 | " shadow = 0.0;\n" |
310 | " for (i = -4.0; i < 4.0; i++)\n" | 316 | " for (i = -4.0; i < 4.0; i++)\n" |
311 | " for (j = -4.0; j < 4.0; j++)\n" | 317 | " for (j = -4.0; j < 4.0; j++)\n" |
312 | " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0)*size).x);\n" | 318 | " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0) * size).x);\n" |
313 | " return shadow / 64.0;\n" | 319 | " return shadow / 64.0;\n" |
314 | "}\n" | 320 | "}\n" |
315 | "#endif //SHADOWED\n" | 321 | "#endif //SHADOWED\n" |
@@ -318,10 +324,16 @@ static const char flat_frag_glsl[] = | |||
318 | "uniform vec4 uLightDiffuse;\n" | 324 | "uniform vec4 uLightDiffuse;\n" |
319 | "#ifdef DIFFUSE_TEXTURE\n" | 325 | "#ifdef DIFFUSE_TEXTURE\n" |
320 | "uniform sampler2D uTextureDiffuse0;\n" | 326 | "uniform sampler2D uTextureDiffuse0;\n" |
327 | "uniform mat3 uTextureMatrixTransformDiffuse0;\n" | ||
328 | "vec3 Tex0CoordDiffuse = \n" | ||
329 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse0;\n" | ||
321 | "#endif //DIFFUSE_TEXTURE\n" | 330 | "#endif //DIFFUSE_TEXTURE\n" |
322 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 331 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
323 | "uniform sampler2D uTextureDiffuse1;\n" | 332 | "uniform sampler2D uTextureDiffuse1;\n" |
324 | "uniform float uTextureDiffuseWeight;\n" | 333 | "uniform float uTextureDiffuseWeight;\n" |
334 | "uniform mat3 uTextureMatrixTransformDiffuse1;\n" | ||
335 | "vec3 Tex1CoordDiffuse = \n" | ||
336 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse1;\n" | ||
325 | "#endif //DIFFUSE_TEXTURE_BLEND\n" | 337 | "#endif //DIFFUSE_TEXTURE_BLEND\n" |
326 | "#endif //DIFFUSE\n" | 338 | "#endif //DIFFUSE\n" |
327 | "#ifdef SPECULAR\n" | 339 | "#ifdef SPECULAR\n" |
@@ -330,10 +342,16 @@ static const char flat_frag_glsl[] = | |||
330 | "uniform vec4 uMaterialSpecular;\n" | 342 | "uniform vec4 uMaterialSpecular;\n" |
331 | "#ifdef SPECULAR_TEXTURE\n" | 343 | "#ifdef SPECULAR_TEXTURE\n" |
332 | "uniform sampler2D uTextureSpecular0;\n" | 344 | "uniform sampler2D uTextureSpecular0;\n" |
345 | "uniform mat3 uTextureMatrixTransformSpecular0;\n" | ||
346 | "vec3 Tex0CoordSpecular = \n" | ||
347 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformSpecular0;\n" | ||
333 | "#endif //SPECULAR_TEXTURE\n" | 348 | "#endif //SPECULAR_TEXTURE\n" |
334 | "#ifdef SPECULAR_TEXTURE_BLEND\n" | 349 | "#ifdef SPECULAR_TEXTURE_BLEND\n" |
335 | "uniform sampler2D uTextureSpecular1;\n" | 350 | "uniform sampler2D uTextureSpecular1;\n" |
336 | "uniform float uTextureSpecularWeight;\n" | 351 | "uniform float uTextureSpecularWeight;\n" |
352 | "uniform mat3 uTextureMatrixTransformSpecular1;\n" | ||
353 | "vec3 Tex1CoordSpecular = \n" | ||
354 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformSpecular1;\n" | ||
337 | "#endif //SPECULAR_TEXTURE_BLEND\n" | 355 | "#endif //SPECULAR_TEXTURE_BLEND\n" |
338 | "#endif //SPECULAR\n" | 356 | "#endif //SPECULAR\n" |
339 | "#ifdef AMBIENT\n" | 357 | "#ifdef AMBIENT\n" |
@@ -341,20 +359,32 @@ static const char flat_frag_glsl[] = | |||
341 | "uniform vec4 uLightAmbient;\n" | 359 | "uniform vec4 uLightAmbient;\n" |
342 | "#ifdef AMBIENT_TEXTURE\n" | 360 | "#ifdef AMBIENT_TEXTURE\n" |
343 | "uniform sampler2D uTextureAmbient0;\n" | 361 | "uniform sampler2D uTextureAmbient0;\n" |
362 | "uniform mat3 uTextureMatrixTransformAmbient0;\n" | ||
363 | "vec3 Tex0CoordAmbient = \n" | ||
364 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformAmbient0;\n" | ||
344 | "#endif //AMBIENT_TEXTURE\n" | 365 | "#endif //AMBIENT_TEXTURE\n" |
345 | "#ifdef AMBIENT_TEXTURE_BLEND\n" | 366 | "#ifdef AMBIENT_TEXTURE_BLEND\n" |
346 | "uniform sampler2D uTextureAmbient1;\n" | 367 | "uniform sampler2D uTextureAmbient1;\n" |
347 | "uniform float uTextureAmbientWeight;\n" | 368 | "uniform float uTextureAmbientWeight;\n" |
369 | "uniform mat3 uTextureMatrixTransformAmbient1;\n" | ||
370 | "vec3 Tex1CoordAmbient = \n" | ||
371 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformAmbient1;\n" | ||
348 | "#endif //AMBIENT_TEXTURE_BLEND\n" | 372 | "#endif //AMBIENT_TEXTURE_BLEND\n" |
349 | "#endif //AMBIENT\n" | 373 | "#endif //AMBIENT\n" |
350 | "#ifdef EMISSION\n" | 374 | "#ifdef EMISSION\n" |
351 | "uniform vec4 uMaterialEmission;\n" | 375 | "uniform vec4 uMaterialEmission;\n" |
352 | "#ifdef EMISSION_TEXTURE\n" | 376 | "#ifdef EMISSION_TEXTURE\n" |
353 | "uniform sampler2D uTextureEmission0;\n" | 377 | "uniform sampler2D uTextureEmission0;\n" |
378 | "uniform mat3 uTextureMatrixTransformEmission0;\n" | ||
379 | "vec3 Tex0CoordEmission = \n" | ||
380 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformEmission0;\n" | ||
354 | "#endif //EMISSION_TEXTURE\n" | 381 | "#endif //EMISSION_TEXTURE\n" |
355 | "#ifdef EMISSION_TEXTURE_BLEND\n" | 382 | "#ifdef EMISSION_TEXTURE_BLEND\n" |
356 | "uniform sampler2D uTextureEmission1;\n" | 383 | "uniform sampler2D uTextureEmission1;\n" |
357 | "uniform float uTextureEmissionWeight;\n" | 384 | "uniform float uTextureEmissionWeight;\n" |
385 | "uniform mat3 uTextureMatrixTransformEmission1;\n" | ||
386 | "vec3 Tex1CoordEmission = \n" | ||
387 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformEmission1;\n" | ||
358 | "#endif //EMISSION_TEXTURE_BLEND\n" | 388 | "#endif //EMISSION_TEXTURE_BLEND\n" |
359 | "#endif //EMISSION\n" | 389 | "#endif //EMISSION\n" |
360 | "void fragmentFlat()\n" | 390 | "void fragmentFlat()\n" |
@@ -363,12 +393,12 @@ static const char flat_frag_glsl[] = | |||
363 | "#ifdef DIFFUSE\n" | 393 | "#ifdef DIFFUSE\n" |
364 | " \n" | 394 | " \n" |
365 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 395 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
366 | " color = mix(texture2D(uTextureDiffuse1, vTexCoord),\n" | 396 | " color = mix(texture2D(uTextureDiffuse1, vec2(Tex1CoordDiffuse)),\n" |
367 | " texture2D(uTextureDiffuse0, vTexCoord), uTextureDiffuseWeight);\n" | 397 | " texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)), uTextureDiffuseWeight);\n" |
368 | " color *= uMaterialDiffuse;\n" | 398 | " color *= uMaterialDiffuse;\n" |
369 | "#else\n" | 399 | "#else\n" |
370 | "#ifdef DIFFUSE_TEXTURE\n" | 400 | "#ifdef DIFFUSE_TEXTURE\n" |
371 | " color = texture2D(uTextureDiffuse0, vTexCoord) * uMaterialDiffuse;\n" | 401 | " color = texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)) * uMaterialDiffuse;\n" |
372 | "#else\n" | 402 | "#else\n" |
373 | " color = uMaterialDiffuse;\n" | 403 | " color = uMaterialDiffuse;\n" |
374 | "#endif //DIFFUSE_TEXTURE\n" | 404 | "#endif //DIFFUSE_TEXTURE\n" |
@@ -380,12 +410,12 @@ static const char flat_frag_glsl[] = | |||
380 | "#ifdef SPECULAR\n" | 410 | "#ifdef SPECULAR\n" |
381 | " \n" | 411 | " \n" |
382 | "#ifdef SPECULAR_TEXTURE_BLEND\n" | 412 | "#ifdef SPECULAR_TEXTURE_BLEND\n" |
383 | " color = mix(texture2D(uTextureSpecular1, vTexCoord),\n" | 413 | " color = mix(texture2D(uTextureSpecular1, vec2(Tex1CoordSpecular)),\n" |
384 | " texture2D(uTextureSpecular0, vTexCoord), uTextureSpecularWeight);\n" | 414 | " texture2D(uTextureSpecular0, vec2(Tex0CoordSpecular)), uTextureSpecularWeight);\n" |
385 | " color *= uMaterialSpecular;\n" | 415 | " color *= uMaterialSpecular;\n" |
386 | "#else\n" | 416 | "#else\n" |
387 | "#ifdef SPECULAR_TEXTURE\n" | 417 | "#ifdef SPECULAR_TEXTURE\n" |
388 | " color = texture2D(uTextureSpecular0, vTexCoord) * uMaterialSpecular;\n" | 418 | " color = texture2D(uTextureSpecular0, vec2(Tex0CoordSpecular)) * uMaterialSpecular;\n" |
389 | "#else\n" | 419 | "#else\n" |
390 | " color = uMaterialSpecular;\n" | 420 | " color = uMaterialSpecular;\n" |
391 | "#endif //SPECULAR_TEXTURE\n" | 421 | "#endif //SPECULAR_TEXTURE\n" |
@@ -398,12 +428,12 @@ static const char flat_frag_glsl[] = | |||
398 | "#ifdef AMBIENT\n" | 428 | "#ifdef AMBIENT\n" |
399 | " \n" | 429 | " \n" |
400 | "#ifdef AMBIENT_TEXTURE_BLEND\n" | 430 | "#ifdef AMBIENT_TEXTURE_BLEND\n" |
401 | " color = mix(texture2D(uTextureAmbient1, vTexCoord),\n" | 431 | " color = mix(texture2D(uTextureAmbient1, vec2(Tex1CoordAmbient)),\n" |
402 | " texture2D(uTextureAmbient0, vTexCoord), uTextureAmbientWeight);\n" | 432 | " texture2D(uTextureAmbient0, vec2(Tex0CoordAmbient)), uTextureAmbientWeight);\n" |
403 | " color *= uMaterialAmbient;\n" | 433 | " color *= uMaterialAmbient;\n" |
404 | "#else\n" | 434 | "#else\n" |
405 | "#ifdef AMBIENT_TEXTURE\n" | 435 | "#ifdef AMBIENT_TEXTURE\n" |
406 | " color = texture2D(uTextureAmbient0, vTexCoord) * uMaterialAmbient;\n" | 436 | " color = texture2D(uTextureAmbient0, vec2(Tex0CoordAmbient)) * uMaterialAmbient;\n" |
407 | "#else\n" | 437 | "#else\n" |
408 | " color = uMaterialAmbient;\n" | 438 | " color = uMaterialAmbient;\n" |
409 | "#endif //AMBIENT_TEXTURE\n" | 439 | "#endif //AMBIENT_TEXTURE\n" |
@@ -413,12 +443,12 @@ static const char flat_frag_glsl[] = | |||
413 | "#ifdef EMISSION\n" | 443 | "#ifdef EMISSION\n" |
414 | " \n" | 444 | " \n" |
415 | "#ifdef EMISSION_TEXTURE_BLEND\n" | 445 | "#ifdef EMISSION_TEXTURE_BLEND\n" |
416 | " color = mix(texture2D(uTextureEmission1, vTexCoord),\n" | 446 | " color = mix(texture2D(uTextureEmission1, vec2(Tex1CoordEmission)),\n" |
417 | " texture2D(uTextureEmission0, vTexCoord), uTextureEmissionWeight);\n" | 447 | " texture2D(uTextureEmission0, vec2(Tex0CoordEmission)), uTextureEmissionWeight);\n" |
418 | " color *= uMaterialEmission;\n" | 448 | " color *= uMaterialEmission;\n" |
419 | "#else\n" | 449 | "#else\n" |
420 | "#ifdef EMISSION_TEXTURE\n" | 450 | "#ifdef EMISSION_TEXTURE\n" |
421 | " color = texture2D(uTextureEmission0, vTexCoord) * uMaterialEmission;\n" | 451 | " color = texture2D(uTextureEmission0, vec2(Tex0CoordEmission)) * uMaterialEmission;\n" |
422 | "#else\n" | 452 | "#else\n" |
423 | " color = uMaterialEmission;\n" | 453 | " color = uMaterialEmission;\n" |
424 | "#endif //EMISSION_TEXTURE\n" | 454 | "#endif //EMISSION_TEXTURE\n" |
@@ -560,7 +590,7 @@ static const char phong_frag_glsl[] = | |||
560 | " shadow = 0.0;\n" | 590 | " shadow = 0.0;\n" |
561 | " for (i = -4.0; i < 4.0; i++)\n" | 591 | " for (i = -4.0; i < 4.0; i++)\n" |
562 | " for (j = -4.0; j < 4.0; j++)\n" | 592 | " for (j = -4.0; j < 4.0; j++)\n" |
563 | " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0)*size).x);\n" | 593 | " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0) * size).x);\n" |
564 | " return shadow / 64.0;\n" | 594 | " return shadow / 64.0;\n" |
565 | "}\n" | 595 | "}\n" |
566 | "#endif //SHADOWED\n" | 596 | "#endif //SHADOWED\n" |
@@ -569,10 +599,16 @@ static const char phong_frag_glsl[] = | |||
569 | "uniform vec4 uLightDiffuse;\n" | 599 | "uniform vec4 uLightDiffuse;\n" |
570 | "#ifdef DIFFUSE_TEXTURE\n" | 600 | "#ifdef DIFFUSE_TEXTURE\n" |
571 | "uniform sampler2D uTextureDiffuse0;\n" | 601 | "uniform sampler2D uTextureDiffuse0;\n" |
602 | "uniform mat3 uTextureMatrixTransformDiffuse0;\n" | ||
603 | "vec3 Tex0CoordDiffuse = \n" | ||
604 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse0;\n" | ||
572 | "#endif //DIFFUSE_TEXTURE\n" | 605 | "#endif //DIFFUSE_TEXTURE\n" |
573 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 606 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
574 | "uniform sampler2D uTextureDiffuse1;\n" | 607 | "uniform sampler2D uTextureDiffuse1;\n" |
575 | "uniform float uTextureDiffuseWeight;\n" | 608 | "uniform float uTextureDiffuseWeight;\n" |
609 | "uniform mat3 uTextureMatrixTransformDiffuse1;\n" | ||
610 | "vec3 Tex1CoordDiffuse = \n" | ||
611 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse1;\n" | ||
576 | "#endif //DIFFUSE_TEXTURE_BLEND\n" | 612 | "#endif //DIFFUSE_TEXTURE_BLEND\n" |
577 | "#endif //DIFFUSE\n" | 613 | "#endif //DIFFUSE\n" |
578 | "#ifdef SPECULAR\n" | 614 | "#ifdef SPECULAR\n" |
@@ -581,10 +617,16 @@ static const char phong_frag_glsl[] = | |||
581 | "uniform vec4 uMaterialSpecular;\n" | 617 | "uniform vec4 uMaterialSpecular;\n" |
582 | "#ifdef SPECULAR_TEXTURE\n" | 618 | "#ifdef SPECULAR_TEXTURE\n" |
583 | "uniform sampler2D uTextureSpecular0;\n" | 619 | "uniform sampler2D uTextureSpecular0;\n" |
620 | "uniform mat3 uTextureMatrixTransformSpecular0;\n" | ||
621 | "vec3 Tex0CoordSpecular = \n" | ||
622 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformSpecular0;\n" | ||
584 | "#endif //SPECULAR_TEXTURE\n" | 623 | "#endif //SPECULAR_TEXTURE\n" |
585 | "#ifdef SPECULAR_TEXTURE_BLEND\n" | 624 | "#ifdef SPECULAR_TEXTURE_BLEND\n" |
586 | "uniform sampler2D uTextureSpecular1;\n" | 625 | "uniform sampler2D uTextureSpecular1;\n" |
587 | "uniform float uTextureSpecularWeight;\n" | 626 | "uniform float uTextureSpecularWeight;\n" |
627 | "uniform mat3 uTextureMatrixTransformSpecular1;\n" | ||
628 | "vec3 Tex1CoordSpecular = \n" | ||
629 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformSpecular1;\n" | ||
588 | "#endif //SPECULAR_TEXTURE_BLEND\n" | 630 | "#endif //SPECULAR_TEXTURE_BLEND\n" |
589 | "#endif //SPECULAR\n" | 631 | "#endif //SPECULAR\n" |
590 | "#ifdef AMBIENT\n" | 632 | "#ifdef AMBIENT\n" |
@@ -592,20 +634,32 @@ static const char phong_frag_glsl[] = | |||
592 | "uniform vec4 uLightAmbient;\n" | 634 | "uniform vec4 uLightAmbient;\n" |
593 | "#ifdef AMBIENT_TEXTURE\n" | 635 | "#ifdef AMBIENT_TEXTURE\n" |
594 | "uniform sampler2D uTextureAmbient0;\n" | 636 | "uniform sampler2D uTextureAmbient0;\n" |
637 | "uniform mat3 uTextureMatrixTransformAmbient0;\n" | ||
638 | "vec3 Tex0CoordAmbient = \n" | ||
639 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformAmbient0;\n" | ||
595 | "#endif //AMBIENT_TEXTURE\n" | 640 | "#endif //AMBIENT_TEXTURE\n" |
596 | "#ifdef AMBIENT_TEXTURE_BLEND\n" | 641 | "#ifdef AMBIENT_TEXTURE_BLEND\n" |
597 | "uniform sampler2D uTextureAmbient1;\n" | 642 | "uniform sampler2D uTextureAmbient1;\n" |
598 | "uniform float uTextureAmbientWeight;\n" | 643 | "uniform float uTextureAmbientWeight;\n" |
644 | "uniform mat3 uTextureMatrixTransformAmbient1;\n" | ||
645 | "vec3 Tex1CoordAmbient = \n" | ||
646 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformAmbient1;\n" | ||
599 | "#endif //AMBIENT_TEXTURE_BLEND\n" | 647 | "#endif //AMBIENT_TEXTURE_BLEND\n" |
600 | "#endif //AMBIENT\n" | 648 | "#endif //AMBIENT\n" |
601 | "#ifdef EMISSION\n" | 649 | "#ifdef EMISSION\n" |
602 | "uniform vec4 uMaterialEmission;\n" | 650 | "uniform vec4 uMaterialEmission;\n" |
603 | "#ifdef EMISSION_TEXTURE\n" | 651 | "#ifdef EMISSION_TEXTURE\n" |
604 | "uniform sampler2D uTextureEmission0;\n" | 652 | "uniform sampler2D uTextureEmission0;\n" |
653 | "uniform mat3 uTextureMatrixTransformEmission0;\n" | ||
654 | "vec3 Tex0CoordEmission = \n" | ||
655 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformEmission0;\n" | ||
605 | "#endif //EMISSION_TEXTURE\n" | 656 | "#endif //EMISSION_TEXTURE\n" |
606 | "#ifdef EMISSION_TEXTURE_BLEND\n" | 657 | "#ifdef EMISSION_TEXTURE_BLEND\n" |
607 | "uniform sampler2D uTextureEmission1;\n" | 658 | "uniform sampler2D uTextureEmission1;\n" |
608 | "uniform float uTextureEmissionWeight;\n" | 659 | "uniform float uTextureEmissionWeight;\n" |
660 | "uniform mat3 uTextureMatrixTransformEmission1;\n" | ||
661 | "vec3 Tex1CoordEmission = \n" | ||
662 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformEmission1;\n" | ||
609 | "#endif //EMISSION_TEXTURE_BLEND\n" | 663 | "#endif //EMISSION_TEXTURE_BLEND\n" |
610 | "#endif //EMISSION\n" | 664 | "#endif //EMISSION\n" |
611 | "#ifdef LIGHT_SPOT\n" | 665 | "#ifdef LIGHT_SPOT\n" |
@@ -635,12 +689,12 @@ static const char phong_frag_glsl[] = | |||
635 | "#ifdef DIFFUSE\n" | 689 | "#ifdef DIFFUSE\n" |
636 | " \n" | 690 | " \n" |
637 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 691 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
638 | " color = mix(texture2D(uTextureDiffuse1, vTexCoord),\n" | 692 | " color = mix(texture2D(uTextureDiffuse1, vec2(Tex1CoordDiffuse)),\n" |
639 | " texture2D(uTextureDiffuse0, vTexCoord), uTextureDiffuseWeight);\n" | 693 | " texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)), uTextureDiffuseWeight);\n" |
640 | " color *= uMaterialDiffuse;\n" | 694 | " color *= uMaterialDiffuse;\n" |
641 | "#else\n" | 695 | "#else\n" |
642 | "#ifdef DIFFUSE_TEXTURE\n" | 696 | "#ifdef DIFFUSE_TEXTURE\n" |
643 | " color = texture2D(uTextureDiffuse0, vTexCoord) * uMaterialDiffuse;\n" | 697 | " color = texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)) * uMaterialDiffuse;\n" |
644 | "#else\n" | 698 | "#else\n" |
645 | " color = uMaterialDiffuse;\n" | 699 | " color = uMaterialDiffuse;\n" |
646 | "#endif //DIFFUSE_TEXTURE\n" | 700 | "#endif //DIFFUSE_TEXTURE\n" |
@@ -657,12 +711,12 @@ static const char phong_frag_glsl[] = | |||
657 | " factor = pow(factor, uMaterialShininess);\n" | 711 | " factor = pow(factor, uMaterialShininess);\n" |
658 | " \n" | 712 | " \n" |
659 | "#ifdef SPECULAR_TEXTURE_BLEND\n" | 713 | "#ifdef SPECULAR_TEXTURE_BLEND\n" |
660 | " color = mix(texture2D(uTextureSpecular1, vTexCoord),\n" | 714 | " color = mix(texture2D(uTextureSpecular1, vec2(Tex1CoordSpecular)),\n" |
661 | " texture2D(uTextureSpecular0, vTexCoord), uTextureSpecularWeight);\n" | 715 | " texture2D(uTextureSpecular0, vec2(Tex0CoordSpecular)), uTextureSpecularWeight);\n" |
662 | " color *= uMaterialSpecular;\n" | 716 | " color *= uMaterialSpecular;\n" |
663 | "#else\n" | 717 | "#else\n" |
664 | "#ifdef SPECULAR_TEXTURE\n" | 718 | "#ifdef SPECULAR_TEXTURE\n" |
665 | " color = texture2D(uTextureSpecular0, vTexCoord) * uMaterialSpecular;\n" | 719 | " color = texture2D(uTextureSpecular0, vec2(Tex0CoordSpecular)) * uMaterialSpecular;\n" |
666 | "#else\n" | 720 | "#else\n" |
667 | " color = uMaterialSpecular;\n" | 721 | " color = uMaterialSpecular;\n" |
668 | "#endif //SPECULAR_TEXTURE\n" | 722 | "#endif //SPECULAR_TEXTURE\n" |
@@ -679,12 +733,12 @@ static const char phong_frag_glsl[] = | |||
679 | "#ifdef AMBIENT\n" | 733 | "#ifdef AMBIENT\n" |
680 | " \n" | 734 | " \n" |
681 | "#ifdef AMBIENT_TEXTURE_BLEND\n" | 735 | "#ifdef AMBIENT_TEXTURE_BLEND\n" |
682 | " color = mix(texture2D(uTextureAmbient1, vTexCoord),\n" | 736 | " color = mix(texture2D(uTextureAmbient1, vec2(Tex1CoordAmbient)),\n" |
683 | " texture2D(uTextureAmbient0, vTexCoord), uTextureAmbientWeight);\n" | 737 | " texture2D(uTextureAmbient0, vec2(Tex0CoordAmbient)), uTextureAmbientWeight);\n" |
684 | " color *= uMaterialAmbient;\n" | 738 | " color *= uMaterialAmbient;\n" |
685 | "#else\n" | 739 | "#else\n" |
686 | "#ifdef AMBIENT_TEXTURE\n" | 740 | "#ifdef AMBIENT_TEXTURE\n" |
687 | " color = texture2D(uTextureAmbient0, vTexCoord) * uMaterialAmbient;\n" | 741 | " color = texture2D(uTextureAmbient0, vec2(Tex0CoordAmbient)) * uMaterialAmbient;\n" |
688 | "#else\n" | 742 | "#else\n" |
689 | " color = uMaterialAmbient;\n" | 743 | " color = uMaterialAmbient;\n" |
690 | "#endif //AMBIENT_TEXTURE\n" | 744 | "#endif //AMBIENT_TEXTURE\n" |
@@ -699,12 +753,12 @@ static const char phong_frag_glsl[] = | |||
699 | "#ifdef EMISSION\n" | 753 | "#ifdef EMISSION\n" |
700 | " \n" | 754 | " \n" |
701 | "#ifdef EMISSION_TEXTURE_BLEND\n" | 755 | "#ifdef EMISSION_TEXTURE_BLEND\n" |
702 | " color = mix(texture2D(uTextureEmission1, vTexCoord),\n" | 756 | " color = mix(texture2D(uTextureEmission1, vec2(Tex1CoordEmission)),\n" |
703 | " texture2D(uTextureEmission0, vTexCoord), uTextureEmissionWeight);\n" | 757 | " texture2D(uTextureEmission0, vec2(Tex0CoordEmission)), uTextureEmissionWeight);\n" |
704 | " color *= uMaterialEmission;\n" | 758 | " color *= uMaterialEmission;\n" |
705 | "#else\n" | 759 | "#else\n" |
706 | "#ifdef EMISSION_TEXTURE\n" | 760 | "#ifdef EMISSION_TEXTURE\n" |
707 | " color = texture2D(uTextureEmission0, vTexCoord) * uMaterialEmission;\n" | 761 | " color = texture2D(uTextureEmission0, vec2(Tex0CoordEmission)) * uMaterialEmission;\n" |
708 | "#else\n" | 762 | "#else\n" |
709 | " color = uMaterialEmission;\n" | 763 | " color = uMaterialEmission;\n" |
710 | "#endif //EMISSION_TEXTURE\n" | 764 | "#endif //EMISSION_TEXTURE\n" |
@@ -905,7 +959,7 @@ static const char normal_map_frag_glsl[] = | |||
905 | " shadow = 0.0;\n" | 959 | " shadow = 0.0;\n" |
906 | " for (i = -4.0; i < 4.0; i++)\n" | 960 | " for (i = -4.0; i < 4.0; i++)\n" |
907 | " for (j = -4.0; j < 4.0; j++)\n" | 961 | " for (j = -4.0; j < 4.0; j++)\n" |
908 | " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0)*size).x);\n" | 962 | " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0) * size).x);\n" |
909 | " return shadow / 64.0;\n" | 963 | " return shadow / 64.0;\n" |
910 | "}\n" | 964 | "}\n" |
911 | "#endif //SHADOWED\n" | 965 | "#endif //SHADOWED\n" |
@@ -921,10 +975,16 @@ static const char normal_map_frag_glsl[] = | |||
921 | "uniform vec4 uLightDiffuse;\n" | 975 | "uniform vec4 uLightDiffuse;\n" |
922 | "#ifdef DIFFUSE_TEXTURE\n" | 976 | "#ifdef DIFFUSE_TEXTURE\n" |
923 | "uniform sampler2D uTextureDiffuse0;\n" | 977 | "uniform sampler2D uTextureDiffuse0;\n" |
978 | "uniform mat3 uTextureMatrixTransformDiffuse0;\n" | ||
979 | "vec3 Tex0CoordDiffuse = \n" | ||
980 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse0;\n" | ||
924 | "#endif //DIFFUSE_TEXTURE\n" | 981 | "#endif //DIFFUSE_TEXTURE\n" |
925 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 982 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
926 | "uniform sampler2D uTextureDiffuse1;\n" | 983 | "uniform sampler2D uTextureDiffuse1;\n" |
927 | "uniform float uTextureDiffuseWeight;\n" | 984 | "uniform float uTextureDiffuseWeight;\n" |
985 | "uniform mat3 uTextureMatrixTransformDiffuse1;\n" | ||
986 | "vec3 Tex1CoordDiffuse = \n" | ||
987 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse1;\n" | ||
928 | "#endif //DIFFUSE_TEXTURE_BLEND\n" | 988 | "#endif //DIFFUSE_TEXTURE_BLEND\n" |
929 | "#endif //DIFFUSE\n" | 989 | "#endif //DIFFUSE\n" |
930 | "#ifdef SPECULAR\n" | 990 | "#ifdef SPECULAR\n" |
@@ -933,10 +993,16 @@ static const char normal_map_frag_glsl[] = | |||
933 | "uniform vec4 uMaterialSpecular;\n" | 993 | "uniform vec4 uMaterialSpecular;\n" |
934 | "#ifdef SPECULAR_TEXTURE\n" | 994 | "#ifdef SPECULAR_TEXTURE\n" |
935 | "uniform sampler2D uTextureSpecular0;\n" | 995 | "uniform sampler2D uTextureSpecular0;\n" |
996 | "uniform mat3 uTextureMatrixTransformSpecular0;\n" | ||
997 | "vec3 Tex0CoordSpecular = \n" | ||
998 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformSpecular0;\n" | ||
936 | "#endif //SPECULAR_TEXTURE\n" | 999 | "#endif //SPECULAR_TEXTURE\n" |
937 | "#ifdef SPECULAR_TEXTURE_BLEND\n" | 1000 | "#ifdef SPECULAR_TEXTURE_BLEND\n" |
938 | "uniform sampler2D uTextureSpecular1;\n" | 1001 | "uniform sampler2D uTextureSpecular1;\n" |
939 | "uniform float uTextureSpecularWeight;\n" | 1002 | "uniform float uTextureSpecularWeight;\n" |
1003 | "uniform mat3 uTextureMatrixTransformSpecular1;\n" | ||
1004 | "vec3 Tex1CoordSpecular = \n" | ||
1005 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformSpecular1;\n" | ||
940 | "#endif //SPECULAR_TEXTURE_BLEND\n" | 1006 | "#endif //SPECULAR_TEXTURE_BLEND\n" |
941 | "#endif //SPECULAR\n" | 1007 | "#endif //SPECULAR\n" |
942 | "#ifdef AMBIENT\n" | 1008 | "#ifdef AMBIENT\n" |
@@ -944,20 +1010,32 @@ static const char normal_map_frag_glsl[] = | |||
944 | "uniform vec4 uLightAmbient;\n" | 1010 | "uniform vec4 uLightAmbient;\n" |
945 | "#ifdef AMBIENT_TEXTURE\n" | 1011 | "#ifdef AMBIENT_TEXTURE\n" |
946 | "uniform sampler2D uTextureAmbient0;\n" | 1012 | "uniform sampler2D uTextureAmbient0;\n" |
1013 | "uniform mat3 uTextureMatrixTransformAmbient0;\n" | ||
1014 | "vec3 Tex0CoordAmbient = \n" | ||
1015 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformAmbient0;\n" | ||
947 | "#endif //AMBIENT_TEXTURE\n" | 1016 | "#endif //AMBIENT_TEXTURE\n" |
948 | "#ifdef AMBIENT_TEXTURE_BLEND\n" | 1017 | "#ifdef AMBIENT_TEXTURE_BLEND\n" |
949 | "uniform sampler2D uTextureAmbient1;\n" | 1018 | "uniform sampler2D uTextureAmbient1;\n" |
950 | "uniform float uTextureAmbientWeight;\n" | 1019 | "uniform float uTextureAmbientWeight;\n" |
1020 | "uniform mat3 uTextureMatrixTransformAmbient1;\n" | ||
1021 | "vec3 Tex1CoordAmbient = \n" | ||
1022 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformAmbient1;\n" | ||
951 | "#endif //AMBIENT_TEXTURE_BLEND\n" | 1023 | "#endif //AMBIENT_TEXTURE_BLEND\n" |
952 | "#endif //AMBIENT\n" | 1024 | "#endif //AMBIENT\n" |
953 | "#ifdef EMISSION\n" | 1025 | "#ifdef EMISSION\n" |
954 | "uniform vec4 uMaterialEmission;\n" | 1026 | "uniform vec4 uMaterialEmission;\n" |
955 | "#ifdef EMISSION_TEXTURE\n" | 1027 | "#ifdef EMISSION_TEXTURE\n" |
956 | "uniform sampler2D uTextureEmission0;\n" | 1028 | "uniform sampler2D uTextureEmission0;\n" |
1029 | "uniform mat3 uTextureMatrixTransformEmission0;\n" | ||
1030 | "vec3 Tex0CoordEmission = \n" | ||
1031 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformEmission0;\n" | ||
957 | "#endif //EMISSION_TEXTURE\n" | 1032 | "#endif //EMISSION_TEXTURE\n" |
958 | "#ifdef EMISSION_TEXTURE_BLEND\n" | 1033 | "#ifdef EMISSION_TEXTURE_BLEND\n" |
959 | "uniform sampler2D uTextureEmission1;\n" | 1034 | "uniform sampler2D uTextureEmission1;\n" |
960 | "uniform float uTextureEmissionWeight;\n" | 1035 | "uniform float uTextureEmissionWeight;\n" |
1036 | "uniform mat3 uTextureMatrixTransformEmission1;\n" | ||
1037 | "vec3 Tex1CoordEmission = \n" | ||
1038 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformEmission1;\n" | ||
961 | "#endif //EMISSION_TEXTURE_BLEND\n" | 1039 | "#endif //EMISSION_TEXTURE_BLEND\n" |
962 | "#endif //EMISSION\n" | 1040 | "#endif //EMISSION\n" |
963 | "#ifdef LIGHT_SPOT\n" | 1041 | "#ifdef LIGHT_SPOT\n" |
@@ -1019,12 +1097,12 @@ static const char normal_map_frag_glsl[] = | |||
1019 | "#ifdef DIFFUSE\n" | 1097 | "#ifdef DIFFUSE\n" |
1020 | " \n" | 1098 | " \n" |
1021 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 1099 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
1022 | " color = mix(texture2D(uTextureDiffuse1, vTexCoord),\n" | 1100 | " color = mix(texture2D(uTextureDiffuse1, vec2(Tex1CoordDiffuse)),\n" |
1023 | " texture2D(uTextureDiffuse0, vTexCoord), uTextureDiffuseWeight);\n" | 1101 | " texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)), uTextureDiffuseWeight);\n" |
1024 | " color *= uMaterialDiffuse;\n" | 1102 | " color *= uMaterialDiffuse;\n" |
1025 | "#else\n" | 1103 | "#else\n" |
1026 | "#ifdef DIFFUSE_TEXTURE\n" | 1104 | "#ifdef DIFFUSE_TEXTURE\n" |
1027 | " color = texture2D(uTextureDiffuse0, vTexCoord) * uMaterialDiffuse;\n" | 1105 | " color = texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)) * uMaterialDiffuse;\n" |
1028 | "#else\n" | 1106 | "#else\n" |
1029 | " color = uMaterialDiffuse;\n" | 1107 | " color = uMaterialDiffuse;\n" |
1030 | "#endif //DIFFUSE_TEXTURE\n" | 1108 | "#endif //DIFFUSE_TEXTURE\n" |
@@ -1040,12 +1118,12 @@ static const char normal_map_frag_glsl[] = | |||
1040 | " factor = pow(factor, uMaterialShininess);\n" | 1118 | " factor = pow(factor, uMaterialShininess);\n" |
1041 | " \n" | 1119 | " \n" |
1042 | "#ifdef SPECULAR_TEXTURE_BLEND\n" | 1120 | "#ifdef SPECULAR_TEXTURE_BLEND\n" |
1043 | " color = mix(texture2D(uTextureSpecular1, vTexCoord),\n" | 1121 | " color = mix(texture2D(uTextureSpecular1, vec2(Tex1CoordSpecular)),\n" |
1044 | " texture2D(uTextureSpecular0, vTexCoord), uTextureSpecularWeight);\n" | 1122 | " texture2D(uTextureSpecular0, vec2(Tex0CoordSpecular)), uTextureSpecularWeight);\n" |
1045 | " color *= uMaterialSpecular;\n" | 1123 | " color *= uMaterialSpecular;\n" |
1046 | "#else\n" | 1124 | "#else\n" |
1047 | "#ifdef SPECULAR_TEXTURE\n" | 1125 | "#ifdef SPECULAR_TEXTURE\n" |
1048 | " color = texture2D(uTextureSpecular0, vTexCoord) * uMaterialSpecular;\n" | 1126 | " color = texture2D(uTextureSpecular0, vec2(Tex0CoordSpecular)) * uMaterialSpecular;\n" |
1049 | "#else\n" | 1127 | "#else\n" |
1050 | " color = uMaterialSpecular;\n" | 1128 | " color = uMaterialSpecular;\n" |
1051 | "#endif //SPECULAR_TEXTURE\n" | 1129 | "#endif //SPECULAR_TEXTURE\n" |
@@ -1062,12 +1140,12 @@ static const char normal_map_frag_glsl[] = | |||
1062 | "#ifdef AMBIENT\n" | 1140 | "#ifdef AMBIENT\n" |
1063 | " \n" | 1141 | " \n" |
1064 | "#ifdef AMBIENT_TEXTURE_BLEND\n" | 1142 | "#ifdef AMBIENT_TEXTURE_BLEND\n" |
1065 | " color = mix(texture2D(uTextureAmbient1, vTexCoord),\n" | 1143 | " color = mix(texture2D(uTextureAmbient1, vec2(Tex1CoordAmbient)),\n" |
1066 | " texture2D(uTextureAmbient0, vTexCoord), uTextureAmbientWeight);\n" | 1144 | " texture2D(uTextureAmbient0, vec2(Tex0CoordAmbient)), uTextureAmbientWeight);\n" |
1067 | " color *= uMaterialAmbient;\n" | 1145 | " color *= uMaterialAmbient;\n" |
1068 | "#else\n" | 1146 | "#else\n" |
1069 | "#ifdef AMBIENT_TEXTURE\n" | 1147 | "#ifdef AMBIENT_TEXTURE\n" |
1070 | " color = texture2D(uTextureAmbient0, vTexCoord) * uMaterialAmbient;\n" | 1148 | " color = texture2D(uTextureAmbient0, vec2(Tex0CoordAmbient)) * uMaterialAmbient;\n" |
1071 | "#else\n" | 1149 | "#else\n" |
1072 | " color = uMaterialAmbient;\n" | 1150 | " color = uMaterialAmbient;\n" |
1073 | "#endif //AMBIENT_TEXTURE\n" | 1151 | "#endif //AMBIENT_TEXTURE\n" |
@@ -1080,12 +1158,12 @@ static const char normal_map_frag_glsl[] = | |||
1080 | "#ifdef EMISSION\n" | 1158 | "#ifdef EMISSION\n" |
1081 | " \n" | 1159 | " \n" |
1082 | "#ifdef EMISSION_TEXTURE_BLEND\n" | 1160 | "#ifdef EMISSION_TEXTURE_BLEND\n" |
1083 | " color = mix(texture2D(uTextureEmission1, vTexCoord),\n" | 1161 | " color = mix(texture2D(uTextureEmission1, vec2(Tex1CoordEmission)),\n" |
1084 | " texture2D(uTextureEmission0, vTexCoord), uTextureEmissionWeight);\n" | 1162 | " texture2D(uTextureEmission0, vec2(Tex0CoordEmission)), uTextureEmissionWeight);\n" |
1085 | " color *= uMaterialEmission;\n" | 1163 | " color *= uMaterialEmission;\n" |
1086 | "#else\n" | 1164 | "#else\n" |
1087 | "#ifdef EMISSION_TEXTURE\n" | 1165 | "#ifdef EMISSION_TEXTURE\n" |
1088 | " color = texture2D(uTextureEmission0, vTexCoord) * uMaterialEmission;\n" | 1166 | " color = texture2D(uTextureEmission0, vec2(Tex0CoordEmission)) * uMaterialEmission;\n" |
1089 | "#else\n" | 1167 | "#else\n" |
1090 | " color = uMaterialEmission;\n" | 1168 | " color = uMaterialEmission;\n" |
1091 | "#endif //EMISSION_TEXTURE\n" | 1169 | "#endif //EMISSION_TEXTURE\n" |
@@ -1167,10 +1245,16 @@ static const char shadow_map_frag_glsl[] = | |||
1167 | "#ifdef DIFFUSE\n" | 1245 | "#ifdef DIFFUSE\n" |
1168 | "#ifdef DIFFUSE_TEXTURE\n" | 1246 | "#ifdef DIFFUSE_TEXTURE\n" |
1169 | "uniform sampler2D uTextureDiffuse0;\n" | 1247 | "uniform sampler2D uTextureDiffuse0;\n" |
1248 | "uniform mat3 uTextureMatrixTransformDiffuse0;\n" | ||
1249 | "vec3 Tex0CoordDiffuse =\n" | ||
1250 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse0;\n" | ||
1170 | "#endif //DIFFUSE_TEXTURE\n" | 1251 | "#endif //DIFFUSE_TEXTURE\n" |
1171 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 1252 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
1172 | "uniform sampler2D uTextureDiffuse1;\n" | 1253 | "uniform sampler2D uTextureDiffuse1;\n" |
1173 | "uniform float uTextureDiffuseWeight;\n" | 1254 | "uniform float uTextureDiffuseWeight;\n" |
1255 | "uniform mat3 uTextureMatrixTransformDiffuse1;\n" | ||
1256 | "vec3 Tex1CoordDiffuse =\n" | ||
1257 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse1;\n" | ||
1174 | "#endif //DIFFUSE_TEXTURE_BLEND\n" | 1258 | "#endif //DIFFUSE_TEXTURE_BLEND\n" |
1175 | "#endif //DIFFUSE\n" | 1259 | "#endif //DIFFUSE\n" |
1176 | "#endif //ALPHA_TEST_ENABLED\n" | 1260 | "#endif //ALPHA_TEST_ENABLED\n" |
@@ -1180,12 +1264,12 @@ static const char shadow_map_frag_glsl[] = | |||
1180 | "#endif\n" | 1264 | "#endif\n" |
1181 | "#ifdef ALPHA_TEST_ENABLED\n" | 1265 | "#ifdef ALPHA_TEST_ENABLED\n" |
1182 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 1266 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
1183 | " gl_FragColor = (texture2D(uTextureDiffuse0, vTexCoord) *\n" | 1267 | " gl_FragColor = (texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)) *\n" |
1184 | " uTextureDiffuseWeight + texture2D(uTextureDiffuse1, vTexCoord) *\n" | 1268 | " uTextureDiffuseWeight + texture2D(uTextureDiffuse1, vec2(Tex1CoordDiffuse)) *\n" |
1185 | " (1.0 - uTextureDiffuseWeight));\n" | 1269 | " (1.0 - uTextureDiffuseWeight));\n" |
1186 | "#else\n" | 1270 | "#else\n" |
1187 | "#ifdef DIFFUSE_TEXTURE\n" | 1271 | "#ifdef DIFFUSE_TEXTURE\n" |
1188 | " gl_FragColor = texture2D(uTextureDiffuse0, vTexCoord) ;\n" | 1272 | " gl_FragColor = texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)) ;\n" |
1189 | "#else\n" | 1273 | "#else\n" |
1190 | " gl_FragColor = vec4(1);\n" | 1274 | " gl_FragColor = vec4(1);\n" |
1191 | "#endif //DIFFUSE_TEXTURE\n" | 1275 | "#endif //DIFFUSE_TEXTURE\n" |
@@ -1361,10 +1445,13 @@ static const char parallax_occlusion_frag_glsl[] = | |||
1361 | "#endif\n" | 1445 | "#endif\n" |
1362 | "varying vec3 vLightVector;\n" | 1446 | "varying vec3 vLightVector;\n" |
1363 | "varying vec3 vLightHalfVector;\n" | 1447 | "varying vec3 vLightHalfVector;\n" |
1364 | "uniform sampler2D uTextureNormal0;\n" | ||
1365 | "varying vec3 vEyeVector;\n" | 1448 | "varying vec3 vEyeVector;\n" |
1449 | "uniform sampler2D uTextureNormal0;\n" | ||
1450 | "uniform mat3 uTextureMatrixTransformNormal0;\n" | ||
1366 | "#ifdef NEED_TEX_COORD\n" | 1451 | "#ifdef NEED_TEX_COORD\n" |
1367 | "varying vec2 vTexCoord;\n" | 1452 | "varying vec2 vTexCoord;\n" |
1453 | "vec3 Tex0CoordNormal = \n" | ||
1454 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformNormal0;\n" | ||
1368 | "#endif //TEX_COORD\n" | 1455 | "#endif //TEX_COORD\n" |
1369 | "#ifdef FOG_ENABLED\n" | 1456 | "#ifdef FOG_ENABLED\n" |
1370 | "uniform float uFogFactor;\n" | 1457 | "uniform float uFogFactor;\n" |
@@ -1381,23 +1468,32 @@ static const char parallax_occlusion_frag_glsl[] = | |||
1381 | " shadow = 0.0;\n" | 1468 | " shadow = 0.0;\n" |
1382 | " for (i = -4.0; i < 4.0; i++)\n" | 1469 | " for (i = -4.0; i < 4.0; i++)\n" |
1383 | " for (j = -4.0; j < 4.0; j++)\n" | 1470 | " for (j = -4.0; j < 4.0; j++)\n" |
1384 | " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0)*size).x);\n" | 1471 | " shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0) * size).x);\n" |
1385 | " return shadow / 64.0;\n" | 1472 | " return shadow / 64.0;\n" |
1386 | "}\n" | 1473 | "}\n" |
1387 | "#endif //SHADOWED\n" | 1474 | "#endif //SHADOWED\n" |
1388 | "#ifdef NORMAL_TEXTURE_BLEND\n" | 1475 | "#ifdef NORMAL_TEXTURE_BLEND\n" |
1389 | "uniform sampler2D uTextureNormal1;\n" | 1476 | "uniform sampler2D uTextureNormal1;\n" |
1390 | "uniform float uTextureNormalWeight;\n" | 1477 | "uniform float uTextureNormalWeight;\n" |
1478 | "uniform mat3 uTextureMatrixTransformNormal1;\n" | ||
1479 | "vec3 Tex1CoordNormal = \n" | ||
1480 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformNormal1;\n" | ||
1391 | "#endif //NORMAL_TEXTURE_BLEND\n" | 1481 | "#endif //NORMAL_TEXTURE_BLEND\n" |
1392 | "#ifdef DIFFUSE\n" | 1482 | "#ifdef DIFFUSE\n" |
1393 | "uniform vec4 uMaterialDiffuse;\n" | 1483 | "uniform vec4 uMaterialDiffuse;\n" |
1394 | "uniform vec4 uLightDiffuse;\n" | 1484 | "uniform vec4 uLightDiffuse;\n" |
1395 | "#ifdef DIFFUSE_TEXTURE\n" | 1485 | "#ifdef DIFFUSE_TEXTURE\n" |
1396 | "uniform sampler2D uTextureDiffuse0;\n" | 1486 | "uniform sampler2D uTextureDiffuse0;\n" |
1487 | "uniform mat3 uTextureMatrixTransformDiffuse0;\n" | ||
1488 | "vec3 Tex0CoordDiffuse = \n" | ||
1489 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse0;\n" | ||
1397 | "#endif //DIFFUSE_TEXTURE\n" | 1490 | "#endif //DIFFUSE_TEXTURE\n" |
1398 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" | 1491 | "#ifdef DIFFUSE_TEXTURE_BLEND\n" |
1399 | "uniform sampler2D uTextureDiffuse1;\n" | 1492 | "uniform sampler2D uTextureDiffuse1;\n" |
1400 | "uniform float uTextureDiffuseWeight;\n" | 1493 | "uniform float uTextureDiffuseWeight;\n" |
1494 | "uniform mat3 uTextureMatrixTransformDiffuse1;\n" | ||
1495 | "vec3 Tex1CoordDiffuse = \n" | ||
1496 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse1;\n" | ||
1401 | "#endif //DIFFUSE_TEXTURE_BLEND\n" | 1497 | "#endif //DIFFUSE_TEXTURE_BLEND\n" |
1402 | "#endif //DIFFUSE\n" | 1498 | "#endif //DIFFUSE\n" |
1403 | "#ifdef SPECULAR\n" | 1499 | "#ifdef SPECULAR\n" |
@@ -1406,10 +1502,16 @@ static const char parallax_occlusion_frag_glsl[] = | |||
1406 | "uniform vec4 uMaterialSpecular;\n" | 1502 | "uniform vec4 uMaterialSpecular;\n" |
1407 | "#ifdef SPECULAR_TEXTURE\n" | 1503 | "#ifdef SPECULAR_TEXTURE\n" |
1408 | "uniform sampler2D uTextureSpecular0;\n" | 1504 | "uniform sampler2D uTextureSpecular0;\n" |
1505 | "uniform mat3 uTextureMatrixTransformSpecular0;\n" | ||
1506 | "vec3 Tex0CoordSpecular = \n" | ||
1507 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformSpecular0;\n" | ||
1409 | "#endif //SPECULAR_TEXTURE\n" | 1508 | "#endif //SPECULAR_TEXTURE\n" |
1410 | "#ifdef SPECULAR_TEXTURE_BLEND\n" | 1509 | "#ifdef SPECULAR_TEXTURE_BLEND\n" |
1411 | "uniform sampler2D uTextureSpecular1;\n" | 1510 | "uniform sampler2D uTextureSpecular1;\n" |
1412 | "uniform float uTextureSpecularWeight;\n" | 1511 | "uniform float uTextureSpecularWeight;\n" |
1512 | "uniform mat3 uTextureMatrixTransformSpecular1;\n" | ||
1513 | "vec3 Tex1CoordSpecular = \n" | ||
1514 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformSpecular1;\n" | ||
1413 | "#endif //SPECULAR_TEXTURE_BLEND\n" | 1515 | "#endif //SPECULAR_TEXTURE_BLEND\n" |
1414 | "#endif //SPECULAR\n" | 1516 | "#endif //SPECULAR\n" |
1415 | "#ifdef AMBIENT\n" | 1517 | "#ifdef AMBIENT\n" |
@@ -1417,20 +1519,32 @@ static const char parallax_occlusion_frag_glsl[] = | |||
1417 | "uniform vec4 uLightAmbient;\n" | 1519 | "uniform vec4 uLightAmbient;\n" |
1418 | "#ifdef AMBIENT_TEXTURE\n" | 1520 | "#ifdef AMBIENT_TEXTURE\n" |
1419 | "uniform sampler2D uTextureAmbient0;\n" | 1521 | "uniform sampler2D uTextureAmbient0;\n" |
1522 | "uniform mat3 uTextureMatrixTransformAmbient0;\n" | ||
1523 | "vec3 Tex0CoordAmbient = \n" | ||
1524 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformAmbient0;\n" | ||
1420 | "#endif //AMBIENT_TEXTURE\n" | 1525 | "#endif //AMBIENT_TEXTURE\n" |
1421 | "#ifdef AMBIENT_TEXTURE_BLEND\n" | 1526 | "#ifdef AMBIENT_TEXTURE_BLEND\n" |
1422 | "uniform sampler2D uTextureAmbient1;\n" | 1527 | "uniform sampler2D uTextureAmbient1;\n" |
1423 | "uniform float uTextureAmbientWeight;\n" | 1528 | "uniform float uTextureAmbientWeight;\n" |
1529 | "uniform mat3 uTextureMatrixTransformAmbient1;\n" | ||
1530 | "vec3 Tex1CoordAmbient = \n" | ||
1531 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformAmbient1;\n" | ||
1424 | "#endif //AMBIENT_TEXTURE_BLEND\n" | 1532 | "#endif //AMBIENT_TEXTURE_BLEND\n" |
1425 | "#endif //AMBIENT\n" | 1533 | "#endif //AMBIENT\n" |
1426 | "#ifdef EMISSION\n" | 1534 | "#ifdef EMISSION\n" |
1427 | "uniform vec4 uMaterialEmission;\n" | 1535 | "uniform vec4 uMaterialEmission;\n" |
1428 | "#ifdef EMISSION_TEXTURE\n" | 1536 | "#ifdef EMISSION_TEXTURE\n" |
1429 | "uniform sampler2D uTextureEmission0;\n" | 1537 | "uniform sampler2D uTextureEmission0;\n" |
1538 | "uniform mat3 uTextureMatrixTransformEmission0;\n" | ||
1539 | "vec3 Tex0CoordEmission = \n" | ||
1540 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformEmission0;\n" | ||
1430 | "#endif //EMISSION_TEXTURE\n" | 1541 | "#endif //EMISSION_TEXTURE\n" |
1431 | "#ifdef EMISSION_TEXTURE_BLEND\n" | 1542 | "#ifdef EMISSION_TEXTURE_BLEND\n" |
1432 | "uniform sampler2D uTextureEmission1;\n" | 1543 | "uniform sampler2D uTextureEmission1;\n" |
1433 | "uniform float uTextureEmissionWeight;\n" | 1544 | "uniform float uTextureEmissionWeight;\n" |
1545 | "uniform mat3 uTextureMatrixTransformEmission1;\n" | ||
1546 | "vec3 Tex1CoordEmission = \n" | ||
1547 | " vec3(vTexCoord, 1.0) * uTextureMatrixTransformEmission1;\n" | ||
1434 | "#endif //EMISSION_TEXTURE_BLEND\n" | 1548 | "#endif //EMISSION_TEXTURE_BLEND\n" |
1435 | "#endif //EMISSION\n" | 1549 | "#endif //EMISSION\n" |
1436 | "#ifdef LIGHT_SPOT\n" | 1550 | "#ifdef LIGHT_SPOT\n" |
@@ -1451,8 +1565,8 @@ static const char parallax_occlusion_frag_glsl[] = | |||
1451 | " vec2 dtex = parallaxScale * view.xy / view.z / numLayers;\n" | 1565 | " vec2 dtex = parallaxScale * view.xy / view.z / numLayers;\n" |
1452 | " vec2 currentTextureCoords = tex;\n" | 1566 | " vec2 currentTextureCoords = tex;\n" |
1453 | "#ifdef NORMAL_TEXTURE_BLEND\n" | 1567 | "#ifdef NORMAL_TEXTURE_BLEND\n" |
1454 | " float heightFromTexture = (1.0 - texture2D(uTextureNormal0, currentTextureCoords).a) * uTextureNormalWeight;\n" | 1568 | " float heightFromTexture = (1.0 - texture2D(uTextureNormal0, vec2(Tex0CoordNormal)).a) * uTextureNormalWeight;\n" |
1455 | " heightFromTexture += (1.0 - texture2D(uTextureNormal1, currentTextureCoords).a) *\n" | 1569 | " heightFromTexture += (1.0 - texture2D(uTextureNormal1, vec2(Tex1CoordNormal)).a) *\n" |
1456 | " (1.0 - uTextureNormalWeight);\n" | 1570 | " (1.0 - uTextureNormalWeight);\n" |
1457 | "#else\n" | 1571 | "#else\n" |
1458 | " float heightFromTexture = 1.0 - texture2D(uTextureNormal0, currentTextureCoords).a;\n" | 1572 | " float heightFromTexture = 1.0 - texture2D(uTextureNormal0, currentTextureCoords).a;\n" |
@@ -1491,7 +1605,7 @@ static const char parallax_occlusion_frag_glsl[] = | |||
1491 | " vec3 normal;\n" | 1605 | " vec3 normal;\n" |
1492 | " vec4 color;\n" | 1606 | " vec4 color;\n" |
1493 | " float parallaxHeight;\n" | 1607 | " float parallaxHeight;\n" |
1494 | " vec2 tex = parallaxMapping(vEyeVector, vTexCoord, parallaxHeight);\n" | 1608 | " vec2 tex = parallaxMapping(vEyeVector, vec2(Tex0CoordNormal), parallaxHeight);\n" |
1495 | " vec3 lv = normalize(vLightVector);\n" | 1609 | " vec3 lv = normalize(vLightVector);\n" |
1496 | "#ifdef NORMAL_TEXTURE_BLEND\n" | 1610 | "#ifdef NORMAL_TEXTURE_BLEND\n" |
1497 | " normal = texture2D(uTextureNormal0, tex).rgb * uTextureNormalWeight / texture2D(uTextureNormal0, tex).a;\n" | 1611 | " normal = texture2D(uTextureNormal0, tex).rgb * uTextureNormalWeight / texture2D(uTextureNormal0, tex).a;\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 489c4ff17e..1d67172fbf 100644 --- a/src/modules/evas/engines/gl_common/shader_3d/include.shd +++ b/src/modules/evas/engines/gl_common/shader_3d/include.shd | |||
@@ -12,10 +12,16 @@ varying vec2 vTexCoord; | |||
12 | define(`FRAGMENT_SHADER_USE_TEXTURE', ` | 12 | define(`FRAGMENT_SHADER_USE_TEXTURE', ` |
13 | #ifdef $1_TEXTURE | 13 | #ifdef $1_TEXTURE |
14 | uniform sampler2D uTexture$2`0'; | 14 | uniform sampler2D uTexture$2`0'; |
15 | uniform mat3 uTextureMatrixTransform$2`0'; | ||
16 | vec3 Tex0Coord$2 = | ||
17 | vec3(vTexCoord, 1.0) * uTextureMatrixTransform$2`0'; | ||
15 | #endif //$1_TEXTURE | 18 | #endif //$1_TEXTURE |
16 | #ifdef $1_TEXTURE_BLEND | 19 | #ifdef $1_TEXTURE_BLEND |
17 | uniform sampler2D uTexture$2`1'; | 20 | uniform sampler2D uTexture$2`1'; |
18 | uniform float uTexture$2Weight; | 21 | uniform float uTexture$2Weight; |
22 | uniform mat3 uTextureMatrixTransform$2`1'; | ||
23 | vec3 Tex1Coord$2 = | ||
24 | vec3(vTexCoord, 1.0) * uTextureMatrixTransform$2`1'; | ||
19 | #endif //$1_TEXTURE_BLEND') | 25 | #endif //$1_TEXTURE_BLEND') |
20 | 26 | ||
21 | define(`FRAGMENT_SHADER_USE_FOG', ` | 27 | define(`FRAGMENT_SHADER_USE_FOG', ` |
@@ -36,7 +42,7 @@ float pcf(vec4 lpos, float size) | |||
36 | shadow = 0.0; | 42 | shadow = 0.0; |
37 | for (i = -4.0; i < 4.0; i++) | 43 | for (i = -4.0; i < 4.0; i++) |
38 | for (j = -4.0; j < 4.0; j++) | 44 | for (j = -4.0; j < 4.0; j++) |
39 | shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0)*size).x); | 45 | shadow += float(smcoord.z <= texture2D(uShadowMap, smcoord.xy + vec2(i / 8.0, j / 8.0) * size).x); |
40 | return shadow / 64.0; | 46 | return shadow / 64.0; |
41 | } | 47 | } |
42 | #endif //SHADOWED') | 48 | #endif //SHADOWED') |
@@ -61,12 +67,12 @@ varying float vLightDist; | |||
61 | 67 | ||
62 | define(`FRAGMENT_SHADER_TEXTURE_BLEND', ` | 68 | define(`FRAGMENT_SHADER_TEXTURE_BLEND', ` |
63 | #ifdef $1_TEXTURE_BLEND | 69 | #ifdef $1_TEXTURE_BLEND |
64 | color = mix(texture2D(uTexture$2`1', vTexCoord), | 70 | color = mix(texture2D(uTexture$2`1', vec2(Tex1Coord$2)), |
65 | texture2D(uTexture$2`0', vTexCoord), uTexture$2Weight); | 71 | texture2D(uTexture$2`0', vec2(Tex0Coord$2)), uTexture$2Weight); |
66 | color *= uMaterial$2; | 72 | color *= uMaterial$2; |
67 | #else | 73 | #else |
68 | #ifdef $1_TEXTURE | 74 | #ifdef $1_TEXTURE |
69 | color = texture2D(uTexture$2`0', vTexCoord) * uMaterial$2; | 75 | color = texture2D(uTexture$2`0', vec2(Tex0Coord$2)) * uMaterial$2; |
70 | #else | 76 | #else |
71 | color = uMaterial$2; | 77 | color = uMaterial$2; |
72 | #endif //$1_TEXTURE | 78 | #endif //$1_TEXTURE |
diff --git a/src/modules/evas/engines/gl_common/shader_3d/parallax_occlusion_frag.shd b/src/modules/evas/engines/gl_common/shader_3d/parallax_occlusion_frag.shd index 598343d43e..6faab218e7 100644 --- a/src/modules/evas/engines/gl_common/shader_3d/parallax_occlusion_frag.shd +++ b/src/modules/evas/engines/gl_common/shader_3d/parallax_occlusion_frag.shd | |||
@@ -1,10 +1,13 @@ | |||
1 | varying vec3 vLightVector; | 1 | varying vec3 vLightVector; |
2 | varying vec3 vLightHalfVector; | 2 | varying vec3 vLightHalfVector; |
3 | uniform sampler2D uTextureNormal0; | ||
4 | varying vec3 vEyeVector; | 3 | varying vec3 vEyeVector; |
4 | uniform sampler2D uTextureNormal0; | ||
5 | uniform mat3 uTextureMatrixTransformNormal0; | ||
5 | 6 | ||
6 | #ifdef NEED_TEX_COORD | 7 | #ifdef NEED_TEX_COORD |
7 | varying vec2 vTexCoord; | 8 | varying vec2 vTexCoord; |
9 | vec3 Tex0CoordNormal = | ||
10 | vec3(vTexCoord, 1.0) * uTextureMatrixTransformNormal0; | ||
8 | #endif //TEX_COORD | 11 | #endif //TEX_COORD |
9 | 12 | ||
10 | FRAGMENT_SHADER_USE_FOG | 13 | FRAGMENT_SHADER_USE_FOG |
@@ -13,6 +16,9 @@ FRAGMENT_SHADER_USE_SHADOWS | |||
13 | #ifdef NORMAL_TEXTURE_BLEND | 16 | #ifdef NORMAL_TEXTURE_BLEND |
14 | uniform sampler2D uTextureNormal1; | 17 | uniform sampler2D uTextureNormal1; |
15 | uniform float uTextureNormalWeight; | 18 | uniform float uTextureNormalWeight; |
19 | uniform mat3 uTextureMatrixTransformNormal1; | ||
20 | vec3 Tex1CoordNormal = | ||
21 | vec3(vTexCoord, 1.0) * uTextureMatrixTransformNormal1; | ||
16 | #endif //NORMAL_TEXTURE_BLEND | 22 | #endif //NORMAL_TEXTURE_BLEND |
17 | 23 | ||
18 | FRAGMENT_SHADER_USE_DIFFUSE_TERM | 24 | FRAGMENT_SHADER_USE_DIFFUSE_TERM |
@@ -35,8 +41,8 @@ vec2 parallaxMapping(in vec3 view, in vec2 tex, out float parallaxHeight) | |||
35 | vec2 currentTextureCoords = tex; | 41 | vec2 currentTextureCoords = tex; |
36 | 42 | ||
37 | #ifdef NORMAL_TEXTURE_BLEND | 43 | #ifdef NORMAL_TEXTURE_BLEND |
38 | float heightFromTexture = (1.0 - texture2D(uTextureNormal0, currentTextureCoords).a) * uTextureNormalWeight; | 44 | float heightFromTexture = (1.0 - texture2D(uTextureNormal0, vec2(Tex0CoordNormal)).a) * uTextureNormalWeight; |
39 | heightFromTexture += (1.0 - texture2D(uTextureNormal1, currentTextureCoords).a) * | 45 | heightFromTexture += (1.0 - texture2D(uTextureNormal1, vec2(Tex1CoordNormal)).a) * |
40 | (1.0 - uTextureNormalWeight); | 46 | (1.0 - uTextureNormalWeight); |
41 | #else | 47 | #else |
42 | float heightFromTexture = 1.0 - texture2D(uTextureNormal0, currentTextureCoords).a; | 48 | float heightFromTexture = 1.0 - texture2D(uTextureNormal0, currentTextureCoords).a; |
@@ -83,7 +89,7 @@ void fragmentParallaxMap() | |||
83 | vec4 color; | 89 | vec4 color; |
84 | 90 | ||
85 | float parallaxHeight; | 91 | float parallaxHeight; |
86 | vec2 tex = parallaxMapping(vEyeVector, vTexCoord, parallaxHeight); | 92 | vec2 tex = parallaxMapping(vEyeVector, vec2(Tex0CoordNormal), parallaxHeight); |
87 | 93 | ||
88 | vec3 lv = normalize(vLightVector); | 94 | vec3 lv = normalize(vLightVector); |
89 | 95 | ||
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 c1e69645e1..23c339e632 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 | |||
@@ -5,11 +5,17 @@ FRAGMENT_SHADER_USE_TEX_COORD | |||
5 | 5 | ||
6 | #ifdef DIFFUSE_TEXTURE | 6 | #ifdef DIFFUSE_TEXTURE |
7 | uniform sampler2D uTextureDiffuse0; | 7 | uniform sampler2D uTextureDiffuse0; |
8 | uniform mat3 uTextureMatrixTransformDiffuse0; | ||
9 | vec3 Tex0CoordDiffuse = | ||
10 | vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse0; | ||
8 | #endif //DIFFUSE_TEXTURE | 11 | #endif //DIFFUSE_TEXTURE |
9 | 12 | ||
10 | #ifdef DIFFUSE_TEXTURE_BLEND | 13 | #ifdef DIFFUSE_TEXTURE_BLEND |
11 | uniform sampler2D uTextureDiffuse1; | 14 | uniform sampler2D uTextureDiffuse1; |
12 | uniform float uTextureDiffuseWeight; | 15 | uniform float uTextureDiffuseWeight; |
16 | uniform mat3 uTextureMatrixTransformDiffuse1; | ||
17 | vec3 Tex1CoordDiffuse = | ||
18 | vec3(vTexCoord, 1.0) * uTextureMatrixTransformDiffuse1; | ||
13 | #endif //DIFFUSE_TEXTURE_BLEND | 19 | #endif //DIFFUSE_TEXTURE_BLEND |
14 | 20 | ||
15 | #endif //DIFFUSE | 21 | #endif //DIFFUSE |
@@ -23,13 +29,13 @@ void main() { | |||
23 | #ifdef ALPHA_TEST_ENABLED | 29 | #ifdef ALPHA_TEST_ENABLED |
24 | 30 | ||
25 | #ifdef DIFFUSE_TEXTURE_BLEND | 31 | #ifdef DIFFUSE_TEXTURE_BLEND |
26 | gl_FragColor = (texture2D(uTextureDiffuse0, vTexCoord) * | 32 | gl_FragColor = (texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)) * |
27 | uTextureDiffuseWeight + texture2D(uTextureDiffuse1, vTexCoord) * | 33 | uTextureDiffuseWeight + texture2D(uTextureDiffuse1, vec2(Tex1CoordDiffuse)) * |
28 | (1.0 - uTextureDiffuseWeight)); | 34 | (1.0 - uTextureDiffuseWeight)); |
29 | #else | 35 | #else |
30 | 36 | ||
31 | #ifdef DIFFUSE_TEXTURE | 37 | #ifdef DIFFUSE_TEXTURE |
32 | gl_FragColor = texture2D(uTextureDiffuse0, vTexCoord) ; | 38 | gl_FragColor = texture2D(uTextureDiffuse0, vec2(Tex0CoordDiffuse)) ; |
33 | #else | 39 | #else |
34 | gl_FragColor = vec4(1); | 40 | gl_FragColor = vec4(1); |
35 | #endif //DIFFUSE_TEXTURE | 41 | #endif //DIFFUSE_TEXTURE |
diff --git a/src/modules/evas/engines/gl_generic/evas_engine.c b/src/modules/evas/engines/gl_generic/evas_engine.c index 2597753e7a..cd089958d7 100644 --- a/src/modules/evas/engines/gl_generic/evas_engine.c +++ b/src/modules/evas/engines/gl_generic/evas_engine.c | |||
@@ -2203,9 +2203,9 @@ eng_drawable_scene_render_to_texture(void *data, void *drawable, void *scene_dat | |||
2203 | } | 2203 | } |
2204 | 2204 | ||
2205 | static void * | 2205 | static void * |
2206 | eng_texture_new(void *data EINA_UNUSED) | 2206 | eng_texture_new(void *data EINA_UNUSED, Eina_Bool use_atlas) |
2207 | { | 2207 | { |
2208 | return e3d_texture_new(); | 2208 | return e3d_texture_new(use_atlas); |
2209 | } | 2209 | } |
2210 | 2210 | ||
2211 | static void | 2211 | static void |
@@ -2215,41 +2215,6 @@ eng_texture_free(void *data EINA_UNUSED, void *texture) | |||
2215 | } | 2215 | } |
2216 | 2216 | ||
2217 | static void | 2217 | static void |
2218 | eng_texture_data_set(void *data, void *texture, Evas_3D_Color_Format color_format, | ||
2219 | Evas_3D_Pixel_Format pixel_format, int w, int h, const void *pixels) | ||
2220 | { | ||
2221 | Evas_Engine_GL_Context *gl_context; | ||
2222 | Render_Engine_GL_Generic *re = data; | ||
2223 | |||
2224 | re->window_use(re->software.ob); | ||
2225 | gl_context = re->window_gl_context_get(re->software.ob); | ||
2226 | evas_gl_common_context_flush(gl_context); | ||
2227 | eng_context_3d_use(data); | ||
2228 | |||
2229 | e3d_texture_data_set((E3D_Texture *)texture, color_format, pixel_format, w, h, pixels); | ||
2230 | } | ||
2231 | |||
2232 | static void | ||
2233 | eng_texture_file_set(void *data, void *texture, const char *file, const char *key) | ||
2234 | { | ||
2235 | Evas_Engine_GL_Context *gl_context; | ||
2236 | Render_Engine_GL_Generic *re = data; | ||
2237 | |||
2238 | re->window_use(re->software.ob); | ||
2239 | gl_context = re->window_gl_context_get(re->software.ob); | ||
2240 | evas_gl_common_context_flush(gl_context); | ||
2241 | eng_context_3d_use(data); | ||
2242 | |||
2243 | e3d_texture_file_set((E3D_Texture *)texture, file, key); | ||
2244 | } | ||
2245 | |||
2246 | static void | ||
2247 | eng_texture_color_format_get(void *data EINA_UNUSED, void *texture, Evas_3D_Color_Format *format) | ||
2248 | { | ||
2249 | *format = e3d_texture_color_format_get((E3D_Texture *)texture); | ||
2250 | } | ||
2251 | |||
2252 | static void | ||
2253 | eng_texture_size_get(void *data EINA_UNUSED, void *texture, int *w, int *h) | 2218 | eng_texture_size_get(void *data EINA_UNUSED, void *texture, int *w, int *h) |
2254 | { | 2219 | { |
2255 | e3d_texture_size_get((E3D_Texture *)texture, w, h); | 2220 | e3d_texture_size_get((E3D_Texture *)texture, w, h); |
@@ -2284,10 +2249,21 @@ eng_texture_filter_get(void *data EINA_UNUSED, void *texture, | |||
2284 | } | 2249 | } |
2285 | 2250 | ||
2286 | static void | 2251 | static void |
2287 | eng_texture_image_set(void *data EINA_UNUSED, void *texture, void *image) | 2252 | eng_texture_image_set(void *data, void *texture, void *image) |
2253 | { | ||
2254 | Evas_Engine_GL_Context *gl_context; | ||
2255 | Render_Engine_GL_Generic *re = data; | ||
2256 | |||
2257 | re->window_use(re->software.ob); | ||
2258 | gl_context = re->window_gl_context_get(re->software.ob); | ||
2259 | |||
2260 | e3d_texture_set(gl_context, (E3D_Texture *)texture, (Evas_GL_Image *)image); | ||
2261 | } | ||
2262 | |||
2263 | static void * | ||
2264 | eng_texture_image_get(void *data EINA_UNUSED, void *texture) | ||
2288 | { | 2265 | { |
2289 | Evas_GL_Image *im = (Evas_GL_Image *)image; | 2266 | return e3d_texture_get((E3D_Texture *)texture); |
2290 | e3d_texture_import((E3D_Texture *)texture, im->tex->pt->texture); | ||
2291 | } | 2267 | } |
2292 | 2268 | ||
2293 | static Ector_Surface *_software_ector = NULL; | 2269 | static Ector_Surface *_software_ector = NULL; |
@@ -2607,15 +2583,13 @@ module_open(Evas_Module *em) | |||
2607 | 2583 | ||
2608 | ORD(texture_new); | 2584 | ORD(texture_new); |
2609 | ORD(texture_free); | 2585 | ORD(texture_free); |
2610 | ORD(texture_data_set); | ||
2611 | ORD(texture_file_set); | ||
2612 | ORD(texture_color_format_get); | ||
2613 | ORD(texture_size_get); | 2586 | ORD(texture_size_get); |
2614 | ORD(texture_wrap_set); | 2587 | ORD(texture_wrap_set); |
2615 | ORD(texture_wrap_get); | 2588 | ORD(texture_wrap_get); |
2616 | ORD(texture_filter_set); | 2589 | ORD(texture_filter_set); |
2617 | ORD(texture_filter_get); | 2590 | ORD(texture_filter_get); |
2618 | ORD(texture_image_set); | 2591 | ORD(texture_image_set); |
2592 | ORD(texture_image_get); | ||
2619 | 2593 | ||
2620 | ORD(ector_get); | 2594 | ORD(ector_get); |
2621 | ORD(ector_begin); | 2595 | ORD(ector_begin); |
diff --git a/src/modules/evas/engines/software_generic/evas_engine.c b/src/modules/evas/engines/software_generic/evas_engine.c index dfdcb5c3bc..3a796f6793 100644 --- a/src/modules/evas/engines/software_generic/evas_engine.c +++ b/src/modules/evas/engines/software_generic/evas_engine.c | |||
@@ -3917,15 +3917,13 @@ static Evas_Func func = | |||
3917 | NULL, // eng_drawable_texture_pixel_color_get | 3917 | NULL, // eng_drawable_texture_pixel_color_get |
3918 | NULL, // eng_texture_new | 3918 | NULL, // eng_texture_new |
3919 | NULL, // eng_texture_free | 3919 | NULL, // eng_texture_free |
3920 | NULL, // eng_texture_data_set | ||
3921 | NULL, // eng_texture_file_set | ||
3922 | NULL, // eng_texture_color_format_get | ||
3923 | NULL, // eng_texture_size_get | 3920 | NULL, // eng_texture_size_get |
3924 | NULL, // eng_texture_wrap_set | 3921 | NULL, // eng_texture_wrap_set |
3925 | NULL, // eng_texture_wrap_get | 3922 | NULL, // eng_texture_wrap_get |
3926 | NULL, // eng_texture_filter_set | 3923 | NULL, // eng_texture_filter_set |
3927 | NULL, // eng_texture_filter_get | 3924 | NULL, // eng_texture_filter_get |
3928 | NULL, // eng_texture_image_set | 3925 | NULL, // eng_texture_image_set |
3926 | NULL, // eng_texture_image_get | ||
3929 | eng_ector_get, | 3927 | eng_ector_get, |
3930 | eng_ector_begin, | 3928 | eng_ector_begin, |
3931 | eng_ector_renderer_draw, | 3929 | eng_ector_renderer_draw, |