Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
DirectX8 + Alpha Channels
#1
[Image: lolololtu5.png]

Converted Winds Whisper's engine to DirectX8 for a new project I'm working on.

It can handle Alpha Channels!

Here's the .png files which are used as textures.

[Image: test2bd2.png]
[Image: test3bp8.png]

If you save those and load them in photoshop, you'll see that those bits which look transparent really are Big Grin

Only took me a couple of hours for the conversion which I think is pretty good.

I replaced my character with the pole thing, so all I need to do now is make the engine recognise what tiles are saved where and render them appropriately Tongue

EDIT:

Here's a special effect Big Grin
[Image: testig8.png]
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#2
Tutorial!

xD. Looks very nice Robin. *is jealous*
Reply
#3
Congratz.

But, does it really take that long to convert just a few blts here and there to DX8?
Reply
#4
Took Smchronos a long time to make his engine dx8.
Reply
#5
Matt Wrote:Congratz.

But, does it really take that long to convert just a few blts here and there to DX8?

Lol. You really don't understand DirectX do you?

DirectX7 allows you to use DirectDraw, which allows you to just copy any piece of a bmp file to a backbuffer and create an image.

In DirectX8 you no longer have 2D support. Everything needs to be created in a 3D environment and all the sprites and tiles need to be saved in a texture format.

All the ingame graphics need to be created using polygons.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#6
3D is really more complicated than 2D, but the problem that I faced when trying to convert to DX8 was not the 3D, because I had some experience with it, but was the DX8 it self... I wasn't able to know which is the best and easiest way to initialize everything so I didn't even started...
Reply
#7
Well pretty much the big difference between using DX7 and DX8 is in DX8, you use textures, not surfaces. You can use surfaces, but it is ugly and slow and ruins the whole purpose.
Reply
#8
Luckily all my graphics were in the correct texture format ^^

Btw, made it so the engine can recognise the Mirage tile system now.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#9
Robin Wrote:
Matt Wrote:Congratz.

But, does it really take that long to convert just a few blts here and there to DX8?

Lol. You really don't understand DirectX do you?

DirectX7 allows you to use DirectDraw, which allows you to just copy any piece of a bmp file to a backbuffer and create an image.

In DirectX8 you no longer have 2D support. Everything needs to be created in a 3D environment and all the sprites and tiles need to be saved in a texture format.

All the ingame graphics need to be created using polygons.

Ahh. I get it now.

We gotta start off somewhere. Lol. Learning DirectX in all would be nice. xD
Reply
#10
Yeah, I know what you mean.

It was such a big transition between BitBlt and DirectDraw, and an even bigger one between DirectDraw and DirectX8.

My advice to anyone is to use DirectX8. It might look harder, but it's actually a lot easier to manage than DirectDraw.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#11
Smchronos removed HP bars from the Engine because he said DX8 had issues drawing 2D rectangles or something.
Reply
#12
He fails at Dx8 then.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#13
Issues drawing rectangles? Everything is triangle, and a rectangle is just made with two triangles. If he is talking about untextured rectangles, they are just that - untextured. Set the texture to Nothing. Thats all it takes. If you can't get that right but you can convert the rendering to DX8, well thats just some good signs of copy-and-paste action. :wink:
Reply
#14
[Image: screenshotxf8.png]

Image of it using Mirage's tile system.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#15
[Image: dx8.jpg]
Reply
#16
God that's ugly.
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#17
It's just text.
It's because it's skinnable.
Reply
#18
I myself have spent the last week working with DirectX 8 and am almost finished converting my engine.

Since you (Robin and Spodi) have done so already, I have a few questions if you don't mind:

