Light categories and Shader Mixer?

Mustakettu85Mustakettu85 Posts: 2,933
edited December 1969 in Technical Help (nuts n bolts)

Hi everyone,

Is there a way to restrict, say, volume or surface shaders made in Shader Mixer to lights belonging a specific category only? It's trivial when writing code "from scratch", but I can't seem to figure it out if it's ever possible with Shader Mixer.

Comments

  • Richard HaseltineRichard Haseltine Posts: 100,833
    edited December 1969

    There's a RayType brick, will that do the job?

  • Mustakettu85Mustakettu85 Posts: 2,933
    edited December 1969

    No Richard, unfortunately no, raytype is for another thing. The way category support is done in code is in a parameter passed to illuminance(). So you write, for example:

    
    illuminance (myCategory, P, Nn, PI/2) {
    // Your surface or volume code here
    // For example: physically based diffuse
    
    // This is the light vector
    vector Ln = normalize(L);
          float nondiff = 0;
    // Now we are asking the light if it is set to be "non-diffuse" or if it does cast diffuse illumination
    
          lightsource ("__nondiffuse", nondiff);
              if (nondiff < 1)
              {
          DiffFinal += Cl * PI * (1 - nondiff) * bsdf(Ln, Nn,"wo", V,"bsdf", "oren-nayar", "roughness", %3%);
              }
    
    }
    

    I am more interested in volume shaders, though, because it is much more difficult to write good volume code (there is actual math needed). So I would love to be able to use Shader Mixer volumes, but have light categories working for them (so as to only have the lights I need affect the volume, like AoA did for his shaders, it's much faster that way).

    When I click "show advanced" on volume bricks like Ray Marcher or Smoke, they will accept the shading point P and view vector I, but nothing like the category.

    I was hoping there may be some workaround for that.

  • meipemeipe Posts: 101
    edited December 1969

    No Richard, unfortunately no, raytype is for another thing. The way category support is done in code is in a parameter passed to illuminance(). So you write, for example:

    
    illuminance (myCategory, P, Nn, PI/2) {
    // Your surface or volume code here
    // For example: physically based diffuse
    
    // This is the light vector
    vector Ln = normalize(L);
          float nondiff = 0;
    // Now we are asking the light if it is set to be "non-diffuse" or if it does cast diffuse illumination
    
          lightsource ("__nondiffuse", nondiff);
              if (nondiff < 1)
              {
          DiffFinal += Cl * PI * (1 - nondiff) * bsdf(Ln, Nn,"wo", V,"bsdf", "oren-nayar", "roughness", %3%);
              }
    
    }
    

    I am more interested in volume shaders, though, because it is much more difficult to write good volume code (there is actual math needed). So I would love to be able to use Shader Mixer volumes, but have light categories working for them (so as to only have the lights I need affect the volume, like AoA did for his shaders, it's much faster that way).

    When I click "show advanced" on volume bricks like Ray Marcher or Smoke, they will accept the shading point P and view vector I, but nothing like the category.

    I was hoping there may be some workaround for that.

    I don't understand, isn't it possible to write your illuminance function in some ShaderBuilder macro, export it, and import it as a custom brick in Shader Mixer?

  • Mustakettu85Mustakettu85 Posts: 2,933
    edited December 1969

    meipe said:

    I don't understand, isn't it possible to write your illuminance function in some ShaderBuilder macro, export it, and import it as a custom brick in Shader Mixer?

    In theory, it might be possible. I just never tried.

    But, you see, when it comes to my own illuminance() loops, I don't need Shader Mixer. I write all my surface and light shaders in RSL and use Shader Builder to help import them into DS (although I could well write all those helper scripts by hand, it's just too tedious).

    I am not good enough to write meaningful volumes, though. I wanted to use the ones already done in Shader Mixer. It's probably one of the very uses I actually see in Shader Mixer for myself (I sound sooo darned haughty and posh now, right?).

  • meipemeipe Posts: 101
    edited December 1969

    meipe said:

    I don't understand, isn't it possible to write your illuminance function in some ShaderBuilder macro, export it, and import it as a custom brick in Shader Mixer?

    In theory, it might be possible. I just never tried.

    But, you see, when it comes to my own illuminance() loops, I don't need Shader Mixer. I write all my surface and light shaders in RSL and use Shader Builder to help import them into DS (although I could well write all those helper scripts by hand, it's just too tedious).

    I am not good enough to write meaningful volumes, though. I wanted to use the ones already done in Shader Mixer. It's probably one of the very uses I actually see in Shader Mixer for myself (I sound sooo darned haughty and posh now, right?).

    I just wondered, because in Shader Mixer's 'Volume repository' (on DS 4.7), I see four bricks: Depth Cue, Ray Marcher, Simple Fog and Smoke. In Shader Builder's sample catalog, there are two volume shaders: RI:DepthCue_Simple and RI_Fog_Simple, with simple macros that can be edited. But I don't know If they match the first and third of Shader Mixer's bricks...

  • meipemeipe Posts: 101
    edited December 1969

    I just remembered this fog shader in Renderman docu:

    https://renderman.pixar.com/resources/RPS_17/atmosphereAndInteriorShaders.html

    I though it may interest you.

    TestSmokeVolume.jpg
    325 x 523 - 18K
  • Mustakettu85Mustakettu85 Posts: 2,933
    edited December 1969

    meipe said:
    I just wondered, because in Shader Mixer's 'Volume repository' (on DS 4.7), I see four bricks: Depth Cue, Ray Marcher, Simple Fog and Smoke. In Shader Builder's sample catalog, there are two volume shaders: RI:DepthCue_Simple and RI_Fog_Simple, with simple macros that can be edited. But I don't know If they match the first and third of Shader Mixer's bricks...

    Stuff along the line of those simple depth cue and "fog" shaders is as far as I can go writing "volumes" =) These aren't true ray marching stuff = they will not respond to lights. And thank you for the PRMan link - I believe I have experimented with making another freely available cousin of this shader work in DS (noisysmoke.sl), but somewhere I keep doing something wrong...

    There is even a dedicated library in 3Delight Studio Pro these days that should help with writing volumes, but I don't think it´s available for the DS-bound 3Delight builds.

Sign In or Register to comment.