Quake3World.com Forums
     Programming Discussion
        Quake3 - vec4_t - colors


Post new topicReply to topic
Login | Profile | | FAQ | Search | IRC




Print view Previous topic | Next topic 
Topic Starter Topic: Quake3 - vec4_t - colors

Recruit
Recruit
Joined: 30 Jul 2009
Posts: 3
PostPosted: 12-17-2012 01:04 PM           Profile   Send private message  E-mail  Edit post Reply with quote


Hey,

I'm trying to change the colours when I'm adding text to the menu screen. All I seem to have is "colour_red" in the UI. However, I'm trying to get colours Green and Grey, possibly blue. How would I go about adding these colours? I've done a little search in the code for "vec4_t" and came to this line defined under the Main_MenuDraw :

Code:
vec4_t         color = {0.5, 0, 0, 1};


What do these values mean also, and are they in any mean related to what I'm trying to do? Thanks!




Top
                 

Grunt
Grunt
Joined: 10 Jun 2009
Posts: 64
PostPosted: 12-17-2012 02:21 PM           Profile Send private message  E-mail  Edit post Reply with quote


I am in no way a programmer but I can tell that those four floats(?) are RGBA values. First is Red, second is Green, third is Blue and the last one is the Alpha value or the opacity.




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44136
PostPosted: 12-17-2012 10:59 PM           Profile   Send private message  E-mail  Edit post Reply with quote


tehSandwich is correct. They are RGBA values. In your paint program, you're used to working with values ranging from 0 to 255. Here you use normalized values, which means that they range from 0.0 to 1.0
So a fully opaque bright red (which you'd define as 255, 0, 0, 255 in your paint program) is 1, 0, 0, 1.
Mix in a slight bit of blue and you'd get (for example) 1, 0, 0.5, 1
In your paint program that would be 255, 0, 127, 255




Top
                 

Messatsu Ko Jy-ouu
Messatsu Ko Jy-ouu
Joined: 24 Nov 2000
Posts: 44139
PostPosted: 12-17-2012 11:45 PM           Profile   Send private message  E-mail  Edit post Reply with quote


i think alpha always goes in decimals, at least that's the standard.
but apart from that; what eraser said.




Top
                 

Cool #9
Cool #9
Joined: 01 Dec 2000
Posts: 44136
PostPosted: 12-18-2012 02:03 AM           Profile   Send private message  E-mail  Edit post Reply with quote


In Paint.NET the alpha value is expressed in ints ranging from 0 - 255 as well :shrug:




Top
                 

Messatsu Ko Jy-ouu
Messatsu Ko Jy-ouu
Joined: 24 Nov 2000
Posts: 44139
PostPosted: 12-18-2012 04:37 AM           Profile   Send private message  E-mail  Edit post Reply with quote


what a cunt of a program :owned:




Top
                 

I'm the dude!
I'm the dude!
Joined: 04 Feb 2002
Posts: 12498
PostPosted: 12-18-2012 08:25 AM           Profile Send private message  E-mail  Edit post Reply with quote


Alpha for most image formats are stored as an additional 8-bits, so 256 values with a range between 0-255.

For example:
TGA offers 24-bit RGB with 8-bits per channel (8-bits/channel * 3 channels RGB = 24-bits), plus an optional alpha channel when stored as TGA-32 (8-bits/channel * 4 channels RGBA = 32-bits).



Quake 3's normalized values converts the channel values by dividing it by the total number of values (256). A 50% opacity would have an alpha value of 127 (halfway up the scale between 0-255).

So the proper math for this is: (127+1)/256=0.5

If you're wondering about why I'm incrementing: 0-255 is the range of values, but including the number zero, we have a total number of values of 256.

There is a bug in GtkRadiant where the colour values aren't properly being converted by the colour picker, so choosing a 50% value would result in a normalized value of 0.49609... or 0.50196... because of some dodgy math and failing to increment.



_________________
GtkRadiant | Q3Map2 | Shader Manual


Top
                 

Recruit
Recruit
Joined: 30 Jul 2009
Posts: 3
PostPosted: 12-18-2012 10:42 AM           Profile   Send private message  E-mail  Edit post Reply with quote


Ah, I see now. Thanks for the help guys! :cool:




Top
                 

Señor Shambler
Señor Shambler
Joined: 07 Mar 2006
Posts: 849
PostPosted: 12-19-2012 02:09 AM           Profile Send private message  E-mail  Edit post Reply with quote


obsidian wrote:
There is a bug in GtkRadiant where the colour values aren't properly being converted by the colour picker, so choosing a 50% value would result in a normalized value of 0.49609... or 0.50196... because of some dodgy math and failing to increment.


Is that on the issue list somewhere?




Top
                 

I'm the dude!
I'm the dude!
Joined: 04 Feb 2002
Posts: 12498
PostPosted: 12-19-2012 07:34 AM           Profile Send private message  E-mail  Edit post Reply with quote


I reported it back when we were working on mfn's old ZeroRadiant branch. I haven't tested it against GtkRadiant 1.6.3, so it's not on TTimo's issue tracker yet.

https://github.com/mfn/GtkRadiant/issues/71

There's a bunch of stuff on mfn's branch that I've been meaning to revisit.



_________________
GtkRadiant | Q3Map2 | Shader Manual


Top
                 
Quake3World.com | Forum Index | Programming Discussion


Post new topic Reply to topic


cron
Quake3World.com
© ZeniMax. Zenimax, QUAKE III ARENA, Id Software and associated trademarks are trademarks of the ZeniMax group of companies. All rights reserved.
This is an unofficial fan website without any affiliation with or endorsement by ZeniMax.
All views and opinions expressed are those of the author.