- Why you you have D3DRS_LIGHTING turned on in that screenshot? I was under the impression that is was useless in a simulated 2D world.
- Did you code in any kind of night or lighting system? I am having trouble figuring out the best way to do it. Multi-texturing sounds good, but it forces the lights to line up with and be the size of a tile, does it not? However, when I alphablend light in random places, I have trouble figuring out how to darken the rest of the tiles (darkening the vertex colors doesn't seem to work).
- How do you directly edit the alpha channel of individual pixels in Photoshop? I have looked and searched and googled and I can't figure it out.

Thanks in advance.
Reply
#19
I just finished converting too. I had the same problem xD Night it self is easy, but draw a big box and set the rgba color of all the vertices to 0,0,0,alpha value, and make it like... 170, that's my night. About the lights, I'm not sure...
Reply
#20
Jonny9797 Wrote:I myself have spent the last week working with DirectX 8 and am almost finished converting my engine.

Since you (Robin and Spodi) have done so already, I have a few questions if you don't mind:

- Why you you have D3DRS_LIGHTING turned on in that screenshot? I was under the impression that is was useless in a simulated 2D world.
- Did you code in any kind of night or lighting system? I am having trouble figuring out the best way to do it. Multi-texturing sounds good, but it forces the lights to line up with and be the size of a tile, does it not? However, when I alphablend light in random places, I have trouble figuring out how to darken the rest of the tiles (darkening the vertex colors doesn't seem to work).
- How do you directly edit the alpha channel of individual pixels in Photoshop? I have looked and searched and googled and I can't figure it out.

Thanks in advance.

I have no experience in DX8 at all.

I literally spent 3 hours converting the other day because I wanted to work with those tiles I have, which are full of alpha channels.

I was basically just ripping out parts of the old DX8 engine Kenko and I worked on for NarutoRealm. Luckily I'm a fast learner, and I know how to do things with it now.

Haven't done a lighting system yet, although I probably will do, as I'm currently in talks with Rory to implement a Harvest Moon style farming system.

Here's a screenshot of the opacity tool:
http://img222.imageshack.us/img222/1231/...lolbk7.png
Quote:Robin:
Why aren't maps and shit loaded up in a dynamic array?
Jacob:
the 4 people that know how are lazy
Robin:
Who are those 4 people?
Jacob:
um
you, me, and 2 others?
Reply
#21
Robin Wrote:I have no experience in DX8 at all.

I literally spent 3 hours converting the other day because I wanted to work with those tiles I have, which are full of alpha channels.

I was basically just ripping out parts of the old DX8 engine Kenko and I worked on for NarutoRealm. Luckily I'm a fast learner, and I know how to do things with it now.

Haven't done a lighting system yet, although I probably will do, as I'm currently in talks with Rory to implement a Harvest Moon style farming system.

Ahh, I see. Thanks anyway.

Robin Wrote:Here's a screenshot of the opacity tool:
http://img222.imageshack.us/img222/1231/...lolbk7.png

Thank you. I can't believe I didn't see that.

Dragoons Master Wrote:I just finished converting too. I had the same problem xD Night it self is easy, but draw a big box and set the rgba color of all the vertices to 0,0,0,alpha value, and make it like... 170, that's my night. About the lights, I'm not sure...
Yeah, I have done similar things to produce a nice night effect, but I still can't get lighting to work the way I would like it to. Oh well, back to working on it! Smile
Reply
#22
If you get any advance, let me know plx ^^
Reply
#23
Jonny9797 Wrote:I myself have spent the last week working with DirectX 8 and am almost finished converting my engine.

Since you (Robin and Spodi) have done so already, I have a few questions if you don't mind:

- Why you you have D3DRS_LIGHTING turned on in that screenshot? I was under the impression that is was useless in a simulated 2D world.
- Did you code in any kind of night or lighting system? I am having trouble figuring out the best way to do it. Multi-texturing sounds good, but it forces the lights to line up with and be the size of a tile, does it not? However, when I alphablend light in random places, I have trouble figuring out how to darken the rest of the tiles (darkening the vertex colors doesn't seem to work).
- How do you directly edit the alpha channel of individual pixels in Photoshop? I have looked and searched and googled and I can't figure it out.

Thanks in advance.

Its been a while, but D3DRS_LIGHTING isn't useless in a 2D world but rather useless on lit verticies. Typically this is how 2D games are done because self-lighting your verticies is incredibly easy. You often have a grid of tiles and don't break that structure very much in a 2D game, while in 3D you, many times, can't even figure out where the verticies are without toggling the display and many verticies need to be handled on a hardware level because you have so many models and a much more varying world using stretched and transformed textures.

To do day and night, just change the lighting. If you're using lit verticies, which you most likely are/will be, you just have to decrease the RGB values of every light. If you are storing your lights as a long which you probably should be to have to prevent converting to a long every render (which happens more often then converting from a long), then you can easily break it apart using a little series of bitshifts and bit-wise operations. I can elaborate how to do this if anyone wants. I love bit twiddling. Big Grin

To edit the individual pixels in Photoshop... good question, and I wish I knew. I wish other programs made the setting of the alpha value as easy as Flash makes it. Sad Only thing I have ever figured out how to do is flood fill the alpha channel in Paint.Net using a 3rd party plug-in, and that just allowed me to get rid of the background. What kind of sick, twisted world is this where people don't care so much about alpha channels? Its madness! Maadddnneesss!!!!

(Robin, you will probably like thisSmile

By the way, if anyone is interested in doing some dynamic lighting in DX8 + VB6 without removing the TLVertex, check this out:
Optimized vbGORE implementation: http://www.vbgore.com/forums/viewtopic.php?t=6258
Unoptimized stand-alone theory implementation: http://www.vbgore.com/forums/viewtopic.php?t=4709

The first is optimized for vbGORE using minimalist updating, a bit based on vbGORE's engine (size of the screen view, for instance), but can easily be changed to your own. The latter is a stand-alone project that doesn't use much optimizing, but is much easier to read. I recommend checking out at least how I optimized it for vbGORE, and probably even just copying a lot of that code. Keep in mind my vbGORE implementation does not make use of the rest of the map lights which makes it a bit like a software version of hardware lights, but you guys can probably change it without too much effort to work with both. I was just sick of trying to deal with vbGORE's map lights to get it to work. Tongue
Reply
#24
Spodi Wrote:you just have to decrease the RGB values of every light
Yeah, that it how I was doing it.

Spodi Wrote:By the way, if anyone is interested in doing some dynamic lighting in DX8 + VB6 without removing the TLVertex, check this out:
Optimized vbGORE implementation: http://www.vbgore.com/forums/viewtopic.php?t=6258
Unoptimized stand-alone theory implementation: http://www.vbgore.com/forums/viewtopic.php?t=4709

The first is optimized for vbGORE using minimalist updating, a bit based on vbGORE's engine (size of the screen view, for instance), but can easily be changed to your own. The latter is a stand-alone project that doesn't use much optimizing, but is much easier to read. I recommend checking out at least how I optimized it for vbGORE, and probably even just copying a lot of that code. Keep in mind my vbGORE implementation does not make use of the rest of the map lights which makes it a bit like a software version of hardware lights, but you guys can probably change it without too much effort to work with both. I was just sick of trying to deal with vbGORE's map lights to get it to work. Tongue
Wow! That is exactly what I was looking for. Thanks for posting the source. I can't wait to go through it.
Reply
#25
Looking good so far! I apologize for some of my sloppy coding. Make sure you don't release the source -- for obvious reasons. Other than that, keep up the awesome work, Robin! :wink:
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)