Sign in to follow this  
s3mt3x

Texture Artifacts - Help me with this and i'll have your children!!

Recommended Posts

Hi Guys, I've been working on generating lightmaps and I keep getting artifacts on the sides of my polygons and i've no idea where they are comming from. Please see the image below: As you can see, there are artifacts on the sides of the poly - i've included the lightmap texture i'm using on the right - the yellow border correspond to the uvs. Can anyone help me with this? It's driving me insane - I can't see any reason why this should be happening? It appears to happen when the UVs span a pixel - any comments or suggestions would be really appreciated. Actually - i've just tried aligining the uvs to the nearest pixel - and it still happens :( Please, Please someone help!!! Also, the red borders on the lightmap will later be filled with the adjacent pixels - i've filled them with red to enhance what's going on. Kind Regards, Chris

Share this post


Link to post
Share on other sites
When you create the texture, did you specify clamp to edge?

In OpenGL, for a 2D texture:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

Share this post


Link to post
Share on other sites
Hi Tabby,

Thanks for replying, yes I have - in fact i've tried it with pretty much every possible comination of texture parameters and it still goes all wierd :(

Kind Regadrs,

Chris

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
That's definitely DXT compression artifacts. Your red color interferes with the compression process... each 4x4 block can only have 2 unique colors, the other 2 are interpolated from those.

You shouldn't compress lightmaps really anyway, it'll just look ugly.

Share this post


Link to post
Share on other sites
How many textures are you overlaying? It's strange to me that the blue texels are significantly larger than those which make up the light map's grey(ish) texels.

Edit: Ahh, compression, that would explain the deviance in grey's purity.

Share this post


Link to post
Share on other sites
Hi Guys,

Texture compression???? I'm using opengl and i've loaded all the extensions at runtime - would this activate it texture compression without specifically specifying it?

Share this post


Link to post
Share on other sites
I'm not sure what is causing those artifacts, but on another note I don't see why you are shifting your uv's in by more than half a pixel on the right and bottom sides of the lightmap texture.

If you are going to give the surrounding red pixels the colour of their nearest neighbour then this should completely remove any bleeding that occurs with filtering and there is no need for the half pixel uv shrink hack. [smile]

Regards,
ViLiO

Share this post


Link to post
Share on other sites
No texture compression is enabled by default, unless it's overrode by the graphic driver itself through some user setting.

So I'm assuming the impurity is from the JPEG compression of the screenshot, and isn't actually displayed when the information is still lossless.

Baring that, is it indeed just one texture per pass? Have you checked the actual raw data in RAM to see if those pixels really aren't just simply blue and the green and red aren't being filled?

Are you using a BGRA colour format? Or RGBA?

Share this post


Link to post
Share on other sites
Quote:
Original post by ViLiO
I'm not sure what is causing those artifacts, but on another note I don't see why you are shifting your uv's in by more than half a pixel on the right and bottom sides of the lightmap texture.

If you are going to give the surrounding red pixels the colour of their nearest neighbour then this should completely remove any bleeding that occurs with filtering and there is no need for the half pixel uv shrink hack. [smile]

Regards,
ViLiO


It's probably your mip mapping that's causing the problem. Try without mipmapping, and also try duplicating the pixels at the edge like ViLiO mentioned.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I'm 100% sure that the large scale banding that you are seeing is because DXT (S3TC) compression is being applied at some stage. You may want to check your driver control panel, some quality parameter may be forcing texture compression.

Share this post


Link to post
Share on other sites
Hi guys,

Thanks for all the replies so far - just to clear up a few issues - i can confirm that the uvs are correct, and that the raw RGB data being uploaded is correct - i've painstakingly ensured this. I'm using a geforce fx 5900 - i can't see anywhere in the dirver settings anything about texture compression.

Can i not explicitly disable this through my code?

If it is texture compression - why does it only appear on particular sides of the polygon??

Thanks again for all your help so far.

Kind Regards,

Chris

Share this post


Link to post
Share on other sites
Ok - i'm so exicited - it's fixed - I used RivaTuner to disable automatic texture compression - and the results are great - so now the question becomes - can i explicity disable texture compression on a texture by texture basis? Other textures in my scene (that are not packed into an atals are fine with the compression on) so i'm assuming i would need to disable texture compression for my lightmap atlas only - is this correct? otherwise anyone who uses texture compression (for my application) will see these artifacts - are there ways around this?

Kind Regards - and thankyou so much for all of your help,

Chris

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You could start by killing off your red lines, instead setting those pixels to averages of their valid neighbours. This will almost kill your artifacts.

It's very weird that your texture unintentionally got compressed though. What does your gluBuildMipmaps or glTexImage call look like?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Its the stupid "optimizations" by the driver. On nv cards in the driver control panel if you slide the image quality settings towards quality then these sorts of things disappear.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this