Tag Archives: Media Player Classic

Cubic Lens Distortion Shader

Introduction

Cubic Lens Distortion (or undistortion as well) is well known in compositing or any VFX package. Basic Lens Distortion would usually solve the distord plate a the center, but closer you would get to the border of the picture, more the distortion will still there. The Cubic parameter let you control that.
It could also be used to give a “Chromatic Aberration” effect

This shader is based on the Algorithm shared by ssonTech website. This algorithm is used in SynthEyes (matchmove software) and is pretty simple.


Examples

k = -1.0 ; kcube = 0.0
k = -1.0 ; kcube = 0.0
k = -1.0 ; kcube = 0.5
k = -1.0 ; kcube = 0.5
Chromatic Aberration example : k = -0.15 ; kcube = 0.15  ||  using red distord channel with green and blue undistord channel
Chromatic Aberration example : k = -0.15 ; kcube = 0.15 || using red distord channel with green and blue undistord channel



Shader (Media Player ClassicHLSL)


code on Pasteall.org

Reblog this post [with Zemanta]

Saturation Shader

saturation-panel

This one should be pretty simple, but still all the shaders I have found on the Internet was based on conversion to HSL color space. Which could be actually useful if  you need some color balance control, but if you just want to control the saturation as fast as you can, it’s probably not the right approach.

Anyway here is a small shader which does the trick (Media Player Classic) :

http://www.pasteall.org/8891/c

Exposure/Offset/Gamma photoshop tool to Shaders

The goal here was to understand how works the Exposure feature of Photoshop for my research on lift/gamma/gain

exposure-photoshop-panel

NB : I wouldn’t say I’m an 100% sure about how it works, but that’s how I understood it worked so far


Exposure :

I though exposure was more complicated than that (maybe it is) but the way I’m reproducing it, is only by adding a percentage of the pixel by himself. nothing more complicated than that.


Offset :

As seen in my previous post, the Offset is just an Add of a value. My first approach on it was saying Offset is controlling the luminance of it, so I guess the correct way would be to convert the pixel in the YCbCr color space, add a value to the Y channel, and reconverting back to RBG color space. But this is doing a lot of calculation for nothing, while adding just a value to the entire picture would probably do the same, and actually would correspond to the Lift (or Offset of the CDL).
Plus switching between color space makes you loose some tiny precision in the color.

Anyway, I’ll give the two solutions, please let me know if you think one is better than the other


Gamma :


As usual, power(1/gamma)

The right order :

If all this was actually all pretty simple, at least I learned one thing (obvious as well I must say). Don’t forget to do the operation in the right order. In my first try I had a small bug, and couldn’t have the same result in Photoshop & in my shader, because I was doing the offset before the exposure. Which is pretty silly, since if you do that, you are loosing all the dynamic range of your picture when you actually want to have as much information as you can for your exposure.

The order is Exposure -> Offset -> Gamma.


Formula :

output = ((input*exposure) + offset)^(1/gamma)

hum… looks a lot like the CDL formula doesn’t it ? :) Except exposure is a single float value between 0 and 20 ? (maybe more, maybe less depends of your picture)and the default value should be 1.The offset should be between -10 ? and 1 I think.


Shaders (HLSL in Media Player Classic) :

http://www.pasteall.org/8868/c

Here I’m giving the version with YCbCr conversion, but I’m pretty sure it is not doing anything more than the above one, except loosing information in conversion. But at least it shows the YCbCr conversion :)

http://www.pasteall.org/8869/c

lift/gamma/gain VS. ASC CDL

Following my previous post “lift-gamma-gain color correction formula with blender compositing” I continue my research about all those formulas.

Comparison

I came to compare the ASC CDL (American Society of Cinematographers Color Decision List) formula to the Lift/Gamma/Gain formula I found on Blender.org

Here are the results :

lift-vs-cdl-image

lift-vs-cdl-gradient

Where the formula are :

  • CDL : ((input*slope)+offset)^(1/gamma)
  • Lift :  gain * (input + lift * (1 – input)^(1/gamma))

(slope = gain ; offset = lift)

You can see that CDL is able to burn (exposure) the white, while the Lift will keep the white unchanged as much as it can.
_dbr did a nice test for me in Shake and create a graph that really shows the differences

lift-vs-cdl-curve

so in both formula by only changing Lift/Offset, you can see clearly that the lift keep the white unchanged while CDL push the black and white as well.

HLSL Shader in Media Player Classic

Yes, in Media Player Classic, you can write shaders compiled in runtime while you are watching your favourite TV Shows ^^ . Awesome !!!


hlsl code on Pasteall.org



Conclusion

So I guess CDL is much easier to use, but I believe that Lift could give you much control other the image. What would need Lift to be able to push the white as well would be an exposure parameter! (which is the goal of my next shader :) )