Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void createCubemapArray(GLuint& cubemap)
- {
- //Generate an array texture
- glGenTextures(1, &cubemap);
- glBindTexture(GL_TEXTURE_CUBE_MAP_ARRAY, cubemap);
- //Create storage for the texture. (4 layers of 1x1 texels)
- glTexStorage3D(GL_TEXTURE_CUBE_MAP_ARRAY,
- 1, //No mipmaps as textures are 1x1
- GL_RGB8, //Internal format
- width, height, //width,height
- 4 //Number of layers
- );
- for (unsigned int i(0); i != 4; ++i)
- {
- glTexSubImage3D(GL_TEXTURE_CUBE_MAP_ARRAY,
- 0, //Mipmap number
- 0, 0, i, //xoffset, yoffset, zoffset
- 1, 1, 1, //width, height, depth
- GL_RGB, //format
- GL_UNSIGNED_BYTE, //type
- 0); //pointer to data
- }
- glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
- glTexParameteri(GL_TEXTURE_CUBE_MAP_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
- 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);
- }
- vec3 position = mirrorCam.getPosition();
- view = look_at(position, position + normalise(viewsX[i]), vec3(0.0, -0.5, -0.5));
- drawloop(view, proj, fb[0][i].framebuffer);
- glFramebufferTexture3D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, cubemapArray, 0, 0);
- glBindTexture(GL_TEXTURE_2D, cubemapArray);
- glUniform1i(glGetUniformLocation(reflectiveShaderID, "cube_array"), 0);
- uniform samplerCube cube_texture;
- //....
- void main()
- {
- //...
- fragment_color = texture(cube_array, vec4(textureCoordinates, 0));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement