Author Topic: CoronaMappingRandomizer is not so random  (Read 432 times)

2023-11-17, 19:07:36

mte

  • Active Users
  • **
  • Posts: 110
    • View Profile
    • www.m-te.de
Hi all,

I´m in the process of rendering flooring tiles. They are cloned using the C4D-cloner. The one tile has a texture tag with the MappingRandomizer.
As you can see in the image there is some sort of randomisation but there is a lot of clustering and very often 2, 3 or 4 times the same tile in a row.
I now manually step through 300 different seed values to find one that is okay for the field of view.
I have 7 different tiles and would expect some sort of evenness in the distribution.

have a great weekend
Andy

2023-11-17, 19:52:49
Reply #1

pokoy

  • Active Users
  • **
  • Posts: 1810
    • View Profile
Have you heard the story about how Apple had to change their random song playing algo on the iPod, exactly because of the same effect: even in truly random sorting the same instance/color can appear numerous times in a row. Making sure something is not repeated is not true randomness. But I agree to some point, it looks wrong especially with texture maps or colors.

2023-11-17, 20:24:47
Reply #2

bnji

  • Corona Team
  • Active Users
  • ****
  • Posts: 162
  • Benjamin
    • View Profile
    • Corona Renderer
Hi theremte
Thank you for posting this.
According to your image, you're providing only 7 different textures to feed up the material; am I correct?
As @pokoy already mentioned, at some point, the same textures will appear again as the shader places each one of the provided textures; it will run out of textures and will start over, placing them in a different location.
If you need a more solid randomization, I'll suggest using more textures to feed up the shader/material.
I hope this helps.
If this is not what you were trying to communicate, please let us know.
Have an amazing weekend ahead.
Benjamin Rosas | chaos-corona.com
3D Support Specialist - Corona | contact us
Corona Uploader l Upload

2023-11-17, 20:45:45
Reply #3

mte

  • Active Users
  • **
  • Posts: 110
    • View Profile
    • www.m-te.de
Hi Benjamin,

thanks for your reply. As a software developer I know how randomisation works and I know the story pokoy told.
Apple changed their algorithm in order to overcome the problem that "true" random is very often not what you want.

My point is that there is clustering of colors! Using more textures is not solving the problem unless you use orders of magnitude more textures than you have tiles. With that, the problem would dissolve in the noise of randomness, but this is not practical at all.

I am pretty sure, that you a more or less, just iterating over the objects (or whatever it is set to). As you can clearly see sometimes the same ID is picked 4 times in a row. This might be pure random, yes but it looks bad.

Instead you could shuffle the IDs beforehand instead of going linear or check the last random value and randomize again if the lastValue equals the currentValue.

Hope this explains it better.
Andy

2023-11-17, 21:39:46
Reply #4

James Vella

  • Active Users
  • **
  • Posts: 430
    • View Profile
7 is still probably not enough to get a good amount of randomness in there, if anyone actually would notice.

However since you are a software developer you may be happy to know that you can write your own float logic/script for the seed value in the Expression dialog:
random" border="0

2023-11-17, 22:18:36
Reply #5

mte

  • Active Users
  • **
  • Posts: 110
    • View Profile
    • www.m-te.de
Hi James,

7 are not enough to avoid repetition. But that was not my point, I´was just talking about clusters. I did a lot of tests even with 5 tiles and 7 textures and there are a lot of seed values where I get say 4 red and one blue.

I was not aware that this is possible, since We are using C4D. I have access to the seed value via python and control it from outside C4D, but I can just change the value and not the actual logic of the distribution. Is this different in Max?
And you are using the MultiTexmap shader and not the MappingRandomizer.
But I like your Idea and will have a look into the MultiTexmap, maybe I get better results.

thanks
Andy

2023-11-17, 23:35:56
Reply #6

romullus

  • Global Moderator
  • Active Users
  • ****
  • Posts: 8617
  • Let's move this topic, shall we?
    • View Profile
    • My Models
Don't forget that with mapping randomizer you can rotate textures by 90, or 180 degree and also flip them horizontally and vertically, so that should help disguise the fact that some neighbouring tiles has the same texture.
I'm not Corona Team member. Everything i say, is my personal opinion only.
My Models | My Videos | My Pictures

2023-11-18, 10:05:24
Reply #7

