Latest Tweets:

*6

Saturation and Gamma Correction formulas

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();

Leaving NYC…

moving to little falls…

Pro-WikiLeaks cyber army gains strength; thousands join DDoS attacks

Time for the silent minority to be heard… :-)

Just a test

Want to see if this Android app is working…

Chrome to Open an App Store - PCWorld

This could be the spark that makes traditional application creation and distribution obsolete…

AppleInsider | Google compares Apple to 'Big Brother' from iconic 1984 ad

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.

Installable Web Apps - Google Code

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…

Ass-kissing Parade - Opinion piece on dumb media

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.

Technology and Intellect (A Chat With Curtis)

  • MikeV: heh, cool thing I just thought of... (and a bit of why I always go to the "tougher side" of the street with development)
  • MikeV: in this culture we've become so fascinated with making better tools that we no longer care for the quality of the craftsman, surrounded by hacks posing as prophets. However, the hacks now outproduce the dedicated among us... so who should we take inspiration from? This isn't to say that those who outproduce are all hacks but in general as a society we admire those who live by shortcuts just as much as those who toil for the fruits of their labor. Finally I ask, what is more important: the ends or the means?
  • MikeV: or am I full of shit?
  • MikeV: :-\
  • CurtisS: no.. i would say alot of american deveelopers would be considered hacks.. but the sad thing is that alot of them are forced to produce.. hacked things cause no time to preplan.. and no time to test.. and well.. shit gets thrown together as ur using it.
  • CurtisS: as far as what matters most.. that i cant ans for u
  • CurtisS: for me i would say it depends on what ur working towards
  • MikeV: yeah, in the end the paradox of the human intellect is that it comes to realize value in things beyond the realm of nature but it is only the realm of nature that truly matters. Love (as an intellectual construct) is less important than the breeze and sex (a natural construct) is the core of our existence
  • MikeV: our intellect is a feedback loop with little purpose other than to keep running until we are gone
  • CurtisS: sadly most wont admit it
  • MikeV: nature can only stare at us like a crowd surrounding a street performer
  • MikeV: I got to put this stuff down
  • MikeV: masturbate someone else's waste of time
  • MikeV: :-P
  • MikeV: "if there's one thing that I'll miss about Mike it's that he made wasting time so interesting"
  • MikeV: /facepalm
  • CurtisS: lol who said that one?
  • MikeV: i did... imagining what I'm leaving in my wake
  • CurtisS: how would one actually think u ever waisted time
  • MikeV: If the only point is to be like nature and dominate then we have little purpose for technology because it only ups the ante until we all lose everything so in the long run technology is a bad investment over time
  • CurtisS: ha
  • CurtisS: unless it puts us in the matrix
  • MikeV: but if we are to be like the imaginary ideal of our intellects and be "good" then technology is crucial because it is the only asset that can bring us to a better tomorrow; the only requirement is that people remain good
  • MikeV: man... maybe I should see if there's any money in philosophy
  • MikeV: would you mind if I put this in my blog?
  • CurtisS: mind what
  • CurtisS: no not at all
  • MikeV: technology is a scalar modifier on ones intent. if someone wanted to use a hammer for good or bad then there's a limit to the scope of whatever is in their reach. if someone could use a wish to make anything they desired possible then all existence would be at their whim for better or for worse
  • CurtisS: i get ya
  • CurtisS: but if u could wish
  • CurtisS: that tool is only limited to ur imagineation
  • CurtisS: wich is not everything
  • MikeV: and yet again, there is our intellect and technology as bedfellows expanding on each other
  • MikeV: our intellect expand our imaginations that lead us to aspire to uncover new technology which expands our capabilities which facilitates (repeat this sentence for the core of why we have evolved beyond all other animals in the jungle)
  • MikeV: I have to work on the grammar but that's it basically
  • CurtisS: therefor technology is important caue it will oneday lead us to a point where we dont just consume and destroy... well as a frame of mind..
  • MikeV: yep... so technology is either the facilitator of our destruction in the hands of civilized people acting like animals or the provider of hope to animals trying to act like civilized people
  • MikeV: to think that for all other animals it is really just a matter of chance
  • MikeV: animals = food + sex + shelter
  • MikeV: humanity = (food + sex + shelter) * (technology + intellect)
  • MikeV: which is funny because
  • MikeV: technology = knowledge * creativity
  • MikeV: creativity = knowledge * technology
  • MikeV: knowledge = creativity * technology
  • MikeV: well, not too sure about that last part (after "which is funny...") but the first part is solid I think
  • CurtisS: lol
  • CurtisS: i get ur drift
  • CurtisS: knowledge = pancake
  • MikeV: cake = lie
  • CurtisS: lol
  • MikeV: you = gay
  • MikeV: ;-)
  • MikeV: X-D
  • CurtisS: lol
  • MikeV: well, I'm gonna stop wasting your time but I'm gonna save this... it's good stuff