Results 1 to 7 of 7

Thread: Handbook: Chapter 4.5 bugged

  1. #1
    Join Date
    Feb 2018
    Posts
    8

    Default Handbook: Chapter 4.5 bugged

    Code:
    scattering_coefficient:
       (transmission_distance <= 0) ?
       color(0.0) :
       -math::log(scattering_color) / transmission_distance

    doesn't seem to quite line up with

    The scattering color describes how much of the light is scattered, so that darker colors scatter the light to a smaller degree that brighter colors [...]

    because above code maps white (the brightest it gets) to a zero vector for the scattering coefficient.

    Does material_volume expect the scattering coefficient in some kind of weird reciprocal representation?

    Iray answers this question with a "no"; I get clear glass when setting the scattering color to white.

    So the scattering color in fact describes the looks of extinction caused by out-scattering, similar to the absorption color, complementary to the color of the light that actually scatters (recall that the transmittance term (modeling absorption + out-scatter) and the scattering term (modeling in-scatter) have opposite signs in the physical model - see e.g. https://www.csie.ntu.edu.tw/~cyy/cou...volume_4up.pdf).

    This means the rest of the text can't be quite right either. What's really going on in that last image?

    The blue scattering color lets yellow light bounce around in the medium. In the middle of the vase we can actually see just that, but green is absorped less than red, so the yellow in-scatter becomes yellow-greenish on its way out. At the bottom and (to a lesser extent) at the sides of the vase we see light accumulated and attenuated over longer paths through the medium, thus extinction dominates.

    Might also say something about directional_bias - it's currently a magic, code-only value:

    The negative directional bias lets scatterd light preferrably bounce back in incoming direction. This way, the effect is quite visible where light enters the volume. A positive value would make the light prefer to scatter into a more forward direction, thus push deeper into the volume. Consequently the paths inside the medium get longer and attentuation and diffusion have a stronger effect in that case (it also takes more time to render properly).

    Finally, and while we're at it, and as a matter of showing good practice, transmission_color should probably have its green component set to a value less than 1.0, so that green light won't be immune to absorption regardless of scale.

  2. #2
    Join Date
    Jan 2007
    Posts
    314

    Default

    Quote Originally Posted by tschw View Post
    Code:
    scattering_coefficient:
       (transmission_distance <= 0) ?
       color(0.0) :
       -math::log(scattering_color) / transmission_distance

    doesn't seem to quite line up with

    The scattering color describes how much of the light is scattered, so that darker colors scatter the light to a smaller degree that brighter colors [...]

    because above code maps white (the brightest it gets) to a zero vector for the scattering coefficient.

    Does material_volume expect the scattering coefficient in some kind of weird reciprocal representation?

    Iray answers this question with a "no"; I get clear glass when setting the scattering color to white.

    So the scattering color in fact describes the looks of extinction caused by out-scattering, similar to the absorption color, complementary to the color of the light that actually scatters (recall that the transmittance term (modeling absorption + out-scatter) and the scattering term (modeling in-scatter) have opposite signs in the physical model - see e.g. https://www.csie.ntu.edu.tw/~cyy/cou...volume_4up.pdf).

    This means the rest of the text can't be quite right either. What's really going on in that last image?

    The blue scattering color lets yellow light bounce around in the medium. In the middle of the vase we can actually see just that, but green is absorped less than red, so the yellow in-scatter becomes yellow-greenish on its way out. At the bottom and (to a lesser extent) at the sides of the vase we see light accumulated and attenuated over longer paths through the medium, thus extinction dominates.
    you are right, using this formula you actually get "how much light passes through unscattered after distance"
    i.e. the probability is higher to be scattered for for yellow/red. the result is what you see. on the top/left you have dominant yellow: light thats traveled short distance through the volume and scattered(back) On the right you have blue due to not scattered/traveled long path with lots of absorption.

    Quote Originally Posted by tschw View Post
    Might also say something about directional_bias - it's currently a magic, code-only value:

    The negative directional bias lets scatterd light preferrably bounce back in incoming direction. This way, the effect is quite visible where light enters the volume. A positive value would make the light prefer to scatter into a more forward direction, thus push deeper into the volume. Consequently the paths inside the medium get longer and attentuation and diffusion have a stronger effect in that case (it also takes more time to render properly).
    I will suggest to either add a sentence or leave the bias at its default to clarify the code.


    Quote Originally Posted by tschw View Post
    [INDENT]
    Finally, and while we're at it, and as a matter of showing good practice, transmission_color should probably have its green component set to a value less than 1.0, so that green light won't be immune to absorption regardless of scale.
    You are absolutely correct, good practice would be to avoid 1.0 (and 0.0 for that matter) while mathematically plausible, the resulting material will not behave intuively.


    Thanks a lot for the feedback!

  3. #3
    Join Date
    Feb 2018
    Posts
    8

    Default Or: ++recipe, ++ux, --confusion

    For the color parameters to actually show up in the output, going for albedo and transmission_color, plus a reference_distance seems to be a good pick:

    Click image for larger version. 

Name:	albedo_and_transmission.jpg 
Views:	16 
Size:	515.4 KB 
ID:	10028

    Here is the code for mapping these inputs to the accepted volume coefficients:

    Code:
    color transmission_coefficient = - math::log( transmission_color ) / reference_distance;
    
    // From solving albedo = sigma_s / sigma_t for sigma_s:
    color scattering_coefficient = albedo * transmission_coefficient;
    
    // From solving sigma_t = sigma_s + sigma_a for sigma_a:
    color absorption_coefficient = transmission_coefficient - scattering_coefficient;
    Just giving the reader a recipe for easy high-level control might be better than trying to explain the effect of the low-level physical quantities.
    Last edited by tschw; February 12th, 2018 at 21:09.

  4. #4
    Join Date
    Jan 2007
    Posts
    314

    Default

    Thanks for the interesting aproach. I still have to wrap my head around the code. i also have to check how it behaves. From a first look i would have 2 comments:
    -albedo * transmission_coefficient
    albedo is a "ratio" while the coefficient is a "probability density". i am not sure what the result will be. It seems albedo becomes effectively a ratio of scattering vs absorption which does seem an interesting aproach, i am just not sure how this relates to the typical meaning of "albedo"

    -transmission_coefficient - scattering_coefficient
    you couple the tinting through absorption to the tinted scattering. Usually they are independent effects and in many simple usecases i would argue the scattering should be the same value for R,G and B (wax, translucent plastics all scatter because of white particles/airbubbles while the absorption happens in the colored substrate)


    For the handbook, the goal should be to provide recepies for intuitive parameters, i totally agree. we will certainly work on improving the chapter. In https://forum.nvidia-arc.com/showthr...7155#post67155
    i discussed ways to expose scattering as parameters that i think are intuitive.
    Last edited by JanJordan; February 13th, 2018 at 11:37.

  5. #5
    Join Date
    Feb 2018
    Posts
    8

    Default Albedo and transmission color vs. scattering and absorption colors

    I've been looking into this, because we have several semitransparent "materials" (in the CAD / CG sense, ideally) composed of visibly thick, textured layers of the same (physical) material. Most unfortunately, Iray does not support varying volume coefficients yet. Will it be in the next release, BTW?

    Since we're having this discussion, I thought it might be helpful sharing it, at least in the forum. I don't care whether it makes it into the handbook (just fix the docs somehow, I'd really like MDL to become accepted at a broader scale). I also totally understand when you don't want to rub Iray's current limitations right into the reader's face (once your material takes albedo, it begs for texture).

    As for the soundness of the approach:

    you couple the tinting through absorption to the tinted scattering
    Well, I would call it "considering the net effect of transmission", also making the naming more accurate: The physical model has a transmission term and a diffusion term. The transmission term models extinction and its coefficient is really just the sum of scattering and absorption coefficients.

    On the same hand, albedo is the nothing else than "the net effect of scattering" - we also like to call it the "diffuse color" in more approximative / analytic models. It is defined as the ratio of reflection (in-scatter) and extinction (sum of out-scatter and absorption), because what we see is affected by what can travel out of the medium.

    Both definitions are given in the lecture I cited in my first post in this thread.

    You are absolutely correct, good practice would be to avoid 1.0 (and 0.0 for that matter)
    usually they are independent effects
    If we leave out absorption or scattering, we have a zero-valued coefficient (though I do agree that leaving out scattering can make some sense for practical/pragmatic reasons). Anyways: If there is scattering, it does affect transmission and vice versa.

    Separating the two is (still low-level enough to leave out scattering and) fail-safe for a renderer interface, because as long as you feed it positive coefficients you end up with something basically plausible. Taking extinction instead of absorption would not be less plausible, but less fail-safe (and arguably slightly more low-level without reasonable gain), since the transmission coefficient would not be allowed to exceed the scattering coefficient for any spectral band considered.

    For some evidence on the renderer side, using OSL implemented in Cycles when we

    Code:
    returrn sigma_a * absorption() + sigma_s * henyey_greenstein( directional_bias );
    we trigger a code path that sums up sigma_a and sigma_s to "sigma_t":

    https://developer.blender.org/diffus...34617c4cd3$703
    https://developer.blender.org/diffus...34617c4cd3$682
    https://developer.blender.org/diffus...634617c4cd3$24

    in many simple usecases i would argue the scattering should be the same value for R,G and B (wax, translucent plastics all scatter because of white particles/airbubbles while the absorption happens in the colored substrate)
    Looking at a candle, we can observe a (more or less) similar hue for albedo and transmission, and in that case the calculation produces a scattering coefficient representing a color with (relatively) low saturation.
    Last edited by tschw; February 13th, 2018 at 22:15.

  6. #6
    Join Date
    Jan 2007
    Posts
    314

    Default

    Quote Originally Posted by tschw View Post
    I've been looking into this, because we have several semitransparent "materials" (in the CAD / CG sense, ideally) composed of visibly thick, textured layers of the same (physical) material. Most unfortunately, Iray does not support varying volume coefficients yet. Will it be in the next release, BTW?
    The first release for 2018 will still have uniform restriction for volumes, i do not have information on the feature set for subsequent releases yet.

    As for the soundness of the approach:
    Well, I would call it "considering the net effect of transmission", also making the naming more accurate: The physical model has a transmission term and a diffusion term. The transmission term models extinction and its coefficient is really just the sum of scattering and absorption coefficients.

    On the same hand, albedo is the nothing else than "the net effect of scattering" - we also like to call it the "diffuse color" in more approximative / analytic models. It is defined as the ratio of reflection (in-scatter) and extinction (sum of out-scatter and absorption), because what we see is affected by what can travel out of the medium.

    Both definitions are given in the lecture I cited in my first post.
    I am a bit rusty at reading lectures so please bear with me.


    The albedo given here is the so called "single scattering albedo", the ratio of how likely a scattering event is vs how likely an extinction event is. (Or the efficiency of scattering vs the efficiency of extinction) And if you solve it the way you did, you get exactly that. a value that, for a given target attenuation, blends between "all attenuation is due to scattering" to "all attenuation is due to absorption". The interesting property is the constant target attenuation. (this is really intriguing and i have to try it)

    in-scattering is not reflection. in-scattering and out-scattering are the exact same effect, the interaction of light a beam with a "particle", thus having exactly the same probability density/effective area sigma_s. The albedo does not differentiate between in and out scattering. whenever light scatters out of one beam it scatters in into another beam. Its thus not "lost" Having it in 2 places is the result of looking at the problem from the point of the beam.

    "single scatter albedo" is still pretty different from "diffuse color" or "diffuse reflectance. Taken from the Lectures, the "single scattering albedo" of milk is close to 1 but its diffuse reflectance is just ~.8. (and diffuse reflection for a dielectric is in this case just far field model for sss) Its thus not the net effect of scattering (as in how much of the light you input is actually scattered away)

    Its important to realise that the models presented at the lecture are just tools. You choose the right tool for the right job. The lecture separates between participating media and translucent materials while in fact both are physically the same and driven by the same parameters. Extinction is not an effect you model but the result of using the "beam of light" model. If you chose photons as the basis for modelling light transport then they might be absorbed or change their direction (scattered), thats all. The lecture also argues that for high albedo materials the "beam" model is not efficient. Iray in fact will use path tracing for evaluating both.

    That all does not affect the validity of your choosen parameterization, in fact like you said the parameters should be intuitive and thats all that matters.

    If we leave out absorption or scattering, we're manually performing constant folding and subsequent dead code elimination for a zero-valued coefficient (though I do agree that leaving out scattering can make some sense for practical/pragmatic reasons). Anyways: If there is scattering, it does affect transmission and vice versa.
    It realise that you see the transmission coefficient as the probability density of how likely a light passes through the volume in a singular direction. In that context you are of course right.

  7. #7
    Join Date
    Feb 2018
    Posts
    8

    Default Hue-neutral scattering and constant target attenutation

    Thank you for your clarifications & comments, they are very helpful and inspiring!

    The interesting property is the constant target attenuation (this is really intriguing and i have to try it).
    Low quality test render using a scattering coefficient with zero saturation by passing the same color for albedo and transmission color everywhere (different reference distance in texture and jelly):

    Click image for larger version. 

Name:	curved-texture-in-aspic-mono-scatter.png 
Views:	14 
Size:	228.6 KB 
ID:	10029

    Low quality test render using constant target attenuation using a hard-coded, gray transmission "color" everywhere (different reference distance in texture and jelly):

    Click image for larger version. 

Name:	curved-texture-in-aspic-const-att.jpg 
Views:	13 
Size:	23.9 KB 
ID:	10030

    Completely constant target attenuation is probably not realistic, but mixing against a constant allows to gradually achieve constant "spatial stickiness":

    Click image for larger version. 

Name:	curved-texture-in-aspic.png 
Views:	13 
Size:	215.5 KB 
ID:	10031

    Extinction is not an effect you model [...] It realise that you see the transmission coefficient as the probability density of how likely a light passes through the volume in a singular direction.
    Exactly! Based on the educated guess that it's roughly what we see, the basic idea was to invert the calculation to get a WYSIWYG parameter.

    I am a bit rusty at reading lectures so please bear with me.
    Therefore you went quite thorough ... I certainly didn't mean to make you read all of it and just wanted to provide some evidence that the calculations don't come out of nowhere - they're all in a relatively small spot.
    Last edited by tschw; February 14th, 2018 at 17:46.

Posting Permissions

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