[Solved]Texture filtering question

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
xarple
Posts: 3
Joined: Fri May 25, 2012 3:15 pm

[Solved]Texture filtering question

Post by xarple »

Hi everyone :)

I making a terrain loader, it's works well for loading.
In order to better performance, that pack all the textures in one.
But now i have a question, all tile textures are displayed the line on the edges.
It seems because of wrong texture filtering option, But it just still edges when i change all the texture filtering.

How i can fix it?
Thanks.


I mean that line on the edges is like:
Image

This is the packed texture:
Image
Last edited by xarple on Sun May 27, 2012 6:41 am, edited 1 time in total.
Mel
Competition winner
Posts: 2292
Joined: Wed May 07, 2008 11:40 am
Location: Granada, Spain

Re: Texture filtering question

Post by Mel »

You have to add a small padding to the textures in the atlas, and, if posible, you should generate as much mipmap levels as needed so your textures don't start to mix between them on the lower mipmap resolutions.

or perhaps you could use a shader so you always read the proper mipmap level, so it never reached the last level, in HLSL you can use the tex2dlod(), in GLSL i can't tell :/
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
REDDemon
Developer
Posts: 1044
Joined: Tue Aug 31, 2010 8:06 pm
Location: Genova (Italy)

Re: Texture filtering question

Post by REDDemon »

very nice texture. try with a power of 2 image. (1024,1024 or 2048, 2048.. you can try also rectangular to save some memory 2048,1024)
(if changin background color from black to red don't change color of seams to RED, than probably your problem is that).

At a first look it seems that seams are between polygons but a closer look (on the first foreground mountain on left) shows that there are black seam even when behind there is some white, so probably is the nPOT2 image, but that could be a Zwrite problem using with Alpha channel

EDIT: probably removing alpha channel will help you too. replace transparency with your snow grey
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
Bl00drav3n
Posts: 48
Joined: Sun Apr 22, 2012 11:55 pm
Location: Vienna
Contact:

Re: Texture filtering question

Post by Bl00drav3n »

I had the same problem and kind of fixed it with the methode Mel suggests. But the problem is, that you have to use a larger border for every mipmap level, so the best solution is doing this with a shader I guess.
By the way, the corresponding GLSL function would be textureLod().
xarple
Posts: 3
Joined: Fri May 25, 2012 3:15 pm

Re: Texture filtering question

Post by xarple »

Thanks for the reply :)

First I try to change the texture background color to RED, that display the line in RED color, and when I try to use power of 2 texture, it just same display.
Image


Next I use a shader with tex2Dlod and set the filtering:

Code: Select all

 
        Mat.setFlag( irr::video::EMF_BILINEAR_FILTER, false );
        Mat.setFlag( irr::video::EMF_TRILINEAR_FILTER, false );
        Mat.setFlag( irr::video::EMF_ANISOTROPIC_FILTER, false );
 
Shader:

Code: Select all

 
PS_OUTPUT pixelMain( float2 TexCoord : TEXCOORD0,
                     float4 Position : POSITION,
                     float4 Diffuse  : COLOR0 ) 
{ 
        PS_OUTPUT Output;
 
        float4 LOD;
        LOD.xy = TexCoord;
        LOD.z = 0;
        LOD.w = 0;
        
        Output.RGBColor = tex2Dlod( tex0, LOD ) * Diffuse;
        return Output;
}
 
But it just still display the edges line :?
Image



Then I change it without padding space, it seems works fine: :D
Image

Used texture:
Image


But in the other terrain that edges line are still displayed!
Image

Used texture:
Image


First I suspect the problem is texcoord wrong, but the implement tell me not.
And the line thickness always not seem like a 'pixel width':
Image


Are someone have any ideas?
Thanks a lot!


EDIT:
Only point filtering and no anti-aliasing can display correctly.
But it's not my want, anti-aliasing can simulate it use shader, but I want to enable the Anisotropic Filtering.
alanacial
Posts: 13
Joined: Tue Sep 20, 2011 6:32 pm
Location: USA

Re: Texture filtering question

Post by alanacial »

How were you able to extract the image files? It looks alot like ragnarok, and I think it be fun to look into custom map generation for the dozens of private servers they have. Do you have a way to repack them for use? Or were you just inspired by that game to create your own?

Image
xarple
Posts: 3
Joined: Fri May 25, 2012 3:15 pm

Re: Texture filtering question

Post by xarple »

Solved, :D
I use this guy's ideas:
http://www.ogre3d.org/forums/viewtopic.php?f=4&t=61602


@alanacial
You are right, this is actually RO's map. :)
There have a few tools can able to edit the map, eg BrowEDIT, you can found it from google.
Post Reply