Welcome, Guest. Please login or register.

Login with username, password and session length

 
Advanced search

11273 Posts in 1452 Topics- by 675 Members - Latest Member: flytosea

09. September 2010, 05:24:00 PM
Xith3D CommunityGeneral CategorySupport (Moderator: Marvin Fröhlich)TextureFilter in Image Widget doesn't work
Pages: [1]
Print
Author Topic: TextureFilter in Image Widget doesn't work  (Read 136 times)
Oliver
Enjoying the stay
*
Offline Offline

Posts: 28


View Profile
« on: 25. June 2010, 01:48:15 PM »

Hi,

after migrating an existing project to the current xith trunk (migrating to the new HUD system), the TextureFilter won't work for Image Widgets any more.

The code to change the filter is like this:

myImage.getTexture().setFilter(TextureFilter.ANISOTROPIC_2);

The TextureFilter works in the Panel Widget. Unfortunately some parts of the HUD in my project aren't easy to convert into a panel.

I had a look into the sources to see if I can find a solution. But unfortunately the HUD system has changed a lot from the old version - thus it isn't easy at all to compare with the old (well filtering) Image class Sad

many thanks if anyone can help!

Cheers,
Oliver
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4153


May the 4th, be with you...


View Profile WWW
« Reply #1 on: 25. June 2010, 03:18:59 PM »

Make the ImageWidget heavyweight. Then it should work.

Marvin
Logged
Oliver
Enjoying the stay
*
Offline Offline

Posts: 28


View Profile
« Reply #2 on: 28. June 2010, 12:55:19 PM »

Hi Marvin,

of course I tried that before posting here, but without success. I tried to dig into the issue meanwhile:
  • The Image object in an example is 28x28 pixel (this is the output size on the screen)
  • The source image is a png (28x28), has an alpha channel and is partially transparent
  • The Image will be rendered in the HUD with a size of 28x28 pixel
  • The Texture2D object created by the ResourceLoader is 32x32 (I guess textures must be in a power of 2?)
  • The texture will be streched into 28x28 pixel what seems to cause the bad quality.
  • With TileMode "Tile_BOTH" the arrow will be rendered in good quality, but of course will be clipped.

The old version of Xith3D rendered the same png file in 28x28 with much better quality. Take a look to the attached images. Both are xith renderings and the blue arrow is 28x28 each:

Old HUD System                   New HUD System

I'am not sure what exactly causes the issue in the new HUD system. Is it the texture's size of 32x32 or is it a change in the HUD/render code?

Thanks for your help,
Oliver

Edit: I rolled back the xith 3D binaries and saw that the Texture2D in my example was 32x32 as well. Thus, the issue must be in the rendering of the 32x32 texture into the  28x28 image. It might be, that the TextureFilter isn't used?
« Last Edit: 28. June 2010, 01:53:04 PM by Oliver » Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4153


May the 4th, be with you...


View Profile WWW
« Reply #3 on: 29. June 2010, 10:02:16 AM »

It can very well be, that the texture filter isn't used. The new HUD system doesn't create and maintain one shape and texture per widget, but creates one texture and shape for the root heavyweight and any lightweight contained in it will use the texture and shape of the (grand-)parent heavyweight and all of its properties and so forth. Any heavyweight will always have its own shape and texture and properties.

Yes, textures must (or should) be power-of-two sized. But only the 28x28 part of your texture is used by appropriate texture coordinates. So this wil not be the problem.

Could you please create a testcase. This will make it much easier for me to check this.

Marvin
Logged
Oliver
Enjoying the stay
*
Offline Offline

Posts: 28


View Profile
« Reply #4 on: 29. June 2010, 12:25:58 PM »

Thanks Marvin,

I've uploaded a new test into xith-tk:

org.xith3d.test.ui.ImageWidgetTest

Cheers
Logged
Marvin Fröhlich
Xith Lord
Administrator
Guru
*****
Offline Offline

Posts: 4153


May the 4th, be with you...


View Profile WWW
« Reply #5 on: 30. June 2010, 09:19:33 PM »

I have renamed the testcase to ImageWidgetFilterTest.

The problem is not the OpenGL texture filter, but the Java Graphics2D interpolation filter. There was only a simple nearest_neighbour filter used when a streched image was rendered. Now a bicubic filter is used. We need to observe, if this doesn't drop performance too much for anyone using a streched image widget.

Additionally the texture filter wouldn't have to be set to the image widget's texture, but the to image widget's shape's texture. Have a look at line 102 in the testcase. Though this doesn't have any effect and only drops performance for nothing, since the shape is not scaled by OpenGL.

Marvin
Logged
Oliver
Enjoying the stay
*
Offline Offline

Posts: 28


View Profile
« Reply #6 on: 01. July 2010, 08:56:49 AM »

Thank you for the fast response and for pointing this out.

The rendering looks much better now, indeed still not as clean as in the old HUD system. See the comparison below:

I still wonder how it worked (in term of quality and performace) in the old system. It's very confusing comparing the sources.

Oliver

Edit: attached the source images from the example above
« Last Edit: 01. July 2010, 08:59:39 AM by Oliver » Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic