Home Technical Talk

3ds Max - Texture Atlas script help

polycounter lvl 4
Offline / Send Message
Dvonio polycounter lvl 4
Hello everyone.

I've been searching for hours and got no result so I tought about asking here.

Im in need of a script that could save me tons of hours, what Im looking for is a 3ds max script that creates a texture atlas based on single objects with single texturas, per example:

Lets say I have 13 3D objects with his respective UVs mapped into single 0-1 uvs.

2 textures of 512, 7 textures of 256 and 4 textures of 128

And I would like to create a texture atlas on 3ds max that should look like this (the order of the textures dosnt matter):

8e165c1870.png

The script itself should move the UV's and Texture data (assigned a standard material with a bitmap on it) of each single object that I have selected in the scene to create a similar atlas described on the picture.

--

The best I could find was this script that pretty much does everything.

http://puu.sh/bNtAt/ab34749ad4.ms (Credits to IO on this thread: http://forums.cgsociety.org/showthread.php?t=1053652)

But there are some things that dosnt work the way I want:

It only accepts textured items that share the same resolution (4x512, 4x256, 16x256 and so on) and I need different resolutions.

And it collapses the meshes in a single big mesh (would be amazing if it just moved uvs and create the texture atlas)


The thing is, can someone help me modify that script to my needs or knows a program / script that would work well for my project?

Thank you so much!! <333

Replies

  • monster
    Options
    Offline / Send Message
    monster polycounter
    https://www.codeandweb.com/texturepacker

    If you use Texture Packer free version to output a Generic XML and atlas, you can use my script to adjust the UV's of the selected objects to match the atlas.

    https://www.dropbox.com/s/mi74dqppaos34up/Tools_MapToAtlas.ms?dl=0

    Then manually apply a material with your atlas texture to all the objects.
  • Dvonio
    Options
    Offline / Send Message
    Dvonio polycounter lvl 4
    Will try that tomorrow, going to sleep now, thank you very much.
  • Dvonio
    Options
    Offline / Send Message
    Dvonio polycounter lvl 4
    monster wrote: »
    https://www.codeandweb.com/texturepacker

    If you use Texture Packer free version to output a Generic XML and atlas, you can use my script to adjust the UV's of the selected objects to match the atlas.

    https://dl.dropboxusercontent.com/u/2904948/MaxScript/Tools_MapToAtlas.ms

    Then manually apply a material with your atlas texture to all the objects.

    It dosnt seem to work or Im doing something wrong, can you please do a mini-tut?

    Thanks!
  • monster
    Options
    Offline / Send Message
    monster polycounter
    I fixed a bug in the script you should download it again. The workflow is a little funny because I ripped this code out of a larger script where most of this was automagic. But it's a lot of work to modify the code and I don't have time to make it simpler to use right now.

    1. Create an atlas in texture packer with GenericXML selected in the Data Format.


    2. Run the script, select the XML file. Select one or more objects with individual textures applied to the model (not the atlas texture). Run the script by pressing Map Selected to Atlas.


    3. The textures on the object will look messed up. The script finds the texture names applied in the XML file and moves the UVs to that location using UVW Xform modifiers. If you have multiple textures you'll see multiple UVW Xform modifiers. At the top of the stack will be an Edit Poly that gives everything one material ID. You can press Un-Map to remove all the modifiers the script added.


    4. Create and apply a new material with the atlas as a texture and apply it to your object.

  • Eric Chadwick
    Options
    Offline / Send Message
    Awesome Juan!

    We also have more texture atlas tutorials and links here on the wiki.
    http://wiki.polycount.com/wiki/Texture_atlas
  • Dvonio
    Options
    Offline / Send Message
    Dvonio polycounter lvl 4
    Dude, I love you.

    It works perfectly.

    I don't need it simpler (What could make it simpler than create the atlas and press 2 buttons?)

    Thanks thanks thanks thanks thanks! we need this on the wiki!
  • Eric Chadwick
    Options
    Offline / Send Message
    It's on there, added to the texture atlas page.
  • tonyd927
    Options
    Offline / Send Message
    Let's say you wanted to combine the texture atlases for multiple models, could we still use this without having to resize the UVW's in 3ds max?
  • Woody3D
    Options
    Offline / Send Message
    monster wrote: »
    I fixed a bug in the script you should download it again. The workflow is a little funny because I ripped this code out of a larger script where most of this was automagic. But it's a lot of work to modify the code and I don't have time to make it simpler to use right now.

    1. Create an atlas in texture packer with GenericXML selected in the Data Format.


    2. Run the script, select the XML file. Select one or more objects with individual textures applied to the model (not the atlas texture). Run the script by pressing Map Selected to Atlas.


    3. The textures on the object will look messed up. The script finds the texture names applied in the XML file and moves the UVs to that location using UVW Xform modifiers. If you have multiple textures you'll see multiple UVW Xform modifiers. At the top of the stack will be an Edit Poly that gives everything one material ID. You can press Un-Map to remove all the modifiers the script added.


    4. Create and apply a new material with the atlas as a texture and apply it to your object.

    HEY MONSTER!

    This looks like a truly life changing tool for MAX Artists. I have worked in 3D Studio since release 1 for DOS and only one of the old greats like Peter Watje could make something this helpful!

    I did have some trouble with it though, It ran without complaint, I applied the material, and some things are the same but other are drastically different,.. I will post Before and ASfter pics, I only followed ther steps you laid out above, no changes..:

    http://s9.postimg.org/r97kz16tb/BEFORE.jpg

    http://s9.postimg.org/5o7k8jge7/AFTER.jpg


    I hope you can help me, I am at the end of a year long odyssey to try to find a simple way to unwrap a character into a nice simple Texture Atlas.with minimal accessories and use it in UNITY.. Seems almost iunpossible from my pov after trying every tool, utility, script and routine I can find out there and they all fail. Yours has come the sloest to being perfectly useful by far so I have great hope,. PLEASE reply,

    Second question is about Opacity channel The script isn't placing the Diffuse yet I know but after that is figured out, How would I apply the opacity map? It is in the Atlas, but in a different spot... Wouldn't this script make the opac misaligned or?? How would I deal with re-applying opac's? Maybe I could offset the mapping for that bitmap in MAX's material editor, but I doubt UNITY would know to accept that.. I had already invented this PEREFECT Atlas making scheme I would pull all may materials into photoshop and 'pack' them together manually, and then all I had to do was apply that Bitmap with MAX Material Bitmap 'CROPPING' to that Same Map in a MultiMaterial, so that different parts of the same map were cropped to be appropriate for each material id,

    BUT Unity didn't accept 'cropped' textures in materials so it never worked out that way,. This has been to biggest bear of my career and I have worked in 3D Studio since release 1 for DOS!

    Thanks again for the amazing tool, If I can figure out what I'm inputting that it doesn't like, (or?) this would be a huge deal for my work,. :~)

    Bravo..
  • Woody3D
    Options
    Offline / Send Message
    monster wrote: »
    I fixed a bug in the script you should download it again. The workflow is a little funny because I ripped this code out of a larger script where most of this was automagic. But it's a lot of work to modify the code and I don't have time to make it simpler to use right now..........................................

    Never mind!, the second time I tried it, (being more careful to do a resource collection first) it seemed much happier this time. I guess I can make a separate littler map just for opacity, it save me a lot of big maps a little grayscale extra few is just fine! Maybe I could use your routine to 'trick' the program into making a Texture atlas of all the OPACITY maps as a separate atlas (in grayscale light format) I could make material copies of the original but with all the opac in the diffuse slot temporarily, then make an atlas with packer then replace with your script, but apply the map to the opac channel with the first atlas put into diffuse, I guess I could even copy the placements in Photoshop and make the second atlas myself, and wouldn't have to run the script twice,. hmmm. lots of possibilities!! Best Atlas Script on Earth!
  • rayleigh2116
    Options
    Offline / Send Message
    hi it wont work in 3d max 2015 and it will crash the script!!1
  • cptSwing
    Options
    Offline / Send Message
    cptSwing polycounter lvl 11
    Looks like a great idea, monster - have yet to try it. How does it handle UV's extending past 0-1 space?

    Seigisato is working on a cool looking Atlas generator as well. Maya, unfortunately.
  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    Ooooh ! I needed that too ! I need to look closer to TexturePacker options (tiling) but this is a cool idea. Hell i made a shitty maxscript for square textures atlas last week. This is far more superior.
    Max lacks of a flawless atlasing tool (among other things...)
  • h3d
    Options
    Offline / Send Message
    h3d
    @Juan - The download link does not seem to work.  Can you refresh your script?
  • monster
  • LaurentiuN
    Options
    Offline / Send Message
    LaurentiuN interpolator
    Great job man, but i tried this on max 2016 and when i hit the Map Selected To Atlas nothing happens, is this limited to one max version? Thanks again
  • NextWorldVR
    Options
    Offline / Send Message
    CAREFUL!!!  THAT DROPBOX LINK ABOVE DESTROYED MY TABLET PC'S CHROME INSTALL!  IT ALL WENT NUTZ AS SOON AS I CLICKED IT! WON'T RE-OPEN!! 
    Dvonio sent me a copy and I made another link here:

    https://www.sendspace.com/file/0wd6b7

    I wonder what happened at the DROPBOX site?  I have never once had luck with DropBox, either it wants a user name and password or it crashes my computer...  Never just 'works' like Sendspace...
  • LaurentiuN
    Options
    Offline / Send Message
    LaurentiuN interpolator
    I downloaded from that link and was fine.
  • monster
    Options
    Offline / Send Message
    monster polycounter
    @NextWorldVR

    Sorry for the trouble. The link works fine for myself. I verified the SendSpace link you posted is the same version.
    BTW, You may want to check if your host file is modified and is sending dropbox.com to other websites.
  • NextWorldVR
    Options
    Offline / Send Message
    s1dK said:
    Great job man, but i tried this on max 2016 and when i hit the Map Selected To Atlas nothing happens, is this limited to one max version? Thanks again
    Did you do all the other stuff? Texture Packer etc? Generate an XML file etc?

    also: make and apply  a material by hand using the Texture Packer Texture Altas output? ,.. (last step there is a doozy v:)  All the Script does is SHIFT the UVW''s to coordinate with the corresponding texture's position in the Packed Atlas ...  Then when you do use that new Atlas texture, it should all align!
  • jbonastre
    Options
    Offline / Send Message
    jbonastre null
    Hi, is it possible to use your script with a 3ds Max batch file? I´m using Texture Packer and the iteration adding new items to the atlas is a bit annoying =)
  • SiftoN
    Options
    Offline / Send Message
    SiftoN polycounter lvl 4
    Hi. Just used this successfully on in a scene. The first try didn't work and I think it was due to some of the textures being tilable. . Are there any settings in Texture Packer that  allow for tiling say in one direction? like a wall texture that tiles left and right?
  • monster
    Options
    Offline / Send Message
    monster polycounter
    Sorry tiling texture and atlasing don't really work together. Only way is to tile geometry.
  • jazznazz
    Options
    Offline / Send Message
    jazznazz polycounter lvl 13
    @monster
    I just want to say THANK YOU for this script ! Works perfectly for our case. 

    @SiftoN
    maybe this will help with tiled textures: http://www.scriptspot.com/3ds-max/scripts/texture-atlas-generator . From what I read it's a bit hard to use though.
Sign In or Register to comment.