Page 1 of 1

Alpha Transparancy in textures

Posted: Sun Jul 11, 2004 9:23 am
by Rocketeer
Okay, I think I've found a bug with the EMT_TRANSPARENT_ALPHA_CHANNEL material...

I can't seem to find any info on this in the forums, except a couple of old posts that say it's not implemented yet. I assume that in the latest version it is now implemented, as on my system, it works just fine - almost.

The problem I have is that I can use this material, but I have to use it for *everything* or nothing. If I just set it for, say, one object, none of the others appear. I think I've tracked it down to the following line (952) in CVideoDirectX8.cpp

Code: Select all

pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
None of the other material type turn this off, so once it's set, it stays set. If someone could point me to a quick tutorial on how to re-compile Irrlicht, I'll see if turning it off elsewhere will do the trick. (Sorry, I know I should search, but I'm really tired!)

---
Another note... It only seems to be implemented in DirectX8 (can't test 9 a.t.m.) - OpenGL just does the ADD_COLOR version (and runs at 2fps on my current system!)
---
Edit: I've got so far in making the change... just can't compile without DX9... Off I go to find the sdk...

Posted: Sun Jul 11, 2004 12:05 pm
by Rocketeer
Okay, I've made the change, and the materials are now working as expected.

The change I made was around line 864 in CVideoDirectX8.cpp (I guess there would be a similar change to make for DX9)

Code: Select all

void CVideoDirectX8::setRenderStates3DMode()
{
...
...
...
	if (ResetRenderStates || LastMaterial.MaterialType != Material.MaterialType)
	{
		pID3DDevice->SetRenderState(D3DRS_ALPHATESTENABLE, FALSE); // * NEW *
		switch(Material.MaterialType)
This turns off Alpha testing for everything by default, so that it is only turned on when requried.

This is only a quick fix - I suspect there may be performance problems with doing it this way...

I'll post screen-shots and sample code - if anyone is interested?

Posted: Sun Jul 11, 2004 6:56 pm
by thesmileman
I think several people are interested in this I know I have seen a few post on the issue.

Posted: Sun Jul 11, 2004 11:21 pm
by Rocketeer
Okay, I'll have to post tomorrow night - I have work during the day, and don't have C++ there. I'll try and break it down into the most basic cases - two objects, one with Alpha transparancy, one with ADD_COLOR transparancy. I can't just post the code I found the bug with, as it's a little convoluted, and mixed in with a lot of other work I'm doing.

Also, how do I get Visual Studio to compile the dll "efficiently"? It's created a 2.4MB file for my new version, whereas the original is less than 900KB.

Incidently, should lighting work with alpha transparancy textures? It doesn't seem to - i.e. setting the flag on the material doesn't make any difference - but I don't know if that's DirectX or Irrlicht.

Here's a quick snap of what I'm doing, with both the original and the new dlls in place

With the original DLL
Image

With my new DLL
Image

Posted: Mon Jul 12, 2004 7:52 am
by bal
Do not Build it but Release it :wink:

Posted: Mon Jul 12, 2004 7:55 am
by bal
You got to Release it, not Build it :wink:

Posted: Tue Jul 13, 2004 7:59 am
by lantis
Tnx Rocketeer for fix ;-) now we can use transparent models ;)

>Also, how do I get Visual Studio to compile the dll "efficiently"? It's created
>a 2.4MB file for my new version, whereas the original is less than 900KB.
Make Realese version , not debug ;)

Posted: Tue Jul 13, 2004 8:15 am
by lantis
Any idea how to fix bug with ADD_COLOR/VERTEX_ALPHA ?
Model with ADD_COLOR stand always behind of model with ALPHA_CHANNEL?