Cartoon Shader
The cartoon shader is a HLSL pixel shader that will render any photorealistic image as a cartoon depiction. It was designed for playing videos through Media Player Classic. Depending on the quality of video, (for example, heavily compressed low-resolution MPEGs) artifacting can occur. The higher quality the video, the better the cartoon result will be.
Variables
There are several values that can be tweeked that effect the final image that is rendered. See the above instructions for opening the shader editor under Media Player Classic. The variables are at the top of the shader's code and are in the format of:
#define
The modifiable variables are:
- LineThickness (default 0.0005) - Controls the thickness of the lines. The value represents the distance between the pixel's sampled (with 1 equalling the horizontal width of the image). A higher number will increase the number of lines and the thickness of the lines.
- SensitivityUpper (default 10) - The upper threshold. Increasing this value will make the darker lines more sensitive to changes in the colour, adding darker lines.
- SensitivityLower (default 10) - The lower threshold. Decreasing this value will make the lighter lines more sensitive to changes in the colour. Increasing this value slightly may help relieve graininess in lower quality film at the cost of line definition.
- Saturation (default 3) - How much the saturation of the colours are multiplied by, creating hyperrealistic cartoon colours. Increasing this too much and all colours will be extremes and look odd. A value of 1 causes the origional colours to be used (doesn't have the 'cartoon' effect) and 0 causes all colours to become greyscale.
Screenshots

Transformers

Stargate: Ark of Truth

Stargate: Ark of Truth

Stargate: Ark of Truth
Downloads
- cartoonshader.hlsl (3,534 bytes)
To use with Media Player Classic, make sure you're using a renderer that supports pixel shaders under View > Options > Playback > Output. Then open the shader editor by going to View > Shader Editor. In the title textbox at the top, enter the name of the shader (for example, "Cartoon Shader"), and select ps_3_0 from the drop down list on the right. Open the .hlsl file into a text editor, and copy and paste the contents into the shader editor. The shader will then be found under the Play > Shaders menu.
Acknowledgements
The shader contains code for converting between the RGB and HSL colourspaces. This code was referenced from the
following site.