UnderwaterApps / overlap2d-runtime-libgdx

Overlap2D - UI and Level Editor libgdx runtime
http://overlap2d.com
Other
170 stars 96 forks source link

Apply shaders on composite objects #94

Closed emaxe closed 8 years ago

emaxe commented 8 years ago
azakhary commented 8 years ago

This part is a bit harder. You see we already have this kind of code for Images only (if you look at TextureRegionDrawLogic it has this shader condition there) so if you put shader on image with this code, you will get shader applied twice. I think your solution is good, if you also remove the shader part from the place I mentioned. Also make sure to pass as uniform some variables like time, delta time for shader animtions.

Does this make sense?

emaxe commented 8 years ago

Well, yes , I tested only with composite objects. I need to get the items from the library , and then add to the engine. Then apply a shader . In the library I can put only a composite object, so my solution I like more .. And the uniforms can pass from any place of code.. For example, from main cycle in ApplicationAdapter

azakhary commented 8 years ago

yes, so because your code works for any item (including images) the shader code for images should be removed to not interfere with this one. Would be nice if you can do this for further testing.

emaxe commented 8 years ago

You know , my first solution works well with all objects and do not have a collision. In Overlap2dRenderer in drawRecursively function we do not have an simple image, only composite objects.

azakhary commented 8 years ago

hmm. oh I see what you mean. let me check that. it should be correct then. Btw have you tested? Also one more note someone who adds shader to a composite, should be aware that this shader without use of FBO, will be performing badly of many objects overlap. Should be used carefully.

emaxe commented 8 years ago

Yes, i test it with composite objects and simple images. And, of course , in the composite object shader apply to each texture separately .

azakhary commented 8 years ago

Tested and confirmed, thanks! Merging now.