more openGL bugs

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

more openGL bugs

Post by afecelis »

hey guys!

just noticed that some particles in opengl don't render properly. You can see the bounding square of the billboard:
Image

whereas with DX9 particles look superb!
Image

and another bug I found was when rendering to full screen. when It sometimes doesn't take the full screen but becomes cornered, like this:
Image

finally: sometimes when rendering the techdemo in opengl fullscreen, after going up the corner of the castle the irrlicht logo becomes a white rectangle
Image

how Ironic. The eternal discussion among DX and Ogl, we fix a bug in DX and 3 appear in opengl or viceversa!!1


we need a patch!!!!
Image
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

Thanks for the report, could You post a small test program where these errors are visible? If You are using IrrNX did You check out the latest version from cvs?

The fullscreen mode where only the upper-left corner is used might occure if You're switching to a resolution Your OpenGL driver is not supporting.

If You're using an unpatched irrlicht v0.7 and are using my changes for the materialrenderers here's a patch for CVideoOpenGL.cpp

Patch for 2D Image problem:
search in all methods draw2DImage where the 2D render states are set. Then cut the line with setTexture( ...... ); and past it after the block where the renderstate is set

Example:

the original function look like this

Code: Select all

void CVideoOpenGL::draw2DImage(video::ITexture* texture, const core::position2d<s32>& pos,  const core::rect<s32>& sourceRect,  const core::rect<s32>* clipRect, SColor color,  bool useAlphaChannelOfTexture)
{
....
// ok, we've clipped everything.
	// now draw it.

	setTexture(0, texture);	
	glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());

	if (useAlphaChannelOfTexture)
		setRenderStates2DMode(false, true, true);
	else
		setRenderStates2DMode(false, true, false);

	core::rect<s32> poss(targetPos, sourceSize);

...
}
change it to look like this:

Code: Select all

void CVideoOpenGL::draw2DImage(video::ITexture* texture, const core::position2d<s32>& pos,  const core::rect<s32>& sourceRect,  const core::rect<s32>* clipRect, SColor color,  bool useAlphaChannelOfTexture)
{
....
// ok, we've clipped everything.
	// now draw it.

	if (useAlphaChannelOfTexture)
		setRenderStates2DMode(false, true, true);
	else
		setRenderStates2DMode(false, true, false);

setTexture(0, texture);	
	glColor4ub(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());


	core::rect<s32> poss(targetPos, sourceSize);

...
}

Patch for Shadows (only minor changes,I don't remember exactly what changed, sorry)

Code: Select all


//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: Frist, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
void CVideoOpenGL::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail)
{
	if (!StencilBuffer || !count)
		return;

	// unset last 3d material
	if (CurrentRenderMode == ERM_3D &&
		LastMaterial.MaterialType >= 0 && LastMaterial.MaterialType < (s32)MaterialRenderers.size())
	{
		MaterialRenderers[LastMaterial.MaterialType]->OnUnsetMaterial();
		ResetRenderStates = true;
	}

	// store current OpenGL	state
	glPushAttrib(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT |
		GL_POLYGON_BIT	| GL_STENCIL_BUFFER_BIT	);

	glDisable(GL_LIGHTING);
	glDisable(GL_FOG);
	glDepthMask(GL_FALSE);
	glDepthFunc(GL_LEQUAL);
	glEnable(GL_STENCIL_TEST);
	glColorMask(GL_FALSE, GL_FALSE,	GL_FALSE, GL_FALSE ); // no color buffer drawing
	glStencilFunc(GL_ALWAYS, 1,	0xFFFFFFFFL	);
	glEnable(GL_CULL_FACE);

	if (!zfail)
	{
		// ZPASS Method

		glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
		glCullFace(GL_BACK);
		glBegin(GL_TRIANGLES);

		s32 i;
		for(i =	0; i < count; ++i)
			glVertex3f(triangles[i].X, triangles[i].Y, triangles[i].Z);

		glEnd();

		glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
		glCullFace(GL_FRONT);

		glBegin(GL_TRIANGLES);
		for(i =	0; i < count; ++i)
			glVertex3f(triangles[i].X, triangles[i].Y, triangles[i].Z);

		glEnd();

	}
	else
	{
		// ZFAIL Method

		glStencilOp(GL_KEEP, GL_INCR, GL_KEEP);
		glCullFace(GL_FRONT);

		glBegin(GL_TRIANGLES);

		s32 i;
		for(i =	0; i < count; i++)
			glVertex3f(triangles[i].X, triangles[i].Y, triangles[i].Z);

		glEnd();

		glStencilOp(GL_KEEP, GL_DECR, GL_KEEP);
		glCullFace(GL_BACK);

		glBegin(GL_TRIANGLES);

		for(i =	0; i < count; i++)
			glVertex3f(triangles[i].X, triangles[i].Y, triangles[i].Z);

		glEnd();

	}

	glPopAttrib();
}



