View Issue Details

IDProjectCategoryView StatusLast Update
0032173Open CASCADEOCCT:Visualizationpublic2024-04-11 19:57
Reporterkgv Assigned Todrochalo  
PrioritylowSeverityfeature 
Status resolvedResolutionopen 
Product Version7.8.1 
Target Version7.9.0 
Summary0032173: Visualization, TKOpenGl - implement simple shadow mapping for a point light source
DescriptionIt is necessary extending shadow maps introduced by 0032039 to support point light sources.
TagsNo tags attached.
Test case numberopengl/shadows/pointlight

Relationships

child of 0031646 newiko Visualization - shadow mapping within real-time renderer 

Activities

git

2024-02-15 15:17

administrator   ~0115099

Branch CR32173_1 has been created by drochalo.

SHA-1: e94bf82880813b3615416592ba3e885b0079e3d5


Detailed log of new commits:

Author: drochalo
Date: Mon Feb 12 17:01:22 2024 +0000

    0032173: Visualization, TKOpenGl - implement simple shadow mapping for a point light source
    
    Debugging changes.

Author: drochalo
Date: Mon Feb 5 15:11:09 2024 +0000

    0032173: Visualization, TKOpenGl - implement simple shadow mapping for a point light source
    
    Startup changes.

git

2024-02-27 18:28

administrator   ~0115180

Branch CR32173_1 has been updated by drochalo.

SHA-1: fbeef208d8f2be37dc69da922cc1d333872cdb43


Detailed log of new commits:

Author: drochalo
Date: Tue Feb 27 14:56:58 2024 +0000

    0032173: Visualization, TKOpenGl - implement simple shadow mapping for a point light source
    
    Modified shadowmap calculations to include multipass for point lights.
    Added shader funtions to calculate point light shadows.
    Added getter for default znear and zfar values in Graphic3d_Camera.
    Added direction and up vector calulations on Graphic3d_CubeMap.
    Added test case.

git

2024-03-04 21:23

administrator   ~0115229

Branch CR32173_1 has been updated by drochalo.

SHA-1: d2ec9717ff22abd60711d742cce669e396d522d0


Detailed log of new commits:

Author: drochalo
Date: Thu Feb 29 11:37:05 2024 +0000

    Minor fix.

git

2024-03-05 19:19

administrator   ~0115234

Branch CR32173_1 has been updated forcibly by drochalo.

SHA-1: 48f8f1e6ea9662512c1c049e1d8a14c64b90527a

drochalo

2024-03-11 19:27

developer   ~0115319

Dear Ilya,

please review this issue.
Tests in Jenkins shows minor issues, but that are not related to the changes made:
http://jenkins-test-10.nnov.opencascade.com/view/CR32173_1-master-drochalo/view/COMPARE/

iko

2024-04-04 17:04

developer   ~0115582

//! return default valut for znear.
Standard_EXPORT Standard_Real GetDefaultZNear();

//! return default valut for zfar.
Standard_EXPORT Standard_Real GetDefaultZFar();

Should be static.

