Question on Ogre::Light Class Reference

The place for artists, modellers, level designers et al to discuss their approaches for creating content for OGRE.
Post Reply
Mugen
Gnoblar
Posts: 9
Joined: Sun Jul 17, 2005 9:14 pm

Question on Ogre::Light Class Reference

Post by Mugen »

I have a question on the Light color in this section.
Public Member Functions
ColourValue (float red=1.0f, float green=1.0f, float blue=1.0f, float alpha=1.0f)
bool operator== (const ColourValue &rhs) const
bool operator!= (const ColourValue &rhs) const
RGBA getAsRGBA (void) const
Retrieves colour as RGBA.
ARGB getAsARGB (void) const
Retrieves colour as ARGB.
ABGR getAsABGR (void) const
Retrieves colours as ABGR.
ColourValue operator+ (const ColourValue &rkVector) const
ColourValue operator- (const ColourValue &rkVector) const
ColourValue operator * (float fScalar) const
ColourValue operator * (const ColourValue &rhs) const
ColourValue operator/ (const ColourValue &rhs) const
ColourValue operator/ (float fScalar) const
ColourValue & operator+= (const ColourValue &rkVector)
ColourValue & operator-= (const ColourValue &rkVector)
ColourValue & operator *= (float fScalar)
ColourValue & operator/= (float fScalar)
I am confused on the range of values for the color value of RGB
is it 0 - 1
or is it 0 - 255
and what is alpha?
User avatar
bal
Greenskin
Posts: 100
Joined: Thu Dec 09, 2004 7:29 pm
Location: Geluwe, Belgium

Post by bal »

Colour is represented as 4 components, each of which is a floating-point value from 0.0 to 1.0.

The 3 'normal' colour components are red, green and blue, a higher number indicating greater amounts of that component in the colour. The forth component is the 'alpha' value, which represents transparency. In this case, 0.0 is completely transparent and 1.0 is fully opaque.
Literally in the same file :).
Mugen
Gnoblar
Posts: 9
Joined: Sun Jul 17, 2005 9:14 pm

Post by Mugen »

hahaha... i dont know how i could have missed that ... i still am confused on why they want to use a 0-1 range for colors, when most artist standard programs use 0-255. I will have to figure a way to adjust for when artist want to use their standards to ogre's code.
User avatar
Walley
Greenskin
Posts: 120
Joined: Fri Dec 03, 2004 4:37 am
Location: Victoria, Australia

Post by Walley »

0-255 is generally better for exact precision with 32-bit colour.

Whilst floating point values ranging from 0.0f to 1.0f provide enough precision, you'd need to convert from the 0-255 value to be exact.
Primarily though, 0.0f to 1.0f is better for math operations (adding colours, multiplying colours, etc).
User avatar
SuprChikn
Bugbear
Posts: 863
Joined: Tue Apr 19, 2005 6:10 am
Location: Melbourne, Aus
Contact:

Post by SuprChikn »

Mugen wrote:I will have to figure a way to adjust for when artist want to use their standards to ogre's code.
easy: divide by 255.
User avatar
:wumpus:
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 3067
Joined: Tue Feb 10, 2004 12:53 pm
Location: The Netherlands
x 1

Post by :wumpus: »

As ogre can render to 10bit, 16bit or even 32bit per channel formats, the range 0.0f .. 1.0f is nicely general.
Post Reply