Re: [Algorithms] Spurious DXT colors
Brought to you by:
vexxed72
From: <ca...@gm...> - 2007-04-20 07:45:32
|
Andreas, you loose some quality, because you loose 2 bits, but I think DXT-compression still does a good job. Take in mind that you also have to adjust the color weighting factors according to the color space, you probably want to have higher accuracy in the luminance than in the chrominance. In the future I'm planning to add these color space transformations to the NVIDIA Texture Tools, that are now publicly available at: http://code.google.com/p/nvidia-texture-tools/ --=20 Ignacio Casta=F1o ca...@gm... On 4/19/07, Andreas Brinck <and...@gm...> wrote: > Hi, > > thanks for the tip. I will try it out, how well does the DXT-compression > scheme suit these color spaces? > > /A.B. > > > On 4/13/07, Ignacio Casta=F1o <ca...@gm...> wrote: > > > > On 4/12/07, Andreas Brinck < and...@gm...> wrote: > > > Hi, > > > > > > I vaguely remember reading somewhere about a method to remove the > spurious > > > greens and magentas that occur when decompressing a DXT (or any 565 > format) > > > texture. I think the idea was to multiply the green channel by 0.5 > before > > > compressing to remove a bit and then multiply it by 2 after > decompressing. > > > > > > Has anyone tried this, and gotten it to work? > > > > Andreas, > > > > you can achieve that storing the colors in the reversible YCoCg color > > space. You can translate from RGB to YCoCg with the following code: > > > > Co =3D R-B; > > t =3D B + (Co/2); > > Cg =3D G-t; > > Y =3D t + (Cg/2); > > > > s =3D Y - (Cg / 2); > > G =3D Cg + s; > > B =3D s - (Co / 2); > > R =3D B + Co; > > > > You will loose one bit in each of the CoCg components, since they are > > signed values, but o the other side you can store Y in the 6 bit > > component, providing more accuracy to the luminance. > > > > A simpler and cheaper alternative is the JPEG-LS transform: > > > > (R-G, G, B-G) > > > > It might not be obvious why that works, but with the following code > > you can easily test that pure greys remain pure greys after the > > transform: > > > > for(int i =3D 0; i < 256; i++) > > { > > int R =3D i; > > int G =3D i; > > int B =3D i; > > > > int a =3D R - G; > > int b =3D G; > > int c =3D B - G; > > > > // Quantize/bitexpand colors. > > a =3D ((a >> 3) << 3) | (a >> 5); > > b =3D ((b >> 2) << 2) | (b >> 6); > > c =3D ((c >> 3) << 3) | (c >> 5); > > > > R =3D a + b; > > G =3D b; > > B =3D c + b; > > > > printf("%d: %d %d %d\n", i, R, G, B); > > } > > > > Hope that helps! > > > > -- > > Ignacio Casta=F1o > > ca...@gm... |