James Vella

  • Active Users
  • **
  • Posts: 430
    • View Profile
Hi James,

7 are not enough to avoid repetition. But that was not my point, I´was just talking about clusters. I did a lot of tests even with 5 tiles and 7 textures and there are a lot of seed values where I get say 4 red and one blue.

I was not aware that this is possible, since We are using C4D. I have access to the seed value via python and control it from outside C4D, but I can just change the value and not the actual logic of the distribution. Is this different in Max?

Just the seed from what I can see, not distribution. Should be no difference in 3dsmax/c4d from my experience, everything that is exposed in one software is usually in the other. Theres a few ways I suppose you could handle it, depending on how you are making your tiles. The seed for the tiles itself (ID's) + the seed for the Multi-Map or Randomizer. With Multimap you can also adjust the hue random which breaks up clustering but could be weird with specific color choices/ranges (or gamma if you just want light/dark instead). Romullus also mentioned a good point about the rotation of the tiles that are clustering.


And you are using the MultiTexmap shader and not the MappingRandomizer.
But I like your Idea and will have a look into the MultiTexmap, maybe I get better results.

thanks
Andy

You could also get creative and do multiple and use a mix with a mask of generated black/white tiles that use a different seed.

random" border="0

Edit: After thinking about it some more, i think you make a good point @mte, if we had the distribution exposed to python/maxscript then we could put in a custom pattern, that would be cool!
« Last Edit: 2023-11-18, 18:18:23 by James Vella »

2023-11-19, 02:07:45
Reply #8

lupaz

  • Active Users
  • **
  • Posts: 881
    • View Profile
I agree with the OP. In fact I think either myself or someone else brought this up at some point with random in corona scatter

2023-11-20, 14:30:28
Reply #9

mte

  • Active Users
  • **
  • Posts: 110
    • View Profile
    • www.m-te.de
@James
Not sure how they could expose the distribution, but it would be great to create custom patterns.
On the other hand, if Corona were to implement something like a weighted random distribution (I think this is what Apple did), the perceived random distribution would benefit greatly.
If the user had some controls for the weighting, it could be phenomenal. And scatter could benefit from the same concept.

@romullus
Of course I already implemented the 180° rotation. You would be surprised how little advantage this brings. Especially with very concise patterns in the wood, it is usually worse than better. The eye immediately recognizes that it is a mirrored or rotated pattern.

2023-11-20, 16:47:23
Reply #10

Ink Visual

  • Active Users
  • **
  • Posts: 156
    • View Profile
I must agree the randomness algorithm that Corona uses is indeed not our favourite. Reading the posts above I kind of understand that randomness does not necessarily mean that two same elements won't appear side by side, although it would be much appreciated if this could be somehow improved?
This has been especially annoying in scatter setups where i.e. way too many cars of the same colour appear one next to another, even with a very high number colour of slots in multimap.

2023-11-21, 19:35:53
Reply #11

BigAl3D

  • Active Users
  • **
  • Posts: 831
    • View Profile
If you are making your planks as meshes and maybe using Mograph cloning, you could also add the random rotation of the planks.

2023-11-21, 19:39:05
Reply #12

mte

  • Active Users
  • **
  • Posts: 110
    • View Profile
    • www.m-te.de
I do, but random rotation does not solve the bigger problem.

2023-11-21, 21:15:58
Reply #13

Beanzvision

  • Corona Team
  • Active Users
  • ****
  • Posts: 3613
  • Bengamin
    • View Profile
    • Cormats
I always had good results with a combo of the multi-shader and the mapping randomizer. Hmm

Bengamin Jerrems l chaos-corona.com
3D Support Specialist - Corona l contact us
Corona Uploader l Upload
Portfolio l Click me!

2023-11-23, 12:50:29
Reply #14

mte

  • Active Users
  • **
  • Posts: 110
    • View Profile
    • www.m-te.de
Hi Ben,

do you use a special setup?
Your distribution looks okay, but with the herringbone pattern the eye gets easily distracted.
I have larger tiles and some of these have very easily recognizable patterns such as knotholes or concise structures. Please have a look at the attachment.

One thing is of course logical: too few textures spread over too many tiles always leads to repetition. But that's not my point. What I find distracting is the formation of clusters of one and the same texture.