Git Product home page Git Product logo

audit-normalmap's Introduction

audit-normalmap is a tool to check internal consistency of normal map image files.

Normalmaps

Normal mapping is a technique to simulate surfaces with bumps of dents in 3D computer graphics. It works by storing additional per-pixel information for material textures: a single vector, indicating a normal protruding perpendicularly from the surface.

This information then can be used from a shader script using an equation like:

color *= dot3(lightdirection, normalize(texture(normalmap, texcoord)));

which will essentially darken surfaces more, the more their normal points away from the light source.

(Note: typically, normalmaps will be encoded in tangentspace, so for above formula, lightdirection needs to be computed in tangentspace first too.)

As the normalmap contains information about surface steepness at each pixel, some consistency expectations can be made - e.g. one would want to assume that a normalmap corresponds to some heightmap, which essentially means that integrating the gradient (which is implied from the normal vectors) across any closed path must yield zero.

Furthermore, commonly normalmaps contain height information in the alpha channel; this also should usually be consistent with the normal vectors.

This tool verifies these consistency properties of normalmaps to aid with quality control of gaming artwork. It supports both the common Direct3D and OpenGL Y axis conventions (a.k.a. green channel inversion).

Usage

git submodule update --remote
make
./audit-normalmap infile.tga

Options:

  • -o output.hdr: additional to a text report, output an image file highlighting the regions of the image that contain inconsistent normals.
    • Red channel: inconsistencies with heightmap (if present).
    • Green channel: denormal vectors.
    • Blue channel: internal inconsistencies (M.C.Escher).
  • -c: do not show global inconsistencies that can be fixed by scaling the image (requires -o).
  • -y: assume the y coordinate is inverted (i.e. assume the 0,0 coordinate of the image is at the bottom left, as opposed to the top left which is default; this is also known as green channel inversion). This matches most OpenGL based game engines. By default, the y coordinate is interpreted according to the usual convention of Direct3D based game engines.
  • -7: assume the range of the normal vector encoding is centered at 127; in this case the "flat" normal vector (0,0,1) would be encoded as (127,127,255).
  • -8: assume the range of the normal vector encoding is centered at 128; in this case the "flat" normal vector (0,0,1) would be encoded as (128,128,255).
  • -n: assume GL_NEAREST normalmap interpolation. By default GL_LINEAR will be assumed as that is what will typically happen when rendering in 3D game engines.

Copyright

See the LICENSE file.

Contributing

See the CONTRIBUTING.md file.

Disclaimer

This is not an official Google product.

audit-normalmap's People

Contributors

divverent avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.