Announcement

Collapse
No announcement yet.

OSL, hiding widgets with [[ string widget = "null" ]]

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

  • OSL, hiding widgets with [[ string widget = "null" ]]

    Hi,

    When creating a UI widget for texture, two widgets are created (myTex and diffuseTexture). I'm trying to hide one of them (as both are not needed) with:

    Code:
    surface test_shader
    (
    	string myTex = "hello.png" [[ string widget = "null" ]],
    	color diffuseTexture = texture(myTex, u, v),	
    )
    
    {
    }
    But for some reason, myTex turns into a textfield... any idea what I may be doing wrong here?
    Best Regards,
    Fredrik

  • #2
    This is all valid OSL code so nothing wrong there.

    But I have some explaining to do.
    The smaller thing is that UI hints (such as the parameters' metadata) are not supported at this time.
    The BIGGER thing is the OSL integration concept adopted in V-Ray.

    Short story:
    String input parameters are considered as texture input parameters.
    Therefore an enabled texture button would be available for every string input parameter.
    This is the only way to establish input connections to an OSL shader (for now).

    I would suggest using this example:
    Code:
    surface test_shader
    (
    	string diffuseTexture = "hello.png",
    	output color result = color(0.0)
    )
    {
    	result = texture(diffuseTexture, u, v);
    }
    Best regards,
    Ivan Mavrov

    Comment


    • #3
      Hi Ivan,

      Originally posted by Ivan Mavrov View Post
      This is all valid OSL code so nothing wrong there.

      But I have some explaining to do.
      The smaller thing is that UI hints (such as the parameters' metadata) are not supported at this time.
      The BIGGER thing is the OSL integration concept adopted in V-Ray.
      Yes, the fact that you adopted OSL is huge!


      Short story:
      Code:
      surface test_shader
      (
      	string diffuseTexture = "hello.png",
      	output color result = color(0.0)
      )
      {
      	result = texture(diffuseTexture, u, v);
      }
      That's great, thank you!
      Last edited by Fredrik Averpil; 16-06-2014, 04:16 AM.
      Best Regards,
      Fredrik

      Comment


      • #4
        When I do as you suggested, I would expect the texture slider to start out as black. But instead, it starts out at white. This means that e.g. refractions would be enabled by default. Any way to change this into making the slider start out as black instead?
        Best Regards,
        Fredrik

        Comment


        • #5
          Hi, the next nightly build will have that corrected.

          Best,
          Emil
          V-Ray for Maya developer

          Comment


          • #6
            I think this was done because some colors like the opacity is bad to start from black (since you will render nothing and wonder what's wrong). The only real solution is to have default values in the OSL shader itself. Don't know if this is supported though .
            V-Ray/PhoenixFD for Maya developer

            Comment


            • #7
              Nope, not supported for connectable texture inputs currently (for colors it is).
              But this should be easy to add.
              V-Ray for Maya developer

              Comment


              • #8
                That's awesome, thanks. I'll check out the next nightly build!
                Best Regards,
                Fredrik

                Comment


                • #9
                  Originally posted by emil.kirichev View Post
                  Nope, not supported for connectable texture inputs currently (for colors it is).
                  But this should be easy to add.
                  Ah I see what you mean. I just downloaded the latest nightly and now all my sliders default to black (color(0.0)), even the diffuse one (which I would like to default to color(0.5)) and opacity...

                  However, black is better than white as white is considered to enable things. So for opacity, I can just change this into "transparency" and that won't be an issue.

                  So really, this should be addressed in OSL rather than in V-Ray?
                  If so, I could bring this up on the OSL dev mailinglist to get it properly fixed.

                  I updated my surface material to use "transparency" rather than "opacity":
                  https://raw.githubusercontent.com/fr...c_material.osl
                  Last edited by Fredrik Averpil; 16-06-2014, 11:56 PM.
                  Best Regards,
                  Fredrik

                  Comment


                  • #10
                    So really, this should be addressed in OSL rather than in V-Ray?
                    I think we can do something about that in our OSL implementation. Maybe specify the default color in a [[ ]] section? Will talk to the guys working on the core OSL implementation (I'm responsible for the Maya integration).
                    V-Ray for Maya developer

                    Comment


                    • #11
                      Specifying default colors in a [[ ]] section sounds good to me.
                      Best Regards,
                      Fredrik

                      Comment


                      • #12
                        I am investigating the solution emil.kirichev has offered. Should have been a straight forward thing but there is a problem with the OSL compiler and color/vector/normal/point/matrix metadata.
                        I will try and sort it out. I just want to remind you guys that every OSL integration is free to interpret the metadata as it wishes, including - ignore it completely.
                        This means that it is guaranteed to work in V-Ray for Maya only.

                        Comment


                        • #13
                          Understood.

                          I posted about this on the OSL dev mailinglist:
                          https://groups.google.com/forum/#!to...ev/Z912TPP-t_w

                          However, like Vlado has said in other threads, it will probably be up to each renderer manufacturer to decide on how to implement such features.

                          I think your suggestion about specifying this in a [[ ]] section is perfect though -- and perhaps you are leading the way of making that the standard way of dealing with this kind of default values.
                          Best Regards,
                          Fredrik

                          Comment


                          • #14
                            Hi again,

                            I believe the OSL specs stipulate how this should be done inside the [[ ]] section (shader metadata):

                            int slider
                            If nonzero, enables display of a slider sub-widget. This also respects the following addi- tional metadata that control the slider specifically: "slidermin" (minimum value for the slider, "slidermax" (maximum value for the slider), "slidercenter" (origin value for the slider), "sliderexponent" (nonlinear slider options).
                            Is that how you were planning on implementing this?
                            Best Regards,
                            Fredrik

                            Comment


                            • #15
                              I was thinking of placing the slider to the maximum by default and allow shader writers to specify the default color.
                              If we do not do anything about the default color we would be limited to grey scale values only.

                              Come to think of it ... it would be most convenient to control both color and slider defaults in Maya.

                              OK ... how about we consider:
                              Code:
                              ... [[ color defaultColor = color(0.1, 0.9, 0.9), float slidercenter = 1.0 ]] ...
                              .

                              Comment

                              Working...
                              X