[fixed]bugfix EMT_TRANSPARENT_ALPHA_CHANNEL_REF

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.
Post Reply
Viz_Fuerte
Posts: 91
Joined: Sun Oct 19, 2008 5:29 pm
Location: Valencia (Spain)
Contact:

[fixed]bugfix EMT_TRANSPARENT_ALPHA_CHANNEL_REF

Post by Viz_Fuerte »

I think it was not fixed in this version.

The error was that any mesh with "EMT_TRANSPARENT_ALPHA_CHANNEL_REF"
did not affect the light and is always lit.

ONLY FOR OPENGL.

Solution:
COpenGLMaterialRenderer.h

Code: Select all

//! Transparent alpha channel material renderer
class COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF : public COpenGLMaterialRenderer
{
public:

	COpenGLMaterialRenderer_TRANSPARENT_ALPHA_CHANNEL_REF(video::COpenGLDriver* d)
		: COpenGLMaterialRenderer(d) {}

	virtual void OnSetMaterial(const SMaterial& material, const SMaterial& lastMaterial,
		bool resetAllRenderstates, IMaterialRendererServices* services)
	{
		Driver->disableTextures(1);
		Driver->setTexture(0, material.getTexture(0));
		Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);

		if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
		{
			glEnable(GL_ALPHA_TEST);
			glAlphaFunc(GL_GREATER, 0.5f);
			REMOVE -> glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
			ADD -> glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_EXT);
		}
	}

	virtual void OnUnsetMaterial()
	{
		glDisable(GL_ALPHA_TEST);
	}

	//! Returns if the material is transparent.
	virtual bool isTransparent() const
	{
		return false;  // this material is not really transparent because it does no blending.
	}
};
DtD
Posts: 264
Joined: Mon Aug 11, 2008 7:05 am
Location: Kansas
Contact:

Post by DtD »

This should go under "Bug reports" since it is a fix to a bug in Irrlicht.
By "ONLY FOR OPENGL." do you mean the problem was only in OpenGL or that your fix is only OpenGL?

~DtD
Viz_Fuerte
Posts: 91
Joined: Sun Oct 19, 2008 5:29 pm
Location: Valencia (Spain)
Contact:

Post by Viz_Fuerte »

Sorry, I'm not very expert at this in the forums.

Admin please, move this post to Bug Report :oops:

The solution for now only is for "OpenGL."
harkathmaker
Posts: 39
Joined: Wed Jun 10, 2009 11:28 pm
Location: Portland, Oregon
Contact:

Post by harkathmaker »

If Viz and I are having the same problem, it only appears when using OpenGL. Meshes with Material type "EMT_TRANSPARENT_ALPHA_CHANNEL_REF" are not lit (it's as if they have lighting switched off).
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Post by CuteAlien »

Thanks. It is fixed now in svn trunk and will be changed in Irrlicht 1.7.
I used GL_MODULATE instead of GL_COMBINE_EXT as that seemed to be used also for solid materials and the result seemed identical to the D3D results.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Post Reply