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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:23:43+00:00 2026-06-14T17:23:43+00:00

I am trying to do OpenGL GLSL based shadow mapping. The trouble is that

  • 0

I am trying to do OpenGL GLSL based shadow mapping. The trouble is that after I have finished rendering the shadow map, I am rendering the map to the screen to test whether the rendering works correctly or not i.e I am simply using the newly generated texture as a texture which I am mapping on to the screen. The expected result is that I will see the new texture. But instead, what i am seeing is a white area with the texture drawn but extremely faint. That is, if I tilt the screen at a certain angle only then I can see the faint outlines of the shadow map.

Can anyone tell me if I am doing anything wrong?

Here is relevant parts of my code :

     void Init_FBO() 
    { 
            //glActiveTexture(GL_TEXTURE3);  
        GLfloat border[] = {1.0f, 0.0f, 0.0f, 0.0f};  

        glGenTextures(1, &depthTex);  
        glBindTexture(GL_TEXTURE_2D, depthTex);  
        glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24,900,900, 0, GL_DEPTH_COMPONENT, GL_FLOAT, NULL);  
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);  
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);  
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);  
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);  
        glTexParameterfv(GL_TEXTURE_2D, GL_TEXTURE_BORDER_COLOR, border);  
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);  
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC, GL_LESS);
        glBindTexture(GL_TEXTURE_2D,0); 

        glGenFramebuffers(1, &shadowFBO);  
        glBindFramebuffer(GL_FRAMEBUFFER, shadowFBO);  
        glDrawBuffer(GL_NONE);  
        glReadBuffer(GL_NONE);  
        glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTex, 0);  
        glBindFramebuffer(GL_FRAMEBUFFER, 0); // go back to the default framebuffer  
        // check FBO status 
        GLenum FBOstatus = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER); 
        if(FBOstatus != GL_FRAMEBUFFER_COMPLETE) 
        {
            printf("GL_FRAMEBUFFER_COMPLETE failed, CANNOT use FBO\n");
        }
        else
        {
            printf("Frame Buffer Done Succesfully\n");
        } 
    }




    void generateShadowTex()
    {
            //Calculate final ligting properties
        glm::vec4 a_f=light_ambient*mat_ambient;
        glm::vec4 d_f=light_diffuse*mat_diffuse;
        glm::vec4 s_f=light_specular*mat_specular;
        int counter=0;
        glEnable(GL_DEPTH_TEST);    // need depth test to correctly draw 3D objects 
        glClearColor(0,0,0,1); 
        //glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 
        glClear(GL_DEPTH_BUFFER_BIT); 
        glCullFace(GL_FRONT);
        if(wframe)
            glPolygonMode(GL_FRONT_AND_BACK,GL_LINE); 
        else
            glPolygonMode(GL_FRONT_AND_BACK,GL_FILL); 


        glUseProgram(programObject);
        //Draw the stuff using Light Position as camera 
        //glutSwapBuffers();
        glActiveTexture(GL_TEXTURE3);
        glBindTexture(GL_TEXTURE_2D,depthTex);
        glUseProgram(0);  

    }

void generateScene()
{
        //Calculate final ligting properties
    glm::vec4 a_f=light_ambient*mat_ambient;
    glm::vec4 d_f=light_diffuse*mat_diffuse;
    glm::vec4 s_f=light_specular*mat_specular;
    int counter=0;
    glEnable(GL_DEPTH_TEST);    // need depth test to correctly draw 3D objects 
    glClearColor(0,0,0,1); 
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT); 

    //Draw the stuff using camera as camera position

    }
    glutSwapBuffers();
    glUseProgram(0);  

}



void display() 
{
    glBindFramebuffer(GL_FRAMEBUFFER, shadowFBO); 
    generateShadowTex(); 
    glBindFramebuffer(GL_FRAMEBUFFER, 0); 
    generateScene(); 
}
  • 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-14T17:23:44+00:00Added an answer on June 14, 2026 at 5:23 pm

    your depth texture is looking normally, depth covers range from near to far clip planes, you can set some reasonable clipping planes using glFrustumf(...)

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

Sidebar

Related Questions

I am trying to get shadow mapping working using GLSL. Unfortunately my depth render
I've been trying to implement GLSL into my program, however given that i have
I'm trying to learn to play with OpenGL GLSL shaders. I've written a very
I'm trying to read some OpenGL tutorials on the net. the problem is that
I'm trying to get MRT working in OpenGL to try out deferred rendering. Here's
I am trying to use GLSL with openGL 2.0. Can anyone give me a
I'm trying to use opengl in C#. I have following code which fails with
I'm trying to make OpenGL draw the figure that I'm loading with OPENFILENAME .
I am trying to study OpenGL and I have the framework added, but I
I have been trying to understand OpenGL ES 2.0 on the iPhone for quite

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.