Texture antialias.

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Texture antialias.

Post by agamemnus »

I cannot figure out how to anti-alias textures. I've searched everywhere...

Help!

This is what I have, right before I set the texture to my material using setTexture:

Code: Select all

irrmaterial.AntiAliasing = 15;
irrmaterial.setFlag(irr::video::EMF_TRILINEAR_FILTER, 1);
irrmaterial.setFlag(irr::video::EMF_ANTI_ALIASING, 1);
The texture is still not anti-aliased. What am I missing/doing wrong?

Edit: I am using "drawIndexedTriangleList" to draw the material.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You first set AntiAlias to 15, and then to 1. This is probably not the thing you want to do.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

I removed it, but it didn't make a difference. :(

Edit: More info: The reduced texture uses precisely nearest-neighbor downsampling, as opposed to bicubic downsampling. Maybe that's not "anti-alias" at all? I don't know.
slavik262
Posts: 753
Joined: Sun Nov 22, 2009 9:25 pm
Location: Wisconsin, USA

Post by slavik262 »

I think you're actually referring to texture filtering, not anti-aliasing. By default, textures use bilinear filtering. If you go into the texture layer (myMaterial.TextureMaterial[n], where n is the texture layer you want to access), you can set filtering options. You can set TrilinearFilter in the layer to true to activate trilinear filtering, or for even better filtering, set AnisotropicFilter to the amount of anisotropic filtering you want (usually powers of two, from 2 to 16).

Hope that helps :D
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

slavik262 wrote:I think you're actually referring to texture filtering, not anti-aliasing. By default, textures use bilinear filtering. If you go into the texture layer (myMaterial.TextureMaterial[n], where n is the texture layer you want to access), you can set filtering options. You can set TrilinearFilter in the layer to true to activate trilinear filtering, or for even better filtering, set AnisotropicFilter to the amount of anisotropic filtering you want (usually powers of two, from 2 to 16).

Hope that helps :D
Do you mean myMaterial.textureLayer[]?

I do this:
irrmaterial.TextureLayer[0].TrilinearFilter = true;

... right before setting the texture. No difference.

I also tried adding:
irrmaterial.TextureLayer[0].AnisotropicFilter = 15;

No difference..

Also tried setting it at various points.. after setting the texture, before, much before, much after... no difference..
Last edited by agamemnus on Sat Sep 11, 2010 8:56 pm, edited 1 time in total.
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Post by REDDemon »

of course you have also to enable the material flag. if anisotropic is x8 but the anisotropic filter flag is false you are not going to use the filters.

NVIDIA and ATI video cards make you able to choos if you want the anisotropic or antialias filter activated (indipendently of your application settings). so maybe you can also look if you video settings are:

Antialias: NO
Anisotropic: NO

and set them to

Antialias : application managed
Anisotropic: application managed.


Try also to see if a medium configuration work on your machine
(antialiasx 2 anisotropic x 8 )

and also run several demos that use those filters.

remember also to set the material to the mesh that you are using
Junior Irrlicht Developer.
Real value in social networks is not about "increasing" number of followers, but about getting in touch with Amazing people.
- by Me
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

* I also tried with: ".setFlag(irr::video::EMF_TRILINEAR_FILTER, 1);" and ".AntiAliasing = 15;", and there is no difference.

* I am not using a mesh; I am using drawIndexedTriangleList.

* Anti-aliasing is enabled system-wide. There is anti-alias between polygons.

* The driver had application-controlled on both anti-alias and ansiotropic filtering. Setting them both to 4x and forcing ansiotropic filtering to "quality with full trilinear" and then running my program did not make any difference.
Last edited by agamemnus on Sat Sep 11, 2010 9:05 pm, edited 1 time in total.
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

can you provide code that runs and shows the problem?
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

No. :(

Here is a part of it... this might help.

Code: Select all

irrmaterial.AntiAliasing = 15;
irrmaterial.setFlag(irr::video::EMF_TRILINEAR_FILTER, 1); 
irrmaterial.TextureLayer[0].TrilinearFilter = true;

 unsigned int pos = 0;
 BatchList::const_iterator i = irrbatches.begin();
 for ( ; i != irrbatches.end(); ++i) {
  irrmaterial.setTexture(0, (*i).first);
  irrdriver.setMaterial(irrmaterial);
  irrdriver.drawIndexedTriangleList(&irrvertices[pos], (*i).second, &irrindices[pos], (*i).second / 3);
  pos += (*i).second;
 }
sudi
Posts: 1686
Joined: Fri Aug 26, 2005 8:38 pm

Post by sudi »

first question.
why do you do

Code: Select all

irrmaterial.setFlag(irr::video::EMF_TRILINEAR_FILTER, 1);
irrmaterial.TextureLayer[0].TrilinearFilter = true; 
this would be the same

Code: Select all

irrmaterial.setFlag(irr::video::EMF_TRILINEAR_FILTER, true);
and second why do use 1 instead of true?is true actually 1 everywhere? dunno

anyway.

next thing maybe you can show us the problem you have with a picture. maybe the result is actually correct?
We're programmers. Programmers are, in their hearts, architects, and the first thing they want to do when they get to a site is to bulldoze the place flat and build something grand. We're not excited by renovation:tinkering,improving,planting flower beds.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Sudi wrote:first question.
why do you do

Code: Select all

irrmaterial.setFlag(irr::video::EMF_TRILINEAR_FILTER, 1);
irrmaterial.TextureLayer[0].TrilinearFilter = true; 
this would be the same

Code: Select all

irrmaterial.setFlag(irr::video::EMF_TRILINEAR_FILTER, true);
and second why do use 1 instead of true?is true actually 1 everywhere? dunno

anyway.

next thing maybe you can show us the problem you have with a picture. maybe the result is actually correct?
From Slavik's post, I thought it was something I was not doing -- that "irrmaterial.setFlag" and "irrmaterial.TextureLayer[0]" are different.

As I said, to use Photoshop terminology, the downsampling uses "nearest neighbor", instead of "bicubic". Here is the difference:

In my game let's say the image is reduced to 32x32. (The image I have linked is magnified 10x) The fish in my game looks like the fish on the left -- nearest neighbor. I want it to look like the fish on the right -- bicubic.

Image
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

For texture filtering you don't need anti-aliasing. Simply set the filter modes of the material and render the objects. If you use 3d rendering (draw3D* or drawVertex*) you have to use setMaterial(). For the 2d elements use the 2dmaterial, which is a global override element.
Please refer to example 6 on usage of 2dmaterial.
agamemnus
Posts: 283
Joined: Sun Jan 31, 2010 6:06 pm

Post by agamemnus »

Except it simply doesn't work. :evil: (at least in DirectX mode.... see the bug link)
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

I've just added a test case in the regressions, and example 6 also has texture filtering in 2d mode. Both work with all hw drivers. Moreover, the GUI problem is also not visible here, gui images still render with the 2d material.
Post Reply