SpiderPig Posted January 10 Share Posted January 10 I have packed integers and floats into a texture to use in my shader. Information is packed into the texture by poking a buffer and then assigning that buffer to an RGBA texture. The following code extracts an integer from a texelFetch result in the fragment shader. It seems to work well. int BytesToInteger( in vec4 pixel ) { return ( int( ( pixel.w * 255.0f ) ) << 24 ) | ( int( ( pixel.z * 255.0f ) ) << 16 ) | ( int( ( pixel.y * 255.0f ) ) << 8 ) | int( ( pixel.x * 255.0f ) ); } However the same process does not work for floats and I'm sure there is a reason why but I can't figure it out. Any one know the answer? float BytesToFloat( in vec4 pixel ) { return float( ( int( ( pixel.w * 255.0f ) ) << 24 ) | ( int( ( pixel.z * 255.0f ) ) << 16 ) | ( int( ( pixel.y * 255.0f ) ) << 8 ) | int( ( pixel.x * 255.0f ) ) ); } Quote Link to comment Share on other sites More sharing options...
Solution SpiderPig Posted January 10 Author Solution Share Posted January 10 intBitsToFloat() Funny how simply making a post can make the answer show up on your next google search. 1 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.