Vampire
Squire
15 Posts |
Posted - Jul 26 2005 : 07:02:04 AM
|
Does anyone know, how to use alpha maps in DX7? I'd like a surface to look in some parts more transparent than in others. |
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Jul 27 2005 : 10:30:20 AM
|
It's not easy. I was never able to figure out how to load any files with alpha maps, such as TGA, PNG, or DDS. However, I was able to get some basic alpha map support by storing alpha informaiton in a secondary file and then modifying the pixels with the appropriate alpha value.
Overall I used two files. The main image was either gif, jpg, or bmp. As for the alpha map, I simply used a second file that had a single byte for each pixel in the original image, and I use .alpha as the file extension. For example, for "tile.jpg", the alpha file would have been "tile.jpg.alpha". The texture load function that I used looked for the alpha file automatically and if it existed then it would use it.
As for using the file, I created a DD surface(texture) from the bmp file (gif and jpg converted to bmp). I then locked the surface and read each pixel, combined the alpha value with the color, and then wrote the pixel value back to the surface. This method could have been faster if I would have used the getlockedarray function instead of accessing each pixel individually.
One problem that I encountered with nVidia GeForce 2 cards was that the color returned from GetPixel was always black. I was never able to figure out how to solve the problem.
I'll look around to see if I can find the code.
|
|
|
Vampire
Squire
15 Posts |
Posted - Jul 29 2005 : 12:04:41 AM
|
Thanks for the info. I've found an example at Lucky's site: http://www.rookscape.com/vbgaming/tutBV.php I'll try it out... But it would be great if you could give me an other example... Thanks again... |
|
|
Vampire
Squire
15 Posts |
Posted - Jul 29 2005 : 01:24:31 AM
|
Well, I looked at it and... it seemed too complicated. I mean there are two steps. One uses DX7 and the other DX8. The first step saves the two (RGB & alpha) images into one and then the second step loads and uses it. I'd like to do it directly... Eric Coleman, can you send me the code you tried? I'd like to stick to one DX. And that is v7. |
|
|
Eric Coleman
Gladiator
USA
811 Posts |
Posted - Aug 04 2005 : 6:14:32 PM
|
The first zip file has code that loads .bmp textures with an alpha file. The second zip file has code to generate the alpha file from gray scale images.
Download Attachment: Test.zip 73.8 KB
Download Attachment: alphamapper.zip 97.98 KB |
|
|
Vampire
Squire
15 Posts |
Posted - Aug 09 2005 : 03:50:56 AM
|
Thanks a lot. I'll give it a try. Ca'nt wait see working... Although I decided to switch to DirectX 8. It has lots of new stuff. I think it is more suitable for what I have in mind. |
Edited by - Vampire on Aug 09 2005 03:54:12 AM |
|
|