Friday, November 17, 2006

Texture coordinate generation and flickering

I fixed quite a large amount of bugs, but the 2 most important ones, would be the ones from topic: texture coordinate generation and flickering.

The first one is quite simple, as most PC hardware, the DS supports texture coordinate generation. This is used, for example, if you want to have a pool with water, the water being a texture mapped plane, and want it to seem to wave: instead of having a large amount of geometry, just generate the texture coordinates varying to get the visual effect of waving. I had made an implemention long ago, but I always found samples which rendered wrong, and then when I fixed one of them, another was broken. The bug was rather stupid: as openGL and DS texcoord generation doesn't map 1:1, I just pre-transformed them, and then sent them to openGL. The problem, was that I was not resetting the texture matrix, and as a such, at last they got pre-transformed by me, and then transformed by openGL. Stupid bug of the year, for sure.

Flickering was a damn annoying bug, which I never got enough motivation to fix, it "just" involved retrieving the openGL framebuffer, then copying it to BG0, and send it to the layering pipeline that desmume uses. Sounds simple, in fact it's simple to implement, but the code is ugly, probably slower than it should be, and, by the fact it has to be transformed from 24bit to 16bit, it looks a bit uglier (as in the DS, :P)

And more, or less, that's all for today, let's just put the usual screenshot:

For further references on texcoords, here you can find a nice explanation.

Have fun :)


GoodNDS said...

Shash, I would just like to say Great job! You have progressed a lot on the emulator. Its looking better and better! Keep it up! Great job!

Federelli said...

Definetly an improvement from the last metroid shot. Textures are there and so is the hud, very good work! Keep it up :)

KemenAran said...

Great screenshot !

And I really enjoy tour technical explanations, keep them up :)

ElJuez said...

Great Job man!!!!
nice progress
still working
don't be pressure about to realese a future version
You said you will "I've really been thinking about when I should release, and I narrowed it down to one option: I'll release when either Super Mario DS or Metroid Prime look right, that means fixing compressed textures or fixing the generated texture coordinates. I'll probably make other speed fixes, but compatibility comes first."

Now one of the bugs is fixed
but take your time
we know you are making a great job
thanks Shash

vineet said...

i vill call u a emulation master if u post a screenshot of running pokemon pearl or pokemon diamond
in dsemu or any other NDS emulator.

i admit u are stepping towards a right thing.
plz,can u also provide a screenshot
for pokemon ranger as i know it is working but i m sumhow unable to run it!!

shash said...

Don't expect screenshots of Pokemon, as I personally don't like the games.