Announcement

Collapse
No announcement yet.

An assortment of OSL shaders for your perusal

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

  • #16
    And the third!

    Merge2
    Merge two inputs using Nuke-style operations.

    Click image for larger version

Name:	merge2_node.JPG
Views:	1
Size:	35.1 KB
ID:	862171

    Links
    Page:
    http://www.rensheeren.com/blog/osl-merge2/
    Download link:
    http://www.rensheeren.com/osl/merge2_tex_v001.osl

    Features
    - Merge two inputs.
    - Takes alpha channels into account.

    How to use
    – Create a VRay OSL Texture map.
    – Load in the downloaded .osl shader.
    – Connect the inputs to merge.
    – Set the mode.

    Click image for larger version

Name:	merge2_ui.JPG
Views:	1
Size:	18.3 KB
ID:	862172

    Click image for larger version

Name:	merge2_rndr1.jpg
Views:	1
Size:	24.2 KB
ID:	862173
    Rens Heeren
    Generalist
    WEBSITE - IMDB - LINKEDIN - OSL SHADERS

    Comment


    • #17
      I think you'll like this one.

      CamMapScale
      Scales an image to the original image ratio when using Camera Map Per Pixel, instead of the annoying 'feature' where it scales the image to the render output size.
      So if you have a square image, you can project a square image!

      Click image for larger version

Name:	cammapscale_rndr.jpg
Views:	1
Size:	44.4 KB
ID:	862187

      Links
      Page:
      http://www.rensheeren.com/blog/osl-cammapscale/
      Download link:
      http://www.rensheeren.com/osl/camMapScale_tex_v001.osl

      Features
      – Scales the input image back to its original aspect ratio when using Camera Map Per Pixel.

      How to use
      – Create a VRay OSL Texture map.
      – Load in the download OSL shader.
      – Plug in the map and set your render and map resolution. The shader will scale the image back to the map resolution.
      – Make sure ‘wrap texture coordinates’ (General tab) is disabled in the OSL shader!

      Click image for larger version

Name:	cammapscale_node.JPG
Views:	1
Size:	29.3 KB
ID:	862188

      Click image for larger version

Name:	cammapscale_ui.JPG
Views:	1
Size:	20.9 KB
ID:	862189
      Last edited by Rens; 27-05-2016, 09:29 PM.
      Rens Heeren
      Generalist
      WEBSITE - IMDB - LINKEDIN - OSL SHADERS

      Comment


      • #18
        This is great Rens! So glad I found it this thread!

        Vlado, would it be possible to make a forum board for OSL? Typing "OSL" in the search results in "Sorry - no matches. Please try some different terms." It would be awesome to have a central place where we can all share this OSL goodness (and a place where we could find it too!). I'd suggest that the OSL board be for all applications, not just Max or Maya.

        Comment


        • #19
          Originally posted by Ihno View Post
          Very cool Rens.
          I'm using your mixNormalMaps map allmost every day. You really deserve your entry
          Looking forward to try this one and see your library grow.

          Has this been posted yet? Maybe I missed it...

          Comment


          • #20
            @sharktacos
            You can find it here:
            http://forums.chaosgroup.com/showthr...ng+normal+maps

            @Rens:
            Cool stuff, keep it up.
            German guy, sorry for my English.

            Comment


            • #21
              Cheers guys!

              Sharktacos, I think you can search for *OSL* or "OSL", that should work.

              Here's the mixNormalMaps shader updated to match the others, with a page and everything:


              MixNormalMaps
              A shader for mixing or blending together normal maps as outlined on this page:
              http://blog.selfshadow.com/publicati...ing-in-detail/
              This gives much better results than simply blending or using overlay mode on two normal maps. It uses Reoriented Normal Mapping as described in the article as well as the idea from the second comment, by "jarkko" in that article. The modes are fairly similar in results.

              Click image for larger version

Name:	mixnormalmaps_rndr.jpg
Views:	1
Size:	46.8 KB
ID:	862194

              Links
              Page:
              http://www.rensheeren.com/blog/osl-mixnormalmaps/
              Download link:
              http://www.rensheeren.com/osl/mixNor...s_tex_v003.osl
              http://www.rensheeren.com/osl/rhfunctions.h
              Right-click and save both in the same folder, both are needed for the shader to work. Overwrite rhfunctions.h if asked.

              Features
              - Blends two normal maps.
              - Two algorithms available.
              - With mix amount to define the second map blend strength.

              How to use
              - Create a VRay OSL Texture map.
              - Load in the downloaded OSL shader.
              - Plug in two normal maps.
              - You can then set the mode and mix amount.

              Click image for larger version

Name:	mixnormalmaps_ui.JPG
Views:	1
Size:	25.6 KB
ID:	862193

              Click image for larger version

Name:	mixnormalmaps_node.JPG
Views:	1
Size:	34.4 KB
ID:	862192
              Last edited by Rens; 28-05-2016, 11:07 PM.
              Rens Heeren
              Generalist
              WEBSITE - IMDB - LINKEDIN - OSL SHADERS

              Comment


              • #22
                ChannelSwitcher
                An OSL shader for switching channels. You input two textures and then you can shuffle the RGBA channels around to make a new output. So for example you could have the red and green channels of texture A, green as a black output, and the alpha from texture B. Or, as good example, you could switch all the channels to use the red channel, so you'd have a monochrome output.
                Or shuffle the alpha into RGB and adjust it, then shuffle it back.

                Click image for larger version

