I’m using glTexImage3D
to push a 3D texture (shadow map) to the shader. This works fine the first time. When the buffer changes, I need to push the texture again so that the shader sees the change. This does not work properly for some reason. Strangely, sometimes the shader does see some of the changes in the buffer, but not all of them.
glActiveTexture(glSamplerUnit)
glBindTexture(GL_TEXTURE_3D, samplerId)
glPixelStorei(GL_UNPACK_ROW_LENGTH, 0)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1)
checkGLError()
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_LINEAR)
glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
_buffer.position(0) // important!
glTexImage3D(
GL_TEXTURE_3D,
0, // mip map level, 0=base
GL_R8, // internal format
xsize,
ysize,
zsize,
0, // border
GL_RED, // format
GL_UNSIGNED_BYTE, // type
_buffer
)
checkGLError()
If I throw away the entire texture, create a new one and push the data, the updated data shows up fine.
I’m using the Java library lwjgl in a Kotlin/JVM project. The project is already quite large and working fine otherwise.