DirectX8 - Transparacy to both sides of a polygon.

Started by
12 comments, last by Jacob Roman 19 years, 6 months ago
My skill level is probably intermediate, at least in DirectX. As for programming in general. I've been programming for about 13 years since I was 10. Started on Amiga BASIC. Then messed around on AppleIIc BASIC in middle school on this computer that was in one of my classes. Then in high school, I chose Computer Programming as an elective, which had Visual Basic 4.0 Professional Edition. Got VB 5.0 Learning Edition and Borland C++ that same year for Christmas and used it ever since. So I've been working in VB for 8 years. Also in my Senior year of High School, a classmate of mine gave me free burned copies of Visual Studio 5.0 Enterprise Edition. So I have little experience in C++ and a lot of experience in VB. I'm also in my 2nd term of college majoring in Computer Programming and Analysis. VB.Net I'm not really caring for, but it's different, and I'm leanring something. Valencia Community College also plans on having a Game Design degree program next term, so I plan on switching my degree to that. I'm 23 now just to let you know.

This game I'm makin is under a building stage since I just started on it like a month or two ago. I have quite a bit of experience in DirectX, but I'm still learning. I used to use DirectX7 a lot, for 2D stuff. But since DirectX8 no longer supports DirectDraw, I'm forced to learn their 3D. But as I learned more and more on it, I got into DirectX8. After working with DirectX8 for over a year, I'm stuck with this problem, which was a problem to me before I even began to write this game. Just to let you know, the camera is in a static position. Only the Local coordinates of the object is being rotated. Or in DX8 terms, World rather than Local. The object rotates, and shows both polygons transparent on only one side. All I have now are these two polygons displayed in an test sub until I can solve this problem. Then I can add the solution to my engine. I'm taking steps one at a time till I can reach my goal. So everytime I run into a problem, I setup an example of my problem till my problem is solved. That way there I'm not confused. I like to make things easy for myself. I'm now stumpted on my own example program, which is why I posted this problem here to see if you guys can figure it out.

[Edited by - Jacob Roman on October 2, 2004 11:20:50 PM]
Advertisement
Quote:Original post by Namethatnobodyelsetook
When dealing with simple meshes like quads, you just have to sort them in camera space. If you have a particle system, with overlapping, intermixing faces, you're pretty much screwed. You can do things like additive blending, but regular alpha blending math just won't work unless you split the individual particles where two particles intersect, and sort all the fragments of quads you end up with. It's a complex mess, which no game ever tries to deal with.


?!?!

or leave z-enable on, and turn z-writing - no sorting, no splitting, everything transparent is rendered perfectly; this should be done after all opaque objects. Go ahead, try it, set the destination to D3DBLEND_ONE and source to D3DBLEND_SRCALPHA for best results. And you don't sort the polygons, you just have to do it in a rough front to back order by objects such as models, level data, and skybox - which is last (it's fillrate intensive if done at the beginning of each frame... wastes more ms than you think on high resolution). By the way, the processor is what slows down a game, very rarely is it the modern graphics card.. times have changed.

And Jacob, it's better in this case to just render 2 triangles, one facing "back", one facing "forward". If you add lighting, then the normals can only face one way anyways! Not that this even matters, 3D objects are "skinned" with polygons unless you are meant to go through them (not sure as to why). Changing renderstates is a bad habit, but of course it has to be done every now and then, but not this case, state changes are pretty expensive if called a lot - repetitive ones are ignored by D3D by the way. Changing the stream source is even worse, one vertex buffer is better than dozens. Having 2-3 buffers for minimal vertex sizes is even better, don't send useless junk such as normals if you don't plan on using them, of course you need thousands or millions of triangles until you can see a difference. You're pretty new to this and it doesn't really matter as long as it works in the end, and you're right, it really doesn't. Just keep it up and have some fun.
Quote:Original post by Anonymous Poster
Quote:Original post by Namethatnobodyelsetook
When dealing with simple meshes like quads, you just have to sort them in camera space. If you have a particle system, with overlapping, intermixing faces, you're pretty much screwed. You can do things like additive blending, but regular alpha blending math just won't work unless you split the individual particles where two particles intersect, and sort all the fragments of quads you end up with. It's a complex mess, which no game ever tries to deal with.

or leave z-enable on, and turn z-writing - no sorting, no splitting, everything transparent is rendered perfectly; this should be done after all opaque objects. Go ahead, try it, set the destination to D3DBLEND_ONE and source to D3DBLEND_SRCALPHA for best results.

ONE, SRCALPHA is an additive blend. Please READ what you quoted. I say it's fine for additive blending. For standard blending it's not fine... standard blending the one that looks like SRCALPHA, INVSRCALPHA. Take two quads, overlap then in a X shape. Now get it to render correctly with SRCALPHA and INVSRCALPHA.
It has definitely got to be a certain combination of how it's blended. The majority of the DirectX8 tutorials around the internet has this:

D3DDevice.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
D3DDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA
D3DDevice.SetRenderState D3DRS_ALPHABLENDENABLE, True

Which is what I have for transparency and is basic for a beginner at DirectX8, only I'm no beginner at it. To alphablend, the tutorials usually have this:

D3DDevice.SetRenderState D3DRS_SRCBLEND, D3DBLEND_SRCALPHA
D3DDevice.SetRenderState D3DRS_DESTBLEND, D3DBLEND_ONE
D3DDevice.SetRenderState D3DRS_ALPHABLENDENABLE, True

Only thing is...it alphablends only on one side on my polygons, and on the other side, it has the same changed color as the first side, only it didn't alphablend. I'm missing a setting. I tried all different kinds of combinations with the constants that I'd think would do it. Note: with the same exact settings I have for DirectX7, it actually does make both sides transparent. Something is up in DirectX8. I don't know.

This topic is closed to new replies.

Advertisement