Randomize UV

Randomize UV

Primabad
Participant Participant
4,294 Views
1 Reply
Message 1 of 2

Randomize UV

Primabad
Participant
Participant

Hello,

 

I am trying to find a solution to my uv mapping problem. My goal is to render multiple thumbnail images of cabinets. I have to render a lot (I mean hundreds) of these thumbnails with all the different cabinet sizes and types. This is all doable. The problem however is that all these cabinets have a wood texture on them and I want them to be random. Mapping the different parts of the cabinets is pretty straightforward as it's basically just a bunch of boxes. But how do I make the texture appear random on my cabinet?

 

I have a wood texture that in reality is 280 x 280 centimeters. So first thing I would do is use an uvw box (280, 280, 280) map on all the objects. After that I would add an Unwrap UV modifier and select all the vertical aligned sides and rotate them 90 degrees (I want all the sides to follow the wood texture so they need to be horizontally aligned). Then I would use the pack together function with rescale unchecked. At this point I almost got what I want. All of my object have their own "random" texture coördinaties. The problem though is that some parts cross the uv tile borders and because my texture isn't seamless I'll get seams where I don't want them. 

 

Random UV 1.jpgRandom UV 2.jpgRandom UV 3.jpgRandom UV 4.jpg

 

I've tried about everything but I couldn't find anything to make them not overlap the tile borders. What I would like to happen is that when it doesn't fit 1 single tile, the parts will be evenly distributed over on the other tiles but without crossing the borders. Another solution is when everything will be on the same tile but with overlap. I don't care if my uv's overlap each other because that doesn't matter in my scenario. 

 

I'v also tried to find a script to solve my problems and I have found a few that, again, almost do what I want. 

I found this script: http://www.scriptspot.com/3ds-max/scripts/uvw-randomizer-0

I can use it to create the initial uvw box map and then randomize (Tiled map unchecked) and all uv's are randomized in a singel uv tile with overlap (but none cross the tile border). Problem however is that some off the sides of my objects are still vertical aligned. To manually align them horizontally after the randomization is a nightmare. But when I first align them correctly using the UV editor I can't use the script anymore (it only works on a uvw map modifier). 

 

Another script I've found is uv-packer: https://www.uv-packer.com/

This tool will place all my uv's random on different uv tiles without overlap and without crossing any uv tile borders. Problem here is that it doesn't keep the uv size that I have created using the uvw box map. It scales all the uv's to fit either 1 tile or multiple tiles. 

 

So the question is: does anybody now of a good way to solve my problem? Either with something already inside Max or with an external script or plugin? (It doesn't matter if it's free or payed). 

I'm losing my mind here 😉

 

0 Likes
4,295 Views
1 Reply
Reply (1)
Message 2 of 2

Primabad
Participant
Participant

So I tried some Max script myself but I'm not very good at it. Using this script I can at least randomize my uv's using the uvw_xform:

 

for i in selection do
				(
					b = uvw_Xform ()
					addModifier i b
					i.modifiers[#UVW_Xform].u_offset = (random 0.0 1.0)
					i.modifiers[#UVW_Xform].v_offset = (random 0.0 1.0)
					)

 

However I can't figure out how I can keep the uv's inside the single uv tile. I am trying to learn from the uv randomizer script to see how he has done it: http://www.scriptspot.com/3ds-max/scripts/uvw-randomizer-0 

But so far I can't really understand it.

 

I know these lines control what I want but I don't understand how I can use it to fix my script. It probably calls back to functions elsewhere in the code. Like I said I don't have much experience writing (or understanding) code.

 

if randomizer.chk_tiled.state == off then
		(
			if randomizer.chk_custom.state == on then
			(
				for b in selection do
				(
					if iskindof b.modifiers[1] uvwmap then
					(
						dimensions = b.max - b.min
						b.modifiers[1].gizmo.pos.x += (random -((randomizer.spn_lengthuvw.value - dimensions[1])/2) ((randomizer.spn_lengthuvw.value - dimensions[1])/2))
						b.modifiers[1].gizmo.pos.y += (random -((randomizer.spn_Heightuvw.value - dimensions[2])/2) ((randomizer.spn_Heightuvw.value - dimensions[2])/2))
						b.modifiers[1].gizmo.pos.z += (random -((randomizer.spn_widthuvw.value - dimensions[3])/2) ((randomizer.spn_widthuvw.value - dimensions[3])/2))
					)
				)
			)
				
		)

 

Can anybody give me some tips to help me along? 

0 Likes