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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:09:24+00:00 2026-05-26T13:09:24+00:00

Im a bit stuck with my lighting. My light can light up meshes but

  • 0

Im a bit stuck with my lighting. My light can light up meshes but it does not light up my ground.

Here is some of my code

The light:

glEnable(GL_LIGHT0);

glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1.0f);
glEnable(GL_COLOR_MATERIAL);


GLfloat ambient_light0[] = { 0.5f, 0.5f, 0.5f, 1.0f };
GLfloat position_light0[] = { 0.0f, 8.0f, 0.0f, 0.9f };


GLfloat spotDirection_light0[] = {0.0, -1.0, 0.0 };
GLfloat specularLightcolor[] = { 1.0, 1.0, 1.0, 1.0 };
glLightfv( GL_LIGHT0, GL_POSITION, position_light0 );
glLightfv( GL_LIGHT0, GL_SPOT_DIRECTION, spotDirection_light0 );
glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION, 0.5);

glLightfv( GL_LIGHT0, GL_AMBIENT, ambient_light0 );
glLightfv(GL_LIGHT0, GL_SPECULAR, specularLightcolor);

glLightf( GL_LIGHT0, GL_SPOT_CUTOFF, 60.0f );
glLightf( GL_LIGHT0, GL_SPOT_EXPONENT, 50.0f );

The ground:

void drawGround(int id) {

glEnable(GL_TEXTURE_2D);

glEnable(GL_COLOR_MATERIAL);



getTexture(id);

glBindTexture(GL_TEXTURE_2D, id); 

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);



GLfloat material_diffuse[] = {0.9, 0.9, 0.9, 1.0 };

    GLfloat material_specular[] = { 1, 1, 1, 1 };



glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, material_diffuse);

glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, material_specular);


glBegin(GL_QUADS); 



for(int i = 0; i<3; i++){

    for(int j= 0; j<3; j++){

    glNormal3f(0.0f, 1.0f, 0.0f);

    glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse);

        glMaterialfv(GL_FRONT, GL_SPECULAR, material_specular);

        glMaterialf(GL_FRONT, GL_SHININESS, 80.0);



    glTexCoord2f(1, 1);

    glVertex3f(-floorSize +((j)*(2*floorSize)/3), 0 ,-floorSize +((i)*(2*floorSize)/3));

    glTexCoord2f(1, 0);     

    glVertex3f(-floorSize +((j)*(2*floorSize)/3), 0 ,-floorSize +((i+1)*(2*floorSize)/3));

    glTexCoord2f(0,0);  

    glVertex3f(-floorSize +((j+1)*(2*floorSize)/3), 0 ,-floorSize +((i+1)*(2*floorSize)/3));

    glTexCoord2f(0, 1);     

    glVertex3f(-floorSize +((j+1)*(2*floorSize)/3), 0 ,-floorSize +((i)*(2*floorSize)/3));


    }

}


glDepthMask( 1.0 );

glDisable(GL_TEXTURE_2D);

glEnd();

}

Drawing of the ground happens after the light is called.
Has anyone any idea why my ground is not lighting up?

here is a screen shot of my problem —> Image

  • 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-26T13:09:25+00:00Added an answer on May 26, 2026 at 1:09 pm

    The problem is, that default fixed function OpenGL lighting does the illumination at the vertices only, and then just interpolates the resulting color. Since all the 4 vertices of the ground are dimly lit, the whole quad gets dim.

    Solutions:

    • further subdivide your ground, so that there are more light sampling points. So far you’ve got only 3×3 points, which is not nearly sufficient. Think 100×100 or even more, to get a nice illumination effect.

    or

    • use a fragment shader to implement per pixel lighting.

    You’re running into a typical OpenGL newbie pitfall there, BTW.

    Update:

    On a side note: You also did not supply normals for the plane. Therefore lighting will not work at all.

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

Sidebar

Related Questions

I am a bit stuck here and can't think further. public struct CandidateDetail {
I'm a bit stuck on what is probably a common situation, but can't find
I'm a bit stuck, and probably not understanding AR properly. Here's what I've got:
Hey guys a bit stuck here. Ill first start with showing you the code.
I'm a bit stuck in a project. I was writing some code to get
So I am a bit stuck here, I can do it with foreach loop
im a bit stuck here. Some hints would be really nice. Asume i have
I'm a bit stuck with my code: def setVenueImage(img): img = images.Image(img.read()) x, y
I'm a bit stuck in developing an application with mono. So here's my question:
I'm a wee bit stuck on this, and was hoping you might have some

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.