Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 643555
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T21:17:44+00:00 2026-05-13T21:17:44+00:00

If I have a texture, is it then possible to generate a normal-map for

  • 0

If I have a texture, is it then possible to generate a normal-map for this texture, so it can be used for bump-mapping?

Or how are normal maps usually made?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T21:17:44+00:00Added an answer on May 13, 2026 at 9:17 pm

    Yes. Well, sort of. Normal maps can be accurately made from height-maps. Generally, you can also put a regular texture through and get decent results as well. Keep in mind there are other methods of making a normal map, such as taking a high-resolution model, making it low resolution, then doing ray casting to see what the normal should be for the low-resolution model to simulate the higher one.

    For height-map to normal-map, you can use the Sobel Operator. This operator can be run in the x-direction, telling you the x-component of the normal, and then the y-direction, telling you the y-component. You can calculate z with 1.0 / strength where strength is the emphasis or “deepness” of the normal map. Then, take that x, y, and z, throw them into a vector, normalize it, and you have your normal at that point. Encode it into the pixel and you’re done.

    Here’s some older incomplete-code that demonstrates this:

    // pretend types, something like this
    struct pixel
    {
        uint8_t red;
        uint8_t green;
        uint8_t blue;
    };
    
    struct vector3d; // a 3-vector with doubles
    struct texture; // a 2d array of pixels
    
    // determine intensity of pixel, from 0 - 1
    const double intensity(const pixel& pPixel)
    {
        const double r = static_cast<double>(pPixel.red);
        const double g = static_cast<double>(pPixel.green);
        const double b = static_cast<double>(pPixel.blue);
    
        const double average = (r + g + b) / 3.0;
    
        return average / 255.0;
    }
    
    const int clamp(int pX, int pMax)
    {
        if (pX > pMax)
        {
            return pMax;
        }
        else if (pX < 0)
        {
            return 0;
        }
        else
        {
            return pX;
        }
    }
    
    // transform -1 - 1 to 0 - 255
    const uint8_t map_component(double pX)
    {
        return (pX + 1.0) * (255.0 / 2.0);
    }
    
    texture normal_from_height(const texture& pTexture, double pStrength = 2.0)
    {
        // assume square texture, not necessarily true in real code
        texture result(pTexture.size(), pTexture.size());
    
        const int textureSize = static_cast<int>(pTexture.size());
        for (size_t row = 0; row < textureSize; ++row)
        {
            for (size_t column = 0; column < textureSize; ++column)
            {
                // surrounding pixels
                const pixel topLeft = pTexture(clamp(row - 1, textureSize), clamp(column - 1, textureSize));
                const pixel top = pTexture(clamp(row - 1, textureSize), clamp(column, textureSize));
                const pixel topRight = pTexture(clamp(row - 1, textureSize), clamp(column + 1, textureSize));
                const pixel right = pTexture(clamp(row, textureSize), clamp(column + 1, textureSize));
                const pixel bottomRight = pTexture(clamp(row + 1, textureSize), clamp(column + 1, textureSize));
                const pixel bottom = pTexture(clamp(row + 1, textureSize), clamp(column, textureSize));
                const pixel bottomLeft = pTexture(clamp(row + 1, textureSize), clamp(column - 1, textureSize));
                const pixel left = pTexture(clamp(row, textureSize), clamp(column - 1, textureSize));
    
                // their intensities
                const double tl = intensity(topLeft);
                const double t = intensity(top);
                const double tr = intensity(topRight);
                const double r = intensity(right);
                const double br = intensity(bottomRight);
                const double b = intensity(bottom);
                const double bl = intensity(bottomLeft);
                const double l = intensity(left);
    
                // sobel filter
                const double dX = (tr + 2.0 * r + br) - (tl + 2.0 * l + bl);
                const double dY = (bl + 2.0 * b + br) - (tl + 2.0 * t + tr);
                const double dZ = 1.0 / pStrength;
    
                math::vector3d v(dX, dY, dZ);
                v.normalize();
    
                // convert to rgb
                result(row, column) = pixel(map_component(v.x), map_component(v.y), map_component(v.z));
            }
        }
    
        return result;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a 320x480 PNG that I would like to texture map/manipulate on the
With WPF 3D, is it possible to have a texture with an alpha channel?
I have an OpenGL RGBA texture and I blit another RGBA texture onto it
I have a sprite loaded as a texture and I need to animate it,
Have you used VS.NET Architect Edition's Application and System diagrams to start designing a
Is it possible to have a server side program that queues and manages processes
When im using this following code: glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 6); and then i enable multisampling,
It's hard to put this into the title, so let me explain. I have
In my engine I have a need to be able to detect DXT1 textures
Have just started using Google Chrome , and noticed in parts of our site,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.