//! Fills the stencil shadow with color. After the shadow volume has been drawn
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this
//! to draw the color of the shadow. 
void CVideoOpenGL::drawStencilShadow(bool clearStencilBuffer, video::SColor leftUpEdge,
			video::SColor rightUpEdge, video::SColor leftDownEdge, video::SColor rightDownEdge)
{
	if (!StencilBuffer)
		return;

	glPushAttrib( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_ENABLE_BIT | GL_POLYGON_BIT | GL_STENCIL_BUFFER_BIT );


	glDisable( GL_LIGHTING );
	glDepthMask(GL_FALSE); 
	glDepthFunc( GL_LEQUAL );
	glEnable( GL_STENCIL_TEST );

	glFrontFace( GL_CCW );
	glColorMask( GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE );

	glEnable(GL_BLEND);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	glStencilFunc(GL_NOTEQUAL, 0, 0xFFFFFFFFL);
	glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

	glDisable(GL_FOG);

	glPushMatrix();
	glLoadIdentity();

	glBegin(GL_TRIANGLE_STRIP);

	glColor4ub (leftUpEdge.getRed(), leftUpEdge.getGreen(), leftUpEdge.getBlue(), leftUpEdge.getAlpha() );
	glVertex3f(-10.1f, 10.1f,0.90f);

	glColor4ub (leftDownEdge.getRed(), leftDownEdge.getGreen(), leftDownEdge.getBlue(), leftDownEdge.getAlpha() );
	glVertex3f(-10.1f,-10.1f,0.90f);

	glColor4ub (rightUpEdge.getRed(), rightUpEdge.getGreen(), rightUpEdge.getBlue(), rightUpEdge.getAlpha() );
	glVertex3f( 10.1f, 10.1f,0.90f);

	glColor4ub (rightDownEdge.getRed(), rightDownEdge.getGreen(), rightDownEdge.getBlue(), rightDownEdge.getAlpha() );
	glVertex3f( 10.1f,-10.1f,0.90f);

	glEnd();

	glPopMatrix();
	glPopAttrib();

	if (clearStencilBuffer)
		glClear(GL_STENCIL_BUFFER_BIT);

	glDepthMask(GL_TRUE); 
	glEnable(GL_DEPTH_TEST); 

}

Thanks again for the report.
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

Ok, this was a tough one because the error did not occure with my test app.

If You have a node with material type SOLID in Your scene every thing should render just fine.
But If You only have particle systems and nodes with REFLECTION or 2 LAYER the basic renderstates some how didn't get updated correctly.

now for the patch. In COpenGLMaterialRenderer.h
cut

Code: Select all

services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
paste

Code: Select all

services->setBasicRenderStates(material, lastMaterial, true);
I did this with all transparent materials. Seems to work.
Tests please :wink:
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

thnx Zola!!!

I'm using a patched version of 0.7 that includes your openGl fixes, and Jox's DX mipmap fixes. Sorry for not answering before but I jut woke up!!!! :D

I'll try your mods and try to upload a test app where you get the errors, but I'll report after work (perhaps at noon, if I come home to have lunch).

thnx for the attention!!!
Image
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

Hi Zola, great newss!!!!

Particles problem was solved:
Image

as well as fullscreen problem and Irrlicht logo displaying properly:
Image

shadows r displaying nicely:
Image

