Hola,
I have been tinkering around with volume rendering to make volumetric clouds. I came across a decent nVidia demo on rendering to a 3d texture using FBOs and blending with ray marching in a shader program.
My goal is to make a 3d noise texture using libnoise and add that into the blending equation. The problem I’m having is when I create my 3d noise texture, it’s only filling up about 1/3 of what it should (the block in the picture):
Here’s how I go about creating it…it’s using the same dimensions as the textures used to make the rest of the volume, but I am uncertain about the [widthheightdepth*4] part.
T* texPtr = new T[width*height*depth*4]; // it's templated
int x, y, z;
unsigned nPointsInSlice = width*height;
for (z = 0; z < depth; ++z)
{
for (y = 0; y < height; ++y)
{
for (x = 0; x < width; ++x)
{
T noise = (T)scaleBias.GetValue(x, y, z);
texPtr[(z*nPointsInSlice + y*width + x)] = noise;
}
}
}
GLuint id;
glGenTextures(1, &id);
glActiveTextureARB(texUnit);
glBindTexture(GL_TEXTURE_3D, id);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_WRAP_R, GL_REPEAT);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA16F_ARB, width,
height, depth, 0, GL_RGBA, dataType, texPtr);
I looked all over, but all I’ve found assumes that what I’m missing is simple I guess.
Thanks in advance.