Sign in to follow this  

problem with groundfog

This topic is 4184 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i had already started a thread but since my problem still is the same i'm trying again. first here is the link to the old thread: http://www.gamedev.net/community/forums/topic.asp?topic_id=373566 is still have the same problem of my fog moving back and front in the scene according to the camera position. to the old thread i wanted to add that i am using quads in this approach. and for further better understanding here a little more of my source code:

      glDepthMask(GL_TRUE);
	glEnable(GL_BLEND);
	glDisable(GL_DEPTH_TEST);
	glDisable(GL_LIGHTING);
	glBlendFunc(GL_SRC_ALPHA,GL_ONE);		
	glDisable(GL_TEXTURE_2D);

	norm2[0] = norm3[0] = start.x;
	norm1[1] = norm3[1] = start.y;
	norm1[2] = norm2[2] = start.z;
	norm1[0] = height;
	norm2[1] = width;
	norm3[2] = depth;

	for(int i=0; i<numquad; i++){
		if(i<numquad-numquad/16) i++;
		if(i<numquad/8) i++;
		if (i<numquad/4) i++;
		w = i*depth/numquad/2;
		h = i*height/numquad/2;
		d = i*width/numquad/2;

		sx = start.x+2*w;
		sy = start.y+2*h;
		sz = start.z+1.5f*d;

		sxw = start.x+depth-2*w;
		syh = start.y+height-2*h;
		szd = start.z+width-1.5f*d;

		glBegin(GL_QUADS);
			setColor(sx, sy, sz, width, depth, numquad+i, start);
			glNormal3fv(Cross(norm1, norm2));
			glVertex3f(sx, sy, sz);			//front
			setColor(sxw, sy, sz, width, depth, numquad+i, start);
			glNormal3fv(Cross(norm1, norm2));
			glVertex3f(sxw, sy, sz);
			setColor(sxw, syh, sz, width, depth, numquad+i, start);
			glNormal3fv(Cross(norm1, norm2));
			glVertex3f(sxw, syh, sz);
			setColor(sx, syh, sz, width, depth, numquad+i, start);
			glNormal3fv(Cross(norm1, norm2));
			glVertex3f(sx, syh, sz);

....

		glEnd();
	}
	glEnable(GL_TEXTURE_2D);
	glDisable(GL_BLEND);
	glEnable(GL_DEPTH_TEST);



Share this post


Link to post
Share on other sites
To me it sounds like you are messing around with the modelview matrix between you render your "fog" and the rest of the scene.. that or you are messing around with your start, width, height or depth variables.
Can't say more without source.

Good luck!

Share this post


Link to post
Share on other sites
well here is a little more of my source code
first the initialisation

glEnable(GL_TEXTURE_2D);
glBlendFunc(GL_SRC_ALPHA,GL_ONE);
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClearDepth(1.0);
glDepthFunc(GL_LEQUAL);
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);




then here i set start and draw my scene then i add my fog

vertex start;
start.x = 2.25f;
start.y = -0.25f;
start.z = 2.5f;

glRotatef(lookupdown,1.0f,0,0);
glRotatef(sceneroty,0,1.0f,0);

glTranslatef(xtrans, ytrans, ztrans);

addFog(start, -5.0f, -4.5f, 0.4f, 70);




and the addFogg function called with
addFog(vertex start, GLfloat width, GLfloat depth, GLfloat height, GLint numquad)

is already in the first post (except for some definitions)

that's really all to it and i can't find any mistake

Share this post


Link to post
Share on other sites
Hello ,
try to send fog information b4 doing camera translating/rotating
like this :

vertex start;
start.x = 2.25f;
start.y = -0.25f;
start.z = 2.5f;
addFog(start, -5.0f, -4.5f, 0.4f, 70);
glRotatef(lookupdown,1.0f,0,0);
glRotatef(sceneroty,0,1.0f,0);

glTranslatef(xtrans, ytrans, ztrans);




cya,

Share this post


Link to post
Share on other sites
according to some blending tutorials it should be enough just to set the depthmask to false but then i can't see my fog at all.

why is that so
i've seen example with standard depthtesting (without depthmask) and enabled blending.

[Edited by - snapdrag on August 4, 2006 10:44:39 AM]

Share this post


Link to post
Share on other sites

is there anything i am doing wrong with the depthtesting?

with disabled depthtesting it looks like that:

the image clearly moves along with the camera although everything has fixed coordinates in that example

Share this post


Link to post
Share on other sites
Sign in to follow this