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 8172547
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T21:49:04+00:00 2026-06-06T21:49:04+00:00

I want to combine 2 textures in a GLSL shader to 1. the problem

  • 0

I want to combine 2 textures in a GLSL shader to 1.

the problem is that I fail to set the sampler2D in the shader from my program. (the shader/program compiles correctly, the textures load correctly, the vertex shader is correct too) I tried it with the following code from a tutorial:

glUniform1i(program.getUniformLocation("Texture0"), 0);
glUniform1i(program.getUniformLocation("Texture1"), 1);

//texture 0, first texture
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, colorTexture.handle);

//texture 1, other texture
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, normalTexture.handle);

the fragment shader code looks like this

uniform sampler2D Texture0;
uniform sampler2D Texture1;

void main(void)
{
    vec4 color = texture2D(Texture0, vec2(gl_TexCoord[0]));
    vec4 normal = texture2D(Texture1, vec2(gl_TexCoord[0]));
    gl_FragColor = normal + color;
}

it gets drawn with

glUseProgram(program.handle);
glColor3f(1, 1, 1);
    glBegin(GL_QUADS);
    glTexCoord2f(0, 0);
    glVertex3f(0, 0, 0);
    glTexCoord2f(1, 0);
    glVertex3f(500, 0, 0);
    glTexCoord2f(1, 1);
    glVertex3f(500, 500, 0);
    glTexCoord2f(0, 1);
    glVertex3f(0, 500, 0);
    glEnd();
  • 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-06-06T21:49:07+00:00Added an answer on June 6, 2026 at 9:49 pm

    try changing the second sampler to use gl_TexCoord[1]

    uniform sampler2D Texture0;
    uniform sampler2D Texture1;
    
    void main(void)
    {
        vec4 color = texture2D(Texture0, vec2(gl_TexCoord[0]));
        vec4 normal = texture2D(Texture1, vec2(gl_TexCoord[1]));
        gl_FragColor = normal + color;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to combine Hadoop based Mahout recommenders with Apache Hive.So that My generated
I want to combine Select top 2 scouting.* From scouting Where scouting.astroLoc Like 'D01%'
I want to combine the following two statements: select password from sys.user$ where name='SYSMAN';
I have two streams that i want to combine into one stream. The first
I want to combine two LINQ query results into one: var query1 = from
I have a folder of several ppt decks that I want to combine into
I have two functions that I want to combine the results of: drawAmbient drawDirectional
I want to combine the following queries into a single query: SELECT val FROM
I want to combine values from multiple lines of varying length into one line
I want to combine values from an array to be output into another array

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.