D3D not so good for ISO maps
I have come upon a huge problem with using D3D for iso maps, if one is trying to make a game like civ2 using 3D for 2D rendering, its not good cause you cant use colorkeying effectively. For example, if you use that tutorial on gamedev for making an iso map in Direct3D, then say you want to place a image of a unit on that map like in civ2. So you would simply create a square (made of 2 triangles) just slightly above the iso surface and place on that square a texture. The texture would be the unit.bmp that you want on it. Now of course you could render all of your units in 3D, but if you have really nice hand drawn units and you want them to look good, you cant make them fully 3D. So you place a 2D image of the unit as a texture on that square and then use a colorkey to get rid of the excess image background, just like in 2D directdraw blitting. BUT, in D3D, it blends the colors, so lets say your unit is calvary unit and you use a bright green background, so you colorkey out that bright green background, right?, just like in 2D but in 3D it blends that bright green with the edge of the unit. So around the whole unit you have a bright green outline! YUCK!, the rest of the bright green image is properly made transparent.
To show exactly what I mean I wrote something that will work on anyones computer, wether they have hardware excelleration or not.
ftp://test:test@206.145.228.91
Check this guy out and you will see a bright green outline around the unit. Use the up and down arrows to zoom in and out.
Now the big question is, how do you get rid of this? Sure i can use another color, like maybe black colorkey, but then I would have black outline around my unit, which would show up if he was over a grass(green) terrain square.
And alpha blitting wont work cause that only works for whole surfaces. I could make the whole texture transparent but then the whole unit would be invisible
So has anyone else in here meet with this problem yet of using D3D to do 2D?
Possibility
Turn of ALL filtering when you render with a colour key, and it will work on most graphics cards out there. Some TNTs don''t like it, though. :-(
By far the easiest thing to do is to read this article:
http://www.gamedev.net/reference/articles/article787.asp
Its not for the current version of DirectX, but its REALLY easy to translate.
By far the easiest thing to do is to read this article:
http://www.gamedev.net/reference/articles/article787.asp
Its not for the current version of DirectX, but its REALLY easy to translate.
July 29, 2000 03:08 PM
I''ve also encountered this problem... Bracket suggest that we should simply turn off all filtering, which indeed works, but what if I _want_ to use filtering? Filtering will make rotation and scaling look so much nicer...
If you want to use filtering, read the article link I posted. ;-p
Basically, it walks you through loading an image into a surface, building a 1-bit alpha channel to represent the colour keyed area (you only do this once, so its quick) and then rendering with D3D set to treat the 1-bit alpha channel as completely transparent. Works like a champ. If people find that other article confusing, I can probably try and knock up a quick demo with source.
Basically, it walks you through loading an image into a surface, building a 1-bit alpha channel to represent the colour keyed area (you only do this once, so its quick) and then rendering with D3D set to treat the 1-bit alpha channel as completely transparent. Works like a champ. If people find that other article confusing, I can probably try and knock up a quick demo with source.
arrrgh the bloody thing changed my screen resolution , why cant directx programmers learn to run programs in windows.
the answer u want is to use a alpha channel with your texture
heres how u do it in opengl , d3d should be similar
2 ways
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
or
glAlphaFunc(GL_GREATER,0.0);
glEnable(GL_ALPHA_TEST);
the answer u want is to use a alpha channel with your texture
heres how u do it in opengl , d3d should be similar
2 ways
glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_BLEND);
or
glAlphaFunc(GL_GREATER,0.0);
glEnable(GL_ALPHA_TEST);
Actually, D3D is pretty good for isometric engines if you know how to use it right. I found using z-buffering with it is really usefull since you don''t need to worry about drawing order anymore .
Anyway, you wouldn''t want to use colorkeying, but instead, alpha testing. It''d take a while to show how to use it, but you can look it up in the DX SDK Docs. Basically, its just a more flexible way of color keying with alpha values. (and you can still use filtering)
----------------------------------------
Whenever I see an old lady slip and fall on a wet sidewalk, my first instinct is to laugh. But then I think, what if I was an ant and she fell on me? Then it wouldn't seem quite so funny.
Anyway, you wouldn''t want to use colorkeying, but instead, alpha testing. It''d take a while to show how to use it, but you can look it up in the DX SDK Docs. Basically, its just a more flexible way of color keying with alpha values. (and you can still use filtering)
----------------------------------------
Whenever I see an old lady slip and fall on a wet sidewalk, my first instinct is to laugh. But then I think, what if I was an ant and she fell on me? Then it wouldn't seem quite so funny.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement