Damn, i just came across a really strange behaviour.
My first test program was simply copying the hightmaps values into another image, using following code:
main.py:
from panda3d.core import Shader, ComputeNode, Texture, NodePath, ShaderAttrib, Filename
from panda3d.core import loadPrcFileData
loadPrcFileData("", "gl-debug #t")
from direct.directbase import DirectStart
# load source image
img_in = loader.loadTexture("hightmap.png")
img_in.setFormat(Texture.F_r16)
img_in.setName("img_in")
img_out = Texture("img_out")
img_out.setup2dTexture(8192,8192,Texture.T_float, Texture.F_r16)
img_out.makeRamImage()
img_out.setKeepRamImage(True)
shader = Shader.load_compute(Shader.SL_GLSL, "bw.glsl")
dummy = NodePath("dummy")
dummy.set_shader(shader)
dummy.set_shader_input("img_in", img_in)
dummy.set_shader_input("img_out", img_out)
sattr = dummy.get_attrib(ShaderAttrib)
base.graphicsEngine.dispatch_compute((8192/32, 8192/32, 1), sattr, base.win.get_gsg())
base.graphicsEngine.extractTextureData(img_out,base.win.get_gsg())
img_out.setFormat(Texture.F_luminance)
img_out.write(Filename("output.png"))
bw.glsl:
#version 430
// Declare the texture inputs
layout (binding=0, r16) readonly uniform image2D img_in;
layout (binding=1, r16) writeonly uniform image2D img_out;
layout (local_size_x = 32, local_size_y = 32) in;
void main() {
ivec2 texelCoords = ivec2(gl_GlobalInvocationID.xy);
vec4 pixel = imageLoad(img_in, texelCoords);
imageStore(img_out, texelCoords, pixel);
}
At the Beginning, all looked fine. When comparing the images in win media player, i saw the same image.
but somehow, output texture, althought in 16bit format, is just halph the size of the original file,
from 68867kb to 31068kb
Any Idea how this could happen?