Re: Linear Color ( or not? )
Re: Linear Color ( or not? )
- Subject: Re: Linear Color ( or not? )
- From: Darrin Cardani <email@hidden>
- Date: Fri, 24 Aug 2012 13:38:38 -0700
David,
You shouldn't have to compensate for any gamma correction. I was just using that as an example to clarify how it works. Either your plug-in should work in linear, if that's appropriate, or it should work in gamma corrected space, if that's appropriate. It sounds like in your case, maybe working in a gamma-corrected space makes more sense. If that's the case, simply use the kFxImageColorInfo_RGB_GAMMA_VIDEO instead of kFxImageColorInfo_RGB_LINEAR in your -properties dictionary.
As a rule of thumb - color correction filters usually need to work in gamma-corrected RGB, whereas anything simulating lighting or light-related effects needs to work in linear RGB. Another way to look at it: if your filter is based on how people perceive color, make it work in gamma-corrected space, whereas if it's based on physically simulating light, make it work in linear RGB. The host app will take care of converting it to the proper output space after you're done with it, you just need to tell us which space your code is working in. Does that make sense?
In your example below, it's kind of hard to tell you what you should do because an RGB value of (0.5, 0.5, 0.5) is meaningless without knowing the color space. So when you say "I need an input image that was rendered 0.5, 0.5, 0.5 to evaluate to 0.5, 0.5, 0.5 in a fragment shader," you need to say in what space the rendered 0.5, 0.5, 0.5 is. If you mean that when it is displayed that a tool like Pixie shows an on-screen value of 0.5, 0.5, 0.5, then your input is in gamma-corrected RGB. But if it's an OpenEXR that has linear RGB in it, then a value of 0.5, 0.5, 0.5 will mean something different. What are your inputs? HD Video? How are you getting the "0.5, 0.5, 0.5"? From Motion's color display in the canvas? If so, that's gamma-corrected.
Darrin
On Aug 24, 2012, at 1:26 PM, "email@hidden" <email@hidden> wrote:
>
> Hmm. It isn't really linear output then right? The outputimage says it is in linear color space. How would I know what gamma to compensate for? Seems like there could be custom gamma curves for each channel in some cases?
>
> I digress, the real issue is that I need an input image that was render 0.5,0.5,0.5 to evaluate to 0.5,0.5,0.5 in a fragment shader. Right now it does not seem that the input image is transformed to linear space.
>
> Appreciate the patience.
>
>
> On Aug 24, 2012, at 3:16 PM, Darrin Cardani wrote:
>
>> David,
>>
>> It sounds like you get the basic concept. You are correct that you need to include that value in your properties dictionary to get inputs that are linear and to output your results in linear RGB.
>>
>> What's not so obvious is that if you output (0.5, 0.5, 0.5, 1.0) in linear RGBA, a couple of things happen. Before displaying your output to the screen or exporting it to a file, we need to convert it from linear to gamma-corrected RGB as a final step. The gamma-corrected value of linear 0.5 will be about 0.72. (That's 0.5 ^ (1.0 / 2.2).) This works as expected, but can be confusing. If you want the gamma-corrected result to be 0.5 (and for it to look like "middle gray") you need to use (0.21, 0.21, 0.21, 1.0) for your RGBA value in linear RGB.
>>
>> If you've ever heard of "18% gray" being middle gray, that's in linear RGB. As you can see, 0.21 is just a little more than 0.18, so they're pretty close.
>>
>> Darrin
>>
>> On Aug 24, 2012, at 12:44 PM, "email@hidden" <email@hidden> wrote:
>>
>>> Hi all,
>>>
>>> I apologize if the following has been addressed and I missed it. If so, just slap me and please point me in the appropriate direction.
>>>
>>> I have just begun updating several of fxplugs from 1.2. Many of them are based on data encoded into the images. I understand that colorspaces are now used and I need to request linear color outputs.
>>>
>>> In properties I am returning "[NSNumber numberWithInteger:kFxImageColorInfo_RGB_LINEAR], kFxPropertyKey_DesiredProcessingColorInfo," in the dicitonary.
>>>
>>> When I query the output image for the color space it returns "kFxImageColorInfo_RGB_LINEAR". I understand this to map the image colors from 0.0 to 1.0.
>>> (FxImage*)outputImage.colorInfo equals kFxImageColorInfo_RGB_LINEAR
>>>
>>> The issue occurs when rendering to the output image ( or read from the input image ). The following code outputs a much brighter luminance value than 0.5.
>>> glClearColor( 0.5, 0.5, 0.5, 1.0 );
>>> glClear( GL_COLOR_BUFFER_BIT );
>>>
>>> Is there somewhere else I need to request linear color? Am I not understanding linear color correctly?
>>>
>>> Regards,
>>> David Patrick Farmer
>>>
>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Pro-apps-dev mailing list (email@hidden)
>>> Help/Unsubscribe/Update your Subscription:
>>>
>>> This email sent to email@hidden
>>
>
> David Patrick Farmer
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Pro-apps-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden