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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:44:57+00:00 2026-05-11T03:44:57+00:00

According to ARB_geometry_shader4 it is possible to render a scene onto the 6 faces

  • 0

According to ARB_geometry_shader4 it is possible to render a scene onto the 6 faces of a cube map with a geometry shader and the cube map attached to a framebuffer object. I want to create a shadow map using this way. However there seems to be a conflict that I can’t resolve:

  1. I can only attach a texture with GL_DEPTH_COMPONENT as internal type to the GL_DEPTH_ATTACHMENT_EXT.
  2. A depth texture can only be 1D or 2D.
  3. If I want to attach a cube map, all other attached textures must be cube maps as well.

So it looks like I can’t use any depth testing when I want to render to a cube map. Or what exactly am I missing here?

EDIT: It looks like newer Nvidia drivers (180.48) support depth cube maps.

  • 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. 2026-05-11T03:44:58+00:00Added an answer on May 11, 2026 at 3:44 am

    Ok, to answer some other questions here:

    Of course it is possible to use 6 FBOs, one for each face. Or to use one FBO and attach each face before you draw to it. In both cases the cube map face will be treated like any other 2D texture and you can use it together with normal 2D textures or Renderbuffers. And there’s probably not much of a difference in all the possible ways (if the hardware supports them).

    However, it’s also possible to draw everything in one step and as I was curious as to how this is done I did some research.

    To create a FBO with all faces of a cube map attached to a single attachment point I used this code (written in D):

    // depth cube map glGenTextures(1, &tDepthCubeMap); glBindTexture(GL_TEXTURE_CUBE_MAP, tDepthCubeMap); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); for (uint face = 0; face < 6; face++) {     glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_DEPTH_COMPONENT24,         width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT, null); }  // color cube map glGenTextures(1, &tColorCubeMap); glBindTexture(GL_TEXTURE_CUBE_MAP, tColorCubeMap); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameterf(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); for (uint face = 0; face < 6; face++) {     glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, GL_RGBA,         width, height, 0, GL_RGBA, GL_FLOAT, null); }  // framebuffer object glGenFramebuffersEXT(1, &fbo); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo); glFramebufferTextureARB(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, tDepthCubeMap, 0); glFramebufferTextureARB(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, tColorCubeMap, 0);  glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT);  if (!isValidFBO()) {     glDeleteFramebuffersEXT(1, &fbo);     fbo = 0; } 
    • If you want to have only a depth map you have to change glDrawBuffer(GL_COLOR_ATTACHMENT0_EXT); to glDrawBuffer(GL_NONE); before validating it (and before drawing to it)
    • MIN and MAG filters must be set to something valid (default would be GL_NEAREST_MIPMAP_LINEAR)
    • width and height of all textures must be the same

    To render to the faces of a cube map you need a geometry shader. The following shader misses some rotations but it should be clear what it does. gl_Layer is used to direct the primitive to the correct face (0 = +X, 1 = -X, …).

    #version 120 #extension GL_EXT_geometry_shader4 : enable  void main(void) {     int i, layer;     for (layer = 0; layer < 6; layer++) {         gl_Layer = layer;         for (i = 0; i < 3; i++) {             gl_Position = gl_PositionIn[i];             EmitVertex();         }         EndPrimitive();     } } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

According To reflector , ExpandoObject Does implemenet IDictionary<string, object> How ever I have this
According to this article Silverlight 2 Beta 2 supports the DataContractJsonSerializer object. But, when
According to a tutorial I am reading, if you want to create a table
According to Mark's awesome tutorial page, The map function applies a given function that
According to what I've heard, integer values that are not the processor's word size
According to Steffen's post this is an efficient way to generate random BOOL s
According to the documentation , socket_read() is supposed to return FALSE when the remote
According to Microsoft , you must sign your ClickOnce application. But it seems to
According to JavaScript Patterns book (p. 79), this should work: var ob = {
according to my knowledge, this feature already exists in PHP. lets look at the

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.