Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 36

Thread: Developing shaders for unified sampling

  1. #11

    Default

    Wouldn't it be necessary to know how often my shader is executed, or how much samples there will be? If I have a transparency of 70%, how can I decide if I have to calculate transparency or diffuse? Or should I use something like mi_sample() and check if the result is greater than 0.7 to get an ida?

  2. #12
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    2,916

    Default

    Exactly. For example, if between 0 0.7 shoot transparency ray, if between 0.7 0.85 calculate diffuse, between 0.85 1.0 calculate reflection. That would be a 50-50 mix of your diffuse and reflection weights. If you actually use a fresnel blend for reflections, that ratio would change across the surface of something.
    Barton Gawboy
    Training and Special Projects, NVIDIA ARC
    LAmrUG Forum Originator

  3. #13
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    2,916

    Default

    Assume we have a function named choose_component_type, that does this qmc sampling. Its inputs would be the weights of the various components of a shader. Those components might be transparency, diffuse reflection, specular/glossy reflection. Maybe treat refraction separately from transparency, maybe not. That is another discussion and might be different for a hair shader than a glass shader for example.

    Anyway, the output would be the component type, so you could use it in a case statement to select which path to trace/calculate.

    psuedocode

    Code:
    component_type = choose_component_type(component_weights)
    switch (component_type)
      case reflection: - if glossy, choose glossy direction, trace reflection ray
      case transparency: - trace transparency ray
      case diffuse: - calculate direct diffuse, then calculate indirect diffuse: either shoot brute force fg ray, or interpolate fg points, based on technique chosen
      case scatter: - if including an sss component, calculate sss
      ...
    Last edited by bart; January 30th, 2012 at 21:41.
    Barton Gawboy
    Training and Special Projects, NVIDIA ARC
    LAmrUG Forum Originator

  4. #14

    Default

    Interesting approach, I'll try that in my shader and post results.

  5. #15
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    2,916

    Default

    Note that you should be able to turn up trace depth much higher if you're testing it on a hair shader, for example. And more eye samples will be shot, so the unified samples quality may go up much higher. But speed/quality tradeoff should be more efficient.
    Barton Gawboy
    Training and Special Projects, NVIDIA ARC
    LAmrUG Forum Originator

  6. #16

    Default

    Just implemented a shadow shader for my hair shader. Fist I simply used a traditional approach with checking for segments, choosing the correct volume and do a trace_shadow_seg(). Worked but with area lights, my rendertime goes up from 6 minutes to 23 minutes.

    Then I did it the modern unified way, I created a mi_sample() and decided with my shadow opacity factor if I return miTRUE or miFALSE. Looks good and is really fast. I'll check brute force finalgather next.

  7. #17
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    2,916

    Default

    Good thinking. I assume at lower samples quality, you may have more noise than with the traditional way, but when you start increasing it to production quality, the speed/quality tradeoff really pays off.
    Barton Gawboy
    Training and Special Projects, NVIDIA ARC
    LAmrUG Forum Originator

  8. #18
    Join Date
    Dec 2004
    Location
    Marina Del Rey, California
    Posts
    2,916

    Default

    Assuming there is some motion, did you try it in animation? Was the noise acceptible?

    The shadow shader implemented that way won't tint shadows like you might need for looking through painted glass. But if it looks good for your hair rendering, and is fast, go with it.

    Mine was a little darker shadowing than with the traditional approach, however that might have been too light the way it was set up anyway. Just significantly modifying the Writing mental ray Shaders book hair shaders for my testing.

    Which shadow mode did you use with the unified approach? Simply "on"?
    Barton Gawboy
    Training and Special Projects, NVIDIA ARC
    LAmrUG Forum Originator

  9. #19

    Default

    I'll try animation on monday with different settings.

  10. #20

    Default

    Was a not very useful idea with shadows. Because there is no shadow tracing I get the same result as if I simply modify the shadow color in a shadow shader. Maybe with a bit more noise. But I hoped to get an accumulative effect what is of course only possible with shadow tracing...

Posting Permissions

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