View Full Version : readPixels right with small accuracy?
02-19-2010, 08:14 AM
is this correct? The best accuracy of readPixels in WebGL is GL_UNSIGNED_BYTE (8Bit for every color channel) ?
Actually I use readPixels to get the surfacepoint of an object. I draw the object with colored objectcoords. (left point X is dark red, right point X is bright red, Y is green and Z is blue) I get the RGB Color and I can calculate the surface point.
But with 8Bit there are only 256 different points per axle. The gl_fragcolor use float per color.
There are only shortInt packed formats not implemented yet? All colors packed into 16 Bit?
So I have to combine the 8 Bits three times to get 16Mio Points per axle and redraw the object 3 times for every axle?
Sorry about my english.
>Actually I use readPixels to get the surfacepoint of an object.
The search term you're looking for is "picking". (Search for: "opengl es" picking)
02-20-2010, 03:24 AM
You can use RGBA color, so you have 2^32 = 4.2 billion possible colors. How many triangles/objects do you want to render?
Once you got the exact triangle you just have to intersect the cursor ray with this single triangle to get the exact surface point.
02-20-2010, 04:14 AM
I paint on the surface. So it is easiest to me to draw the object one or three time to an texture/hidden framebuffer/array with objectcoords. On drawing it took the right surfacepoint from the buffer without calculating rays and collisions, or?
If i use Alpha, the backgroundcolor would not destroy the RGB value? (RGB = 24Bit is very good, the display resolution reduces the accuracy too (x=1280 pixel or less or so ... but more than 8Bit :>))
So there will be no more than 8 Bits per color Channel, right? (readpixels at WebGL)
Pic shows the colored objectcoords
02-20-2010, 04:44 AM
On drawing it took the right surfacepoint from the buffer without calculating rays and collisions, or?
That might work on normal OpenGL, but not on WebGL because it would require a high color resolution.
If i use Alpha, the backgroundcolor would not destroy the RGB value?
That's not a problem if Blending is disabled an you do render into a framebufferobject (FBO).
So there will be no more than 8 Bits per color Channel, right?
Yes, floating point textures are not supported.
However, if you want to paint on the surface you need texture coordinates, not the actual 3D location of the surface point, correct? That way you only need two coordinates instead of three. Using RGBA you have 16bit per axis, which allows a texture size of 65536x65536, what should be large enough. You can use these texture coordinates to render into the "paint"-texture.
02-20-2010, 05:54 AM
I send you a pm to solve some things in german :)
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.