Results 1 to 4 of 4

Thread: Normal Maps

  1. #1

    Normal Maps

    I've got 2 Objects. One Highres, the other Lowres. The Texture can be applied to both and fits perfectly. Now i want to store all the n.x,n.y and n.z into a normalmap for per-pixel lighting. A simple question : how do i clamp the floats from the normals into bytes, to store in R,G and B channels of the texture ?

    Is there something else, i could store in the normalmap's alpha (That i could use for per-pixel precomputation)?

    What is a good size for such a texture ? I think i will have to interpolate between the points, that did not have a vertex in the hires-obj. How is this performed ? Simply interpolate ?

    Hope you can help me. And thanks in advance

  2. #2
    Senior Member Regular Contributor
    Join Date
    Sep 2001
    Eastern USA

    Re: Normal Maps

    This is really more of an algebra question.

    Think about it, you want to convert a clamped floating point value to a byte. The floats SHOULD be all clamped on [-1, 1] since you'll want to have a unit normal vector at each point.

    The float values range on [-1, 1]. The byte values should range on [0, 255]. So, mathematically, we want a linear function f(x) where f(-1)=0 and f(1)=255. A simple way to do this (by no means the only way) is:


    ...or to be more precise:


    Of course if you're dealing with "signed bytes" as OpenGL likes to call them you can just use...


    ...for a fairly decent approximation. Which method you take depends on what you're working on.

  3. #3

    Re: Normal Maps

    Thanks for the answer. I'm using r=1+127*nv.x and it is doing fine (I think i worried too much about precision loss). But the bigger problem is the interpolation on the pixels, that do not have a correspondig vertex with normals in the hires model. At bigger triangles linear interpolation tends to become "stairs-like" at closeups. What kind of interpolation should I use for the problem.
    The second problem i have is that i preview the textures and decide about their res. Any idea how to compute the needed res out of the vertex-density and how big the model is ?


  4. #4

    Re: Normal Maps

    I meant r = 127 * (nv.x+1).


Similar Threads

  1. normal maps
    By heinz85 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-25-2012, 11:00 AM
  2. VBO and Normal Maps
    By Mctittles in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 04-23-2011, 09:42 AM
  3. Normal Maps
    By toneburst in forum OpenGL: GLSL
    Replies: 4
    Last Post: 03-31-2008, 11:00 AM
  4. Normal Maps
    By pedrovr in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 02-20-2003, 07:11 AM
  5. Normal maps?
    By M/\dm/\n in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-30-2002, 04:35 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Proudly hosted by Digital Ocean