but I think I retook an unpatched file for the 2 layer blending:
Image
the rocls should be blended.

so I'm uploading the files in case anybody wants them, and for you to check them to see if I placed everything where it's supposed to!!!

:D

and also to see if you can help me out with the 2 layer blending stuff, otherwise I'll have to use the NX version and damage the other pacth we got working!!!
http://www.danielpatton.com/afecelis/Zo ... Renderer.h
http://www.danielpatton.com/afecelis/Zo ... OpenGL.cpp

thnx for all your interest and help!
Image
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

ps. I got a question, Why is Irrlicht's Opengl renderer version 1.2 when the current version is 1.5? commercial issues?
Image
Electron
Posts: 874
Joined: Sun Mar 14, 2004 12:05 am
Location: Massachusetts USA

Post by Electron »

As far as I know, the msot recent OGL headers for windows are 1.1 :cry: I'm hoping that with the new OGL 2.0 coming out they'll get an update
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.

Crucible of Stars
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

@afecelis
Cool screenshots!

Seems You're not using my COpenGLMaterialRenderer.h file but it works never the less! cool seems I've been a bit too cautious with reseting the renderstates ;)

Ok, what are we talking about? The reflection of the water in the pool?
That is the transparent_reflection_2_layer?

heres my implementation

Code: Select all

//! reflection 2 layer material renderer
class COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER : public COpenGLMaterialRenderer
{
public:

	COpenGLMaterialRenderer_TRANSPARENT_REFLECTION_2_LAYER(video::CVideoOpenGL* d)
		: COpenGLMaterialRenderer(d) {}

	virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
		bool resetAllRenderstates, IMaterialRendererServices* services) 
	{
		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
		{
			if (Driver->hasMultiTextureExtension())
			{
				Driver->setTexture(0,material.Texture2);
				glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
				glEnable(GL_BLEND);
				glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);

				Driver->setTexture(1,material.Texture1);
				glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
				glEnable(GL_BLEND);
				glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);

				glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
				glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

				glEnable(GL_TEXTURE_GEN_S);
				glEnable(GL_TEXTURE_GEN_T);
			}
			else
			{
				glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);

				glEnable(GL_BLEND);
				glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_COLOR);

				glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
				glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);

				glEnable(GL_TEXTURE_GEN_S);
				glEnable(GL_TEXTURE_GEN_T);	
			}
			
					
		}

		material.ZWriteEnable = false;
		services->setBasicRenderStates(material, lastMaterial, true);
	}

	virtual void OnUnsetMaterial()
	{
		if (Driver->hasMultiTextureExtension())
		{
			Driver->extGlActiveTextureARB(GL_TEXTURE0_ARB);
			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); // default value!
			glDisable(GL_BLEND);
			glDisable(GL_TEXTURE_GEN_S);
			glDisable(GL_TEXTURE_GEN_T);
			glDisable(GL_TEXTURE_2D);

			Driver->extGlActiveTextureARB(GL_TEXTURE1_ARB);
			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
			glDisable(GL_BLEND);
			glDisable(GL_TEXTURE_GEN_S);
			glDisable(GL_TEXTURE_GEN_T);
			glDisable(GL_TEXTURE_2D);

		}
		else
		{
			glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
			glDisable(GL_BLEND);
			glDisable(GL_TEXTURE_GEN_S);
			glDisable(GL_TEXTURE_GEN_T);
		}	
	}

	//! Returns if the material is transparent. 
	virtual bool isTransparent() 
	{
		return true; 
	}
};
but I'm not sure if this is compatible with Your other renderers :)
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

afecelis wrote:ps. I got a question, Why is Irrlicht's Opengl renderer version 1.2 when the current version is 1.5? commercial issues?
I think this all depends on the version of the glext.h file. irrlicht is suppost to use feature of version 1.2 but Your driver might actually support OGL 1.5.
You could print out the version of Your driver take a look at CVideoOpenGL::loadExtensions() for that.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

Many thnx Zola! That's old work but I retook it with Irr07 and making it evolve!!

