We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is it possible to throw 16-bits/channel image data back and forth to a shader and then save it as a 48-bit PNG in Processing? Has anyone done anything like this?
For the adventurers who find their way to this question, looking for an answer, this should theoretically work.
In your shader, pack the result
vec4 pack (float depth) { const vec4 bitSh = vec4(256 * 256 * 256, 256 * 256, 256, 1.0); const vec4 bitMsk = vec4(0, 1.0 / 256.0, 1.0 / 256.0, 1.0 / 256.0); vec4 comp = fract(depth * bitSh); comp -= comp.xxyz * bitMsk; return comp; }
And in your sketch, unpack it
float unpack (vec4 colour) { const vec4 bitShifts = vec4(1.0 / (256.0 * 256.0 * 256.0), 1.0 / (256.0 * 256.0), 1.0 / 256.0, 1); return dot(colour , bitShifts); }
Credit for this goes to stackoverflow (I .. think), I lost the original source. : (
Answers
For the adventurers who find their way to this question, looking for an answer, this should theoretically work.
In your shader, pack the result
And in your sketch, unpack it
Credit for this goes to stackoverflow (I .. think), I lost the original source. : (