Author Topic: Texture becomes blur and pixelated after many onResume  (Read 4305 times)

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Texture becomes blur and pixelated after many onResume
« 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture becomes blur and pixelated after many onResume
« Reply #1 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?

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Texture becomes blur and pixelated after many onResume
« Reply #2 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.


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture becomes blur and pixelated after many onResume
« Reply #3 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"...

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Texture becomes blur and pixelated after many onResume
« Reply #4 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?

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Texture becomes blur and pixelated after many onResume
« Reply #5 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture becomes blur and pixelated after many onResume
« Reply #6 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture becomes blur and pixelated after many onResume
« Reply #7 on: September 03, 2014, 09:38:55 pm »
Here's a jar that includes the method: http://jpct.de/download/beta/jpct_ae.jar

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Texture becomes blur and pixelated after many onResume
« Reply #8 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?

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture becomes blur and pixelated after many onResume
« Reply #9 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.

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Texture becomes blur and pixelated after many onResume
« Reply #10 on: September 04, 2014, 09:36:06 am »
It should be alright then. Thanks alot for your help, egon.

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Texture becomes blur and pixelated after many onResume
« Reply #11 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. 

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture becomes blur and pixelated after many onResume
« Reply #12 on: September 04, 2014, 07:09:49 pm »
What performance fix?

Offline kkl

  • float
  • ****
  • Posts: 291
    • View Profile
Re: Texture becomes blur and pixelated after many onResume
« Reply #13 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

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Texture becomes blur and pixelated after many onResume
« Reply #14 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.