Jump to content
  • Advertisement
Sign in to follow this  
ade-the-heat

exposions with particles look bad-FIXED BUT WHY ?!

This topic is 4866 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

Explosion as I require and as occasionally works in my game : http://myweb.tiscali.co.uk/3drocknroll/explodeblur.bmp However, with the same explosion class and the same settings it most often looks like this: http://myweb.tiscali.co.uk/3drocknroll/explospoor.bmp note the black quad around each particle. So what am i doing wrong ? here is the code I use to draw the explosion:
  glDisable(GL_FOG);
  glDisable(GL_DEPTH_TEST);
  glEnable(GL_BLEND);
  glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
 
  glEnable(GL_TEXTURE_2D);
  glBindTexture(GL_TEXTURE_2D, m_texture);
  glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

  glEnable(GL_COLOR_MATERIAL);

  scalar_t size;
  CVector pos;
  CVector temp;

  glBegin(GL_QUADS);
  for (int i = 0; i < m_numParticles; ++i)
  {
    size = (scalar_t)m_particleList.m_size/2;
    pos = m_particleList.m_pos;
    glColor4fv(m_particleList.m_color);

    glTexCoord2f(0.0, 0.0); 
	temp=pos + -size*(right+up);
	glVertex3f(temp.x,temp.y, temp.z);

    glTexCoord2f(1.0, 0.0); 
	temp=pos+size*(right - up);
	glVertex3f(temp.x, temp.y, temp.z);

    glTexCoord2f(1.0, 1.0);
	temp=pos+size*(right + up);
	glVertex3f(temp.x, temp.y, temp.z);

    glTexCoord2f(0.0, 1.0); 
	temp=pos+size*(up - right);
	glVertex3f(temp.x, temp.y, temp.z);
  }
  glEnd();

  glDisable(GL_TEXTURE_2D);
  glDisable(GL_BLEND);
  glEnable(GL_DEPTH_TEST);
  glEnable(GL_FOG);


[Edited by - ade-the-heat on July 22, 2005 7:57:56 AM]

Share this post


Link to post
Share on other sites
Advertisement
I don't think you need that glEnable(GL_COLOR_MATERIAL) there.

It looks like an improper glBlendFunc state - but that's weird because you seem to be setting the correct blend func before you render your particles.

explicitly disable lighting and color materials, see if that helps you.

EDIT:
embedded in html tags for clicking fun :)
correct particle rendering: clicky

incorrect particle rendering: clicky

Share this post


Link to post
Share on other sites
hmmm made no difference.

However, I notice the following: the quads surrounding each particle only appear when the background is the skybox. eg when the background to the particle is a wall or the terrain then it's fine.

So I guess this means the skybox is done wrong in some way.

skybox code:


glShadeModel(GL_SMOOTH);//smooth
glDisable(GL_BLEND); //am disable
glEnable(GL_TEXTURE_2D);


glDepthMask(GL_FALSE); //don't write to depth buffer
glDisable(GL_LIGHTING); //so join between box isn't seen

glBindTexture(GL_TEXTURE_2D, m_toptexture);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE); glBegin(GL_QUADS);
// Assign the texture coordinates and vertices for the
glTexCoord2f(0.0f, 1.0f); glVertex3f(maxx, maxy, maxz);
glTexCoord2f(0.0f, 0.0f); glVertex3f(minx, maxy, maxz);
glTexCoord2f(1.0f, 0.0f); glVertex3f(minx, maxy, minz);
glTexCoord2f(1.0f, 1.0f); glVertex3f(maxx, maxy, minz);
glEnd();

//back
glBindTexture(GL_TEXTURE_2D, m_backtexture);
glBegin(GL_QUADS);
// Assign the texture coordinates and vertices for the
glTexCoord2f(0.0f, 0.0f); glVertex3f(minx, miny, maxz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(minx, maxy, maxz);
glTexCoord2f(1.0f, 1.0f); glVertex3f(maxx, maxy, maxz);
glTexCoord2f(1.0f, 0.0f); glVertex3f(maxx, miny, maxz);
glEnd();

//front
glBindTexture(GL_TEXTURE_2D, m_fronttexture);
glBegin(GL_QUADS);
// Assign the texture coordinates and vertices for the
glTexCoord2f(0.0f, 0.0f); glVertex3f(minx, miny, minz);
glTexCoord2f(1.0f, 0.0f); glVertex3f(maxx, miny, minz);
glTexCoord2f(1.0f, 1.0f); glVertex3f(maxx, maxy, minz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(minx, maxy, minz);

glEnd();

//LEFT
glBindTexture(GL_TEXTURE_2D, m_lefttexture);
glBegin(GL_QUADS);
// Assign the texture coordinates and vertices for the
glTexCoord2f(0.0f, 0.0f); glVertex3f(minx, miny, maxz);
glTexCoord2f(1.0f, 0.0f); glVertex3f(minx, miny, minz);
glTexCoord2f(1.0f, 1.0f); glVertex3f(minx, maxy, minz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(minx, maxy, maxz);
glEnd();

//right

glBindTexture(GL_TEXTURE_2D, m_righttexture);
glBegin(GL_QUADS);
// Assign the texture coordinates and vertices for the
glTexCoord2f(0.0f, 0.0f); glVertex3f(maxx, miny, minz);
glTexCoord2f(1.0f, 0.0f); glVertex3f(maxx, miny, maxz);
glTexCoord2f(1.0f, 1.0f); glVertex3f(maxx, maxy, maxz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(maxx, maxy, minz);

glEnd();


//bottom

glBindTexture(GL_TEXTURE_2D, m_bottomtexture);
glBegin(GL_QUADS);
// Assign the texture coordinates and vertices for the
glTexCoord2f(1.0f, 0.0f); glVertex3f(minx, miny, maxz);
glTexCoord2f(1.0f, 1.0f); glVertex3f(maxx, miny, maxz);
glTexCoord2f(0.0f, 1.0f); glVertex3f(maxx, miny, minz);
glTexCoord2f(0.0f, 0.0f); glVertex3f(minx, miny, minz);
glEnd();


glEnable(GL_LIGHTING); //so join between box isn't seen
glDepthMask(GL_TRUE); //write to depth buffer




Share this post


Link to post
Share on other sites
I do disable depth writes for the particles (see code)
The sky box is drawn before anything else, then I draw the terrain, then later on I draw explosions.

Share this post


Link to post
Share on other sites
Shouldn't it be:
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

instead of:
glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);


With the latter, it's a strong suggestion that your skybox somehow has alpha == 0. Don't know how you could do that unintentionaly, though... :/

Share this post


Link to post
Share on other sites
With that blendfunc, if the skybox had an alpha of 0, it'd mean that the skybox would make no contribution to the final fragment color. But it looks like (and it's hard to tell from such a small screenshot) there's blending between the skybox and particle texture.

If the skybox alpha is something between 0 and 1 (exclusive) though, that could explain it.

Share this post


Link to post
Share on other sites
I tried the replacement value GL_ONE_MINUS_SRC_ALPHA and it was worse !!
In addition the skybox has no alpha channel - it is a simple bitmap.

Just in case I've done it all wrong - the particle bitmap is loaded without an alpha channel as well -eg the black parts to the bitmap aren't set to see through.

NOW! - I just changed the particle bitmap to have an alpha channel - it made no difference - the same as before.

Share this post


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

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!