#175449 - zelbo - Wed Nov 24, 2010 12:39 pm
Running into a problem getting a looping palette set up, for something like a plasma, say.
This image shows what is happening. What i am getting is on the left, what i want is on the right.
The first three are from Lode's tutorials. The fourth one is from Relminator's plasma, i don't know what it should actually look like, was just looking for a different take on the problem. (i'm guessing it should look better than it does here)
Some potential suspects:
I'm using ant512's WhoopsiGfx library for drawing lines, maybe that is handling colors strangely? i kinda doubt it, but don't know.
Using a few functions stolen from Lode's quickcg library, maybe these don't work the same on the DS for some reason?
Testing with emulator (no$gba, desmume), my ability to test on hardware is currently impared. Most likely problem?
Using MODE_5_2D. Is this limited to 256 colors?
Maybe some math errors in these algorithms? I know there are some int/u16 type mismatches, but i don't think that's causing it.
Setting up the hardware:
Generate the palettes:
Using a third party library here, maybe part of the problem?:
Drawing lines (if WoopsiGfx does somehow turn out to be the problem, i reckon i could build my own line drawing functions, hoping to save some time while using functions written by someone that most likely knows their stuff better than yours truly:
I'm know this is something i should be able to figure out if i knew what i was doing, but if you've read any of my previous posts, you would know that's not the case as of yet. I've googled everything i can think of regarding ds framebuffer mode, seem to be hitting a wall here. Anyone point me in the right direction?
Last edited by zelbo on Wed Nov 24, 2010 8:53 pm; edited 1 time in total
This image shows what is happening. What i am getting is on the left, what i want is on the right.
The first three are from Lode's tutorials. The fourth one is from Relminator's plasma, i don't know what it should actually look like, was just looking for a different take on the problem. (i'm guessing it should look better than it does here)
Some potential suspects:
I'm using ant512's WhoopsiGfx library for drawing lines, maybe that is handling colors strangely? i kinda doubt it, but don't know.
Using a few functions stolen from Lode's quickcg library, maybe these don't work the same on the DS for some reason?
Testing with emulator (no$gba, desmume), my ability to test on hardware is currently impared. Most likely problem?
Using MODE_5_2D. Is this limited to 256 colors?
Maybe some math errors in these algorithms? I know there are some int/u16 type mismatches, but i don't think that's causing it.
Setting up the hardware:
Code: |
videoSetMode( MODE_5_2D | DISPLAY_BG3_ACTIVE );
vramSetBankA( VRAM_A_MAIN_BG ); bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0, 0); |
Generate the palettes:
Code: |
u16 palette_0[256];
u16 palette_1[256]; u16 palette_2[256]; u16 palette_3[256]; ColorRGB colorRGB; for(int x = 0; x < 256; x++) { // lode 1 http://www.student.kuleuven.be/~m0216922/CG/plasma.html#Plasmas_with_Palette_Looping_ colorRGB = HSVtoRGB(ColorHSV(x, 255, 255)); palette_0[x] = RGB15(colorRGB.r, colorRGB.g, colorRGB.b); // lode 2 colorRGB.r = int(128.0 + 128 * sinLerp(3.1415 * x / 32.0)); colorRGB.g = int(128.0 + 128 * sinLerp(3.1415 * x / 64.0)); colorRGB.b = int(128.0 + 128 * sinLerp(3.1415 * x / 128.0)); palette_1[x] = RGB15(colorRGB.r, colorRGB.g, colorRGB.b); // lode 3 colorRGB.r = int(128.0 + 128 * sinLerp(3.1415 * x / 16.0)); colorRGB.g = int(128.0 + 128 * sinLerp(3.1415 * x / 128.0)); colorRGB.b = 0; palette_2[x] = RGB15(colorRGB.r, colorRGB.g, colorRGB.b); // Relminator's translucent plasma sample http://rel.betterwebber.com u8 r = (u8)(abs(int(16 - 15 * sinLerp(x * M_PI / 16.0f)))); u8 g = (u8)(abs(int(16 - 15 * sinLerp(x * M_PI / 12.0f)))); u8 b = (u8)(abs(int(16 - 15 * sinLerp(x * M_PI / 18.0f)))); palette_3[x] = RGB15(r,g,b); } |
Using a third party library here, maybe part of the problem?:
Code: |
WoopsiGfx::FrameBuffer topScreen((u16*)BG_BMP_RAM(0), 256, 192);
WoopsiGfx::Graphics* topGfx = topScreen.newGraphics(); |
Drawing lines (if WoopsiGfx does somehow turn out to be the problem, i reckon i could build my own line drawing functions, hoping to save some time while using functions written by someone that most likely knows their stuff better than yours truly:
Code: |
for(int x = 0; x < 256; x++)
{ topGfx->drawLine(x, 0, x, 5, palette_0[x]); topGfx->drawLine(x, 6, x, 11, palette_1[x]); topGfx->drawLine(x, 12, x, 17, palette_2[x]); topGfx->drawLine(x, 18, x, 23, palette_3[x]); } |
I'm know this is something i should be able to figure out if i knew what i was doing, but if you've read any of my previous posts, you would know that's not the case as of yet. I've googled everything i can think of regarding ds framebuffer mode, seem to be hitting a wall here. Anyone point me in the right direction?
Last edited by zelbo on Wed Nov 24, 2010 8:53 pm; edited 1 time in total