Page 1 of 3

UVRandomMapping2D (and LocalRandomMapping3D)

Posted: Mon Aug 31, 2020 3:16 pm
by Dade
UVRandomMapping2D

UVRandomMapping2D is a special kind of texture mapping 2D intended to randomize the UV mapping across multiple objects or the "islands" (by using the IslandAOVShape) of the same object.

This is normal mapping+normal tiling:

nn.jpg

This is normal mapping+random tiling:

nr.jpg

And this is random mapping+random tiling:

rr.jpg

The syntax is:

Code: Select all

scene.textures.imgtex.mapping.type = uvrandommapping2d
# Type of seed: "object_id", "triangle_aov" or "object_id_offset"
scene.textures.imgtex.mapping.seed.type = object_id
# If seed type is "triangle_aov", the index of the AOV to use
scene.textures.imgtex.mapping.triangleaov.index = 0
# The offset to add to object ID when seed type is "object_id_offset"
scene.textures.imgtex.mapping.objectidoffset.value = 0
# Rotation Min/Max range
scene.textures.imgtex.mapping.rotation = 0 360
# U Scale Min/Max range and V Scale Min/Max range
scene.textures.imgtex.mapping.uvscale = 2 2 2 2
# If to use the same scale for U and V or decouple them
scene.textures.imgtex.mapping.uvscale.uniform = 1
# U Delta Min/Max range and V Delta Min/Max range
scene.textures.imgtex.mapping.uvdelta = 0 0.2 0 0.2
This feature was discussed here: viewtopic.php?f=5&t=2516&start=10#p24959

Image


LocalRandomMapping3D

LocalRandomMapping3D can be used to achieve the same result with procedural textures:

Code: Select all

scene.textures.140689401127944Color.type = checkerboard3d
scene.textures.140689401127944Color.texture1 = 0.7 0.0 0.0
scene.textures.140689401127944Color.texture2 = 0.7 0.7 0.7
##
# localrandommapping3d
##
scene.textures.140689401127944Color.mapping.type = "localrandommapping3d"
scene.textures.140689401127944Color.mapping.transformation = 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1
# Type of seed: "object_id", "triangle_aov" or "object_id_offset"
scene.textures.140689401127944Color.mapping.seed.type = object_id
# If seed type is "triangle_aov", the index of the AOV to use
#scene.textures.140689401127944Color.mapping.triangleaov.index = 0
# Rotation Min/Max range
scene.textures.140689401127944Color.mapping.xrotation = 0 360
scene.textures.140689401127944Color.mapping.yrotation = 0 360
scene.textures.140689401127944Color.mapping.zrotation = 0 360
# Translate Min/Max range
scene.textures.140689401127944Color.mapping.xtranslate = 0 0
scene.textures.140689401127944Color.mapping.ytranslate = 0 0
scene.textures.140689401127944Color.mapping.ztranslate = 0 0
# Scale Min/Max range
scene.textures.140689401127944Color.mapping.xscale = 1 1
#scene.textures.140689401127944Color.mapping.yscale = 0.7 1.3
#scene.textures.140689401127944Color.mapping.zscale = 0.7 1.3
# If to use the same scale for X, Y and Z or decouple them
scene.textures.140689401127944Color.mapping.xyzscale.uniform = 1
This is a normal rendering (i.e. the procedural texture look the same on all 4 objects):

nrnd.jpg

and this using localrandommapping3d:

rnd.jpg

Re: UVRandomMapping2D

Posted: Tue Sep 01, 2020 5:04 am
by AndreasResch
This would be great. You might also consider adding this to triplanar mapping as well where randomization makes a lot of sense. In those wooden pieces I actually used triplanar mapping. All the sides are randomly rotated and shifted to get the variation which simulated the randomness of production.

Cheers for your efforts.

Re: UVRandomMapping2D

Posted: Tue Sep 01, 2020 11:53 am
by Dade
Added the GPU support.

Re: UVRandomMapping2D

Posted: Thu Sep 03, 2020 1:32 pm
by Dade
AndreasResch wrote: Tue Sep 01, 2020 5:04 am This would be great. You might also consider adding this to triplanar mapping as well where randomization makes a lot of sense. In those wooden pieces I actually used triplanar mapping. All the sides are randomly rotated and shifted to get the variation which simulated the randomness of production.
I added the support for a new seed type "object_id_offset" so an arbitrary value can be added to the object ID as seed. This allow to have 3 different seeds (i.e. random transformation) for triplanar mapping (using 3 imagemap texture with 3 different object_id_offset values):

Code: Select all

