Jump to content
  • Advertisement
Sign in to follow this  
Paul Griffiths

Render cubemap texture to cubemap framebuffer?

This topic is 715 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Im receiving an eror:


The fragment shader uses varying TexCoords,l but previous shader does not write to it.


geometry shader:


#version 330 core
layout (triangles) in;
layout (triangle_strip, max_vertices=18) out;
void main()
    for(int face = 0; face < 6; ++face)
        gl_Layer = face; // built-in variable that specifies to which face we render.
        for(int i = 0; i < 3; ++i) // for each triangle's vertices
            gl_Position = gl_in.gl_Position;





vetex shader:


#version 330 core
layout (location = 0) in vec3 position;
layout (location = 1) in vec2 texCoords;

out vec2 TexCoords;

void main()
    gl_Position = vec4(position, 1.0f);
    TexCoords = texCoords;





fragment shader:


#version 330 core

in vec2 TexCoords;
out vec4 FragColor;
uniform samplerCube depthMap;

void main()
    FragColor = textureCube(depthMap, vec3(TexCoords, 1.0f));



render code;


void RenderQuad()
    if (quadVAO == 0)
        GLfloat quadVertices[] = {
            // Positions        // Texture Coords
            -1.0f, 1.0f, 0.0f, 0.0f, 1.0f,
            -1.0f, -1.0f, 0.0f, 0.0f, 0.0f,
            1.0f, 1.0f, 0.0f, 1.0f, 1.0f,
            1.0f, -1.0f, 0.0f, 1.0f, 0.0f,
        // Setup plane VAO
        glGenVertexArrays(1, &quadVAO);
        glGenBuffers(1, &quadVBO);
        glBindBuffer(GL_ARRAY_BUFFER, quadVBO);
        glBufferData(GL_ARRAY_BUFFER, sizeof(quadVertices), &quadVertices, GL_STATIC_DRAW);
        glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)0);
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 5 * sizeof(GLfloat), (GLvoid*)(3 * sizeof(GLfloat)));
    glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);




Any ideas?


thank you.


more code:


for (GLuint light = 0; lightCount < 4; ++light)
            glBindFramebuffer(GL_FRAMEBUFFER, depthMapFBO[lightCount]);
            // 1. Render scene to depth cubemap
            glViewport(0, 0, SHADOW_WIDTH, SHADOW_HEIGHT);
            glUniform1i(glGetUniformLocation(shaderMultipassShadows.Program, "depthMap"), 1);
            glBindTexture(GL_TEXTURE_CUBE_MAP, depthCubemap[light]);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!