ahh! help!
Hi guys..
I am working on a FPS type engine which is pretty good so far and could already be used for a game but I am working on lightmaps without multi-texturing, I am trying to keep the engine simple for other beginning programmers. So to do lightmapping, I create the lightmap texture and use it as a regular texture and blend it onto an already-drawn polygon..
i am basically trying to draw a polygon at the same location as an already drawn polygon and I have my blending all set correctly but when it''s drawn, it clashes rather than blends, with the textured polygon that is already there..
I get very bad shimmering effect on the walls when I walk around. It''s horrible.
That''s when I offset (translate) the lightmap drawing a bit from the actual map (because I wanted to see if it was even drawing) but when it''s not translated from where it''s supposed to be, I don''t even see it..
Someone please help! When I turn all the blending stuff on and stuff it draws the lightmap correctly but it shimmers with the wall rather than blends with it.
-Chazz
September 14, 2000 09:40 PM
I think your problem is that you have to call glDepthMask() function with the parameter GL_FALSE before doing blending on the object then after you are done with the drawing of the object just call glDepthMask() again but with the parameter GL_TRUE to set it back. What this function is doing is making the depth buffer read-only when you pass GL_FALSE.
what blend mode are you useing?
-------------------------------------------------
Don't take life too seriously, you'll never get out of it alive. -Bugs Bunny
Edited by - Authustian on September 14, 2000 11:09:56 PM
-------------------------------------------------Don't take life too seriously, you''ll never get out of it alive. -Bugs Bunny
Wow, I wish I read ahead in the tuts. Let''s see if I can guess at the problem (I''m almost to lightmaps, anywho)...
My guess is that the lightmap is not being blended enough, i mean, you could try to lower the alpha in it so it doesn''t appear as much...
If that isn''t the effect you want, maybe it''s that your lightmap is the same picture as the wall texture and that, when offset because of the camera angle and perspective and whatever else, you get a doubling of pixels with it alternating. You need to place these pixels right on top of each other in order to get rid of the shimmering.
Maybe you should make your wall fade a bit so that you don''t have full strength wall with a, say, half blended lightmap. Make it more like 75% wall and half lightmap or something.
In case you didn''t catch it the first time, I don''t really know how lightmaps work, or even (admittedly) what they are. I''m just throwing out possible solutions that might help you think of an idea.
S.
My guess is that the lightmap is not being blended enough, i mean, you could try to lower the alpha in it so it doesn''t appear as much...
If that isn''t the effect you want, maybe it''s that your lightmap is the same picture as the wall texture and that, when offset because of the camera angle and perspective and whatever else, you get a doubling of pixels with it alternating. You need to place these pixels right on top of each other in order to get rid of the shimmering.
Maybe you should make your wall fade a bit so that you don''t have full strength wall with a, say, half blended lightmap. Make it more like 75% wall and half lightmap or something.
In case you didn''t catch it the first time, I don''t really know how lightmaps work, or even (admittedly) what they are. I''m just throwing out possible solutions that might help you think of an idea.
S.
k but when I turn off depth buffering i can see through walls.. or at least walls behind walls (because I don''t sort from back to front)..
lemme try this right now..
damn.. the glDepthMask(GL_TRUE/GL_FALSE); thing just makes everything rainbow colors.. I don''t think you guys understand what my problem is.
openGL isn''t accepting the fact that my polygons exist in the same space.. It rejects whatever is trying to be drawn where something is already drawn. I am talking in 3d terms, not pixels but polygons.
I will post a screenshot up..
lemme try this right now..
damn.. the glDepthMask(GL_TRUE/GL_FALSE); thing just makes everything rainbow colors.. I don''t think you guys understand what my problem is.
openGL isn''t accepting the fact that my polygons exist in the same space.. It rejects whatever is trying to be drawn where something is already drawn. I am talking in 3d terms, not pixels but polygons.
I will post a screenshot up..
-Chazz
Wait!
I got it to work! yay. gldepthmask fixed it...
thnx anonymous..
now I gotta convert arrays into textures..
thnx guys.
I got it to work! yay. gldepthmask fixed it...
thnx anonymous..
now I gotta convert arrays into textures..
thnx guys.
-Chazz
dont turn the depth test off this can give nasty probs
use glDepthFunc(GL_LEQUAL);
use glDepthFunc(GL_LEQUAL);
But depthtest works fine now..
Another problem has arised, or atleast I am just now noticing it.
Ok, after I generate my lightmaps, no matter what I do, it always draws the last generated lightmap on all the polygons. I did it in a little lightmap example program and it does it too. I can''t have more than 1 lightmap or something.. here is my lightmap code..
void updatelightmap1 ()
{
int x,y;
byte data[16][16][4];
float brightness;
float distx, disty;
glBindTexture(GL_TEXTURE_2D, Glightmap[1]);
for (x=0 ; x<16 ; x++)
{
for (y=0 ; y<16 ; y++)
{
//-5 = polygon corner, 0.625 = 10 / 16
//& 10 = polygon size
distx = (-5 + 0.625 * x) - lightx;
disty = (-5 + 0.625 * y) - lighty;
if(distx < 0)
distx *= -1;
if(disty < 0)
disty *= -1;
brightness = sqrt(distx * distx + disty * disty) * sustain;
if(brightness > 255)
brightness = 255;
data[y][x][0] = 255;
data[y][x][1] = 255;
data[y][x][2] = 255;
data[y][x][3] = brightness; //Brightness of 0-9 (255 = max)
}
}
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D (GL_TEXTURE_2D, 0, 4, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
but for some STUPID reason it doesn''t use whatever lightmap I glBindTexture();, it just uses the last one created. No matter what.
Another problem has arised, or atleast I am just now noticing it.
Ok, after I generate my lightmaps, no matter what I do, it always draws the last generated lightmap on all the polygons. I did it in a little lightmap example program and it does it too. I can''t have more than 1 lightmap or something.. here is my lightmap code..
void updatelightmap1 ()
{
int x,y;
byte data[16][16][4];
float brightness;
float distx, disty;
glBindTexture(GL_TEXTURE_2D, Glightmap[1]);
for (x=0 ; x<16 ; x++)
{
for (y=0 ; y<16 ; y++)
{
//-5 = polygon corner, 0.625 = 10 / 16
//& 10 = polygon size
distx = (-5 + 0.625 * x) - lightx;
disty = (-5 + 0.625 * y) - lighty;
if(distx < 0)
distx *= -1;
if(disty < 0)
disty *= -1;
brightness = sqrt(distx * distx + disty * disty) * sustain;
if(brightness > 255)
brightness = 255;
data[y][x][0] = 255;
data[y][x][1] = 255;
data[y][x][2] = 255;
data[y][x][3] = brightness; //Brightness of 0-9 (255 = max)
}
}
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexImage2D (GL_TEXTURE_2D, 0, 4, 16, 16, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
}
but for some STUPID reason it doesn''t use whatever lightmap I glBindTexture();, it just uses the last one created. No matter what.
-Chazz
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement