XNA Creators Club Online
Page 1 of 1 (9 items)
Sort Posts: Previous Next

Normal Mapping to Dynamic Runtime Mesh

Last post 6/27/2007 10:11 AM by Charles Humphrey. 8 replies.
  • 6/24/2007 5:43 PM

    Normal Mapping to Dynamic Runtime Mesh

    Probably not the best title...

    I have a terrain that is generated at runtime from an array of a custom vertex format, I would like to add some normal mapping to my terrain shader but (to my knowledge) you can't use MeshHelper.CalculateTangentFrames outside of the ModelProcessor, so how can I calculate the tangents for my custom vertex format?

    Thanks in advance...

  • 6/24/2007 11:05 PM In reply to

    Re: Normal Mapping to Dynamic Runtime Mesh

    Answer
    Reply Quote
    Assuming you are using a 2D terrain grid, this is incredibly easy. The tangent is just a vector along your terrain surface pointing west to east, and the binormal is the vector along the terrain surface pointing south to north (you might need to swap or negate those depending on which way up your normalmap is stored). You can compute these just by subtracting the position of the previous terrain point from the next point along.
    XNA Framework Developer - blog - homepage
  • 6/25/2007 4:25 AM In reply to

    Re: Normal Mapping to Dynamic Runtime Mesh

    Hi Chazsoft,

    I am another user of Hazy Mind Engine and I have been keeping track of your engine for quite sometime. You have bring HMEngine to a new level. I acknowledge you for your work cause sometimes I does reference from your blog on some stuff that I don't know how to do.

    Thanks pal!

    cheers!
    Cheers,
    lXciD

    --
    DirectXNA | The one stop for C#, DirectX and XNA!
    http://www.DirectXNA.com/
    (Work In Progress)
  • 6/25/2007 4:32 AM In reply to

    Re: Normal Mapping to Dynamic Runtime Mesh

    Shawn,

    The terrain is 3D, having a depth(z) a width(x) and a height(y). It is based on Reimers terrain tutorial. Would this method still work, it sounds like it would??

  • 6/25/2007 11:11 AM In reply to

    Re: Normal Mapping to Dynamic Runtime Mesh

    Answer
    Reply Quote
    Aren't two of the terrain coordinates just a regular 2D grid, though, using the heightmap to displace the value of the third axis?

    Calculating tangents for a displaced 2D grid is much easier than for an arbitrary 3D mesh.
    XNA Framework Developer - blog - homepage
  • 6/25/2007 11:40 AM In reply to

    Re: Normal Mapping to Dynamic Runtime Mesh

    Shawn,

    Yes, sorry for the confusion, I am new so terminology sometimes confuses me. I have done as you have said and it works :) I just have to get some nice normals for my terrain now, I tested it with the good ols rock.tga with it's normal map.

    @IXciD,

    Thanks, it's nice to know people read the blog, glad my stuff helps. :) Once I have the normal mapped terrain finished I will put it up on the blog.

  • 6/25/2007 12:07 PM In reply to

    Re: Normal Mapping to Dynamic Runtime Mesh

    here is an article from ziggyware.com that covers this topic (link).
  • 6/25/2007 2:51 PM In reply to

    Re: Normal Mapping to Dynamic Runtime Mesh

    Wow, that was  a lot of code... I must be missing a trick because I just did what Shawn said, it seemed to do the job. I guess it will all come out in the testing...

    Thanks for the link though, gives me a place to start when it all goes wrong. :)

  • 6/27/2007 10:11 AM In reply to

    Re: Normal Mapping to Dynamic Runtime Mesh

    Shawn,

    Thanks for that I have it working now Terrain with Bump Mapping

Page 1 of 1 (9 items) Previous Next