Home Technical Talk

[NDS] Looking through semitransparent objects

polycounter lvl 14
Offline / Send Message
Mr_Drayton polycounter lvl 14
Hi everyone, I hope this is not a dumb question.

Let's suppose I have a row of semitransparent walls and I'm looking through them. The further I look, the more opaque the walls appear. You all know this is the normal behaviour of semitransparent textures.

Then I export the scene for using it on my Nintendo DS. When I look through the walls, an annoying bug happens and it looks like the second wall is 100% opaque, having only the first wall correctly semitransparent.

I know this is quite usual, and obviusly I can't expect much from a DS, but I'm sure I haven't seen this issue in certain games. Is there a particular texture compresion I need to use to avoid this problem or it's only a matter of coding?

Thanks for the help!

Replies

  • Mark Dygert
    Few things bring hardware to their knees like semi-transparent sorting. You might be able to use alpha test (on or off no partial transparency) and stack a few.

    TreePlanesExplained01.jpg
    Left: Alpha Sort.
    Very hard to calculate, the more you stack the worse it gets.
    What % of this pixel is transparent?
    Wait there's another transparent texture... oh gawd... how much can you see? What is its relationship to the camera and other textures. Ok we can do this its only two. Lets figure out how much you can see at the deepest level then figure out how much of that you can see with the next.
    Wait there's another.
    Tiny DS brain exploding!

    Right: Alpha Test.
    Pretty simple test, is it transparent y/n?

    There are ways to blur alpha test maps on the hardware to soften them up, but those methods are very hardware dependent.

    CrazyButcher had a great post about this stuff about a year ago... can't seem to find it.
  • Mr_Drayton
    Offline / Send Message
    Mr_Drayton polycounter lvl 14
    Thanks for the fast replies! You're always reliable Vig! ;)

    Poor DS! :D I already made some similar tests in the past, but what I tried to achieve wasn't edge smoothing (Alpha Test is enough for simple borders). I wanted to create a series of alligned white-yellow translucent planes and put them at the end of a dark tunnel, in order to simulate a fake blinding effect.
    In MAX it worked wonderfully, in the DS obviusly it didn't... My face turned from :D to D: in a second, hehe... But I expected it in some way.

    Maybe I can try to use a 100% opaque texture and then set the transparency for the object directly from code...
  • Minos
    Offline / Send Message
    Minos polycounter lvl 16
    Mr_Drayton wrote: »
    Hi everyone, I hope this is not a dumb question.

    Let's suppose I have a row of semitransparent walls and I'm looking through them. The further I look, the more opaque the walls appear. You all know this is the normal behaviour of semitransparent textures.

    Then I export the scene for using it on my Nintendo DS. When I look through the walls, an annoying bug happens and it looks like the second wall is 100% opaque, having only the first wall correctly semitransparent.

    I know this is quite usual, and obviusly I can't expect much from a DS, but I'm sure I haven't seen this issue in certain games. Is there a particular texture compresion I need to use to avoid this problem or it's only a matter of coding?

    Thanks for the help!

    The NDS handles alpha maps very poorly. When I worked on a DS game just I avoided them at all costs. Go with alpha test textures instead, they work fine 99% of the time.
  • Mark Dygert
    You could try turning every other pixel transparent. It would leave you the speed of test but might MIGHT get close enough to look like sort, depends on how bit the pixels are.

    What about using a cone the camera flies through, instead of stacked planes? It would cover the walls in light and make it look like its getting brighter.
  • danr
    Offline / Send Message
    danr interpolator
    On gta CTW (ds version) we had several layers of alpha that weren't alpha test - in fact very little of the geometry used 1-bit alpha cos it generally looked arse.

    It was juggled with a mix of code and art, manually setting in what order to draw each bit. Bit of a pain to get right, and helped a lot by the fact it was sort of top down so there was always a "bottom" layer. But quite possible to do. Light a fire under a coder
  • Mr_Drayton
    Offline / Send Message
    Mr_Drayton polycounter lvl 14
    Thanks for the replies! ^^

    @danr: There should be more games on the DS like GTA CW! It's technically excellent, and I remember that shadows were almost impeccable. Having them work correctly via coding it's quite difficult, and I'm sure that the coder of the Software House I'm working with is way too lazy to try that... -_-'
    Vig wrote: »
    You could try turning every other pixel transparent. It would leave you the speed of test but might MIGHT get close enough to look like sort, depends on how bit the pixels are.
    What do you mean, precisely? I'm not sure to understand well... What pixels should I turn transparent (100% transparent)?
    Vig wrote: »
    What about using a cone the camera flies through, instead of stacked planes? It would cover the walls in light and make it look like its getting brighter.
    This sounds like a great solution (man, I feel so stupid), but... It would only work for the walls of the tunnel. Look at this short video renders I posted on the Lowpoly thread: at 0:13 you can see exactly what I wanted to achieve.

    [ame]http://www.metacafe.com/watch/4219943/nds_futuristic_racing_project_teaser/[/ame]

    The effect is beautiful, because the more you drive closer to the exit, the more the light fades out. Unfortunately DS doesn't stand it...

    Uhm, I just had an idea. What if I make a simple object that varies its opacity depending on how much you are close to it? Think about that tunnel in the video: when you are far, the fake light object it's 100% opaque (still having some transparent shades to cover the wall), then, approaching it, the object fades to be completely insivible. I think it's the best way to do it without juggling too much with the code!

    For everyone willing to know, that project in the video were abandoned because no publishers were interested in it (I want to cry)... Hehe, I'm selling myself to the first one interested in making it... Seriously!
    Anyway I'm asking for this transparency issue because it could be useful for later projects. You all are very helpful, thanks! :poly121:
  • Eric Chadwick
    If you want to try the proximity trick, see if you can manually adjust the mips for your DS textures... then you could fill the largest mip with black, and brighten them up as you go down, until the bottom one is white.

    Some info in the wiki.
    http://wiki.polycount.net/Mip_Map
  • Mr_Drayton
    Offline / Send Message
    Mr_Drayton polycounter lvl 14
    If you want to try the proximity trick, see if you can manually adjust the mips for your DS textures... then you could fill the largest mip with black, and brighten them up as you go down, until the bottom one is white.

    Some info in the wiki.
    http://wiki.polycount.net/Mip_Map
    If I remeber well, DS can't handle mip maps, beacuse using only 33% Vram more would be a big loss. Just consider that NDS has 512kb of Vram, divided in 4 slots. There should be other very small slots, but they are generally left empty.
  • LEViATHAN
    Offline / Send Message
    LEViATHAN polycounter lvl 11
    Additive blending mode, or isn't that supported as well?
  • Mr_Drayton
    Offline / Send Message
    Mr_Drayton polycounter lvl 14
    LEViATHAN wrote: »
    Additive blending mode, or isn't that supported as well?
    I'm pretty sure it's not supported. This alpha problem occurs in lots of games, so I think there isn't a direct way of fixing it.
Sign In or Register to comment.