Latest Tweets:
Here’s a copy of a post I placed back on 31MAY08 for my “final project” at Full Sail University…
So I’ve been trying to figure out how to get my shaders to implement gamma corrections and saturation modification. This may not seem like a big deal but truth be told, if you’re using a pretty crappy monitor, these features can make or break a game.
After toiling on the internet finding equations on the Wikipedia and other miscellaneous websites, I derived my gamma correction formula which is as follows…
OUT = IN ^ (1/GAMMA)
Basically, you would take the components of your color vector (IN) and increase it exponentially by 1/GAMMA. GAMMA would be a floating point number between 0.5 and 2.2 ideally though you can modify these values to your heart’s content. I realize that there are ways to handle this through the OS or rendering API (most of them anyways) but I wanted to find a way to allow a player to modify these values and play a game in windowed mode without impacting their desktop as they play.
Saturation modification took a bit less time to figure out but was still a bit tricky as there are actually steps you must go through first as opposed to just running it through a single step, here is the procedure for that…
First you will need to determine what I call the “De-saturation constant” (yeah, probably a misnomer, but whatever). Basically, if you have a color like red (255, 0, 0) or blue (0, 0, 255), you will need to figure out what they look like completely de-saturated. This number can be found by taking the minimum value and adding to it the difference of the maximum and minimum value and divide by two. This number will then be applied to every color field. Here is the formula and an example:
FORMULA:
DSC = INmin + ( (INmax – INmin) / 2 )
EXAMPLE:For the arbitrary color (192, 64, 32)
DSC = 32 + ( (192-32) / 2)
= 112
The fully “desaturated” version of the color will be (112, 112, 112).
Now that we know what the color looks like if it were going to be placed in an episode of “I Love Lucy”, we can use that as our “base”. The BASE is useless without the DELTA however. The DELTA is the difference between the normal color and the fully “desaturated” version of that normal color. Here’s the example:
FORMULA:
DELTA = (NORMAL – DSCVERSION);
EXAMPLE:
DELTA = (192, 64, 32) – (112, 112, 112)
= (192-112, 64-112, 32-112)
= (80, -48, -80)
If you do a quick check on your work, you’ll realize that adding the DELTA to the “desaturated” color will return us back to normal; this is how we get around from “colorless” to normal and even into over-saturation. We basically would scale our DELTA vector in order to properly display what we would like. Want to take out color? Make your SATURATION scale value 0.0f. Want to make it have just half the color to compensate for a funky monitor? Set it to 0.5 for half color. Want to keep it as is? Leave it at 1.0f (which I’m considering leaving a check in the shader to bypass the entire process if it is) and be happy. Here’s the implementation of the final step.
FORMULA:
OUT = DSCVERSION + (DELTA * SATURATION)
Remember that SATURATION is a scale value on a vector of floats.
EXAMPLES
OUT = (112, 112, 112) + ( (80, -48, -80) * 1.0 )
= (112 + 80, 112 – 48, 112 – 80)
= (192, 64, 32)
= ORIGINAL VALUE!!!
OUT = (112, 112, 112) + ( (80, -48, -80) * 0.5 )
= (112 + 40, 112 – 24, 112 – 40)
= (152, 88, 72)
= Color’s are dulled by 50%
OUT = (112, 112, 112) + ( (80, -48, -80) * 2.0 )
= (112 + 160, 112 – 96, 112 – 160)
= (255, 16, 0)
= Color’s are exaggerated by 200% and
will are clamped to their max/min values.
Well, I hope you guys find this info useful, feel free to get back to me anytime (Michael.Vittiglio@ReclusiveDesigns.com) though I have to admit that my time is limited due to my tasks regarding the “Lost Marbles” project.
Be well,
~Mike();
moving to little falls…
Pretty sweet
Time for the silent minority to be heard… :-)
Want to see if this Android app is working…
This could be the spark that makes traditional application creation and distribution obsolete…
You know what? The comparison is accurate. The tables seem to have turned as Apple takes the mantle once held by the former champions that it stood before in the company’s infancy (IBM, etc). I’ve felt this way for years but there is one good piece of insight from all this: the drones in the commercial weren’t dragged there, they were happy to be there and they were convinced that whatever came through the screen was good.
Just a heads up folks but this could be the future of how applications are released. An alternative to the iTunes Store that doesn’t care where you are or what you’re running…
So I was walking through a pharmacy the other day when I saw the Time magazine issue “Top 100 influential people” where I saw Madonna (who turned out to be Lady Gaga) and Bill Clinton standing side by side. I was curious so I opened up the magazine and checked it out. Then I almost started vomiting.
I’m not saying that I was going to blow chunks on my shoes because of their choices, I’ve come to expect stupidity in media of the masses. What pained me was who was writing what. The main thing that popped out at me was that there was an article about Sarah Palin by Ted Nugent and then (I couldn’t believe it) an article about Glenn Beck by Sarah Palin.
Here’s my gripe. These are opinion articles about people by their biggest fans. I read both these articles hoping for a gleaming beam of understanding. The much sought after “why” was no where to be found. All I found was “I like this guy/gal. You should too! Let me run down a list of ambiguous and/or irrelevant compliments.” I wish I could see something concrete, a list of accomplishments for one would be nice.
I can see why Steve Jobs is on the list, he runs one of the most influential technology companies in the world (helped to found it with his pal Steve Wosniak). But what in the world do two political circus acts helping to keep this country divided bring to the table other than chaos? I remember right-wing television reminding the left summarily to “shut up and support the president, he’s in charge now after all”. Now that the shoe is on the other foot it would seem we just switch roles; big boys take the blame and tell people to get in line with the new order while the under-dog undermines the big dog’s authority with hear-say and speculation.
But I digress…
Prince was on the list too… what the fuck has Prince done to get on the top 100 list? Are we really putting leaders of the free world next to circus acts? Makes me sick.
Good entertainment if it wasn’t for the fact that this fiction is being sold as fact and people buy into it.