Custom RGB colors  Printable Version + LDraw.org Discussion Forums (https://forums.ldraw.org) + Forum: Models and Parts (https://forums.ldraw.org/forum18.html) + Forum: Parts Authoring (https://forums.ldraw.org/forum19.html) + Thread: Custom RGB colors (/thread12516.html) Pages:
1
2

Custom RGB colors  Stephen  20140220 I'm trying to find documentation that explains the encoding of custom colors. http://www.ldraw.org/article/218.html#colours The above link explains that custom ("direct") colors are defined as 0x2RRGGBB. But if in MLCad I choose R=64 G=128 B=192 (which should be 0x24080C0) it shows in MLCad/LDView as 0x0455548C and is stored in the .ldr in decimal as 72701068 (which is 0x0455548C). It seems to be encoded, but where's the specification of the encoding? Re: Custom RGB colors  Philippe Hurbain  20140220 Clearly this needs to be detailed somewhere on LDraw.org... Some explanations here Re: Custom RGB colors  Stephen  20140220 Thanks. Re: Custom RGB colors  Travis Cobbs  20140220 In addition to the link Philo already provided, below is info from comments in my LDView source code. Note that I didn't create any of these color schemes; I simply coded LDView to recognize them. Code: // 0x2RRGGBB = opaque RGB Notes:
Note that I believe that if you manually enter the integer value from one of the 0x2RRGGBB or 0x3RRGGBB colors into MLCad, it will display it in the right color. (In other words, calculate the big integer value, and then enter that into the color number box, instead of entering R, G, and B.) I could be wrong about this, though. Re: Custom RGB colors  Stephen  20140220 Thanks for that clear and concise list of color ranges. Travis Cobbs Wrote:Note that I believe that if you manually enter the integer value from one of the 0x2RRGGBB or 0x3RRGGBB colors into MLCad, it will display it in the right color. (In other words, calculate the big integer value, and then enter that into the color number box, instead of entering R, G, and B.) I could be wrong about this, though. Yes, it accepts decimal or hex into the color box. It also produces a nice guaranteed access violation if you attempt to edit the definition of an existing custom color (using the "Custom..." button) without first resetting it to a standard color Re: Custom RGB colors  Michael Heidemann  20140220 Ok, the nice message is there You can try to use DATHeader for composing the color you like or LDConfig Manager. Both apps let you compose the color you like and gives a value that can be used for LDraw files. Re: Custom RGB colors  Travis Cobbs  20140220 Travis Cobbs Wrote:Combining two 12bit colors together in a 50/50 checkerboard does not give you a 24 bits of color space. Totally unrelated question. Do any math types out there know how to calculate the actual size of the color space for a 50/50 average of two 12bit colors, where the results are 24bit colors? I was curious and wrote a real quick program to come up with the number empirically (by calcuating all 16m+ combinations of 12bit values and counting all the unique results), but the answer I got seemed very strange: 29,791 (which, for what it's worth, is 0x745F in hexadecimal). I can't decide if I messed up my (very simple) program or not. I would have expected some simple equation to give the count, but I also would have expected the result to have some kind of visible pattern in hexadecimal notation, and I don't see one. For reference (for the programmers out there), here is the program. Store the below in a .cpp file and compile it and it should work on just about any semimodern C++ environment. (Having said that, I've only run it as a Win32 C++ Console Application, build with Visual C++ 2010.) Code: #include <stdio.h> Re: Custom RGB colors  Michael Heidemann  20140221 Just a quick thought: 4096 colors are possible with 12 bit this should be mixed with other 4096 colors As both colors are the same and a mixture 'ab' is visually the same as 'ba' I would calculate 4096 * (4096/2). Re: Custom RGB colors  Travis Cobbs  20140221 I understand your calculation, but it results in a value of over 8 million, while my empirical calculated value is only around 29 thousand. That's a pretty big difference. The thing is, in addition to ab being the same as ba, the components for the average color are calculated as (a + b) / 2, so you things like this: (2 + 5) / 2 = (5 + 2) / 2 = (1 + 6) / 2 = (0 + 7) / 2 = 3.5 Note that there are of course quite a few other input values that result in an output value of 3.5. For my calculations, the 3.5 is then multiplied by 17 and the result is rounded down, giving an 8bit color component of 59. For reference, in case it's not obvious, the reason for the muliplication by 17 is because 15 is the largest 4bit number, and 15 * 17 = 255, which is the largest 8bit number. This works to double the number of bits in any number. For example, to extend a 3bit number to 6 bits, you multiply it by (2^3) + 1, or 9. (7 * 9 = 63.) To go from 5 bits to 10 bits, multiply by (2^5) + 1, or 33. (31 * 33 = 1023.) Re: Custom RGB colors  Tim Gould  20140221 Naive information theory says it should be the same as 24 bit, since you need 12 bits x 2 to represent it. But... many combinations of bits reduces the number of _unique_ pieces of 24 bit space you can sample. So it's actually much smaller. You can easily show that, for each colour element, you can get every value from 0 to 2^41 and thus, the sum of the two (ignoring halving) means you can get every value from 0 to (2^41)*2 ie. 31 possible values. Thus, you have a colour space of (31)^3=29791 And my maths and your program agree Or in other words, by dithering you are disposing of 99.82% of the information. If instead you dither across N elements, then you get (1+N*(2^41))^3 effective colour values 