this thread has become bloody big
What it is all about?
A plugin or script collection if you will that boosts the 3dsmax tasks of UV Unwrapping and Texture related stuff. This includes handy align, relax and transformation tools for UV editing but also nifty single button scripts for baking AO, Lighttracer maps or blockout maps directly to your clipboard.
All of that super easy to install (just drag the download file into the max viewport),- and if you are interested in the scripting part or contribution you can look into the code as well.
For a full overview head over to:
http://www.renderhjs.net/textools
it has lots of GIF animations of each tool explaining them without the need of much text- though some of the text might explain some more background info for each tool. Here is a excerpt of some of the things you can do:
and here is the original first message:
just a thread to dumb my UV-related scripts into, some of these scripts will be eventually ported in a GUI so they are more in a usefull collection.
some of my goals:
- should run in max9+
- no xtra plugins required
- reduce tasks that are usually required
1.) render UV- template to clipboard
(does not require the avg_dlx.dlx extention!!! nor any other third party xtra plugin)
lets you render a UV-template directly into the windows clipboard so you can paste it directly into photoshop. Nor Framebuffer is displayed,- you dont even need to open the UV-editor- it requires though a UV-unwrap modifier.
--render uv to clipboard
_size = 512;
$.modifiers[#unwrap_uvw].renderuv_width = _size;
$.modifiers[#unwrap_uvw].renderuv_height = _size;
$.modifiers[#unwrap_uvw].renderuv_fillmode = 0;--solid
$.modifiers[#unwrap_uvw].renderuv_seamColor = color 255 255 255;
$.modifiers[#unwrap_uvw].renderuv_showframebuffer = false;
clipboardClass = dotNetClass "System.Windows.Forms.Clipboard" --create a Clipboard dotNetClass
theFileName = GetDir #image + "_renderToClipboard.bmp" --define a temp.file name
$.modifiers[#unwrap_uvw].unwrap5.renderUV theFileName;--save UV layout to the temp folder
theImage = dotNetClass "System.Drawing.Image" --create an Image dotNetClass
theBitmap = theImage.FromFile theFileName --get the saved image from file as bitmap
clipboardClass.setImage theBitmap --copy the image to clipboard
theBitmap.Dispose() --release the bitmap
deleteFile theFileName --delete the temp. file
clipboardClass.ContainsImage() --return true if the clipboard contains image
$.modifiers[#unwrap_uvw].renderuv_showframebuffer = true;--reset defaults
at first I found this great thread:
http://forums.cgsociety.org/showthread.php?t=677106
but its to much of a hassle and it requires some extra steps like photopshop scripts to be manually activated. With my script now all I need to do in photoshop once pasted is to select either a color range or use the magic wad or invert and set the layer mode to multiply.
Used this reference for the setClipboard part:
http://www.scriptspot.com/bobo/mxs9/dotNet/UsingTheClipboard.html
comming next is a align tool that aligns vertex UV`s on a real line and not like all the lazy scripts out there only horizontal or vertical. A angle snap determinces if they should be aligned vertical or horizontal e.g if all the points in a line are +- 5° apart from 90°. It should help up aligning verts from the faces of block type objects.
Replies
it works like this, you select your verts and hit the script, it automaticly detects the flow and will align the verts between the 2 end points on that line.
example usage:
or
what I still plan is a angle snap value (e.g within 2° or 5°) where it detects to snap to either 45° angles or most common 90° angles which would be the same as the rest of the scripts that can only snap vertical or horizontal.
this is how it works:
draft script (requires a uv-unwrap modifier a opened UV-editor + at least 3 selected UV-verts
2nd one looks interesting but I dont see that much use diagonally aligning things, at least I've never personally felt the need to do it for any reason
but thanks for sharing, I'll keep an eye on this thread!
1st one will most likely end up in a rollout dialogue with a dropdown menu and or input text box.
Alternativly one could predict the size for example based on the associated material and its difuse texture bitmap size - if one is applied. Or the units of the 3d poly and some math guessing the size where 1 max units in 3d space is 1 pixel or something like that. Or... a popup window appears asking you to verify the resolution - that should be possible with a macroscript
2nd script:
One main Idea was not to align vertecies diagonally but foremost having just ONE simple button that alligns things for you- like a smart button that detects automaticly if things should be aligned horizontal, vertical diagonal or snapped to the border. Depending on the vertex positions it will the automaticly determine the smartest move. To me its bothersome having 2 buttons to align horizontal and vertical,- it might be even the case that I want to align in 45°.
as for further ideas:
I am thinking of a distribute scripts that works similar to the align script as it ditributes evenly along a line in any direction- or perhaps ease to a line.
Another script I have in mind is to auto-rotate shells based on their z-axis flow or topXY alignment. I find myself often finding the right edges in the 3d view in order to know how to rotate certain islands and faces because I prefer not having flipped UV-layouts- or weired rotated ones. I think the easiest approach will be by selecting 1 edge and letting the script gess if its a side, bottom or top side on the 3d model and align the UV- shells occordingly.
yet another idea is to smart rotate shells because often my shells are +- 0.05 ° rotated and not perfectly aligned to the axis. This script should analyze the vert points and snap to the most matching 90° related vertexes. If it would go well it would simply align the rototation to the base axis in the UV view in the most suited manner.
another one:
render only selected faces/shells with a random block/face color to the clipboard. That way I could faster block out a mesh by its base elements. And quickly paste it in my existing photoshop texture.
I have to say your second goal is foolish. If you can leverage something, such as avg, or libraries you find on the net, you should, without a doubt. Otherwise you are duplicating code by writing it yourself, or copying and pasting (I'm not sure which is worse).
One of the greatest obstacles of tech art development is that there is no mentality or infrastructure for good tool distribution. Developers and scripters are both to blame- the first for not creating any good frameworks or systems in their programs, the second for not fostering a collaborative mentality even when there are some available.
Real programmers have long known the benefit of modular, reusable code, between individuals and companies both. One of the great benefits of .NET has been the utterly successful ability to share classes between users and languages, via things such as codeproject.
I'd urge you, and everyone else, to reconsider "no extra things required" as something good, and instead considering "leveraging other code but distributing it in a sensible way".
If you write your scripts in such a way as they are modular and reusable, I'm sure many, many people will have good use for your code and put it to many other tools and applications inside Max.
that's definitely true Rob, and I think in actual production where you have a little more control over who's using it that's stellar - but the majority of users for these free scripts probably don't know enough about it to put everything into place correctly.
So for them, the fewer pieces they have to worry about the better.
over all we'd probably be able to create way superior stuff, but that runs the risk of leaving some people behind - the people who know the least about the technical aspects. I think that'd be unfair because that might be the group that relies on them most.
But I'm teh noobzorz, so I don't mind being told I'm wrong. :poly142:
the community scripts project you guys have been working towards sounds wonderous, btw
I just tried it and I cant undo/redo once I've used it.... which pretty much makes it useless for now
The other reason is that I can go anytime with those xtras but:
- what happens if those plugins are not updated for a newer max relese?
- what if the download url should vanish
- what if autodesk no longer supports parts of it
...
surely someone like you is in a different position,- maybe I need to discover more advantages of others classes for now Id rather avoid them if possible.
selected UVs straight into photoshop with 1 key press of F2.
its expensive though, especially since the only function i actually use is the send UVs into photoshop part, and select marked polygons in photoshop. plus its vector UVs.
The only way I found to make it correctly behave with undo is put a relative move of 0,0,0 in before the actual setVertexPosition. Then the undo clause worked correctly.
Good idea to put the functionality for aligning all into one button.
I might take this idea for my UV Line Relax script so that it falls back to default align behaviour if it doesn't find a contiguous line to relax along.
You probably don't need the ".unwrap2" in there, I think you can just point it to your unwrap modifier object (in this case mine's called "uv" ).
It is very inconvenient to have to install a bunch of extra stuff to run a program. But few programs develop everything themselves, they have external libraries they depend on. The difference is, they are better about how they are distributed and they understand the need for them. We haven't figured out a distribution mechanism (part of this is because how our shitty scripting languages and programs work), but much of it, and what we can change, is the part about understanding the need for them. Once we understand and demand the need, we can develop the systems- and once the systems are developed it will be trivial/assumed/usual to distribute external code as part of a tool or app.
So what? That is an issue with how you are installing scripts, nothing more.
Feel free to recompile them if they are plugins or rewrite them if they are scripts. But it is always better and faster to refactor someone else's working code than it is to write that code from scratch (and if you think it isn't always faster- unless the code is real shite which you shouldn't be using in the first place- then you haven't been developing enough, because it unequivocally and 100% is).
You are distributing the needed stuff with your script. See response to your second point.
No I'm not in a different position, at all. I have a different perspective and I probably need to explain better, but my position is the same.
So I have this program, called 'ProgramX' that installs to 'C:\\Program Files\\ProgramX\\'. Inside I have something like 'ProgramX.exe', 'dx9.dll', 'openal.dll', 'Ionic.Zip.Utils.dll', 'DesktopDecorator.dll'. Each of these dll's are essentially someone else's code you are using.
dx9.dll- You are using DirectX, which is an API (key word is 'interface')
openal.dll- A sound library, instead of having to write all your sound stuff in C++, you can just call stuff from openal, it is also an API.
Ionic.Zip.Utils.dll and DesktopDecorator.dll- These are two C# classes. The first is for dealing with zip files, the second is for changing wallpaper.
You could, of course, write all of this stuff from scratch (assuming you had the requisite skills). But programmers don't, why? Because they have a rich library of available, good (sometimes not so good, in the case of the last dll) code they can reuse. That they don't have to update. That they don't have to maintain. But they still have the ability to extend classes and fix bugs (this is one of the infrastructure issues in our scripting languages we cannot do easily right now).
So for example I'll take chuggnut's functionally-excellent but structurally-shit UV plugin (I dont' blame him, this was made years ago when this sort of scripting was the norm and pretty usual). Great, it works, end of story, right? No. Because if the tool were written in a sensible way, the user experience wouldn't be the end of the story. Other devs would be able to take the methods and utilities chuggnut wrote and do tons of other things with them. They'd also be much better able to expand/replace/enhance functionality within the tool itself.
You should be able to use an existing script library, expand it, and others should be able to take yours (depending on license, of course, which if anything but open-source is selfish) and expand and distribute it. To the user, they are just downloading and installing stuff as usual. The problem is with few people writing extensible scripts and libraries, and fewer people participating in the discussion about how to best distribute and what systems are needed, there are still substantial issues to be solved. But simply giving up is no way to behave, as there is a solution there if we discuss and collaborate and we all acknowledge the end result will be exponentially better than what we put in (which is the entire idea behind developing tools, isn't it?).
There was something else I wanted to say but my brother called and I can't catch my train of thought a half hour later. I hope that explains my perspective more clearly.
Now the script count black pixel on the uv map, and drop a percentage of "wast uv space" depending on the wanted size of the map.
result just below
my code is perhaps not very optimised, but its working well on editpoly object
just select an editObj and run the script
Maybe it's completely useless, but it was a challenge for me
I saw too, on your post, that you want to make a uv face selection 3ds==>photoshop?
like this?
http://www.zortech.de/uv2psScript.xhtml
I find that very useful
hope you like it
I got this error in max9 thats propably the result from that thread- I just dont like the PS script part. But its a nice script to learn from.
but on max 9 sp1 I sometimes have the same error
I'll try to see where the problem may come
is copy to clipboard limited in size?
a 1024x1024 works well, but not 2048x2048?!
Renderhjs, you have some sweet stuff going, don't stop!
render ambient occlusion map to clipboard
you will see a render progress bar so you know when max is done rendering the map and when its in your clipboard - but you dont see the framebuffer or renderwindow.
still prototype but here is the code: I am still figuring out how to use as less parameters as possible to reduce complexity in the interface or usage. But in the end it might end up with textureSize², samples/qulity, spread/softness
the next thing I started roughly is a GUI for all these scripts (texture/UV stuff) though I plan designing most functions in a way so that they can used as well on keys and single buttons - so that they can survive as well without parameters somehow
I crossed the buttons that have no functions yet - those are planned atm. but not yet added. Be carefull though as open UV-editor overwrites color settings of your UV-editor such as background color and edge color. I have not yet tried it on other computers here but those should be the only settings that change things in your uv-unwrap editor in case you might edit your UV`s the regular way.
script as download (source view at the bottom)
http://www.renderhjs.net/bbs/polycount/texture_maxscript_tools/renderhjs_texture_tools_05.ms
more in detail:
the vertex align script:
changes:
- can handle face or edge selections as well
- spinner for the snap angle that defines within what 90° offset angle it should snap to the axis.
align edge-shell to axis
features:
- detects automaticly the closest axis to the edge slected
- aligns the associated shell around the center of the selected edge
- align shells to each other based on a edge- pair (similar to Modo or uvLayout)
future ideas:
- align face selection to 3d space equivalent orientation. Often when automatic unwrapping shells get rotated or flipped in the wrong direction - I want to get rid of that.
- render selected faces to quicker block out textures in photoshop (inking base shapes of certain model shapes)
- render convex/concave map (convexity map) based on vertex color script I found. This will be a alternative dirt map. maybe some material stuff with difuse-RTT output might be another nice idea, or a difuse-RTT of a falloff map with world-z direction (dust map).
script code (in case my url gets offline or you want to dig specific code)
Thanks for the idea to change the colours of the uv window, I was always annoyed at that background grid thing and how the lines were not visible in the black squares, cant believe changing the colours didnt occur to me until now -.-
btw you can make the uv window pop up by default by enabling the "always bring up the edit window"under options and then saving preferences.
The features are awesome, I really like that shell aligning idea and the copy-uv-wire. But a few things I dont like;
First I cant hotkey the UV aligning tools, this is really important because I dont want to be clicking on a 2nd window to do this. Actually I'd like to put all of this stuff in a quad menu or hotkeyed instead of a clicking interface, but I guess it will be impossible to do with the ones that require a number input box.
Secondly when undoing the UV aligning, it undos each vertex individually instead of the whole process. So If I align 20 UVs, it will have to go through 20 undos to get back to the previous state whereas with chuggnuts (or mops tools), you can undo the whole thing.
And I realize I can rip your script to make a hotkeyable version of the alignment tool, I just felt like suggesting you to put it in there by default
That is also why I mentioned in the beginning to try to design functions to be useable even witout parameters (e.g angle snap value - would then be hard coded i the function and each time come with the same value). Another goal was to reduce the amount of functions or keys one use (by smartly determining between horizontal or vertical align for example).
but thx for the try and feedback
Cheers, dude
functions added meanwhile (will post code later)
- render selected UV faces as mask into clipboard
- edge-loop align (aligns a edge loop based on a edge selection)
I had some smal success writing the align selection to 3d space (so you dont have flipped or 180° rotated shells) but its not yet working quite right yet.
Another idea I have is to distribute vertecies along a line with a kind of relax behaviour which could work great on pelt-mappings that need to be straighten on the borders but remain relaxed to the connected vertecies.
feature request:
could you make a script that relaxes the selection, but constrains some edges/verts to either their uv position, or just the u or v position? so you could create straight edges, yet still relax it so that you get the smallest amount of distortion? (so you select the top edges of an island, make sure they are aligned in the v direction, then constrain them to that axis so they can only move in the other direction.
hard to explain, but it'd be an amazing feature, and if you could pull it off i'd be worshipping you for the rest of your life until you get so annoyed of me you wish you never wrote the script in the first place! haha.
at the bottom of my last message: I think that is what you mean or at least close related,- here is a picture of what I had in mind:
is dat wat jij bedoelt ?
note the equal distribution at the end, the same of course could be applied to a snapped axis (just U or V). My idea was to have a version of that script or button that eases step by step (always 1/2 of the distance to its perfect position from its current) so the transition would not be that rough and adjustable in steps (like the old relax behaviour in max except that this one can align on line flows)
Any idea what causes it?
seems like it cant find a path,- got the same when rendering the UV ?
c:\documents and settings\ ???? \..
or maybe you removed that part in the screenshot in that case perhaps you dont have write access at that location.
that code line that is highlighted refers to a string ao_bake.fileType which is the path of the image to be saved it gets declared here:
so if you paste just in your listener what does it puke? a path that does not exist?
I wanted to go with grey styled icons only just like in PS but compared to PS I do not simply need to visualize tools but rather actions and affection which becomes difficult.
that would be certainly nice perhaps in the style of silo where you hover over the button with the mouse and hit a key on your keyboard. Unfortunately scripting access to keys is from my understanding very limited- macroscripts though will be added once I have this all running nice and smooth without puking errors.
I sent some info to Renderhjs, though, so let's hope he figures it out. Not that I really needed the ao-bake, I just clicked buttons to see if they'd work and found one that didn't
It worked here with 3dsmax 9 32 bit and with 3dsmax 2009 Design 32 bit on Windows Xp 32 bit so I almost believe that the problem is somewhat because of that.
It might be that the path`s in vista are not present, write-able (in that case maxscript returned the wrong url for the #image url), or that 64 bit has different access or whatever to dotNet either way cant reproduce and thereby debug the problem here- sorry.
[php]ao_bake.fileType = GetDir #image + "_renderToClipboard3.bmp";--appearently the target filename/path[/php] its the part of the script that tells the RTT job of the AO pass where to save the file.
Appearently it defines the filename instead of the extention. There is a attribute for the filename as well but its something else or is ignored. I got this glitch from a forum where people freaked out because maxscript would simply not save the AO render pass. It could be that autodesk fixed that only in the 64-bit version in vista - maybe I could test things out based on this assumption and define the path where one would assume it for Vista64bit users - propably some try()catch() thing. Will test it out this weekend
It pulls the actual file format from what is defined in the "Render Setup > Render Output" window "rendOutputFilename" to be exact. If this is blank (like any new scene is) then it will not save anything, which is why it fails for some people. If they picked a file path and type, (and possible rendered once with those settings) it would save something. The sad thing is lets say you have it set to .mov but the script names it .png you get a .mov with a renamed extension to png.
You have to set "rendOutputFilename" first, in order to set the file format correctly. Kind of a pain and not very well documented... I remember there being one more hickup/roadblock to outputting renders but can't think of it... Hopefully that will get you moving in the right direction?
But isnt't rendOutputFilename somethiing that is rather close to render in general not the RTT stuff? Its odd as when throwing the render job using: you can pass through an additional parameter of where the framebuffer should be stored (though obviously not what I want). I will give your hint a in depth shot if my current version should still fail on 64-bit max versions - as I changed some variables where it crashed before for 64bit users.
so here is the update, this time however you need a additional bitmap to run the script it holds the icons of my buttons - so copy booth to the scripts/statup folder
interface
crossed buttons are not yet available or finished
a quick video showing some of the features
download
www.renderhjs.net/bbs/polycount/texture_maxscript_tools/uv_toolbox_0.6.zip
so if some 64 bit users could give esspecially this code fraction another shot (copy it and run it in the maxscript listener) that would be fine (you need to select a object to render the AO map)
-- Syntax error: at ), expected <factor>
-- In line: )
Whats the purpose of the 3 icons at the top that arent buttons? Is it meant to be some logo for this script? I think they're a waste of space
yes a smal logo or caption for the tool itself will be placed there because the initial window title is hardly readable - I am working atm. on that so that some GUI parts will work propper. Its just 20 pixels in height If you dont like it you can remove it later its just 1 line of code.
You might want to warn the user that their render-er is not set correctly and offer three options.
1) Set it to MR and leave it.
2) Set it to MR and switch it back, another prompt comes up warning them about instability and make sure to blame MR/AD so you don't unfairly get blamed.
3) Do nothing and let them set switch it over, ie cancel.
here is error screen
PS: 3dsmax 2009 32 bit , WinXP Pro x86 SP3
Please help:poly122:
Titus: fixed it,- thanks for your feedback - remove the older files and now simply use this single file
http://www.renderhjs.net/bbs/polycount/texture_maxscript_tools/uv_toolbox_0.7.mzp
again just copy this single file into your 3dsmax/scripts/startup folder so that it runs at each launch,- or simply start the script from the maxscript listener.
Vig: thanks for the input,- you are right I guess I will stay with a warn message so that the user has to switch by himself instead of me hacking around the system.
btw. I addded the script at scriptspot some time ago
http://www.scriptspot.com/3ds-max/uv-toolbox-for-the-texture-artist-set-of-uv-texture-maps-rendering-tools
though this thread will be my main update/inspiration thread regarding this project
the command that is responsible for the rotation there is:
[php]obj.modifiers[#unwrap_uvw].unwrap2.RotateSelected (-_a_off * PI/180) [(ptA.x + dx/2),(ptA.y + dy/2),0][/php]
the way it seems (havent tested yet) is that max takes even within single maxscript commands the snap value into consideration. I found a command that toggles the ratation snap but not a variables that tells me the current state - which I need in order to detect when to switch,
[php]max angle snap toggle[/php]
maybe I can trick abit and do a temporary rotation and calculate the result of that rotation transformation - if it fits within the default 5° snap value toggle the autoSnap.
thx for letting me know
- 3 new functions: assign checker map; set "flat" view mode; normalize UV shells (thx to MoP)
changes/updates:
(1.) ask's the user in case mental Ray is not assigned as the renderer if the script should assign it and continue the script.
If mentalRay is already the scene renderer everything should work right away and nothing gets changed at all.
(2.) high and low presets (not yet tuned values,- some recomendations? - sets spread and falloff value for AO)
(3.) Assigns a checker map (greyish with 8*8 tiling) to the selected object with visibility inside set the viewport. This has nothing to do with the material instance editor (the 3dsmax material editor) as each object node in max can (has) have its own material.
(4.) set self illujmination viewmode in the active viewport. Its a bit hidden in the default 3dsmax interface but this button does not at all modify the material - instead it sets the viewport mode to 'flat' which basicly means no shading and 100 difuse view.
(5.) thx to tumberboy I fixed the auto-align button thingy my script can actually DETECT angle snap mode . If it is active it will temporarily disable it- align rotate again and enable back your angle snap toggle.
(6.) included the normalize UV-shells script from MoP
http://boards.polycount.net/showthread.php?t=52415
which normalizes all uv-shells without hardly changing their position. This often results into equal pixel space density over all shells, thx MoP for the great script
... and some minor enhacements like the get Size button that better detects if a bitmap material is assigned to the selected object- and use its width or height value ect. It would be nice if some of those former 64-bit users could give the AO-bake part another spin to see if it was actually rather not because in their cases MR was not assigned as the renderer.
download:
uv_toolbox_0.8.mzp
remove prior versions and copy this into your startup folder
click yes and it applys your icons as a hugely stretched viewport background, click cancel and it does nothing (no script box, nothing)