Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 13

Thread: texturing md2s

  1. #1
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,264

    texturing md2s

    I just finished, well sort of , my perpixel bump map demo (probably my millionth perpixel bump variation ) which uses arb vertex programs (my first REAL arb_v_p prog) and well it looks all bumpy and whatnot but there is a wierd problem. I load all the md2 stuff in correctly, it's being done the same as everyone else so that part is fine. But for some reason the texture is not oriented like it should be. I used the textures from the md2bump demo on nvidia's site so it should look just like, well pretty much, the md2shader demo. Oh ya I'm using the knight model. Ok anyway, when it's running the part of the texture that is the knight's shield is on his FACE! Ok and his face from the texture is on his SHIELD! It's kind of funny looking though. Oh and his face is upside down. Is there anything kind of wierd or funky about md2 texturing that I may not know about. From what I could tell everything _should_ be right. I'm going to write a quick md5mesh loading function later and try that. But I would like the md2 to work properly.

    I know it's not much to go on but I'm not at home now so I cant post any kind of code. So if there is any kind of wierd thing that has to be done to md2's to texture them I would like to know. Cuz something is gimped.

    -SirKnight

    [This message has been edited by SirKnight (edited 12-06-2002).]
    -SirKnight

  2. #2
    Intern Newbie
    Join Date
    Apr 2002
    Location
    Split, Croatia
    Posts
    43

    Re: texturing md2s

    You must use 1-t for t texture coordinate if you use glTexCoord2f(floating point coords are stored in glcommands) or skinheight-t if you use glTexCoord2i(these short coords are stored in dstvert_t struct).

    Hope this helps.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: texturing md2s

    ... or just turn the tga upside down while loading it.

  4. #4
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,264

    Re: texturing md2s

    use glTexCoord2f(floating point coords are stored in glcommands) or skinheight-t if you use glTexCoord2i(these short coords are stored in dstvert_t struct).
    Oh so that's what the problem is. Hmm I had no idea about that. Well I'll try it later when I get home. I knew there had to be something screwy with the texcoords somehow. I don't use the glcommand thing in the md2 file, so I guess I am using the other coords, the short coords as you say in the vert struct. Thanks!

    -SirKnight

    [This message has been edited by SirKnight (edited 12-06-2002).]
    -SirKnight

  5. #5
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,264

    Re: texturing md2s

    Ok just wondering. Why would the texture be upside down? I noticed also that even with the doom 3 md5mesh file they do a 1-v when loading the texture coords. I have never had a problem of upside down textures before. Is it just something wierd that Carmack does to his stuff?

    -SirKnight
    -SirKnight

  6. #6
    Junior Member Newbie
    Join Date
    Dec 2002
    Location
    Las Vegas, NV, USA
    Posts
    9

    Re: texturing md2s

    It has to do with how TGAs are stored.

  7. #7
    Intern Newbie
    Join Date
    Apr 2002
    Location
    Split, Croatia
    Posts
    43

    Re: texturing md2s

    I'm not sure that it has something with how TGAs are stored because Q2 originally used PCX files for models. In TGAs there is bit flag for picture orientation (in Image Descriptor) but I never seen anyone actually use it.

  8. #8
    Member Regular Contributor
    Join Date
    Sep 2000
    Location
    California
    Posts
    410

    Re: texturing md2s

    Most TGA images are stored from bottom to top. OpenGL likes bottom to top also, so they work well together. PCXs are stored from top to bottom, so in an Md2 file, loading a PCX would map correctly, whereas a TGA would be upsidedown.

    Instead of flipping the image flip the V coordinate.
    V=1.0f-V

    LightWave likes to store TGAs from top to bottom :/. PaintShop Pro saves the from bottom to top.

  9. #9
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,264

    Re: texturing md2s

    Ohh I see. I wasn't sure if tga's were stored bottom-top or not. I never wrote any code that saves them, actually my code that loads them isn't even mine.

    Well I just tried the one minus thing and it works. And now that this was pointed out, I can obviously see why it works. I wonder why I never thought of this before.

    For some reason my model seems a little dark, quite a bit darker than the md2shader demo's models for some reason. Maybe my normal map is just crappy.

    -SirKnight
    -SirKnight

  10. #10
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    The Round Table at Camelot
    Posts
    1,264

    Re: texturing md2s

    Welp solved the dark problem. I just added a base pass so I can add in the ambient term. I totally forgot about that. I guess that's what happens when I have tons of finals comming up sooner than I would like.

    -SirKnight

    [This message has been edited by SirKnight (edited 12-06-2002).]
    -SirKnight

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •