OSL shaders: Camo
=================

This shader is for use with the OSL node in Redshift. It was developed in Cinema 4D, but should work in Redshift on other platforms, though there is no guarantee that it will.

Parameters
----------

Redshift has not implemented the 'help' metadata for OSL scripts so there is no indication of what a parameter does. Experimentation and trial-and-error are sometimes needed, and you can always look at the code to see what a parameter does. Again, in most cases it isn't difficult to figure out what the parameters do.

The shader takes a texture file and produces a pixelated result, with (optionally) a visible grid or masked with a pattern file.

Inputs:

* Source Image: the image to be pixelated.
* Screen Pattern: the optional pattern file. You can download a set of these from the original author's web site at https://vadrouillegraphique.blogspot.com/2012/11/image-2-screen-shader.html. Or you can find more on the net if required.
* Pixels X/Pixels Y: the resolution of the pixelated image. The lower the values, the more blocky the result will appear.
* Color Bit Depth: the colour bit depth of the result. As the value is lowered colours are lost; a value of zero gives plain black. Exceeding the bit depth of the source image will have no effect. For a typical JPEG of 8-bit colour depth, a value of 4-6 gives a good result.
* Grid Thickness: the thickness of the grid lines. Zero will remove any grid; a value of 1 will give pure black. Values of 0.1-0.2 usually work well.
* Grid Fade Range: the appearance of the grid depends on the distance from the object to the camera. At low values you may not see a grid, so try increasing this until it matches the distance to the camera. Then reducing it will gradually fade the grid.
* Pattern Fade Range: the same as for the 'Grid Fade Range' but for the screen pattern masking.
* UVW Map: the uv map of the object, which can be obtained from the 'uvwcoord' output of a State node.

Output:

* screened: the generated colour from the pixelated source image.
* pixeluv: the object UVs are adjusted internally by the shader, this is the adjusted result for the source image.
* patternuv: same as for the source image but these are the adjusted UVs for the pattern map.

You can connect the 'screened' output to the colour input of a node such as a standard material. Since the masking effect can darken the image, you can instead connect it to the illumination colour of an incandescent node if required.

Copyright and licensing
-----------------------

This and most other shaders on the Microbion site were found all over the internet then converted by me (where necessary) for use in Redshift, sometimes with additional features and/or an improved interface. Some were written from scratch by me and if so are released under the Apache software licence.

I make no claim to copyright for any of these shaders except where expressly stated when the shader was written by me. In all other cases copyright remains with the original authors. Occasionally it has not been possible to identify the author of the original script but whoever it was still has copyright over it.

With regards to licensing, many of the shaders either contain no licensing information or were released under the terms of one of the various open-source license models (such as GNU, BSD, Apache, etc.). This is not true of all of them, however. Therefore, before using any of these shaders, especially commercially, it is your responsibility to check the licensing status: details, if any, of this will be found in the .osl file.

Download
--------

Each shader is in its own .zip file, which contains:

* The shader itself, file extension .osl, which is a plain-text file.
* A render showing what the shader can do (sometimes using the default settings, sometimes with settings altered and additional nodes added).
* A sample scene file saved in Cinema 4D R2024. This in turn contains a shaderball object, a simple light setup, and an OSL material.
* This readme.txt file.

If you load any of the sample files, you may find that Redshift can be particularly bad at keeping links to the .osl file when using relative file paths. All the scene files use relative paths as an absolute path saved on my PC would certainly fail on yours. You will know if the link has broken because Redshift will display a message saying that the OSL file does not exist. All you need to do is navigate to the file on your machine and it will work again, but you will need to reconnect the ports from the OSL node to others in the node tree. In each case therefore I have added a Note to the node tree indicating which ports to connect. In most cases it's pretty obvious anyway.

Finally, please note that OSL on Redshift can be a little flaky and sometimes perfectly good scripts will fail, causing Redshift to develop a hissy fit and shut down. You will need to restart Cinema if that happens. So make sure you save a scene file before creating an OSL material so you don't lose any work if Redshift objects to it. I cannot accept responsibility if you lose work when trying to use any of these shaders.

Steve Pedler
https://www.microbion.co.uk
