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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T12:09:39+00:00 2026-05-13T12:09:39+00:00

How i can disable lighting for only one of the textures in this multitexturing

  • 0

How i can disable lighting for only one of the textures in this multitexturing scheme? I tried to use glDisable(GL_LIGHTING) and glEnable(GL_LIGHTING) but it doesnt remember the settings when i render the quad.

Here is the code snippet:

glDisable(GL_LIGHTING);
glEnable(GL_BLEND);

glDisable(GL_TEXTURE_RECTANGLE_ARB);
glDisable(GL_TEXTURE_2D);

//------------------------
glActiveTextureARB(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, LIGHT_MAP); // texture with black/white

//------------------------
glActiveTextureARB(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, MY_TEXTURE); // normal texture
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_RGB, GL_ADD);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE0_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE1_RGB, GL_TEXTURE);
glTexEnvi(GL_TEXTURE_ENV, GL_SOURCE2_RGB, GL_PREVIOUS);
glTexEnvi(GL_TEXTURE_ENV, GL_COMBINE_ALPHA, GL_ADD);

glColor4f(1, 1, 1, 1);

glBegin(GL_QUADS);
    glNormal3f(0,0,1);

    glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f, 0.0f);
    glMultiTexCoord2fARB(GL_TEXTURE1, 0.0f, 0.0f);
    glVertex3f(-1.0f, -1.0f, 0.0f);

    glMultiTexCoord2fARB(GL_TEXTURE0, 0.0f, 1.0f);
    glMultiTexCoord2fARB(GL_TEXTURE1, 0.0f, 1.0f);
    glVertex3f(-1.0f, 1.0f, 0.0f);

    glMultiTexCoord2fARB(GL_TEXTURE0, 1.0f, 1.0f);
    glMultiTexCoord2fARB(GL_TEXTURE1, 1.0f, 1.0f);
    glVertex3f(1.0f,  1.0f, 0.0f);

    glMultiTexCoord2fARB(GL_TEXTURE0, 1.0f, 0.0f);
    glMultiTexCoord2fARB(GL_TEXTURE1, 1.0f, 0.0f);
    glVertex3f(1.0f, -1.0f, 0.0f);
glEnd();

glActiveTextureARB(GL_TEXTURE0);
glDisable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE1);
glDisable(GL_TEXTURE_2D);

Edit: the texture loading:

glGenTextures(1, &LIGHT_MAP);
glBindTexture(GL_TEXTURE_2D, LIGHT_MAP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);

Weird thing is that when i enable lighting at the first line of code, i cant see the light_map texture rendered at all in the multitexture quad. Also the lighting doesnt seem to affect that quad at all, it works on other quads (which arent multitextured) in my app.

Any help appreciated.

  • 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-13T12:09:39+00:00Added an answer on May 13, 2026 at 12:09 pm

    Your first sentence does not make sense. GL Lighting happens at the vertex level. texturing, be it single texture or multitexture. happens way after. In more details:

    The lighting that got computed per vertex is interpolated to each fragment, and that value is input to the texturing pipeline stage 0.

    So… The lit color L comes in and gets combined with the texture on the texture stage 0 (your light map here), according to the texture environment of stage 0. You don’t show how you set up the Texture environment for texture stage 0, so I can’t tell you how it will pass down.

    Then your output from stage 0 (computed from lighting and texture 0) get sent to the texture stage 1 input (where your “normal” texture is bound. That’s called a diffuse texture). You use an environment of COMBINE with ADD on both RGB and ALPHA here, which is not typical of lightmapping: You’re adding your lighting+lightmap to the diffuse color. Usually you want to multiply them (GL_TEXTURE_ENV_MODE=GL_MODULATE rather than GL_COMBINE).

    Also, you did not set the SOURCE0_ALPHA and SOURCE1_ALPHA, so I’m not sure what exactly you add to generate the stage 1 ALPHA output.

    All in all, I’d advise to write down exactly what you want as a result first (as math), and try to map that to the GL multitexturing pipeline.

    Edit: Following your comments, if you don’t specify stage 0 TexEnv, then you get the default:

    GL_TEXTURE_ENV_MODE defaults to GL_MODULATE and GL_TEXTURE_ENV_COLOR
    defaults to (0, 0, 0, 0).

    So your color coming from the lighting is modulated with your lightmap (which may make sense depending on what you’re trying to achieve). That gets added to your diffuse (where, as I said, it should probably get modulated instead).

    None of these change what I said earlier: write down exactly what math you would like for your result. From that we can help find which texture environment you may need. But you did not say what result you want to achieve.

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

Sidebar

Related Questions

I can disable one and one by doing this: jQuery('#ListBoxA').attr('disabled','true'); But how can I
I'm new to OpenGL/JOGL. I'm experimenting with lighting: gl.glEnable(GL2.GL_LIGHT1); gl.glEnable(GL2.GL_LIGHTING); When I disable the
I can disable viewstate of each control, but not entire page. Is there a
Can I disable the minimize button in JFrame? I have already tried setUndecorated() and
How can you disable the send -button if there is one or more input
I've just try to use Google docs and I see it can disable Ctrl
$(this).closest(fieldset).find(input:not(:checkbox), select,textarea).attr('disabled', this.checked); with this I can Disable Input,select,textarea how to do with the
Does anyone know if and how one can disable items in a databound ListBox
Using this rather neat approach I can disable weekends and holidays from the datepicker.
Here is table with email and checkbox cells. But how i can disable textwrapping?

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.