3
$\begingroup$

This question already has an answer here:

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?

$\endgroup$

marked as duplicate by gandalf3, David, CharlesL, Qwertie, cegaton Jun 19 '14 at 12:22

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

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

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.