Results 1 to 6 of 6
  1. #1

    Can OSL use amount of light as a factor?

    Normally, Cycles cannot use the amount of light hitting a surface as an input within a material (whereas Blender Internal can.) With OSL, is this possible? I'd like to mix between two different textures based on the amount of light hitting a surface.
    Non-Photorealistic Rendering and basic character tutorials:
    http://www.aversionofreality.com/



  2. #2
    Member Secrop's Avatar
    Join Date
    Dec 2011
    Location
    Berlin
    Posts
    1,844
    The recurring question.....

    The whole purpose of Cycles is exactly this: find the amount of light hitting any point being sampled.
    I don't know if you get the irony in this... but that value will only be trully known after you render your scene with lots of samples.

    Materials (shaders) are just representations of how the surface treats light rays, and they don't know anything about those rays except, where they are comming from, and what type of ray they are. The light amount that a ray can carry it's only known much later, after the shader has already been called.
    So, no. You cannot use OSL to know that value.

    You can hardcode light positions and orientations into your shader (no need for OSL here), but it will be very complicated to get the correct amount of light that hits the object. And your shader will be useless on any other scene; this is the main point for Cycles' shaders, so that they produce an expected result no matter what are the lighting conditions of your scene (in other words, reusability).
    It's also possible to force the shader (with OSL) to throw rays in search for light sources, while the shader is being called... but this is not a good approach, and it's better to bake illumination instead.



  3. #3
    Just do it in compositing, where light level can be deduced from image rendered



  4. #4
    Originally Posted by Secrop View Post
    The recurring question.....

    The whole purpose of Cycles is exactly this: find the amount of light hitting any point being sampled.
    I don't know if you get the irony in this... but that value will only be trully known after you render your scene with lots of samples.
    In Arnold you can use Lambert shader to return an RGB value at any given shading point. It's not an absolute value, but I've done this here to return the dark side of an object as an emission matte:

    https://answers.arnoldrenderer.com/q...845#answer-845

    I know that arnold can be kind of strange sometimes - and it's not like I can just plug in standard surface into standard surface node (at least I don't think you can) ... but what exactly is doing on that allows arnold to behave this way?

    Here's another similar hack for thin glass, using a black reflective material to drive alpha:

    https://answers.arnoldrenderer.com/q...04#answer-1204
    Last edited by shawn.kearney; 03-Oct-17 at 23:03.
    "Houdini ain't that great a software. Why not something simpler like Blender?" - Internet Fanboy



  5. #5
    Member Secrop's Avatar
    Join Date
    Dec 2011
    Location
    Berlin
    Posts
    1,844
    Originally Posted by shawn.kearney View Post
    In Arnold you can use Lambert shader to return an RGB value at any given shading point. It's not an absolute value, but I've done this here to return the dark side of an object as an emission matte:

    https://answers.arnoldrenderer.com/q...845#answer-845
    yes, but it's not really a solution. you also have the diffuse_ramp and the phong_ramp closures in OSL that can do a similar effect.



  6. #6
    Originally Posted by Secrop View Post
    yes, but it's not really a solution. you also have the diffuse_ramp and the phong_ramp closures in OSL that can do a similar effect.
    definitely a hack, but it is a better solution than "it can't be done".
    "Houdini ain't that great a software. Why not something simpler like Blender?" - Internet Fanboy



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •