Announcement

Collapse
No announcement yet.

V-ray maps baking script. v0.04 (Free)

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

  • V-ray maps baking script. v0.04 (Free)

    Hey,

    I would like to share an script I've been working on lately. It simply bakes textures from V-Ray shaders (VRayBlends, multisub etc)

    Features:

    Bakes texture maps: Diffuse, Reflection, Refraction, Reflection Glossiness, Refraction Glossiness, Normal Bump, Fresnel IOR, Opacity, Illumination.

    Creates VRayMtl with all textures correctly assigned.

    Can convert exr to jpg using djv_converter.exe (part of the http://djv.sourceforge.net/ )

    Ability to load custom render settings preset for baking. It reverts back to old preset.

    Interface:




    Example:




    Before Baking:


    After Baking:


    Why?


    - Renders faster. When all this mess is baked into maps, you get simplified result that in general render faster.

    - Easier to share. This also opens up options to convert your shader to VRMat and use it in Maya / Modo etc.

    - More flexibility. Baked maps could be used for other things like exporting model to real time engine or other renderers.

    General notes:


    It bakes only selected object.

    Use the same BRDF model on all the shaders you're working on. Recommended: WARD

    Camera based maps like falloff won't work.

    This script will bake complex VRayBlend shaders down to Single VRayMtl, but reflections, glossiness etc will be averaged and result may be different than original.

    Proper UVW mapping is required. No overlapping, No inverted faces. By default it looks for mapping at channel 10 (as usually lower channels are used for shading, and it can get messy)

    Doesn't work with SSS.

    You don't need lights / shadows / GI in your scene.



    This Script is free of charge. I just hope it will help your pipleline in the way it helps us. You can modify it, but please let me know and share your code. So we can improve it further. Just remember: this Script cannot be resold in anyway.

    Download: http://www.dabarti.com/uploads/scrip...v0.05_macro.ms

    You can find the script in Category: Dabarti in Customize/Customize User Interface

    Best,

    Tomasz Wyszołmirski
    Attached Files
    Last edited by wyszolmirski; 14-08-2014, 12:55 AM. Reason: I want to remove v0.04 from the title.
    @wyszolmirski | Dabarti | FB | BE

  • #2
    This is awesome! Thanks for sharing

    Love that it easily allows for above 2k maps with the drop down. Love that it includes options for all the channels that actually matter.

    If no baking preset is selected, it will simply use the current settings of the file, correct?

    Why would you convert to JPG, if there's an option already to render as JPG?

    Does this bake every single thing in the scene, or only things selected? (it seems to bake selected objects)

    Also I wonder if it might be helpful to have that Padding size auto adjust depending on the Texture resolution ( I've been following this page as a rule of thumb for padding vs texture resolution, http://wiki.polycount.com/wiki/EdgePadding)


    I'm going to play with it a bit now...

    Oops. Looks like nothing starts when I hit BAKE. Although it did throw up an error that I was missing the mapping channel. After I corrected it, it never fired up. I closed the script and re-opened it, making sure I had the right channel selected. And it started! I canceled so as to try baking at a smaller resolution. It wouldn't bake again. So each time you have to close and open the script. And each time the settings in the script reset. I suppose I should open up the script and just set the defaults I want...

    Hmm.. after baking a 256x256 texture set (File Format JPG). The images weren't in the custom location I specified. Maybe because I hit cancel during the countdown after it finished. I tried again and let it countdown, it fired up again and started to bake the same object again. Still nothing saved with EXR as the file format edit: interestingly enough, I found the images saved in the folder where the folder I specified was (so on the desktop instead of within the folder I had made on the desktop)

    Maybe there's issue that I'm rendering locally with DR?

    EDIT: should also mention I'm running 3dsmax 2012 w/Vray 3.0
    Last edited by cheerioboy; 13-08-2014, 12:23 PM.
    Brendan Coyle | www.brendancoyle.com

    Comment


    • #3
      Hey,

      Yes it works on the selected object. After it's done, it will create copy of your model and create new material. I should have explained this better.

      Thanks for the feedback. It seems the switch for cancelling I've added today does prevent the script from running 2 times in the row... Easy fix, but tomorrow morning .

      The option to convert to JPG is there as we had issues with direct rendering do JPG... I think I found the reason, but the option stayed there. Anyway if you want you can bake directly to JPG and hope that gamma is correct.

      There is a bag if you choose custom path... It should add "\" at the end of it but it doesn't so it saves in the wrong place. I will fix it too. Try to bake something without changing path for now and restart it after each bake.

      Best,
      @wyszolmirski | Dabarti | FB | BE

      Comment


      • #4
        Good point about the gamma. So maybe that would solve my gamma issues. So the conversion happens all during the process correct? You'd just choose the 'Convert to JPG' button and you'd only see converted JPG textures in the output folder?
        Brendan Coyle | www.brendancoyle.com

        Comment


        • #5
          You would have exr and jpg's but only jpgs would be used for creating VRayMtl. You can play with your output gamma as well to see when it gives you correct results. But it was strange that for us it rendered correctly to tga / exr, but jpg's were messed up.

          Also you can edit script and there are global variables that you can change for default location of djv_converter nad render preset.
          @wyszolmirski | Dabarti | FB | BE

          Comment


          • #6
            This is great, thanks! Started playing with UE4 recently so being able to make materials how i'm used to doing them and converting them after is amazing.

            Comment


            • #7
              Hey Guys,

              I've updated the script in the first post. Is there any way to change thread title ?

              For some more info, instruction and changelog go to: http://dabarti.com/vfx/vraymtl-maps-baking-script/

              Best,
              @wyszolmirski | Dabarti | FB | BE

              Comment


              • #8
                Does the script render the same object again & again for each texture (normal, reflection, etc) of a single object? It seems like when I have one object selected - it doesn't end after the first render, unless I cancel. With one texture selected (diffuse), it finishes and just does the countdown to cancel, over & over. Which works.

                Is there not a way to capture all passes in a single render?

                Also not having much success with using 'Convert to JPG', converter path is set: C:\Program Files (x86)\djv 0.8.3\bin\djv_convert.exe
                Are the .jpg's put in another folder somewhere?

                Otherwise it is baking the .exrs into the correct folder/path
                Might also be useful to stick the version of the script somewhere in the window - I had to double check that I had & was running the latest script

                thanks
                Brendan Coyle | www.brendancoyle.com

                Comment


                • #9
                  Hey,

                  It's not possible to bake everything through single standard bake to texture render. There is no way to bake down reflection / IOR / Opacity. This script basically converts shader to one that allows baking those values through baking diffuse. For example it calculates correct values of IOR in scale from 0 to 1 (as it pretty much mirrors the values from 1 to 100) and puts them in diffuse, switching off all the unnecessary options in VRayMtl and than it bakes it through Diffuse.

                  I will have to change a bit of code to sort out the cancel countdown issue though.

                  Could you try putting djv_converter in folder without spaces? For example C:\djv\bin\djv_converter.exe and let me know if this works ? Jpg's should be in the same folder as .exr. I'm still not sure about this DJV converter. I implemented it because in 2014 it rendered out exr, tga in correct gamma, but jpgs were messed up. 3ds Max 2014 doesn't have direct control over bitmap output gamma like it used to, but it can remember settings from older scenes. Maybe that messed it up. That's something I'll have to look into.

                  Big thanks for the feedback, as there wasn't much of it after I released the script despite having quite a bit of downloads.

                  Best,
                  @wyszolmirski | Dabarti | FB | BE

                  Comment


                  • #10
                    Hey Tomasz,

                    Is it possible to add a button for baking the Complete map as an option?
                    I really need to upgrade my baking beyond 3dsmax render to texture...
                    Brendan Coyle | www.brendancoyle.com

                    Comment


                    • #11
                      Originally posted by wyszolmirski View Post
                      Hey,

                      It's not possible to bake everything through single standard bake to texture render. There is no way to bake down reflection / IOR / Opacity. This script basically converts shader to one that allows baking those values through baking diffuse. For example it calculates correct values of IOR in scale from 0 to 1 (as it pretty much mirrors the values from 1 to 100) and puts them in diffuse, switching off all the unnecessary options in VRayMtl and than it bakes it through Diffuse.

                      I will have to change a bit of code to sort out the cancel countdown issue though.

                      Could you try putting djv_converter in folder without spaces? For example C:\djv\bin\djv_converter.exe and let me know if this works ? Jpg's should be in the same folder as .exr. I'm still not sure about this DJV converter. I implemented it because in 2014 it rendered out exr, tga in correct gamma, but jpgs were messed up. 3ds Max 2014 doesn't have direct control over bitmap output gamma like it used to, but it can remember settings from older scenes. Maybe that messed it up. That's something I'll have to look into.

                      Big thanks for the feedback, as there wasn't much of it after I released the script despite having quite a bit of downloads.

                      Best,
                      The DJV converter messed up my machine, even after I uninstalled it some programs refused to save to jpg's and would get warning promps every time I opened a jpg in outlook. I needed to repair the registry for jpg's to get things back to normal.

                      ***BEWARE***
                      "I have not failed. I've just found 10,000 ways that won't work."
                      Thomas A. Edison

                      Comment


                      • #12
                        Originally posted by eyepiz View Post
                        The DJV converter messed up my machine, even after I uninstalled it some programs refused to save to jpg's and would get warning promps every time I opened a jpg in outlook. I needed to repair the registry for jpg's to get things back to normal.

                        ***BEWARE***
                        I wonder if it was this feature request, https://sourceforge.net/p/djv/feature-requests/17/
                        I think I used the software before that update so I never encountered the issue. But good to know moving forward.
                        Brendan Coyle | www.brendancoyle.com

                        Comment


                        • #13
                          Great script. Thanks! Love DJV. Use it on every machine as a quick RAM viewer.

                          Comment

                          Working...
                          X