Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 1 of 1

Thread: [Shadow] I have strange result from depth buffer.

  1. #1
    Newbie Newbie
    Join Date
    Aug 2017
    Posts
    2

    [Shadow] I have strange result from depth buffer.

    Hello, mates.

    I have strange result from depth buffer while working on shadows from directional light.

    Click image for larger version. 

Name:	pro0_strangeDepth.jpg 
Views:	81 
Size:	8.2 KB 
ID:	2441

    The bunny and sphere have artifacts.

    Could you guys help me to figure out what the problem is?

    The funny thing is when I drew only a quad, it looks like working.

    Click image for larger version. 

Name:	pro0_strangeDepth2.jpg 
Views:	74 
Size:	7.5 KB 
ID:	2442


    Therefore, I've checked the models are okay.

    Click image for larger version. 

Name:	pro2_camView.jpg 
Views:	75 
Size:	4.6 KB 
ID:	2443

    Unfortunately, it looks like the models are not problem.

    I also checked the light's view.

    Here's how I constructed the light view.

    Code :
    // Bring its direction from rotation factor at Transform Component
    // The location factor is converted like PhysicalLength * -(Rotation)
    // Physical length is 5.0f by default
    mat4 EntityDirectionalLight::GetViewMatrix()
    {
      using namespace ComponentHelper;
      assert(this->GetComponent<CameraComponent>() != nullptr);
      assert(this->GetComponent<TransformComponent>() != nullptr);
     
      auto cCamera = this->GetComponent<CameraComponent>()
      auto cTrans = this->GetComponent<TransformComponent>();
      if (cCamera->mFlag & CameraEnum::EViewUpdatable)
      {
        cCamera->SetViewMatrix(
          glm::lookat(cTrans->GetLocation // eye
            , cTrans->GetLocation() + cTrans->GetRotation() // center
            , vec3(0.0f, 1.0f, 0.0f) // up
          ));
      }
      return cCamera->GetViewMatrix();
    }

    Click image for larger version. 

Name:	pro1_lightView.jpg 
Views:	73 
Size:	4.0 KB 
ID:	2444


    It's from the light view. I, also, think light view matrix looks okay.

    Projection matrix is constructed by glm:rtho(-10.0f, 10.0f, -10.0f, 10.0f, near, far);
    near and far are 0.1f and 10.0f by default.

    I also tried to change the near from 0.1f to 0.01f because objects might be too close to the near clip plane.

    However, the result is still same with the first picture that I've attached.

    The depth test is enabled, of course and depth function's flag is GL_LEQUAL ( I also tried GL_LESS )

    The color buffer from the depth frame buffer is using GL_RED and GL_R32F as its texture format and internal format.

    I would appreciate so much if you give me what possible problems are.

    Thank you for reading it!
    Last edited by jerome503; 08-12-2017 at 02:44 PM. Reason: formatting

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •