Pack TOP unpacking

Hi,

I was wondering if you could share the algorithm to unpack the PackTOP in order to be able to use the packed texture in other applications with spout etc. ?

Thanks!

You can check our git repository that does this. I cant remember everything in the repository but it should provide useful resources.

github.com/nVoid/Pixel-Packing-Examples

thanks, I was hoping to do the conversion on the GPU directly…
found this stackoverflow thread about it
stackoverflow.com/questions/184 … glsl-webgl
I’m struggling with the two different input sizes and the right sampling at the right point…

edit: ah nice, found the glsl example in one of the toe files… will have a look at it!

unfortunately I’m still lost on how to regenerate the original image with the right texture sampling method…

could the getTexel function be the right thing to look for?

In the last step of your unpack function you need to use uintBitsToFloat() to convert the uint to a float. Right now you are just straight casting the uint to a float, which is just keeping the interger value, rather than converting the binary bits from a uint representation to a float representation.

thanks!

It seems like i have the right lightness-values now, but somehow there are still a lot of artifacts and I’m really unsure whether my offset calculation is right…
Can you hint me in the right direction with this?

edit:
taking baby-steps… artifacts are gone, was due to half-texel-offset, but now the image is greyscale :smiley:

edited post:
made it work, not sure how well its done, but works for now:

[code]

ivec2 o_size = textureSize(sTD2DInputs[0],0);
vec2 offset = 1/o_size;
ivec2 pix_Coordinates = ivec2((vUV.s+0.5offset.x) * o_size.x, (vUV.t+0.5offset.y) * o_size.y );

vec4 pixelR = texelFetch(sTD2DInputs[1],ivec2(pix_Coordinates.x*4,gl_FragCoord.y),0);
vec4 pixelG = texelFetch(sTD2DInputs[1],ivec2(pix_Coordinates.x*4+1,gl_FragCoord.y),0);
vec4 pixelB = texelFetch(sTD2DInputs[1],ivec2(pix_Coordinates.x*4+2,gl_FragCoord.y),0);
vec4 pixelA = texelFetch(sTD2DInputs[1],ivec2(pix_Coordinates.x*4+3,gl_FragCoord.y),0);
fragColor = vec4(unpack(pixelR), unpack(pixelG),unpack(pixelB),unpack(pixelA));[/code]
1 Like