# Override final pixel color in a Cycles/OSL shader? [duplicate]

In the Renderman Shading Language, the whole purpose of a shader is to determine the final pixel color for each fragment. You have complete control over what the shader does and what the final color is. If you have a scene with a mountain covered in snow, with trees in the foreground and a lake, if you want the whole image to be completely red--like (255, 0, 0) red in every single pixel--you can do that by setting the final color at the end of each shader. It can completely disregard the lights, image textures and geometry.

Is this possible in Cycles or OSL? I realize that the REYES algorithm is a very different beast than OSL closures in a unidirectional path tracer. But, can I override the physically-based-ness of Cycles in a shader?

## marked as duplicate by gandalf3♦, David♦, CharlesL, Qwertie, cegatonJun 19 '14 at 12:22

• You're right. Not sure why that question didn't show up in my searches. – Justin Jun 18 '14 at 20:48

I do believe that RSL scripts might have more control over the final colour than OSL scripts do. From the OSL specification --

A closure is an expression or function call that will be stored, along with necessary contextual information, to be evaluated at a later time.

What this means is the green node sockets that connect to the Material Output provide the render engine with a way to calculate the final colour not the specific colour to use in the final image. The steps of mixing reflections and lighting is performed by the renderer not by the OSL script.

For interest the first example that gandalf3 pointed you to can be achieved in OSL with --

shader flatcolour(color Colour = 0.8,
float Strength = 1.0,
output closure color BSDF = 0 )
{
if(raytype("camera"))
BSDF = (Strength * Colour) * emission();
else
BSDF = transparent();
}

• This script didn't work for me. The model always comes out black, no matter what color I set it to. – Justin Jun 19 '14 at 13:50
• Did you turn on OSL in the render properties? – sambler Jun 20 '14 at 0:44
• Of course not! That would be too simple. ;) – Justin Jun 20 '14 at 5:16