lookin' for some textures

This is a discussion on lookin' for some textures within the Game Programming forums, part of the General Programming Boards category; I'd like to test my program with some .png textures with some partially transparent regions (png files have an alpha ...

  1. #1
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916

    lookin' for some textures

    I'd like to test my program with some .png textures with some partially transparent regions (png files have an alpha channel). I'm not sure if I have the transparency working correctly (loading the alpha channel) or if the one file I have only worked because of color keying. So, if anyone feels like making one or two (powers of two in size please... 128*128 or 256*256), or knows where I could get some for free, it would be much appreciated.

    (...or if anyone knows if these code snippets, in the correct places, will load the transparency from the alpha channel, I wouldn't have to test...)

    Code:
    m_pDirect3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
    m_pDirect3DDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
    m_pDirect3DDevice->
         SetRenderState(D3DRS_DESTBLEND,
         D3DBLEND_INVSRCALPHA);
    m_pDirect3DDevice->
         SetTextureStageState(0,D3DTSS_ALPHAARG1,
         D3DTA_TEXTURE);
    
    ....
    	
    D3DXCreateTextureFromFileExA(g_App.GetDevice(),"texture.png",D3DX_DEFAULT,
    D3DX_DEFAULT,D3DX_DEFAULT,NULL,D3DFMT_UNKNOWN,
         D3DPOOL_MANAGED,D3DX_DEFAULT,D3DX_DEFAULT,
         0x00ffffff,NULL,NULL,&pTexture);
    Away.

  2. #2
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Your render states and texture states look good. Your loading of the texture is not correct though. Change 0x00FFFFFF for the color key to 0. This will say don't use color keying.

    Also you set your texture state arg1 to alpha but you don't set the operation, you need to do both!

    Code:
       pDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1);
       pDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
    Try that and let me know what happens.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  3. #3
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    >>Try that and let me know what happens.
    It looks beautiful
    Away.

  4. #4
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    I thought it was beautiful, but it appears that one side of the cube is not transparent. It's all being rendered as one primitive, so I have no idea what could be causing this. I had a friend check it and there was one opaque side on his computer as well. Any ideas? I'll attach a zip of the source files and the texture.
    Attached Files Attached Files
    Away.

  5. #5
    Registered User
    Join Date
    Apr 2002
    Posts
    1,571
    Ah yes, transparency for 3D objects. This has to be handled differently! Here is the basic idea for that. Make an additional cube and reverse the normals so they are pointing inward. Render this inner cube first so the front faces are culled ( maybe CCW or CW culling depending on how you have it setup ) then render your outside one with back-face culling. The basic idea is you need to render triangles that are alpha blended back to front sorted. If you have a rotating cube there is no good way to do it. Think about if you have a huge scene, it would be so slow to sort every polygon from back to front. Here is how it can be done for large scenes.

    I. Render all non-transparent objects.
    II. Sort all transparent OBJECTS from back to front.
    III. Render these objects using the above technique.

    That should take care of it.
    "...the results are undefined, and we all know what "undefined" means: it means it works during development, it works during testing, and it blows up in your most important customers' faces." --Scott Meyers

  6. #6
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Took me a while to get it, but I got it To think that as soon as I code the model loading I'll be deleting all the hard coded stuff...

    Oh well, now I know how to do it Thanks man, you've been a ton of help.
    Away.

  7. #7
    Registered User MicroFiend's Avatar
    Join Date
    Nov 2002
    Posts
    80
    if ur still looking for textures (only for tests ^^) then buy wc3 reign of chaos, goto www.war3campaigns.com and download the texture extractor, very useful ^^, my games all look like high quality warcraft games now lol

  8. #8
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    Uhmmm,

    Anyone want to explain to a novice
    [int novice = ME! ]
    How to compile this zip into an exe?

    I am using Dev-C++ 4

    Which things do I need to compile?
    Do I need the Dx SDK installed?
    Should I go back to Hello.cpp? << LOL!

    Thanks.

  9. #9
    *******argv[] - hu? darksaidin's Avatar
    Join Date
    Jul 2003
    Posts
    314
    I'm not sure if all of this is needed in DirectX, but in OpenGL you should also make sure that your transparent objects don't write to the depth buffer and maybe disable backface culling. For example, a billboard flare should be rendered after the scene is complete (postrender), not write to the depth buffer (so it doesn't prevent other flares behind itself from being drawn) but check the depthbuffer (so you won't see them through walls).

  10. #10
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    Grumpy, you don't compile my zip into an .exe. You'd need the DirectX SDK installed, and need to link all the libraries and such. If you just want to see the current state of my program, check out the link in my signature. The file on that page is the .exe.

    Darksaidin - yeah, I had some trouble with the transparency - one face wasn't turning transparent. Mr. Wizard helped me out with that and told me that I needed to render the back faces of the object with the front ones culled, and then render the front faces with the back ones culled. That's been incorporated into the program, but only for the hard coded primitive... it will take some work to get the transparency working again after I get the model loading done.
    Away.

  11. #11
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    I just started reading Thinking in C++, Sharam Hekmat's C++ Programming from pragsoft.com, and a couple of other tutorials I found on the web.

    I imagine it will be a while before I can use Dx in anything other than a tutorial... Is the Dx SDK free to download?


    If I had the SDK installed would I be able to assemble the zip?

    Are the contents of the Directx_9_engine_current.zip what is compiled into the exe in engine.rar?

    I d/l'ed the engine.rar and saw the spinning cubes, zoom options, and other features. How long did it take to write that?

  12. #12
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    It took quite a while to write that, with the help of a lot of tutorials. I'd say probably at least 50 hours of typing - but I more or less know what I'm doing with C++ and was just learning the SDK. It took even longer to get knowledgable enough with C++ to be able to do all that. Stay motivated, and keep learning, and someday you can make a spinning cube.

    Anyway, the source in the zip on this thread is older than the source that made the program in the .rar on my site, but the source in the zip here will compile into an older version of that, when properly linked with the SDK libraries.

    Yes, the DX SDK is available to download for free from Microsoft. However, you'll need a broadband connection to do so, because it is quite large. (Over 100 mb, I believe).
    Away.

  13. #13
    Crazy Fool Perspective's Avatar
    Join Date
    Jan 2003
    Location
    Canada
    Posts
    2,640
    >> Stay motivated, and keep learning, and someday you can make a spinning cube.



    heh, that is the greatest quote ive ever read with regards to 3D graphics programming. I dont have a sig at the moment but im going to create one just to quote you confuted priceless

  14. #14
    Registered User
    Join Date
    Aug 2003
    Posts
    56
    LOL!

    Thanks for the timely answers; I figured posting in an active thread would get a quicker response than a whole bunch of questions in a new thread.

    Please excude the thread hijack, Although it seems as if my hijack occurred after the original thread questions were answered.

    Quarterninimums??? Wont even go there... LOL!

    But... anyone know of a good tutorial for making a paint program?
    -Just basic pen, color and white background to write on.
    -using the window enviroment

  15. #15
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    >>Quarterninimums??? Wont even go there... LOL!
    I assume you meant quaternions :P I wrote a bunch about them here, and my quaternion code is here, Good luck understanding any of it unless you're very very strong in math, or you've done a lot of graphics programming. Hehe.

    But... anyone know of a good tutorial for making a paint program?
    -Just basic pen, color and white background to write on.
    -using the window enviroment
    You just started reading your C++ book? You're aiming about 5000% too high with that program. It would require you knowing C++ fairly well, and learning the WinAPI, which is a whole other bucket of cake. Start with a Hello World program or two, and once you understand the basics, you could try the Tic-tac-toe tutorial that I wrote, which is here. After you get that far, you could consider starting to learn the WinAPI, but I'd suggest several more simple programs before you did that (most people do best this way. I more or less dove straight into the deep end, with a few short stops along the way)
    Away.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Textures
    By fighter92 in forum Game Programming
    Replies: 1
    Last Post: 03-21-2009, 11:57 AM
  2. Textures not texturing the way I want
    By scwizzo in forum Game Programming
    Replies: 0
    Last Post: 12-16-2008, 12:12 PM
  3. loading textures from resources (dx8/9)
    By X PaYnE X in forum Game Programming
    Replies: 1
    Last Post: 12-25-2005, 04:44 PM
  4. the effects of textures on my frame rate
    By DavidP in forum Game Programming
    Replies: 37
    Last Post: 10-03-2003, 12:24 PM
  5. Q3A textures
    By glUser3f in forum Game Programming
    Replies: 11
    Last Post: 09-04-2003, 04:40 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21