Announcement

Collapse
No announcement yet.

An assortment of OSL shaders for your perusal

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

  • #46
    Originally posted by mohammadreza_mohseni View Post
    fantastic shaders man!
    Thanks!

    Originally posted by ikomitov View Post
    Actually, VRayOSLTex and VRayOSLMtl are already MaxScript-able. Here is a small MaxScript excerpt that demonstrates how to control the VRayOSLTex map, including getting and setting the properties of the shader.
    Great stuff, thanks, that'll make Dave happy. : )
    Rens Heeren
    Generalist
    WEBSITE - IMDB - LINKEDIN - OSL SHADERS

    Comment


    • #47
      Originally posted by ikomitov View Post
      Actually, VRayOSLTex and VRayOSLMtl are already MaxScript-able. Here is a small MaxScript excerpt that demonstrates how to control the VRayOSLTex map, including getting and setting the properties of the shader. This example uses the CamMapScale shader posted by Rens:

      Hope this helps in your MaxScript adventures!
      Thanks Ivan, that's great... Can I put a request in to have a method to return the tweak names? Similar to how in maxscript we have 'getPropNames'

      Best regards

      Dave
      Maxscript made easy....
      davewortley.wordpress.com
      Follow me here:
      facebook.com/MaxMadeEasy

      If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

      Comment


      • #48
        Originally posted by vlado View Post
        Ivan, maybe you should put that on the docs page...

        Best regards,
        Vlado
        There will be a detailed MaxScript documentation/tutorial on the docs page in the near future. BTW, VRayGLSLMtl and VRayGLSLTex support the same TweakInterface too.

        Best regards,
        Ivan

        Comment


        • #49
          Originally posted by Dave_Wortley View Post
          Thanks Ivan, that's great... Can I put a request in to have a method to return the tweak names? Similar to how in maxscript we have 'getPropNames'

          Best regards

          Dave
          Yes, I'll extend the interface. If you can think of other methods that might be useful, please let me know.

          Best regards,
          Ivan

          Comment


          • #50
            Originally posted by ikomitov View Post
            Yes, I'll extend the interface. If you can think of other methods that might be useful, please let me know.

            Best regards,
            Ivan
            I guess something along the lines of showProperties that list all the properties and their types, and/or a method to get the type of data expected for the value, you can query a value you Get but if you haven't got a texmap in for instance it'll return undefined value.
            Maxscript made easy....
            davewortley.wordpress.com
            Follow me here:
            facebook.com/MaxMadeEasy

            If you don't MaxScript, then have a look at my blog and learn how easy and powerful it can be.

            Comment


            • #51
              Rens,
              A question for you: I'm working on implementing the Disney Principled BRDF in OSL. For the "spec tint" they say they tint the incident specular towards the base color, while keeping the grazing specular achromatic (this on a GGX brdf). Any ideas as to how to approach that in OSL? The GGX closure has fresnel built into it (the eta parameter), but I suppose one could also do the Fresnel manually too, like this

              Code:
              float fresnelReflectionFactor(normal bumped_normal, float ior, color TintSpec)
              {
                  float c = abs(dot(I, bumped_normal));
                  float g = ior * ior - 1.0 + c * c;
                  if (g > 0.0) {
                      g = sqrt (g);
                      float A = (g - c) / (g + c);
                      float B = (c * (g + c) - 1.0) / (c * (g - c) + 1.0) ;
                      return 0.5 * A * A * (1.0 + B * B);
                  }
               
                  return 1.0;
              }
              .I'm just not sure how to tint just just the incident specular/reflections without affecting the grazing specular/reflections.

              Comment


              • #52
                Originally posted by sharktacos View Post
                Rens,
                A question for you: I'm working on implementing the Disney Principled BRDF in OSL. For the "spec tint" they say they tint the incident specular towards the base color, while keeping the grazing specular achromatic (this on a GGX brdf). Any ideas as to how to approach that in OSL? The GGX closure has fresnel built into it (the eta parameter), but I suppose one could also do the Fresnel manually too, like this
                .I'm just not sure how to tint just just the incident specular/reflections without affecting the grazing specular/reflections.
                Nice! I was looking at that a couple of months ago, but the main issue with implementing this in OSL is that you can't write BRxFs/closures yourself. In this case specifically you need a new closure for the diffuse. You could however, come to think of it, try and scale an existing closure somehow? So you could scale the Lambert closure to fit. However you still don't have access to lights so I'm not sure how far you'd get.

                To answer your question, the GGX closure Fresnel parameter will scale the reflection, but not tint it. If I remember correctly you'd mix the tint colour and white using a Fresnel function like you posted. However I'd use Schlick as it's a bit quicker.
                Have a look at the rhfunctions.h file, it has several reflection funtions.

                To mix you could use something like this:
                Code:
                a = Fresnel_Amount;
                c1 = Tint;
                c2 = White;
                
                r = Reflection_Without_Fresnel;
                
                out = r * (  (c2 * a) + (c1 * (1 - a)) );
                Rens Heeren
                Generalist
                WEBSITE - IMDB - LINKEDIN - OSL SHADERS

                Comment


                • #53
                  Thanks. This mixes between two colors using the fresnel as the mask. So if the tint color is red, you get white edges and red in the middle. But for Fresnel it should be dark red in the middle and white on the edges. Perhaps I'm not getting what Reflection_Without_Fresnel refers to. Is it the same as the reflection amount (Ks)?

                  Perhaps I could multiply the mix by the Fresnel to tint it:
                  Code:
                  color Mix = r * (  (c2 * a) + (c1 * (1 - a)) );
                  Mix = a * Mix;
                  Last edited by sharktacos; 02-06-2016, 10:58 PM.

                  Comment


                  • #54
                    Well, it depends on if you would want to drive the zero incidence / front facing colour completely or have it as a pure tint only. Looking at the paper they have a metalness parameter, so your example would be the one to use. And then you change the Fresnel falloff amount to switch to a metal, and leave the tint colour as just a pure tinting.

                    And in my example r would be a pure reflection closure without Fresnel falloff, like a raw reflection.
                    Rens Heeren
                    Generalist
                    WEBSITE - IMDB - LINKEDIN - OSL SHADERS

                    Comment


                    • #55
                      Don't know whom to get on the nerves with this, propably vlado:
                      If I use the Mix normal map with a VrayBump2Normal in one of the inputs, max allways crashes.

                      Rens, could you be so kind and make a blur map? Just a map which burs its input map, maby with several bur algorithms.
                      And if possible keep it seamless.
                      I was allways wondering why max dosn't allready has such map, could be so usefull.

                      Thanks for the uv transform. I wish for that for a long time.
                      German guy, sorry for my English.

                      Comment


                      • #56
                        Originally posted by Rens View Post
                        Well, it depends on if you would want to drive the zero incidence / front facing colour completely or have it as a pure tint only. Looking at the paper they have a metalness parameter, so your example would be the one to use. And then you change the Fresnel falloff amount to switch to a metal, and leave the tint colour as just a pure tinting.

                        And in my example r would be a pure reflection closure without Fresnel falloff, like a raw reflection.
                        Actually the part I'm working on currently is not the "metallic" parameter, but the "spec tint" parameter which just tints the incident spec color for a dielectric material. Here's what I came up with. I think it will do the trick.

                        Code:
                        color TintColor= mix(1,BaseColor,Specular_Tint); //mix between baseColor and white based on Specular_Tint amount
                        color Tint = mix(TintColor,1,Fresnel); //mix between tintColor and white based on Fresnel
                        Fresnel *= Tint;
                        Thanks for helping me kick start my brain with that

                        Comment


                        • #57
                          Originally posted by Ihno View Post
                          If I use the Mix normal map with a VrayBump2Normal in one of the inputs, max allways crashes.
                          Yes, I know. We will correct the crash, but I'm not sure we can fix the actual issue.

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

                          Comment


                          • #58
                            Originally posted by vlado View Post
                            Yes, I know. We will correct the crash, but I'm not sure we can fix the actual issue.

                            Best regards,
                            Vlado
                            Just out of interest, this happens because the VrayBump2Normal is only calculated properly while rendering?
                            Are there other Maps that can cause the same?

                            If somone else runs into that Problem too:
                            As workaround, you can bake the vraybump2normal and put the resulting Texture into the input.
                            Last edited by Ihno; 03-06-2016, 05:46 AM.
                            German guy, sorry for my English.

                            Comment


                            • #59
                              Originally posted by Ihno View Post
                              Just out of interest, this happens because the VrayBump2Normal is only calculated properly while rendering?
                              No, it's because the VRayBump2Normal map requires a V-Ray compatible shade context, but the Normal map only passes a regular 3ds Max shade context to it. It might work better with the VRayNormalMap instead.

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

                              Comment


                              • #60
                                Originally posted by Rens View Post
                                Nice! I was looking at that a couple of months ago, but the main issue with implementing this in OSL is that you can't write BRxFs/closures yourself. In this case specifically you need a new closure for the diffuse. You could however, come to think of it, try and scale an existing closure somehow? So you could scale the Lambert closure to fit.
                                I think I can get the diffuse to work like this
                                Code:
                                color BaseLess = BaseColor * ( (1.0 - Fresnel) * 0.5 ); // reduce diffuse by 0.5 at grazing angles for smooth surfaces
                                color BaseMore = BaseColor * Fresnel * 2.5; // increase diffuse by up to 2.5 at grazing angles for rough surfaces.
                                BaseColor = mix(BaseLess,BaseMore,RoughnessAmount);
                                The place where I get stuck is the subsurface. They use the Hanrahan-Krueger BSDF to do a cheap/fast sss, and as you say, you can't write BxDFs/closures in OSL. So I'm at a loss what to do for that part -- other than to exclude it. Any thoughts?

                                Comment

                                Working...
                                X