Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

24-bit float precision in color vectors?

Jack Abraham
Lantern By Day
Join date: 11 Apr 2008
Posts: 113
01-07-2010 09:19
Has anyone tested whether color data in a prim retains the full 24-bit float precision of the floats comprising the vector? I'm looking to store some non-color data in there (using a transparent texture to hide the prim) and I'm hoping someone can save me testing whether it's all retained.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
01-07-2010 09:22
I'm pretty sure prims only store 8 bits each of R, G, and B.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-07-2010 11:11
I know they'll store outside the range of 0.0 to 1.0, an that data outside that range will be read as the closest limit for the purpose of color ... but I don't remember if any greater precision is retrievable... you'd have to test.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
01-07-2010 12:27
In order to accurately store the values 0-255 in a float range of 0.0-1.0, you have to consider the representation of 1.0 / 255 and all multiples of it.

Normally, if the values were 0-256, it would be a trivial and exact representation using only up to 8 bits of significance (1/256 is 0.00000001 in binary). However, since the range is 0-255, there might not be exact representations, but depending on how they turn them back into 8-bit values, it could still return correct integer values without any conversion loss.

At least, as far as standard float tests are concerned, it seems to work fine, no rounding error is observed.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
01-07-2010 12:32
I think you have that backwards, Tal. 0..255 (256 values) can be perfectly mapped to binary floating point, but 0..256 (257 values) can't.
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
01-07-2010 12:33
Oh, and to answer the question, yes, the value is still retained as a full vector. The color is interpreted from the actual data, and clamped during the conversion process for display. The stored color value is not affected, unless you fiddle with it in the editor.
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
01-07-2010 12:54
From: Argent Stonecutter
I think you have that backwards, Tal. 0..255 (256 values) can be perfectly mapped to binary floating point, but 0..256 (257 values) can't.


No, it is correct. Remember, you're mapping from 0.0 to 1.0, not 0.0 to the division just shy of 1.0. There are actually only 255 divisions and 256 points. To get 256 divisions, you have to have 257 points.

0-255:

0 -> 0.0/255.0 = 0.0
1 -> 1.0/255.0 = 0.003921568627450980392156862745098d ~= 0.00000001000000010000001b
...
254 -> 254.0/255.0 = 0.9960784313725490196078431372549d ~= 0.11111110111111101111111b
255 -> 255.0/255.0 = 1.0d = 1.0b

0-256:
0 -> 0.0/256.0 = 0.0
1 -> 1.0/256.0 = 0.00390625d = 0.00000001b
...
255 -> 255.0/256.0 = 0.99609375d = 0.11111111b
256 -> 256.0/256.0 = 1.0d = 1.0b
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
01-07-2010 14:04
Doh!
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
Meade Paravane
Hedgehog
Join date: 21 Nov 2006
Posts: 4,845
01-07-2010 14:24
/me wonders if anybody is going to just test it and see what happens.

vector colorIn = <0.000001, 0.000002, 0.000003>;

llSetColor (colorIn, 0);

if (llGetColor(0) != colorIn)
llOwnerSay ("Bah!";);
else
llOwnerSay ("Yay!";);

er.. can you compare vectors like that? IIRC seems busted.

edit: or whatever min/max float values you want to use.
_____________________
Tired of shouting clubs and lucky chairs? Vote for llParcelSay!!!
- Go here: http://jira.secondlife.com/browse/SVC-1224
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
01-07-2010 14:46
From: Meade Paravane
/me wonders if anybody is going to just test it and see what happens.


It is in fairly common use for storing values; I also tested it to make sure LL hadn't busted it before I posted the "to answer the question" post above. :)
Jack Abraham
Lantern By Day
Join date: 11 Apr 2008
Posts: 113
01-07-2010 16:31
I also just tested myself; no rounding observed. Huzzah! Thanks to all who responded.
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
01-07-2010 17:34
From: Talarus Luan
It is in fairly common use for storing values; I also tested it to make sure LL hadn't busted it before I posted the "to answer the question" post above. :)

I've never heard of using color on faces for storing data. Neat idea but am annoyed I didn't think of it first.

So.. What's the conclusion? How many bits per face can we keep? Anybody tried faking up texture UUIDs to store larger values?
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
01-07-2010 17:55
Storing data as color values on faces is, if anything, a novel idea, but why do so when you can store quite a bit more data as strings (127 bytes worth) in the object description? Back in the day, before LL caught on, one could store upwards of 8k of data there, but LL figured it out and plugged up that hole :(
SuezanneC Baskerville
Forums Rock!
Join date: 22 Dec 2003
Posts: 14,229
01-07-2010 18:04
The idea of storing data in a prim's colors is not new at all, as shown in this post from 11-19-2003, 09:42 AM :

From: Ezhar Fairlight 11-19-2003

There are several ways to permanently store data in SL.

Notecards are one, and while being the largest in size (64kbyte), they're not writeable via script.

Small amounts of data (integer, float, vector types) can be stored using the hidden faces of an object (like the infinitely small top face of a 4-sided pyramid), or if you don't care about the looks, the visible faces too. Texture offsets, rotation, alpha and color (vector) can be set/get via script, and thus be used to store small amounts of data.


/13/b5/6935/1.html
_____________________
-

So long to these forums, the vBulletin forums that used to be at forums.secondlife.com. I will miss them.

I can be found on the web by searching for "SuezanneC Baskerville", or go to

http://www.google.com/profiles/suezanne

-

http://lindenlab.tribe.net/ created on 11/19/03.

Members: Ben, Catherine, Colin, Cory, Dan, Doug, Jim, Philip, Phoenix, Richard,
Robin, and Ryan

-
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
01-07-2010 18:37
From: Johan Laurasia
Storing data as color values on faces is, if anything, a novel idea, but why do so when you can store quite a bit more data as strings (127 bytes worth) in the object description? Back in the day, before LL caught on, one could store upwards of 8k of data there, but LL figured it out and plugged up that hole :(

because it neatly stores an extra vector or 3*4bytes of float values beyond that field, doesn't need to be cast, and isn't immediately visible/readable to anyone editing =)

there're lots of fields that can be used this way.
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
01-07-2010 20:18
Yeah, you can store data in the texture field, but it must be a valid key (even though it doesn't exist in the asset server), otherwise, you get a "texture not found" error (anything not a key is assumed to be in object inventory).