Announcement

Collapse
No announcement yet.

An assortment of OSL shaders for your perusal

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Originally posted by Ivan Mavrov View Post
    You do the Fresnel term math (hopefully matching that of the microfacet_ggx) and figure out the reflection weight.
    Right. The burning question then is: What would the code be for that?

    Comment


    • You can probably trust the built-in "fresnel" function.

      Code:
      surface FresnelWeightedSurface (
      	color diffuse_color = color(1.0),
      	color reflection_color = color(1.0),
      	
      	float environment_ior = 1.0,
      	float material_ior = 1.5
      ) {	
      
      	float environmentIOR = max(1.0, environment_ior);
      	float materialIOR = max(1.0, material_ior);
      	
      	float reflectionWeight;
      	float transmissionWeight;
      	vector reflectionDirection;
      	vector transmissionDirection;
      	
      	fresnel(
      		I, N, environmentIOR / materialIOR, 
      		reflectionWeight, transmissionWeight,
      		reflectionDirection, transmissionDirection
      	);
      	
      	color reflectionFilterColor = reflectionWeight * reflection_color;
      	color diffuseFilterColor = diffuse_color * (1.0 - reflectionFilterColor);
      	
      	Ci = 
      		diffuseFilterColor * diffuse(N) + 
      		reflection_color * microfacet_ggx(N, 0.25, materialIOR / environmentIOR);
      }
      Best regards,
      Ivan M.

      Comment


      • Okay so you are using the built in OSL Fresnel standard library function. That makes sense. I guess the question then is this: If in the next SP the microfacet_ggx will be updated to use per microfacet Fresnel, will the OSL fresnel function also be updated to calculate based on each microfacet of a surface, rather than calculating the Fresnel just once based on the viewing angle?

        Comment


        • You got me there. No, it cannot be updated.
          It is part of the OSL 1.3.3 standard and even if we edit it - the microfacet normals used for sampling will be on the renderer side of the wall and totally unreachable by the OSL code.
          We'll have to figure something else.

          Comment


          • Originally posted by Ivan Mavrov View Post
            You got me there. No, it cannot be updated.
            It is part of the OSL 1.3.3 standard and even if we edit it - the microfacet normals used for sampling will be on the renderer side of the wall and totally unreachable by the OSL code.
            We'll have to figure something else.

            Yeah. I think if we just used the per viewing angle Fresnel to attenuate the diffuse, we would end up with yucky darkening on the edges (an error that comes up a lot with sss), which is one of the issues that per microfacet Fresnel solves.

            I asked again in the OSL developers group. Hopefully someone there can suggest a good approach.

            BTW, OSL is now at 1.7.4. Are you guys planning on staying with 1.3.3?

            Comment


            • Here's a link to the OSL group thread if you want to have a look. Not sure I follow, as this gets deeper into shader writing than I can swim:
              https://groups.google.com/forum/#!to...ev/Pm4rAapxOj0

              it seems tho that the recommended way that SPI does it is to have a closure that does both diffuse + spec together
              Last edited by sharktacos; 02-09-2016, 09:07 AM.

              Comment


              • We are not planning to stay indefinitely with 1.3.3 - we will update eventually.

                Thank you for bringing up the problem in the OSL group. I'll be following the topic.

                Comment


                • Now that I think about it, a blendMtl in additive mode is not energy conserving either. Have you Chaos folks thought of making the additive mode work with weighted averages, rather than just cumulative adds? While this would not entirely make it energy conserving, it would go in the right direction. Thoughts?

                  Comment


                  • i scripted one such shader.
                    http://forums.chaosgroup.com/showthr...688#post636688

                    It lacked the interplay features (shared fresnels and such) of coded ones, but it was energy preserving at the top, and allowed for a few layers to be stacked on each other without breaking reciprocity anywhere.
                    The unfortunate side-effect of doing it with scripting was that i decided to not analyse the layers for their residual energy (no texture sampling), so i did conserve energy allright, but often a bit too much.
                    I stopped short of texture mapping of the parameter set, and just did one for the diffuse color to show how.
                    The code then went the Chaos Group way, a few months before I followed.
                    Its current status is MIA, but i believe the guys have long been looking at ways to do such a thing, and a bit more to the side.
                    Lele
                    Trouble Stirrer in RnD @ Chaos
                    ----------------------
                    emanuele.lecchi@chaos.com

                    Disclaimer:
                    The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                    Comment


                    • Originally posted by sharktacos View Post
                      Now that I think about it, a blendMtl in additive mode is not energy conserving either. Have you Chaos folks thought of making the additive mode work with weighted averages, rather than just cumulative adds? While this would not entirely make it energy conserving, it would go in the right direction. Thoughts?
                      It can be done, of course, but I don't like the concept very much as such weighted average composites tend to behave somewhat unexpectedly as you start adjusting the weights... We had to do it in order to support MDL materials, but I still haven't decided if I want it exposed as part of the blend material itself.

                      Best regards,
                      Vlado
                      I only act like I know everything, Rogers.

                      Comment


                      • Hmmm. I was not aware of any unexpected results with it, but I only have experience with trying it in OSL shaders. Perhaps it could be an option checkbox under "additive mode" that defaults to off?

                        Incidentally, I don't see MDL materials in the docs. Where is that?

                        Comment


                        • Rens,

                          Thank you for sharing these great textures.

                          Is anyone else having problems with slow updates in the material editor? When I go to the OSL texture, it seems to redraw 3-4 times (slowly) before it lets me work with the interface.

                          Comment


                          • Originally posted by davision View Post
                            Is anyone else having problems with slow updates in the material editor? When I go to the OSL texture, it seems to redraw 3-4 times (slowly) before it lets me work with the interface.
                            Yes, I have this issue in 3ds Max 2017. I reported it to our OSL developers and they are looking into it.

                            Best regards,
                            Vlado
                            I only act like I know everything, Rogers.

                            Comment


                            • Thanks Rens for all these very useful stuff !
                              I have a question regarding "The Reflector" one and I am sorry if that have been answered before but I would like to know how to use this l with a texture for the reflection ?(
                              (I have created a material in Substance Painter and when I export it I need to use a reflection map to re-create it in Max .)
                              Thanks in advance
                              -------------------------------------------------------------
                              Simply, I love to put pixels together! Sounds easy right : ))
                              Sketchbook-1 /Sketchbook-2 / Behance / Facebook

                              Comment


                              • Hi - just with the archglass shader - is opacity supposed to work on it? I'm not getting an alpha out of it.
                                Maya 2020/2022
                                Win 10x64
                                Vray 5

                                Comment

                                Working...
                                X