Sign in to follow this  

Render cubemap texture to cubemap framebuffer?

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[i].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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this