www.jpct.net

jPCT-AE - a 3d engine for Android => Support => Topic started by: kkl on September 02, 2014, 03:42:20 pm

Title: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 02, 2014, 03:42:20 pm
Hi egon,

I have this issue where the texture becoming more blur and pixelated each time the live wallpaper resumes from pause. It takes many times till the effect is obvious. The texture is in 512x512, mipmap, and compression enabled ( setTextureCompression(true) ).

Can it be the texture is compressed over and over again till it loses the quality?
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: EgonOlsen on September 02, 2014, 04:21:45 pm
No. The raw pixel data of a texture remains untouched. Do you have screen shots for comparison?
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 02, 2014, 04:41:48 pm
I roughly take the same portion of the screen for comparison. But you can see the pixelated area in lost.jpg whereas the other one is fine.

Title: Re: Texture becomes blur and pixelated after many onResume
Post by: EgonOlsen on September 03, 2014, 09:21:38 am
That looks strange. More like some diagonal pixel rubbish introduced by something rather than a compression artifact (which it actually can't be, because, as said, raw pixel data remains untouched).
Can you try to reproduce this with a higher frequency texture (i.e. more differences in colors). It's hard to tell anything from "blue with slightly darker blue on top of it"...
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 03, 2014, 04:43:51 pm
Hi Egon,

I think I found the root cause. I'm translating the texture matrix for that object. When the translation values gets bigger, the texture starts to get pixelated.

The attachment shows the pixelated and fine textures respectively (with distinct colored texture).

Is it common that texture may be get distorted when texture matrix values are too big for the shader to handle?
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 03, 2014, 06:17:26 pm
is it a good idea to control the limit values of texture matrix? I wanted to check the texture matrix translation if it exceed certain value then reset it back to 0, but it seems like the matrix returns new object of translation in getTranslation() and there is no clear translation method. Is it possible if we can get translation from matrix by object pointing (e.g. getTranslation(SimpleVector)) and clear translation method?
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: EgonOlsen on September 03, 2014, 07:28:05 pm
I see...it's an accuracy issue of the hardware then. Mobile devices tend to have awful texture accuracy ranging from pretty good (Adreno) to really poor (Tegra). Limiting the translation values sounds like a good idea. I can add the getTranslation(SimpleVector)-method. Instead of a clearTranslation, the setIdentity() should do it, shouldn't it? Or are you rotating the matrix as well?
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: EgonOlsen on September 03, 2014, 09:38:55 pm
Here's a jar that includes the method: http://jpct.de/download/beta/jpct_ae.jar (http://jpct.de/download/beta/jpct_ae.jar)
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 04, 2014, 05:11:30 am
Hi egon,

Thanks for the new jar.

So far I'm just translating the matrix, no rotation yet. But it'd be a great feature in the future to clear only translation without affecting the rotation. BTW, if rotation values get bigger, possible that it will distort the texture too? and may be even object rotation matrix and translation? Should we limit all the values as well?
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: EgonOlsen on September 04, 2014, 08:32:44 am
No, rotations shouldn't have this effect. And object transformations are no issue as long as you don't reach the borders of floats.
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 04, 2014, 09:36:06 am
It should be alright then. Thanks alot for your help, egon.
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 04, 2014, 06:10:02 pm
Hi egon,

I realized some parts of my code are using scalarMul for texture matrix. I think I might need clearTranslation instead. Is it ok if you could include the method in jpct-ae? In addition, the jpct-ae.jar does not include the virtualizer performance fix. Could you tag along the fix with the jar as well? Thank you so much and sry for any inconvenience. 
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: EgonOlsen on September 04, 2014, 07:09:49 pm
What performance fix?
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 04, 2014, 07:43:20 pm
It was about the cache compression IO performance fix, if im not mistaken.

Here's the post: http://www.jpct.net/forum2/index.php/topic,3341.msg26761.html#msg26761 (http://www.jpct.net/forum2/index.php/topic,3341.msg26761.html#msg26761)
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: EgonOlsen on September 04, 2014, 08:15:51 pm
Nothing has changed regarding that change in this jar. Whatever i did back then, it's still in this jar too.
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 05, 2014, 03:21:19 am
Okay, I thought it was always a separate compilation. How about the clear translation in texture matrix?
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: EgonOlsen on September 05, 2014, 08:40:50 am
I could add it, but wouldn't a simple call to

Code: [Select]
matrix.setRow(3, 0, 0, 0, 1);   

be good enough?
Title: Re: Texture becomes blur and pixelated after many onResume
Post by: kkl on September 05, 2014, 06:57:58 pm
Ahh.. I could do that. Missed that part. Thanks alot egon.