Name:	channelswitcher_rndr.jpg
Views:	1
Size:	74.1 KB
ID:	862195

                Links
                Page:
                http://www.rensheeren.com/blog/osl-channelswitcher/
                Download link:
                http://www.rensheeren.com/osl/channe...r_tex_v002.osl
                Right-click and save.

                Features
                - Switch or shuffle the channels from two inputs around.
                - You also choose fill white or black for a channel.
                - Or invert the channel.

                How to use
                - Create a VRay OSL Texture map.
                - Load in the downloaded OSL shader.
                - Plug in two maps, and set the switch modes.

                Modes:
                1 - red1
                2 - green1
                3 - blue1
                4 - alpha1
                5 - red2
                6 - green2
                7 - blue2
                8 - alpha2
                9 - one
                10 - zero

                Click image for larger version

Name:	channelswitcher_node.JPG
Views:	1
Size:	43.1 KB
ID:	862197

                Click image for larger version

Name:	channelswitcher_ui.JPG
Views:	1
Size:	26.5 KB
ID:	862196
                Last edited by Rens; 29-05-2016, 01:24 AM.
                Rens Heeren
                Generalist
                WEBSITE - IMDB - LINKEDIN - OSL SHADERS

                Comment


                • #23
                  Awesome stuff Rens!

                  Comment


                  • #24
                    Hey Rens, do you know of a way to make OSL attributes greyed out? For example, on the VrayMtl the "highlight glossiness" is greyed out as long as the "lock" is on. I'm wondering if it possible to do something similar in OSL?

                    Comment


                    • #25
                      Hey! No I don't think OSL specifies anything like that, unfortunately.
                      Rens Heeren
                      Generalist
                      WEBSITE - IMDB - LINKEDIN - OSL SHADERS

                      Comment


                      • #26
                        Originally posted by Rens View Post
                        Hey! No I don't think OSL specifies anything like that, unfortunately.

                        I was afraid of that . On a related note, I see you have #ifdef __VRAY_OSL__ calls on many of your OSL shaders. Do you know if there is a way to specify with a similar call whether one is using OSL for Vray with Max as opposed to OSL for Vray with Maya? The syntax of how one needs to write OSL stuff for Maya and Max differs so it would be useful to specify.

                        p.s. Where did you learn about the #ifdef __VRAY_OSL__ call? I don't recall seeing it in the docs.

                        Comment


                        • #27
                          Originally posted by sharktacos View Post
                          I was afraid of that . On a related note, I see you have #ifdef __VRAY_OSL__ calls on many of your OSL shaders. Do you know if there is a way to specify with a similar call whether one is using OSL for Vray with Max as opposed to OSL for Vray with Maya? The syntax of how one needs to write OSL stuff for Maya and Max differs so it would be useful to specify.

                          p.s. Where did you learn about the #ifdef __VRAY_OSL__ call? I don't recall seeing it in the docs.
                          I found it here:
                          http://docs.chaosgroup.com/display/V...ationSpecifics
                          And there's a bit in the OSL docs saying they support the standard C preproc calls.

                          The #ifdef preprocessor just checks if __VRAY_OSL__ is defined, which it would be when rendering with VRay.
                          I haven't tested these shaders with maya, but does it use colour inputs instead of texture inputs? Or how exactly does the code differ for max and maya?
                          Basically that is what the preprocessor bit is for, it will rewrite the code to fit the renderer, it preprocesses the code/script before it gets compiled. So for VRay it would use texture inputs (UVs yay!) instead of colour inputs. Unfortunately I don't think you can see if it's maya or max. And yes that would be very useful!


                          Vlado / Chaosgroup, is there a definition to distinguish between the VRay platform used?
                          Last edited by Rens; 30-05-2016, 07:27 PM.
                          Rens Heeren
                          Generalist
                          WEBSITE - IMDB - LINKEDIN - OSL SHADERS

                          Comment


                          • #28
                            holy moly, Rens, you've been busy!
                            Fantastic stuff!
                            Lele
                            Trouble Stirrer in RnD @ Chaos
                            ----------------------
                            emanuele.lecchi@chaos.com

                            Disclaimer:
                            The views and opinions expressed here are my own and do not represent those of Chaos Group, unless otherwise stated.

                            Comment


                            • #29
                              Originally posted by ^Lele^ View Post
                              holy moly, Rens, you've been busy!
                              Fantastic stuff!
                              It's true!
                              Thanks Lele! You're keeping yourself busy as well I see!
                              Rens Heeren
                              Generalist
                              WEBSITE - IMDB - LINKEDIN - OSL SHADERS

                              Comment


                              • #30
                                Originally posted by Rens View Post
                                Vlado / Chaosgroup, is there a definition to distinguish between the VRay platform used?
                                Unfortunately, no. What are the differences that you find between the Max and Maya implementations?

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

                                Comment

                                Working...
                                X