Announcement

Collapse
No announcement yet.

OSL goodness in Vray

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

  • mayanic
    replied
    I'm trying to get the complex_ior to run ...

    when i plug the shader nothing changes and i wonder where the interface is?

    Leave a comment:


  • sharktacos
    replied
    Originally posted by mayanic View Post
    sorry for that dumb question, but how to wire up the nodes in order to get the osl shader to work?

    [ATTACH=CONFIG]25163[/ATTACH]
    Depends on the OSL shader. Which one are you using? Most are meant to go in the reflection with Fresnel off on the material.

    Leave a comment:


  • mayanic
    replied
    sorry for that dumb question, but how to wire up the nodes in order to get the osl shader to work?

    Click image for larger version

Name:	Screen Shot 2015-07-20 at 00.26.21.jpg
Views:	1
Size:	504.1 KB
ID:	857887

    Leave a comment:


  • sharktacos
    replied
    Originally posted by vlado View Post
    It is in the changelog for the 3.20 releases:

    (*) VRayOSLMtl/VRayOSLTex: Support for drop-down controls;

    The nightly builds release notes are pulled automatically from Mantis, but this is not very reliable.

    Best regards,
    Vlado
    Are you possibly referring to Max? I do see a 3.20 release for Max (which we don't use), but I only see 3.0 for Maya in the downloads section. Thanks

    Leave a comment:


  • vlado
    replied
    Originally posted by sharktacos View Post
    I looked in the release notes in the nightlies and I do not see this mentioned there. Where could I get a list of the changes to OSL that have been implemented?
    It is in the changelog for the 3.20 releases:

    (*) VRayOSLMtl/VRayOSLTex: Support for drop-down controls;

    The nightly builds release notes are pulled automatically from Mantis, but this is not very reliable.

    Best regards,
    Vlado

    Leave a comment:


  • sharktacos
    replied
    Originally posted by vlado View Post
    Drop-down menus actually do work in the latest builds - you used that in the fabric shader...

    Best regards,
    Vlado

    LOL, I put the code in, but it was not working in my version. I'm glad it is now.
    I looked in the release notes in the nightlies and I do not see this mentioned there. Where could I get a list of the changes to OSL that have been implemented?

    Leave a comment:


  • vlado
    replied
    Originally posted by sharktacos View Post
    One thing to note is a lot of the metadata widgets are not yet implemented yet which impact the user interface (sliders, dropdown menus, etc).
    Drop-down menus actually do work in the latest builds - you used that in the fabric shader...

    Best regards,
    Vlado

    Leave a comment:


  • joconnell
    replied
    You're a superstar - much appreciated for that.

    Leave a comment:


  • sharktacos
    replied
    Joconnell asked elsewhere
    Actually that's a thing too - your cloth shader looks great, do you have any links for intro to osl stuff or did you just jump in and start messing with other peoples examples?
    What I basically did was create shader in Maya by connecting a bunch of stuff in the Hypershade of Maya to mock it up, then I built that in OSL, adding more functionality as I went beyond what I could do with just a node tree.

    Here are some links to stuff that helped me get my head around OSL:

    Manuals First is the Chaos OSL help.
    One thing to note is a lot of the metadata widgets are not yet implemented yet which impact the user interface (sliders, dropdown menus, etc). Also the print functions do not currently work which would help a lot with debugging. Now it either works or doesn't with no way to know what is broken.

    Next is the official manual: SPI OSL manual (pdf)

    Examples the next thing, as you said, is to learn from examples of what other folks are doing.
    First up, of course, are the examples from Chaos: Chaos OSL respository
    Then there are lots of Maya nodes here OpenMaya example OSL (remember that as the Chaos help says "The VRayOSLMtl takes into account only closure color output parameters." So all of these need to have the output changed to color so they will work)
    and some fun textures here Sambler example OSL dfggd
    and some examples from Sony too SPI example OSL

    Since OSL is C-based, it's pretty easy to take a shader from a paper that was written in C++ and re-write it in OSL which means all those Siggraph papers with new cool functionality can be used in Vray with OSL.

    Leave a comment:


  • sharktacos
    replied
    Here's another OSL shader I thought was cool. It was originally posted in the Max forums here: http://forums.chaosgroup.com/showthr...light=gold+osl.

    It uses the complex fresnel equation for metals, but to make it more artist friendly it remaps the refractive index (n) and extinction coefficient (k) to the more intuitive reflectivity (r) and edge tint (g) which are input as RGB colors. You use it just like the complex_IOR.osl (i.e. in a VrayOSLTex mapped to the reflection with Fresnel off).

    I tweaked it so it would work in Maya, and hard-coded in the gamma correction:

    Code:
    //--Artist Friendly Metallic Fresnel--
        // BY Ole Gulbrandsen - Framestore
        //olegul@hotmail.com
        //http://jcgt.org/published/0003/04/03/
        //OSL version by JayCMiller
        //jcmiller.web@gmail.com
        
    
    float n_min( float r )
    { return (1-r )/(1+ r ); }
    
    
    float n_max( float r )
    { return (1+ sqrt ( r ))/(1- sqrt ( r )); }
    
    float get_n ( float r , float g)
    { return n_min( r )*g + (1-g)*n_max( r ); }
    
    
    float get_k2 ( float r , float n)
    { 
    float nr = (n+1)*(n+1)*r-(n-1)*(n-1);
    return nr/(1-r );
    }
    
    float get_r ( float n, float k)
    { return ((n-1)*(n-1)+k*k )/(( n+1)*(n+1)+k*k);  }
    
    float get_g ( float n, float k)
    {
    float r = get_r (n,k);
    return (n_max( r)-n )/( n_max( r)-n_min( r ));
    }
    
    float AFMF ( float r , float g, float theta )
    {
    //clamp parameters
    float _r = clamp(r ,0 ,0.99);
    
    //compute n and k
    float n = get_n (_r ,g);
    float k2 = get_k2 (_r ,n);
    float c = cos ( theta );
    float rs_num = n*n + k2 - 2*n*c + c*c;
    float rs_den = n*n + k2 + 2*n*c + c*c;
    float rs = rs_num/ rs_den ;
    float rp_num = (n*n + k2)*c*c - 2*n*c + 1;
    float rp_den = (n*n + k2)*c*c + 2*n*c + 1;
    float rp = rp_num/ rp_den ;
    
    return 0.5*( rs+rp );
    }
    
    shader AFMFresnelTex
    (
    
    color Reflectivity = color(0.9451,0.7294,0.3725),
    color Edgetint = color(0.9961,0.9725,0.7333),
    //float Color_Gamma = 0.4545,
    
    output color result = color(0.5)
    )
    
    {
    float thetaB = acos(dot(-I,N));
    float RCH = AFMF(Reflectivity[0],Edgetint[0],thetaB);
    float GCH = AFMF(Reflectivity[1],Edgetint[1],thetaB);
    float BCH = AFMF(Reflectivity[2],Edgetint[2],thetaB);
    
    
    //result = pow(color(RCH,GCH,BCH), 1/Color_Gamma);
    
    result = pow(color(RCH,GCH,BCH), 2.2);
    
    }

    Leave a comment:


  • sharktacos
    replied
    Let me also mention that the bump map behavior is not the same as a VrayMtl. It looks to me like it is off by a factor of around 100, so to get the same bump as a vrayMtl with a bump value of 1.0 the OSL needs a bump value of 100. A quick and dirty workaround is just to add a multiplication like this:
    Code:
    float Bump_amount = Bump_amount * 100;
    but I thought I'd mention it as I'm sure there must be a more elegant/accurate way to address it in the code so it matches the behavior of a VrayMtl more precisely.

    Leave a comment:


  • sharktacos
    replied
    Originally posted by vlado View Post
    Here I've added tooltips to some parameters and renamed others to be perhaps a bit clearer:
    https://confluence.chaosgroup.com/di...Fabric+shader#

    @Derek: do you want me to add some additional information to the page (like a link to your website)?

    Best regards,
    Vlado
    Looks great. It makes sense to rename things more explicitly as you have (Spec_glossiness instead of Glossiness etc). Hopefully once widgets are implemented in OSL one can use the "page" widget to organize the sliders the way a VrayMtl is (diffuse section, spec section, and so on).

    The pic would look better if it were lit by a directional light (it looks like it has HDRI lighting on it now), and was on a model of draped cloth like this: http://i.ytimg.com/vi/hmPHq0WTt-k/maxresdefault.jpg

    I'll see if I can render something, and email it to you along with the Maya scene.

    Leave a comment:


  • vlado
    replied
    There is a bug in the OSL library that manifests itself on Windows 8.1; we've fixed this and submitted a patch, but for the moment you will need a nightly build to get it working. You can email support@chaosgroup.com to get that.

    Best regards,
    Vlado

    Leave a comment:


  • doark
    replied
    Hello,

    I tried to use the Frabic file from OSLShaders in the V-Ray for Maya 2015 SP6, Win 8.1 (version 3.05.04, revision 25954 from Jun 29 2015) But once I load the file I get fatal error. Is there any other step that I did not understand?

    Thanks for OSL and attention!

    Leave a comment:


  • vlado
    replied
    Here I've added tooltips to some parameters and renamed others to be perhaps a bit clearer:
    https://confluence.chaosgroup.com/di...Fabric+shader#

    @Derek: do you want me to add some additional information to the page (like a link to your website)?

    Best regards,
    Vlado

    Leave a comment:

Working...
X