Mirage Source
http://web.miragesource.net/forums/

DirectX8 + Alpha Channels
http://web.miragesource.net/forums/viewtopic.php?f=201&t=3266
Page 1 of 3

Author:  Robin [ Sat Jan 12, 2008 10:26 pm ]
Post subject:  DirectX8 + Alpha Channels

Image

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
Image

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

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 :P

EDIT:

Here's a special effect :D
Image

Author:  Anthony [ Sun Jan 13, 2008 12:41 am ]
Post subject:  Re: DirectX8 + Alpha Channels

Tutorial!

xD. Looks very nice Robin. *is jealous*

Author:  Matt2 [ Sun Jan 13, 2008 6:08 am ]
Post subject:  Re: DirectX8 + Alpha Channels

Congratz.

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

Author:  Rezeyu [ Sun Jan 13, 2008 6:57 am ]
Post subject:  Re: DirectX8 + Alpha Channels

Took Smchronos a long time to make his engine dx8.

Author:  Robin [ Sun Jan 13, 2008 2:19 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

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.

Author:  Dragoons Master [ Sun Jan 13, 2008 4:19 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

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...

Author:  Spodi [ Sun Jan 13, 2008 4:34 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

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.

Author:  Robin [ Sun Jan 13, 2008 7:15 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

Luckily all my graphics were in the correct texture format ^^

Btw, made it so the engine can recognise the Mirage tile system now.

Author:  Matt2 [ Mon Jan 14, 2008 1:31 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

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

Author:  Robin [ Mon Jan 14, 2008 4:40 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

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.

Author:  Rezeyu [ Mon Jan 14, 2008 8:25 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

Smchronos removed HP bars from the Engine because he said DX8 had issues drawing 2D rectangles or something.

Author:  Robin [ Mon Jan 14, 2008 10:00 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

He fails at Dx8 then.

Author:  Spodi [ Tue Jan 15, 2008 12:49 am ]
Post subject:  Re: DirectX8 + Alpha Channels

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:

Author:  Robin [ Sat Jan 19, 2008 12:26 am ]
Post subject:  Re: DirectX8 + Alpha Channels

Image

Image of it using Mirage's tile system.

Author:  Rezeyu [ Sat Jan 19, 2008 12:32 am ]
Post subject:  Re: DirectX8 + Alpha Channels

Image

Author:  Robin [ Sat Jan 19, 2008 12:43 am ]
Post subject:  Re: DirectX8 + Alpha Channels

God that's ugly.

Author:  Rezeyu [ Sat Jan 19, 2008 1:02 am ]
Post subject:  Re: DirectX8 + Alpha Channels

It's just text.
It's because it's skinnable.

Author:  Jonny9797 [ Fri Jan 25, 2008 12:16 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

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.

Author:  Dragoons Master [ Fri Jan 25, 2008 2:10 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

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...

Author:  Robin [ Fri Jan 25, 2008 2:50 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

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/lolololololololbk7.png

Author:  Jonny9797 [ Fri Jan 25, 2008 10:17 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

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:


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! :)

Author:  Dragoons Master [ Fri Jan 25, 2008 10:58 pm ]
Post subject:  Re: DirectX8 + Alpha Channels

If you get any advance, let me know plx ^^

Author:  Spodi [ Sat Jan 26, 2008 12:06 am ]
Post subject:  Re: DirectX8 + Alpha Channels

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. :D

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. :( 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 this:)

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. :P

Author:  Jonny9797 [ Sat Jan 26, 2008 1:47 am ]
Post subject:  Re: DirectX8 + Alpha Channels

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. :P

Wow! That is exactly what I was looking for. Thanks for posting the source. I can't wait to go through it.

Author:  Kenko [ Sun Jan 27, 2008 7:00 am ]
Post subject:  Re: DirectX8 + Alpha Channels

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:

Page 1 of 3 All times are UTC
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/