OSL goodness in Vray

Hi guys,

Was there any solution to the VRayOSLMtl issues where when you try to render with a *.osl file directly using VRay Standalone, you get the error “OSL include path not set”? I assume it is a path required for oslc.exe?

I’m trying to setup an environment where I can easily code up some complex OSL shaders with V-Ray and was thinking VRay Standalone would be a great solution to this.

Best regards,
Ben Houston

yes, it works perfectly fine, my issue was some nodes had weird privelleges bug where enviroment varibale would disappear after install. So after setting it manually everything reads nicely!

Just having some time on RnD, before next episode starts. The idea is to have rain shader on top of the materials, to represent wetting with falling rain. Smth, like in UE4 and unity engines.

Any ideas ?

Very good looking stuff here done in blender

https://vk.com/video164595741\_171582289

and the papers behind this

Do you have the GLSL source that was used in the Blender example?

Best regards,
Vlado

I wish I had :slight_smile:

Only this

with old .fx shaders inside.

Does GLSL work with animated parameters in Vray? My understanding is that OSL does not currently.

In Max or in Maya?

Best regards,
Vlado

referring
I was to OSL in Maya.

Maya has an XML Attribute Editor template that defines how materials display. I was wondering if it would be theoretically possible to modify this to change how custom OSL materials display in the attribute editor? For example, currently the plastic example OSL currently lumps all the parameters together into one “shader parameters” section. Could an XML Attribute Editor template be used to divide this up into, say, diffuse and specular sections, the way other shaders appear in the attribute editor?

The XML files are static and there is no way to do what you’re after at the moment.
It seems to be a limitation in Maya.

The closure for subsurface is

closure color vray_subsurface (float refractiveIndex, float phaseFunction, color meanFreePath, color albedo);

previously there was no parameter for the sss subdivs. Has this been added in Vray 3.3? If so what is the new closure syntax? I was not able to find it listed in the docs.

Also, is it assumed that the scattering uses raytracing (rather than a prepass-based illumination map)?

There is no parameter for the subdivs right now. I’ll make a note to add it.

Yes, it uses raytracing only.

Best regards,
Vlado

Thanks. I’ll add the following to my materials so it will be forward compatible:


vray_subsurface (ior, phase_function, subsurfaceColor * radius, subsurfaceColor, [COLOR=#ff0000]"subdivs", subdivs[/COLOR]);

Here’s a fun OSL texture that give you hair color defined by Melanin and Dye color parameters, based on the paper “An Energy-Conserving Hair Reflectance Model

Usage: The resulting texture hair color goes in “transmission color” and “diffuse color” of a VrayHairMtl3, with the “diffuse value” ideally less than 0.5. The secondary specular is the hair color multiplied with itself (which is what the “lock secondary” checkbox in the VrayHairMtl does).

Some additional notes: I used a color for the melanin amount since there are no sliders for floats in Vray’s OSL in Maya, and colors have sliders. I just grabbed the red channel. Kinda sloppy, so perhaps someone has some ideas about a better way to do that. I’m thinking maybe a luminance().

Also I wanted the ability to put a texture map into the dye color. When you do that the color defaults to black, but the dye color should be white by default (if there is no dye). I used the gettextureinfo function to get it to actually default to white in the texture, but it still appears black in the attribute editor. So again, if folks have any ideas about how to address this, I’m all ears!


/*
 *
 * Hair color defined by Melanin and Dye color parameters
 * based on the paper "An Energy-Conserving Hair Reflectance Model"
 * http://www.eugenedeon.com/wp-content/uploads/2014/04/egsrhair.pdf
 * written for OSL by Derek Flood 
 * from http://docs.sharktacos.com/misc.php?action=help&hid=66
 *
 */

 color getTextureDif(string texture_name, color no_texture_default_color)
{
    int channels = -1;
    if (gettextureinfo(texture_name, "channels", channels))
    {
        return texture(texture_name, u, v);
    }

    return no_texture_default_color;
}

shader hairColorTex
[[ string description = "Hair color defined by Melanin and Dye color parameters " ]]
( 
    string Dye_color = "color.png"
        [[ string description = "White for non-dyed hair. If using a map, 
        put it here and set Melanin Amount to zero" ]],
    color Melanin_amount = 0.3 
        [[ string description = "Melanin concentration in hair fiber (from 0 to 1).
        0.0 is white hair, 0.2 is blond, 0.3 is auburn, ... until you get to 1.0 for black hair. 
        Since there are no sliders, we use a color and grab the red channel" ]], 
    float Texture_Gamma = 1,

    output color result = 0  
)  

{  

    /* Read texture map or default to white color */
    color DyeColor = getTextureDif(Dye_color, color(1,1,1));

    /* Compute a perceptualy linear absorption weight from Melanin_amount */

    float Weight = max( pow(Melanin_amount[2], 2.0) * 33.0, 0.02);

    /* The fiber color is actually an absorption term. As light travels through fibers, 
    melanin particles filter out some wavelength. We compute it using Beer's Law. */

    color hairColor = exp(Weight * -color(0.187, 0.4, 1.05));

    /* Now we model the dying process as a thin transparent film over the fiber that will filter transmitted light.
    This is simply a multiplication. */

    hairColor *= DyeColor;

    /* Finally we derive the values for the transmission and secondary specular, 
    which is the value of the hairColor squared. */

    result=pow(hairColor, Texture_Gamma); //optionally gamma correct color

}

Thank you, I was after this Hair OSL on the forums a few weeks ago. I was also on the RenderMan forums where I found this code. Are you able to supply it as an OSL file? I tried copy paste it into a text editor and it didn’t work.

I’m extremely interested in using the wet surface shader in my current project. Ill have to subscribe to this thread somehow.

If you look at my blog post you will see I have to render rain, steam, smoke. Maybe those pictures on my blog may inspire you to write some OSL shaders?

Sure, here you go:
http://docs.sharktacos.com/images/tutorials/Assets/OSL/DFhairTex.osl

Thank you very much for that :slight_smile:
- Ill test it out and give feedback.

That’s amazing work. Can you add a SSS control?

Not sure what you are referring to. SSS control for what?

hey sharktacos,

where are you applying linear workflow on your fabric.OSL?

MainColor = pow (MainColor, 2.2);?

I’ve since removed this line under V-Ray 3.3 and Maya 2016 because of native color management. Is this the only thing you did to “correct” linear workflow for older versions?