################################################################################
scene.textures.140690754759176Color0.type = "imagemap"
scene.textures.140690754759176Color0.file = scenes/randomizedtiling/pattern-7.jpg
scene.textures.140690754759176Color0.gain = 1
scene.textures.140690754759176Color0.gamma = 1
scene.textures.140690754759176Color0.storage = "byte"
scene.textures.140690754759176Color0.randomizedtiling.enable = 1
scene.textures.140690754759176Color0.mapping.type = uvrandommapping2d
scene.textures.140690754759176Color0.mapping.seed.type = object_id_offset
scene.textures.140690754759176Color0.mapping.objectidoffset.value = 0
scene.textures.140690754759176Color0.mapping.rotation = 0 360
scene.textures.140690754759176Color0.mapping.uvscale = 1 1 -1 -1
scene.textures.140690754759176Color0.mapping.uvscale.uniform = 0
scene.textures.140690754759176Color0.mapping.uvdelta = 0 0.2 0 0.2
##
scene.textures.140690754759176Color1.type = "imagemap"
scene.textures.140690754759176Color1.file = scenes/randomizedtiling/pattern-7.jpg
scene.textures.140690754759176Color1.gain = 1
scene.textures.140690754759176Color1.gamma = 1
scene.textures.140690754759176Color1.storage = "byte"
scene.textures.140690754759176Color1.randomizedtiling.enable = 1
scene.textures.140690754759176Color1.mapping.type = uvrandommapping2d
scene.textures.140690754759176Color1.mapping.seed.type = object_id_offset
scene.textures.140690754759176Color1.mapping.objectidoffset.value = 1
scene.textures.140690754759176Color1.mapping.rotation = 0 360
scene.textures.140690754759176Color1.mapping.uvscale = 1 1 -1 -1
scene.textures.140690754759176Color1.mapping.uvscale.uniform = 0
scene.textures.140690754759176Color1.mapping.uvdelta = 0 0.2 0 0.2
##
scene.textures.140690754759176Color2.type = "imagemap"
scene.textures.140690754759176Color2.file = scenes/randomizedtiling/pattern-7.jpg
scene.textures.140690754759176Color2.gain = 1
scene.textures.140690754759176Color2.gamma = 1
scene.textures.140690754759176Color2.storage = "byte"
scene.textures.140690754759176Color2.randomizedtiling.enable = 1
scene.textures.140690754759176Color2.mapping.type = uvrandommapping2d
scene.textures.140690754759176Color2.mapping.seed.type = object_id_offset
scene.textures.140690754759176Color2.mapping.objectidoffset.value = 2
scene.textures.140690754759176Color2.mapping.rotation = 0 360
scene.textures.140690754759176Color2.mapping.uvscale = 1 1 -1 -1
scene.textures.140690754759176Color2.mapping.uvscale.uniform = 0
scene.textures.140690754759176Color2.mapping.uvdelta = 0 0.2 0 0.2
################################################################################
scene.textures.140689401127944Color.type = "triplanar"
scene.textures.140689401127944Color.texture1 = "140690754759176Color0"
scene.textures.140689401127944Color.texture2 = "140690754759176Color1"
scene.textures.140689401127944Color.texture3 = "140690754759176Color2"
scene.textures.140689401127944Color.uvlessbumpmap.enable = 1
scene.textures.140689401127944Color.mapping.type = "localmapping3d"
scene.textures.140689401127944Color.mapping.transformation = 2 0 0 0 0 2 0 0 0 0 2 0 0 0 0 1
################################################################################
This is a normal rendering with triplanar and UVRandomMapping2D with "object_id" seed:

randtri0.jpg

and this with "object_id_offset":

randtri1.jpg

Re: UVRandomMapping2D

Posted: Thu Sep 03, 2020 1:44 pm
by AndreasResch
This sounds promising.

But will this be dependent on the "Object ID" value of the object? So will objects with the same ID have the same randomization? This might be helpful in some cases, but would be hard to do when you have a lot of objects and you want to randomize them all.

Re: UVRandomMapping2D

Posted: Thu Sep 03, 2020 2:24 pm
by Dade
AndreasResch wrote: Thu Sep 03, 2020 1:44 pm This might be helpful in some cases, but would be hard to do when you have a lot of objects and you want to randomize them all.
By default, the object ID is random, you can overwrite it to have a fixed value.

Re: UVRandomMapping2D

Posted: Thu Sep 03, 2020 3:02 pm
by AndreasResch
Sounds great. Thanks a lot.

Re: UVRandomMapping2D (and LocalRandomMapping3D)

Posted: Mon Sep 07, 2020 2:43 pm
by Dade
I added the support for LocalRandomMapping3D to achieve the same result with procedural textures. Updated the first post with information about LocalRandomMapping3D.

Re: UVRandomMapping2D (and LocalRandomMapping3D)

Posted: Mon Sep 07, 2020 3:09 pm
by AndreasResch
Wohoooo!!! 2.5 will be awesome. For this feature and the Bevel shader alone. Cheers.

Re: UVRandomMapping2D (and LocalRandomMapping3D)

Posted: Sat Oct 24, 2020 11:24 am
by juangea
This is not yet in BlendLuxCore right?