Hello Carsten,

first off, I'm not an expert with textures. First I will show you how I 
initialize my shadow maps in my plain OpenGL example. So that you 
understand what I want to map into OpenSG land.

Example: [1]

Next the sources I have studied:
https://www.khronos.org/opengl/wiki/Framebuffer_Object
https://www.khronos.org/opengl/wiki/Geometry_Shader#Layered_rendering

https://www.opengl.org/sdk/docs/man/html/glFramebufferTextureLayer.xhtml
https://www.opengl.org/sdk/docs/man/html/glFramebufferTexture.xhtml


I have reread these articles and I now tend to agree with you wrt to the 
LayeredTextureBuffer. However, the GL_TEXTURE_CUBE_MAP_ARRAY is missing 
nevertheless (?)

This stuff is not easy to grasp. Most important for me is that I have 
the OpenSG primitives at hand that I need to translate my plain OpenGL 
shadow implementation into OpenSG land.

Best,
Johannes


[1]
void OpenGLWindow::InitializeShadowFBO()
{
     if (_shadow_casters_point > 0)
     {
         glGenTextures(1, &_texture_shadow_array_point_id);
         glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 
_texture_shadow_array_point_id);

         glTexImage3D(
             GL_TEXTURE_CUBE_MAP_ARRAY,
             0,
             GL_DEPTH_COMPONENT,
             SHADOW_WIDTH,
             SHADOW_HEIGHT,
             6 * _shadow_casters_point,
             0,
             GL_DEPTH_COMPONENT,
             GL_FLOAT,
             nullptr);

         glTexParameteri (GL_TEXTURE_CUBE_MAP_ARRAY, 
GL_TEXTURE_MIN_FILTER,   GL_NEAREST);
         glTexParameteri (GL_TEXTURE_CUBE_MAP_ARRAY, 
GL_TEXTURE_MAG_FILTER,   GL_NEAREST);
         glTexParameteri (GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_S, 
      GL_CLAMP_TO_EDGE);
         glTexParameteri (GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_T, 
      GL_CLAMP_TO_EDGE);
         glTexParameteri (GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_WRAP_R, 
      GL_CLAMP_TO_EDGE);

         for (unsigned int i = 0; i < _shadow_casters_point * 6; i++)
         {
             GLuint fbo_id;
             glGenFramebuffers(1, &fbo_id);

             glBindFramebuffer(GL_FRAMEBUFFER, fbo_id);
             glFramebufferTextureLayer(GL_FRAMEBUFFER, 
GL_DEPTH_ATTACHMENT, _texture_shadow_array_point_id, 0, i);

             glDrawBuffer(GL_NONE);
             glReadBuffer(GL_NONE);

             glBindFramebuffer(GL_FRAMEBUFFER, 0);
         }

         glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, 0);
     }

     if (_shadow_casters_dir > 0)
     {
         glGenTextures(1, &_texture_shadow_array_dir_id);
         glBindTexture(GL_TEXTURE_2D_ARRAY, _texture_shadow_array_dir_id);

         glTexImage3D(
             GL_TEXTURE_2D_ARRAY,
             0,
             GL_DEPTH_COMPONENT,
             SHADOW_WIDTH,
             SHADOW_HEIGHT,
             _shadow_casters_dir,
             0,
             GL_DEPTH_COMPONENT,
             GL_FLOAT,
             nullptr);

         glTexParameteri (GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_S, 
GL_CLAMP_TO_BORDER);
         glTexParameteri (GL_TEXTURE_2D_ARRAY, GL_TEXTURE_WRAP_T, 
GL_CLAMP_TO_BORDER);

         GLfloat borderColor[] = { 1.0, 1.0, 1.0, 1.0 };
         glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, 
borderColor);
         glTexParameteri (GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, 
GL_NEAREST);
         glTexParameteri (GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, 
GL_NEAREST);

         for (unsigned int i = 0; i < _shadow_casters_dir; i++)
         {
             GLuint fbo_id;
             glGenFramebuffers(1, &fbo_id);

             glBindFramebuffer(GL_FRAMEBUFFER, fbo_id);
             glFramebufferTextureLayer(GL_FRAMEBUFFER, 
GL_DEPTH_ATTACHMENT, _texture_shadow_array_dir_id, 0, i);

             glDrawBuffer(GL_NONE);
             glReadBuffer(GL_NONE);

             glBindFramebuffer(GL_FRAMEBUFFER, 0);
         }
         glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
     }
  }



------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Opensg-users mailing list
Opensg-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensg-users

Reply via email to