Alpha Transparancy in textures

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
Rocketeer
Posts: 9
Joined: Sun Jul 11, 2004 9:13 am
Contact:

Alpha Transparancy in textures

Post 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...
Rocketeer
Posts: 9
Joined: Sun Jul 11, 2004 9:13 am
Contact:

Post 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?
thesmileman
Posts: 360
Joined: Tue Feb 10, 2004 2:20 am
Location: Lubbock, TX

Post by thesmileman »

I think several people are interested in this I know I have seen a few post on the issue.
Rocketeer
Posts: 9
Joined: Sun Jul 11, 2004 9:13 am
Contact:

Post 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
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

Do not Build it but Release it :wink:
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
bal
Posts: 829
Joined: Fri Jun 18, 2004 5:19 pm
Location: Geluwe, Belgium

Post by bal »

You got to Release it, not Build it :wink:
General Tools List
General FAQ
System: AMD Barton 2600+, 512MB, 9600XT 256MB, WinXP + FC3
lantis
Posts: 64
Joined: Thu Jun 17, 2004 2:46 pm

Post 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 ;)
lantis
Posts: 64
Joined: Thu Jun 17, 2004 2:46 pm

Post 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?
Post Reply