#107186 - Tassu - Fri Oct 27, 2006 2:22 pm
What would be the best way to make a 3D quad fade from solid to transparent so that one end would be solid and the other transparent? I'm trying to make a beam of light.
With PC it would be as easy as this:
Code: |
glBegin(GL_QUADS);
glColor4f(1,1,1,1);
glVertex3f(0,0,0);
glVertex3f(1,0,0);
glColor4f(1,1,1,0);
glVertex3f(1,1,0);
glVertex3f(0,1,0);
glEnd(); |
How could I do this on the DS? Should I use a texture or something?
#107214 - Goosey - Fri Oct 27, 2006 6:57 pm
A alpha transition exactly like your looking for cant be done on the DS with a single quad. Two options spring to mind:
- Use multiple quads in different ID groups with progressively less poly alpha.
- Use a alpha texture that progressivly has more alpha-rejected pixels.
To clarify the 2nd option, since alpha textures in the DS are single bit rejection (drawn or not) you would do something like this (X = no alpha, A = alpha)
XXXXX
XXAXX
XAXAX
AXAXA
AAXAA
Not sure if it will look great!
#107221 - Rockard - Fri Oct 27, 2006 7:43 pm
easiest would be to use a texture. there is a recent thread started by me that clearifies how to make such a texture.
#107222 - M3d10n - Fri Oct 27, 2006 7:44 pm
"Alpha reject"? As in fully transparent? That would look horrible, no?
Using textures with alpha channels is the way to go for alpha gradients. Search for "texture formats" and you might find a thread which talks about them.
#107264 - Tassu - Sat Oct 28, 2006 3:25 am
M3d10n wrote: |
Using textures with alpha channels is the way to go for alpha gradients. Search for "texture formats" and you might find a thread which talks about them. |
I found this: http://forum.gbadev.org/viewtopic.php?t=11494 Thanks very much!
My quad now fades nicely but it shows completely black. Only the alpha works, not the color. I think the palette doesn't get loaded.
#107277 - Goosey - Sat Oct 28, 2006 4:35 am
*blush*
Oh yes, you can do that.
#107319 - Sausage Boy - Sat Oct 28, 2006 1:57 pm
Mind sharing the source Tassu? I'll try to help you.
_________________
"no offense, but this is the gayest game ever"
#107320 - Tassu - Sat Oct 28, 2006 2:17 pm
Rendering:
Code: |
glEnable(GL_BLEND);glAlphaFunc(BLEND_ALPHA);
glBindTexture(GL_TEXTURE_2D,fade_tex);
glColorTable(GL_RGB32_A3, fadetex_pal_addr);
glBegin(GL_TRIANGLES);
glTexCoord2f(0,0.125);glVertex3f(x1,y1+hadd,0);
glTexCoord2f(0.25,0);glVertex3f(x1-1,y1,0);
glTexCoord2f(0.25,0.25);glVertex3f(x1+1,y1,0);
glEnd(); |
Loading:
Code: |
glGenTextures(1, &fade_tex);
glBindTexture(GL_TEXTURE_2D, fade_tex);
glTexImage2D(0, 0, GL_RGB32_A3, TEXTURE_SIZE_32 , TEXTURE_SIZE_32, 0, TEXGEN_TEXCOORD | GL_TEXTURE_WRAP_S | GL_TEXTURE_WRAP_T, (u8*)fadetex);
fadetex_pal_addr=gluTexLoadPal( (u16*)fadetexpal, 32, GL_RGB32_A3 ); |
fadetex_pal_addr always remains zero. Is that the problem?
#107321 - Sausage Boy - Sat Oct 28, 2006 2:24 pm
If fadetex_pal_addr really is 0 all the time, it is certainly a problem. Where does it come from? Which command line did you use for conversion? How do you include your files?
_________________
"no offense, but this is the gayest game ever"
#107323 - Tassu - Sat Oct 28, 2006 2:53 pm
I convert with TexMex with command: TexMex fadetex.png -o fadetex -1
I rename the files to fadetex.bin and fadetexpal.bin and put them in data folder.
Then:
Code: |
#include "fadetex.h"
#include "fadetexpal.h"
int fade_tex;
int fadetex_pal_addr; |
I noticed that in the paletted cube example the generated .h files are different from mine.
It looks like this in the example:
Code: |
extern const u8 texture8_RGB32_A3_pal_bin_end[];
extern const u8 texture8_RGB32_A3_pal_bin[];
extern const u32 texture8_RGB32_A3_pal_bin_size; |
And this in my project:
Code: |
extern const u8 fadetexpal[];
extern const u32 fadetexpal_size[]; |
Does this have something to do with the makefiles? I use the one that came with palib...
#107324 - Sausage Boy - Sat Oct 28, 2006 2:57 pm
Remove the fadetex_pal_addr, and replace every reference to it with fadetexpal.
Edit:
Scratch that, I don't know what I'm thinking today.
_________________
"no offense, but this is the gayest game ever"
#107361 - omaremad - Sun Oct 29, 2006 12:32 am
Why not just use standard textures and polyalpha 15 or something i think the ds` default transparency mode is addition alpha, so a normal texture with a white to black gradient should do the trick.
#107404 - Tassu - Sun Oct 29, 2006 12:51 pm
omaremad wrote: |
Why not just use standard textures and polyalpha 15 or something i think the ds` default transparency mode is addition alpha, so a normal texture with a white to black gradient should do the trick. |
That wouldn't look right. The whole quad would be visible from every place, even the darker parts.
#107427 - omaremad - Sun Oct 29, 2006 4:33 pm
since its additive blending the black parts would still be invisible
#107428 - Tassu - Sun Oct 29, 2006 4:38 pm
omaremad wrote: |
since its additive blending the black parts would still be invisible |
DS doesn't have additive blending. I'm not sure what's the correct word for the kind of transparency mode the DS has, but it's not additive. Just normal basic transparency. The dark parts would show.
#107468 - omaremad - Sun Oct 29, 2006 10:36 pm
Hmmm i had toon shading turned on(+smoothing) with transparency and the darker parts of the toon table had been more transparent than the lighter ones.
#107508 - Payk - Mon Oct 30, 2006 10:28 am
^^Yep...exactly
in a blended image, dark parts are much more transparancy then white or something...
Also if u get a blended pic in front of a black bg, it has no effect...but when you got white as bg it mixes up.
i am just thinking about to make a loading routine for textures...u can give it 2 bmps (a texture and a alphamap) and it convertes it to that format with 32 colors and some alphabits... will post that here when finished