Page 3 of 13 FirstFirst 12345 ... LastLast
Results 21 to 30 of 121

Thread: G.T.A.2 Map Editor

  1. #21
    Ok, i will try.

    Any ideas how to handle textures that are not POT? Not 16x16, not 32x32, not 64x64.
    But like 30x26, 8x64 etc.

    How to make opengl accept them and center them on the quad to draw them properly?
    If every texture like this has black background (for transparency) and if i go through each images background and find a pixel that is not black and if i copy all non black pixels to memory to create texture from, will this work?

    Will it be very slow?

    I need to handle such small non POT textures because GTA2 uses them for sprites like peds, map objects, guns etc.

  2. #22
    Non power of 2 textures work by default on nxPascal. I can still remember the key issue there used to be
    Code:
    glTexImage2D(GL_TEXTURE_2D, 0, intFormat, sizeX, sizeY, 0, Format, GL_UNSIGNED_BYTE, Data);
    I used to have intFormat 3 or 4, but it should be GL_RGBA or GL_RGB if no alpha channel. There were no other special tricks to make them work

  3. #23
    But what about OpenGL itself, i have read that he doesn't like such textures very much.
    And some guys were getting black textures instead of actual textures on some cards.
    But i also have read that GL 1.1 should support them. Dunno what's true and what's not.

  4. #24
    You can read the limitations on wiki:
    http://www.opengl.org/wiki/NPOT_Texture
    Bottom line: "All newer hardware can handle NPOTs of any kind perfectly."

    While i still had that white/black texture bug myself because of 3, 4 thing, i implemented the TQuadTexture class. It divides the texture into power of 2 texture parts. There's also 2 different loading options for textures:
    toScale: Loads image into power of 2 texture, and scales to nearest match. For example 400x900 would round to 512x1024.
    toFitScale: Loads image into power of 2 texture, and makes the size to current or higher match. This actually doesn't scale, but leaves black gaps on the outside area. Each texture has separately SizeX, SizeY, Width, Height, where Width/Height is the actual image size, and SizeX, SizeY is texture size. So nx drawing functions still know how to deal with them.

    QuadTexture - Reserves near exactly the needed area from memory, pixel perfect.
    toScale - May cause slight blurring, pixel perfect data is propably lost, memory efficient.
    toFitScale - Keeps pixel perfection but reserves more memory than QuadTexture, propably not very usable on 3D-models.
    (no option at all) - Pixel perfect, memory efficient non power of 2, if card supports it.
    Last edited by User137; 17-02-2013 at 04:04 PM.

  5. #25
    About getting black textures when trying to deal with non-POT stuff, I had the same problem until I began to include this in my texture loading code:
    Code:
    glPixelStorei(GL_UNPACK_ALIGNMENT,1);

  6. #26
    Quote Originally Posted by User137 View Post
    toFitScale - Keeps pixel perfection but reserves more memory than QuadTexture, propably not very usable on 3D-models.
    Why not very usable on 3D models?
    I tried these options and best seems to be toFitScale.
    The other one blurs too much.

    All my 3D models are just small "planes". For ped i created this:
    Code:
    model.CreatePlane(2,2);
    2,2 is ofc too big for ped, it's just for testing purposes. Later it will be even smaller.

    But loading NPOT textures from file seems to work fine.
    Will try later how to supply img data from memory to it and how it renders them.

  7. #27
    Quote Originally Posted by hwnd View Post
    Why not very usable on 3D models?
    Because often times 3D models UV maps rely on coordinate range from 0..1. If Image Width is 257 then texture's sizeX would be 512. So right side of the texture has black stripe. That obviously cannot be used as a repeating texture, and the usable UV range would be closer to 0-0.5.

    edit: Ah it's actually not black stripe. It will clamp with border line like that right side image:
    http://i.msdn.microsoft.com/dynimg/IC142381.gif
    Last edited by User137; 20-02-2013 at 02:35 PM.

  8. #28
    Here i rendered a transparent ped. The lines around him are "little" blocky.
    Is it possible to somehow tell OpenGL to smoothen these curves, so they don't look so blocky?
    If it's not, i can live with that, but i decided to ask just in case.

    The black behind it, is very basic fake shadow.
    It has large offset because ped is dead and floating in air. This i just a test rendering.
    The shadow should be transparent a bit also instead of complete black.
    Shadow is practically same quad rendered with offset and with glColor3f(0,0,0);



    Here is far view of ped
    http://img843.imageshack.us/img843/8071/farview.png
    Last edited by hwnd; 22-02-2013 at 02:15 AM.

  9. #29
    You can make the shadow transparent with alpha color: glColor4f(0,0,0, 0.6);

    Not sure if this is what you are after, but the smoothening of texture's alpha edges is done with:
    Code:
    glAlphaFunc(GL_GREATER, 0.008);
    That means that only color with alpha value greater than 0.008 is rendered.
    If you set it like (GL_ALWAYS, 0), it would draw the whole texture as smooth as it is, also fully transparent pixels with 0 alpha.

  10. #30
    I will leave that sprite rendering for a while. I get tired and bored working on one thing for long time. Instead i worked on some other things.

    With Ctrl+G shortcut it's possible to navigate to any X,Y coordinate on map.
    I use simple Delphi function: InputBox to get coords from user. Temporary thing i guess.
    Later i will use my own dialog i think.

    Instead of instantly going to X,Y location it goes there smoothly. This will be optional of course.
    First it goes fast and when arriving to specific X,Y it slows down until specified X,Y is exactly in center of the cam. And when camera is moving to that point and user clicks on minimap it stops moving.

    Because slow PC im unable to make video, it's smooth in editor but not smooth while recording video.
    Last edited by hwnd; 23-02-2013 at 04:50 PM.

Page 3 of 13 FirstFirst 12345 ... LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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