Search Maya Zest



Wednesday, June 17, 2020

Sketchup to vray maya, lightmapping then to Unity with original SKP textures.




Sketchup to vray maya, apply lightmapping then to Unity with original SKP textures.

1. From sketchup export an FBX

2. (IMPORTANT) In maya import the FBX, first thing to do is correct any texture path errors. I suggest running a script for maya called texture genie.

It also may be helpful to use the maya file path editor to copy ALL textures into one location this will simplify things later down the pipeline.

3. All the materials come in as PHONG, so unless you want that run this MEL script

string $replaceType = "lambert";
string $sNode[] = `ls -sl`; 
for ($each in $sNode)
    {
    string $replaceWith = `createNode $replaceType`;
    replaceNode $each $replaceWith;
    delete $each;
    rename $replaceWith $each;
    }


Or if you prefer use this script to convert the phongs directly to vray maya
http://www.dryzen.com/scripts_mia2vray.html

4. Apply any bump maps etc and material adjustments as needed.

Now we need to prepare the items to maintain the original textures and UV's

5. Take careful note of the groups that came in from sketchup. Select each group and run a combine on each so that the contents of each group aka (a chair, a desk) each only have one model. These will be your light baking groups so you do not want these to be for instance a single door hinge you want it to be the entire door. Each group should represent a UV set texture for your light map.

6. After you have combined each group it's time to clean up the UV's. Sketchup UV's are going to be wonky and extending off the UV range but it still displays the texture map as it should . We want to leave that alone so select ALL your geomtry. You may need to go to maya menu>select>all by type>geo.

7.Now go to your UV in the UV set editor, there should just be a single UV1 set. With all your geo selected create a new UV set. And rename it to "lightmap"

8.Now make sure that lightmap UV set is selected, and ALL your GEO is selected. Then goto UV>automatic mapping in maya.

9. Now you will have a perfect second UV set for the light mapping to take place in.

10. Now it's time to set up the vray bake sets, these pretty much are just to define say sections at different resolutions. For instance the floor we want to bake at 4k, but the desks and chairs at 512pixels

11.Choose the GEO you want in a given bake set goto the Vray menu assign single vray bake options.



12. This will create a new node in your outliner with the texture bake size and settings. In the top you can select the UV set that will be used for the bake (where it says map1), choose your new lightmap UV set for all the bake groups that you create and set the resolution.


Once you have all your bake groups defined. this is VERY IMPORTANT. BEFORE you bake. Save your maya project as BEFORE BAKED. Once you do a bake on a set, vray will REMOVE the original materials, apply a surface shader with an image on it to the baked geo. This means you cannot simply change the lighting and bake the object again. A second bake will NOT change the way your object looks because it will simply bake what was already on it, leaving it the same.

So in order to make any changes to a section that you have baked, you will need to revert back that section to the prebaked setup project.

Alright now Bake away!

13. Once the bake is completed, it's time to bring it into unity!

14. Select your entire model in maya and export to FBX. trying to use "embed textures" didn't work for me, I think due to the size of all the textures. It would simply generate an FBX with no FBM texture folder. To get around this, since all the textures are now located on a single folder anyway (because of our cleanup). I just copied it into the same folder as the FBX.

15. Now in unity just plop your model and it's textures into your project folder and it will import everything. It's somewhat likely it won't use the correct UV set and the textures will look wacked. If this happens in the unity model settings just choose swap UV and that should fix it.


That's it you should now have a Vray baked model in unity!