Hi everyone,
For a Global Illumination project, I want to compute the GI of the screen by splitting it into patches of size 32x32 and compute the visibility of each pixels of the patch from there (this is a naive implementation of GI but the first step of my project). Therefore, for each pixel in the patch, I render the scene on a hemicube (5 faces), get the result the rasterization, build a mega texture with the result of each face of each pixel in the patch, and pass that texture to the fragment shader who will apply the BRDF convolution from there.
As a first step, a face on the hemicube is 128x128 pixels and there are 5 faces of them. So, for one single patch, I’ve got 32 x 32 x 128 x 128 x 5 pixels in my mega texture. This is almost 3 Gb of data here.
But let’s say that this is not a big deal for now.
I create an OpenGL texture of size Width=32x32x128x128x5 and Height=1 and sets it as uniform in order to feed it to my fragment shader.
Now I only need to sample it correctly, but I don’t know how simple it is to sample from such a huge texture.
So I did the following code to check that I indeed get some colors from my CPU :
uniform sampler2D MegaTexture;
// (...)
float MegaTextureSize = textureSize(MegaTexture, 0).x;
float MegaTexelSize = 1.0f / textureSize(MegaTexture, 0).x;
Color = vec4(0.0f, 0.0f, 1.0f, 1.0f); // I chose blue because there is no blue in my test scene, si the result should not be blue
for(int TexelIndex = 0; TexelIndex < MegaTextureSize; ++TexelIndex)
{
vec2 MegaCoord = vec2(float(TexelIndex) / MegaTexelSize, 0.0f);
vec4 MegaPixel = texture(MegaTexture, MegaCoord);
if(length(MegaPixel.xyz) > 0.2f)
{
Color = MegaPixel;
Color.w = 1.0f;
break;
}
}
It basically checks if I get some color from the MegaTexture but I can see from this code that I basically get nothing and I know that the MegaTexture pixel array, on the CPU side, does not contains black only.
So. My questions are :
(A) Can I create such a huge texture in OpenGL ? 3 Gb is already a big deal. Should I split the MegaTexture into, for example, 5 MegaTextures (one for each face of the hemicubes) ? Should I give them a Height greater than 1 ?
(B) Is my sampling correct ? I think so but since I’m using such thin texture and not usual ones (such as texture maps and normal maps), I’m afraid I should not sample it this way.
Thanks a lot
Rivten.