Most of the things were fixed. I used your Copenglmaterialrenderer.h with the transparent material correction and the 2 layer material water is displaying nicely as well as the particles! however..... where I was getting this:
Image
with the previous dll (the one that displayed the bounding boxes of the sprites)

now I'm getting this:
Image

nothing shows up when I use the newer dll (the one that show particles and 2 layer blended materials ok). weird, huh?

I uploaded 2 test apps for you to try. In the first one I show the error that used to happen with the particles. This is the old dll; save it in a folder called "old_dll" or something for testing purposes.
http://www.danielpatton.com/afecelis/Zola/Particles.zip

the second app is the particle editor; save this dll also in a separate folder, call the folder "new_dll", also for testing purposes.

now, if you place old dll in the particle edito app, it will work properly. as well as if you place the particle's ed dll into the particles app. and viceversa.

so there's still something missing. Right now we got 2 layer materials and particles transparency working fine. It should display properly in the particle editor window as well. Dunno.

I'm uploading the latest copenglmaterialrenderer.h here:
http://www.danielpatton.com/afecelis/Zo ... Renderer.h

Please check it when u have a chance.

ps. U should also help Jox and i track the mipmapping bug in DX down!!!


:D

http://www.danielpatton.com/afecelis/sc ... rror01.jpg

check the jaggie shadows in the upper corner!!

cheers! and thnx!!
Image
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

Hm, I can't reproduce Your error

Image

here my OpenGL Files

COpenGLMaterialRenderer.h
CVideoOpenGL.h
CVideoOpenGL.cpp

You might need to make a diff from myfiles to the original irrlicht implementations to find the changes.

BTW: Do You mind if I actually use Your ParticleEditor? I think this is an excellent tool :)
and here are some additions I'd like to see in version 2:
- select different emitter
- add more than one affector to the particles
- try to include the particle changes we included in the CVS

just kidding
:lol:

Cheers
Tom
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

sorry guys, I forgot to post the link to the particle editor.

And Zola, it's not my work!!! lol!!! I wish!!!!

It's Lantis' work. All the credits go to him. I just modified it a bit to make it more simple so that I could understand it (remember I'm no programmer). So I decided to make it a standard tool aprt of my Irrlcith version.

here's the link:
http://www.danielpatton.com/afecelis/Zo ... icleEd.zip

I'm going to try your files, Zola. Thnx for all the help.

ps. Any clues on the DX mipmapping bug?

cheers!!

btw. Today's Valentine's day in Colombia so happy Valentine's day to you all!!!

:D :D :D :D :D :D :D :D :D

ps. Zola: but if you get to modify anything or make it cooler please post your new version, as Lantis did!!!

ps1: Zola you used my dlls or yours?
Image
zola
Posts: 52
Joined: Thu Jul 15, 2004 2:31 pm
Location: switzerland
Contact:

Post by zola »

I recompiled with my Irrlicht version. I tried both Your dlls and none worked.
*shrug*

If You try my files make shure to backup Yours 'cause mine are from CVS version which has some additional drawing methods. Anyway they should compile with the normal irrlicht sources.
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

thnx for the files Zola. I tried them but unfortunately my dll didn't compile.

here's the build log (in case you may help me)

http://www.danielpatton.com/afecelis/Zola/BuildLog.htm

perhaps too much NX in them? :wink:

cheers!
Image
afecelis
Admin
Posts: 3075
Joined: Sun Feb 22, 2004 10:44 pm
Location: Colombia
Contact:

Post by afecelis »

ok guys, good and bad news:

The good news is that I fixed the OpenGl bugs. How? I downloaded IrrlichtNX, lol!!! It was my only chance of having a patched version since trying to fix the DX mipmapping problem with Jox plus the GL problems with Zola left me with a very weird version. At the end nothing was working properly.

The bad news is that since my Opengl issues are solved and since I'll be using the NX files I won't be able to help track down the traditional Irrlicht 0.7 gl issues.

but I'll keep on posting any new things I find here.

Besides... the DX9 mipmapping bug is also present in NX!!!! :D

cheers! Happy Valentine's day !!!(Colombian Date) :D :D :D :D
Image
Post Reply