Announcement

Collapse
No announcement yet.

VRayOSLMtl appears to cache previously loaded OSL shaders by name

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

  • VRayOSLMtl appears to cache previously loaded OSL shaders by name

    Hi,

    Not sure if this is a bug or not. I guess it was confusing to me so I'll share it.

    I'm trying to play around with OSL again. One thing I noticed is that V-Ray caches OSL "surface" shaders by name internally to the VRayOSLMtl. And it seems to do so forever, even if you change the source code to the OSL shader and reload it.

    Here is how to reproduce the caching forever issue:

    Code:
    shader Test
    (
    	color diffuseColor = color(1.0,0.0,0.0),
    	color specularColor = color(1.0),
    	float glossiness = 1.0,
    
    	output closure color Result = diffuse(0.8)
    
    )
    
    {
    	closure color d = diffuseColor * diffuse(N);
        closure color s = specularColor * vray_blinn(N, glossiness, 0.0, 0.0, "trace_reflections", 1 );
    
        Result = s + d; // render once, and then uncomment out s or d, and run again, no change will be visible in viewport.
    }
    Save it to disk as test.osl. Then create a simple scene and add a VRayOSLMtl with this as its shader. It will render fine. Now modify the above OSL code, like remove "+ d" to remove the diffuse BRDF closure. Now try to get V-Ray to render this new OSL shader. You can try to reload it in the VRayOSLMtl, or you can load a different *.osl file and then reload this *.osl file, but it will always render with both "s + d" even though the code doesn't read that way.

    The only want to get the new *.osl file to load is to either create a new VRayOSLMtl, or you need to change the Name of the shader in the first line of the OSL shader and then reload it -- thus there seems to be forever caching of valid OSL shaders per VRayOSLMtl that is based on the OSL shader name.

    Best regards,
    Ben Houston

  • #2
    BTW I do not need this fixed. I'll switch to editing osl attached to a *.vrscene and run it on the command line. Probably a better workflow for code editing anyhow.

    Comment


    • #3
      Which V-Ray version is that? I've done a few OSL shaders now and reloading the shader always recompiles the right thing.

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

      Comment


      • #4
        V-Ray version 3.20.03 for 3DS Max. OSL is pretty neat and the integration into V-Ray is really powerful I have to say. Thank you!

        BTW it still compiles the OSL shader, that is part of the confusion for me. I get error messages if I have syntax errors or whatever. But I believe that once there are no errors, it is put into a cache. It may not always be cached but I've been playing around with it again this evening, and it is giving me results that only make sense if it is cached, and it starts to behave properly if I rename the shader in the OSL file to a unique name and reload it.

        -ben

        Comment

        Working...
        X