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

  • SEARCH
  • Home
  • 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 6084109
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T11:28:59+00:00 2026-05-23T11:28:59+00:00

I’m passing to vertex shader (glsl) 2 textures: from the screen and smaller, normalmap.

  • 0

I’m passing to vertex shader (glsl) 2 textures: from the screen and smaller, normalmap.
Normalmap is scaled for the screen size. So if first texture is 1152×864 pixels and normalmap is 256×256, it will be scaled from it’s size to bigger.

How can I make it tiled? E.g. make it size as 256×256 and tile through all the texture.


UPD:

For example, my main (big) texture is mapped like this:

[0.17, 0.61, 0.33, 0.83]

Instead of:

[0, 0, 1, 1]

This way my normal texture is mapped for the first coordinates too. So I see a small mapped rectangle of it. How can I map it in shader for the full size?

  • 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-23T11:28:59+00:00Added an answer on May 23, 2026 at 11:28 am

    it will be scaled from it’s size to bigger.

    No, it most certainly will not. This is a common misunderstanding about textures. Textures are nothing more than fancy look-up tables. Textures are not “scaled” relative to one another; it is merely a question of what texture coordinates you use.

    In all likelihood, what you are doing is using the same texture coordinate for the screen texture as your normal map. Since we’re likely talking about normalized texture coordinates, this means that you’re mapping the same [0, 1] range to both of them.

    To get the effect you’re talking about, you need to compute texture coordinates for your normal texture that do what you need them to do. So if you have a texture coordinate that is relative to the screen texture, you must transform it into the space you want it in for the normal texture.

    There are a couple of ways to do it. The manual way is to compute the ratio of the textures’ sizes to one another on the CPU, then pass it to the shader. Using the numbers you’ve given, the size ratios would be:

    (1152.0/256.0, 864.0/256.0) = (4.5, 3.375).
    

    Make sure that this is done in floating-point math. Once done, simply pass this along in a uniform and multiply the texture coordinates by this ratio in the shader before sampling:

    uniform vec2 textureRatio;
    
    void main() {
    //Get the texture coordinate.
    vec4 screenTexColor = texture(screenTex, texCoord);
    vec2 normTexCoord = textureRatio * texCoord;
    vec4 normalValue = texture(normalTex, normTexCoord);
    //Do something with these.
    }
    

    The automatic way in GLSL is to do this directly in the shader. This requires GLSL 1.30 or better. Basically, you use the available features of the language to compute the ratio:

    void main() {
    //Get the texture coordinate.
    vec2 textureRatio = textureSize(screenTex) / textureSize(normalTex);
    vec4 screenTexColor = texture(screenTex, texCoord);
    vec2 normTexCoord = textureRatio * texCoord;
    vec4 normalValue = texture(normalTex, normTexCoord);
    //Do something with these.
    }
    

    In both of these cases, I’m assuming that your GL_TEXTURE_WRAP_S/T are set to GL_REPEAT with appropriate texture or sampler parameters.

    Do note that computing the ratio on the CPU and passing it as a uniform will likely be faster than computing it in the shader. Particularly for fragment shaders, which will be run a very great deal.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have a reasonable size flat file database of text documents mostly saved in

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.