Sign in to follow this  
the_moo

texture filtering and transparency

Recommended Posts

hey all, i'm progressing on my next game fairly quickly now and that means problems are showing their ugly faces more often :( ! my problem now is (i think) with texture filtering and distance. when i draw one of my sprites close to the camera (between 0 and 400) it appears as normal. however, when i draw them further away (i've tested 450+) they then get white surrounding them where the transparent colour would've been (transparent colour is RGB(255,0,255)). i've tried changing the min and mag filters from point to some others but the same problem still exists. i would post a screenshot but it appears my web space was removed when the host decided no more freebies... anyway, if anyone knows of any way i can fix this problem i would greatly appreciate it. thanks,

Share this post


Link to post
Share on other sites
Quote:
Original post by the_moo
i would post a screenshot but it appears my web space was removed when the host decided no more freebies...
I think an image would help people understand the problem. Point your browser at ImageShack.us [smile]

I'm inclined to go with jamesw's suggestion - if it's specifically related to distance from the camera then Mip Mapping could be to blame. Two things:

1. Are you creating/loading your texture with mip-mapping (or having it auto-generated)?

2. What is your Mip filter (not just Min and Mag [wink])

hth
Jack

Share this post


Link to post
Share on other sites
ok i've uploaded a screenshot snippet to imageshack:
Free Image Hosting at www.ImageShack.us

as you can see the big green "circle" can been seen past where the red-orange "circles" have a white "background" where the transparent pixels are.

my filters are set like so:
device->SetSamplerState(0,D3DSAMP_MIPFILTER,D3DTEXF_NONE);
device->SetSamplerState(0,D3DSAMP_MINFILTER,D3DTEXF_POINT);
device->SetSamplerState(0,D3DSAMP_MAGFILTER,D3DTEXF_POINT);

and sprite images are loaded with: D3DX_FILTER_NONE settings

i think that's everything. hope this all helps to clear things up and find a solution.

thanks again,

Share this post


Link to post
Share on other sites
Seems like a classic alpha-blending problem to me [smile]

Any of the blending operations specified by D3DRS_SRCBLEND and D3DRS_DESTBLEND are draw order dependent. That is, you will potentially get different results depending on when (relative to other objects) you choose to render your geometry.

The _SRCBLEND component will be the same, but the value used in the _DESTBLEND component will simply be whatever is in the frame-buffer/render-target at the time of rendering.

Given in your case its white, I'll bet you're rendering your particles early on in the frame - before the landscape (?) part. Thus its just picking up the white Clear() colour. Change that white background colour to something obvious like pink and the white parts around your particles should change to reflect this.

The solution is to change the order in which you draw your semi-transparent objects. Simply put, you need to sort them from back-to-front and then render them in that order. This isn't so easy with particle systems, so a useful "hack" is to roughly sort the whole particle system/groups and then render with ZTESTENABLE = TRUE and ZWRITEENABLE = FALSE.

You should also make sure you render any solid/opaque geometry before any semi-transparent models...

hth
Jack

Share this post


Link to post
Share on other sites
ok thanks jollyjeffers!
that little bit of advice made me realise (and find...) that i wasn't properly sorting that one single object! now i've got it so that it sorts properly and i can override the sorting so that it all works they way it's supposed to!

thanks a heap for the little hack too [wink]! that works a treat for my particle generators!

with this fixed i've got no problems with my engine or game now so hopefully i can keep moving at a fast pace!

thanks again jollyjeffers!

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