gp_Dir Graphic3d_CubeMap::GetCubeDirection (Graphic3d_CubeMapSide theFace)
{
  gp_Dir aResult;
  switch (theFace)
  {

gp_Dir Graphic3d_CubeMap::GetCubeUp (Graphic3d_CubeMapSide theFace)
{
  gp_Dir aResult;
  switch (theFace)
  {

Algorithm can be used instead of 'switch'.

//if (!aLight->IsEnabled())
//{
//  continue;
//}

Commented code.

if (theIsCubeMap)
{
  for (Standard_Integer aCubeFace = 0; aCubeFace < 6; ++aCubeFace)
  {
    theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
                                                  GLenum(GL_TEXTURE_CUBE_MAP_POSITIVE_X + aCubeFace),
                                                  myDepthStencilTexture->TextureId(), 0);
  }
}

for (Standard_Integer aCubeFace = 0; aCubeFace < 6; ++aCubeFace)
{
  theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
                                                GLenum(GL_TEXTURE_CUBE_MAP_POSITIVE_X + aCubeFace),
                                                myDepthStencilTexture->TextureId(), 0);
  theGlContext->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT,
                                                GLenum(GL_TEXTURE_CUBE_MAP_POSITIVE_X + aCubeFace),
                                                myDepthStencilTexture->TextureId(), 0);
}

After this code only last side of cubemap is always attached. There is just 6 time reattaching of the same slot in framebuffer.

void OpenGl_FrameBuffer::BindBufferCube (const Handle(OpenGl_Context)& theGlCtx, const Standard_Integer theFace)
{
  theGlCtx->arbFBO->glBindFramebuffer (GL_DRAW_FRAMEBUFFER, myGlFBufferId);
  theGlCtx->arbFBO->glFramebufferTexture2D (GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT,
                                            GLenum(GL_TEXTURE_CUBE_MAP_POSITIVE_X + theFace),
                                            myDepthStencilTexture->TextureId(), 0);
}

During building FBO there are two different cases when dpeth and stencil are attached together and separate. There is only one.

// point light shadows are not currently supported on opengles 2.0

What is the reason? Does it support regular 2D shadow maps?

const gp_Pnt& aLightPos = myShadowLight->Position();

Redundant variable used only once.

myShadowCamera->SetZRange (1.0, myShadowCamera->GetDefaultZFar());

There could be range of light source.

case Graphic3d_TypeOfTexture_CUBEMAP:
{
  Bind (theCtx);
  applyDefaultSamplerParams (theCtx);
  if (theCtx->GraphicsLibrary() == Aspect_GraphicsLibrary_OpenGL)
  {
    // use proxy to check texture could be created or not
    theCtx->core11fwd->glTexImage2D (GL_PROXY_TEXTURE_2D, 0, anIntFormat,
                                     theSizeXYZ.x(), theSizeXYZ.y(), 0,
                                     theFormat.PixelFormat(), theFormat.DataType(), NULL);
    theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &aTestWidth);
    theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &aTestHeight);
    theCtx->core11fwd->glGetTexLevelParameteriv (GL_PROXY_TEXTURE_2D, 0, GL_TEXTURE_INTERNAL_FORMAT, &mySizedFormat);

There is GL_PROXY_TEXTURE_CUBE_MAP.

// set znear and zfar
float aNear = POINTLIGHT_ZNEAR;
float aFar = POINTLIGHT_ZFAR;

Hardcoded values.

Please add to test dump of cube shadow map.

git

2024-04-11 19:57

administrator   ~0115690

Branch CR32173_1 has been updated by drochalo.

SHA-1: 102278b9feb1d2174109bab2f297e7852ffdb9fe


Detailed log of new commits:

Author: drochalo
Date: Thu Apr 11 17:53:27 2024 +0100

    0032752: Visualization, TKOpenGl - extend V3d_View::ToPixMap() options with Z-layer
    
    Changed shadow cubemap calculation of up and direction vectors.
    Included point light range to shader calculations.
    Replaced use of define values in shaders for uniforms vectors with range
    parameters.
    Code cleanup.

Issue History

Date Modified Username Field Change
2021-02-25 21:53 kgv New Issue
2021-02-25 21:53 kgv Assigned To => osa
2021-02-25 21:53 kgv Relationship added child of 0031646
2021-02-25 21:54 kgv Description Updated
2021-02-25 21:54 kgv Summary 0032172: Visualization, TKOpenGl - implement simple shadow mapping for a point light source => Visualization, TKOpenGl - implement simple shadow mapping for a point light source
2021-08-24 14:19 kgv Target Version 7.6.0 => 7.7.0
2022-08-17 11:57 kgv Target Version 7.7.0 => 7.8.0
2023-08-01 15:09 dpasukhi Target Version 7.8.0 => Unscheduled
2023-12-22 17:44 drochalo Assigned To osa => drochalo
2024-02-09 14:36 drochalo Target Version Unscheduled => 7.9.0
2024-02-09 14:37 drochalo Priority normal => low
2024-02-12 19:53 drochalo Time allocated 12.2.2024: 8 h. => set
2024-02-15 15:17 git Note Added: 0115099
2024-02-27 18:28 git Note Added: 0115180
2024-03-04 21:23 git Note Added: 0115229
2024-03-05 19:19 git Note Added: 0115234
2024-03-11 19:27 drochalo Note Added: 0115319
2024-03-11 19:29 drochalo Assigned To drochalo => iko
2024-03-11 19:29 drochalo Status new => resolved
2024-03-11 19:29 drochalo Test case number => opengl/shadows/pointlight
2024-03-25 12:51 dpasukhi Product Version => 7.8.1
2024-04-04 17:04 iko Note Added: 0115582
2024-04-04 17:04 iko Assigned To iko => drochalo
2024-04-11 19:57 git Note Added: 0115690