Announcement

Collapse
No announcement yet.

OSL goodness in Vray

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

  • #46
    Originally posted by vlado View Post


    how would one adjust the scatter subdivs in OSL? I tried adding an "int subdivs" variable to the sss closure but it does not appear to have any affect.

    It looks like the global min. shading rate is the only way to control this.

    Best regards,
    Vlado
    Would it be possible to add subdiv control to the sss scatter in OSL in a future release?

    Also, two more questions on theory here:

    1. Am I correct that the sss part of the VraySkinMtl is made of 3 layers of sss2 added together with differing values for the scatter radius (in OSL the meanFreePath)? Or is there something more complex going on? That is, is the VraySkinMtl just this:

    spec
    +
    spec
    +
    sss2 (shallow
    +
    sss2 (med)
    +
    sss2 (deep)

    2. Some other renderers use 3 values for the scatter radius instead of a single float. The idea here I think is to have the red wavelength pass more light though that the blue or green.

    One could of course easily multiply the meanFreePath value (which is a color) by another color value. This seems kind of unintuitive to me however. I don't see any advantage of doing this. Is there something more complex/fancy going on with these the approach of these other sss shaders that I'm missing? I'm sort of guessing that since you guys opted to only have a single float for the radius that you are not a fan of the 3 channel approach. So perhaps you could comment on why you opted for the single channel radius approach?

    thanks

    Comment


    • #47
      2. Some other renderers use 3 values for the scatter radius instead of a single float. The idea here I think is to have the red wavelength pass more light though that the blue or green.
      You do have three values for the scatter radius - the meanFreePath is a color, so it has three separate values. Although it is represented as a color, the meanFreePath is actually the scatter radius for the red, green and blue light components.

      Originally posted by sharktacos View Post
      Would it be possible to add subdiv control to the sss scatter in OSL in a future release?
      Yes, will make a note about it.

      1. Am I correct that the sss part of the VraySkinMtl is made of 3 layers of sss2 added together with differing values for the scatter radius (in OSL the meanFreePath)?
      No, not exactly. The vray_subsurface() closure corresponds to the VRayFastSSS2 material. The VRaySkinMtl material is somewhat different; there I tried to follow the way it is implemented in other renderers and it works pretty much in the same way. It is calculated internally as three grayscale vray_subsurface() closures multplied by the color of the respective component (with the VRayFastSSS2 material being a special case where the three components have red, green and blue colors). The VRaySkinMtl is also optimized to compute the three sub-surface components together, whereas if you just add them in an OSL material, you could get the same result, but it would lead to way more calculations.

      Best regards,
      Vlado
      Last edited by vlado; 30-08-2015, 11:03 PM.
      I only act like I know everything, Rogers.

      Comment


      • #48
        Great thread - thanks for the fabric shader sharktacos - it's easier and looks better than my own I've been using for years.

        @Vlado- will there be basic texture support coming for VP2? I see that it already works in VP1 so I assume it is on the list...but just in case I thought I should post something.
        Maya 2020/2022
        Win 10x64
        Vray 5

        Comment


        • #49
          How does one achieve a "gold" look with the advanced refraction osl texture?

          I go to here;
          http://refractiveindex.info/?shelf=3...tals&page=gold

          And use wavelengths for:
          Red: 0.65
          Green: 0.51
          Blue: 0.475

          to extract k and n values for gold but the colour I get from the OSL texture looks like a copper colour? Anyone can give me pointers where I am doing this wrong?

          Click image for larger version

Name:	gold.JPG
Views:	1
Size:	29.8 KB
ID:	858244
          Click image for larger version

Name:	goldShad.JPG
Views:	1
Size:	53.0 KB
ID:	858245
          Maya 2020/2022
          Win 10x64
          Vray 5

          Comment


          • #50
            I've been thinking about that as well; I think the problem comes from point-sampling the reflectance curves at specific wavelengths. For some materials just moving the wavelengths a little bit up or down can change the appearance a lot, which doesn't seem normal. I think the correct approach would be to integrate the color values over the CIE color curves for red/green/blue. However that would require some tool to download preprocess the n/k curves over the entire visible spectrum (or at least, some more wavelengths, like 20 or 50 or 100). Maybe one of the devs here can look into this...

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

            Comment


            • #51
              No problem, thanks Vlado.

              With regards to the OP's cloth shader, it seems that "Trace reflections" is not respected.

              Click image for larger version

Name:	Capture.JPG
Views:	1
Size:	66.5 KB
ID:	858247
              Maya 2020/2022
              Win 10x64
              Vray 5

              Comment


              • #52
                Hm, ok will look into it.

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

                Comment


                • #53
                  I'm noticing that the code I have for a bump map in OSL does not match a VrayMtl bump exactly. Wondering if someone knows how to fix this? Here's a gif showing the difference:

                  Click image for larger version

Name:	OSLb.png
Views:	1
Size:	57.2 KB
ID:	858334
                  Click image for larger version

Name:	OSLa.png
Views:	1
Size:	56.5 KB
ID:	858335

                  The images are close, but still off. It seems that the VrayMtl bump goes in a bit more and is shifted slightly (as if it is rotated in Y). Also the delta is set in the OSL to 0.004 while the delta in the VrayMtl defaults to 1.0.

                  Note to get this I had to set the bump amount on the OSL to 10 rather than 1 (which the VrayMtl bump is set to). So initially the difference is even greater.

                  Here's the OSL

                  Code:
                  normal getBumpedBump(color centerColor, color uColor, color vColor, float inverseBumpAmount)
                  {
                  
                      vector worldTangent = normalize(dPdu);
                      vector worldBitangent = normalize(dPdv);
                      vector worldNormal = normalize(N);
                      vector average = vector(0.3333333);
                  
                      float center = dot(average, vector(centerColor));
                      float ddu = center - dot(average, vector(uColor));
                      float ddv = center - dot(average, vector(vColor));
                      
                      return normalize(ddu * worldTangent + ddv * worldBitangent + inverseBumpAmount * worldNormal);
                  
                  }
                  
                  
                  surface bump_mat
                  (
                      /* Diffuse section */   
                      color Diffuse_color = 0.5,
                      float Diffuse_weight = 0.8,
                      float Roughness = 0.0,
                      
                      /* Bump section */
                      string Bump_texture = "bump.png",
                      float Bump_amount = 1.0,
                      float delta = 0.004,
                      output color result = 1 )
                  
                  {
                  
                      /* Define Bump */
                      normal bumped_normal = N;
                      if (Bump_amount > 0.0)
                      {
                          color center = texture(Bump_texture, u, v);
                          color uColor = texture(Bump_texture, u + delta, v);
                          color vColor = texture(Bump_texture, u, v + delta);
                          bumped_normal = getBumpedBump(center, uColor, vColor, 1.0 / Bump_amount);
                      }
                   
                          
                          closure color diffuse_component =  Diffuse_color * Diffuse_weight * diffuse(bumped_normal, "roughness", Roughness);
                          Ci = diffuse_component;
                     
                  }

                  Comment


                  • #54
                    Vlado - I can't work out what it is but it may not be "trace reflections" that is causing the issue but rather glossiness of the specular is not respected. Well at least on my tests and scenes it seems this is the case.
                    Maya 2020/2022
                    Win 10x64
                    Vray 5

                    Comment


                    • #55
                      Okay it is definitely the specular, something is messed up - it is fixable by turning the spec colour to 100% black.

                      Click image for larger version

Name:	spec.JPG
Views:	1
Size:	31.6 KB
ID:	858373
                      Maya 2020/2022
                      Win 10x64
                      Vray 5

                      Comment


                      • #56
                        Can you post a test scene? I am not able to reproduce the error.

                        Comment


                        • #57
                          Originally posted by snivlem View Post
                          Okay it is definitely the specular, something is messed up - it is fixable by turning the spec colour to 100% black.

                          [ATTACH=CONFIG]26068[/ATTACH]

                          Okay I think I see the problem. The shader uses a Vray_Blinn closure combined with a reflection closure. The reflection closure has a parameter for the ETA (the fresnel reflection IOR), but does not have a parameter for reflection glossiness. The Blinn closure has glossiness, but does not have the ETA. A quick fix would be to do this:

                          Code:
                          closure color specular_component = Spec_amount * SpecColor *       
                                      vray_blinn (bumped_normal, Glossiness, Anisotropy, Aniso_rotation,       
                                      "subdivs", Subdivs, "trace_reflections", Trace_reflections);       
                          
                                  Ci = diffuse_component + specular_component + sheen_component;
                          This basically removes the reflection component. The Vray_Blinn is also doing reflections, so the reflection closure is redundant. The Vray_Blinn closure does not have a parameter for fresnel, but the shader has code that adds this to it.
                          Last edited by sharktacos; 21-09-2015, 10:21 AM.

                          Comment


                          • #58
                            Awesome, that code seems to have fixed it. This is a very nice shader - thanks for sharing it.
                            Maya 2020/2022
                            Win 10x64
                            Vray 5

                            Comment


                            • #59
                              Originally posted by Zdravko.Keremidchiev View Post
                              Alright, let me know if the issue still persist.
                              Filed a ticket, i get this issue on 3 out of 4 identical nodes :/
                              OSL include path not set error, and i get black bucket

                              Click image for larger version

Name:	issue.jpg
Views:	1
Size:	535.1 KB
ID:	858413

                              Comment


                              • #60
                                The support guys will look into that, but in the meantime have you tried using .oso files instead of the original .osl?

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

                                Comment

                                Working...
                                X