Jump to content

Sign in to follow this  
Cerealmike

Difficult Randomness

Recommended Posts

Hi all,

 

I have a tough problem. The client is asking for a huge wall randomly covered in posters. BUT he doesn't want to see the same picture next to each other (Especially no more than 3 times).

 

My quick setup:

  • Mograph with a plane object
  • Random effector with cell noise shader
  • Multishader with 8 different images.

 

My practical solutions so far:

  • I could generate some more extra / 'fake' images.
  • Maybe some blank ones.
  • Replace the duplicates in Photoshop.

 

My theoretic solution:

Basically I should generate my own random shader:

  1. I could use xpresso which recognizes the multishader images by their number.
  2. Use an if/else loop which compares the 4 positions around one image.
  3. If a number = equal to its neighbour --> switch it (how do you force that switch??)

 

 

Thanks!

 

render.jpg

Schermafbeelding 2019-09-05 om 12.01.34.png

Share this post


Link to post
Share on other sites

can't you just pick those out with a mograph selection and change just those ?

 

Deck

Share this post


Link to post
Share on other sites
  • Topic Author
  • 1 hour ago, deck said:

    can't you just pick those out with a mograph selection and change just those ?

     

    Deck

     

    Great solution! But then again that's the 'manual' solution I was trying to avoid.

    I was curious about the technical solution which I could reuse on future randomise projects.

    Share this post


    Link to post
    Share on other sites

    We could do with some general cafe awards. If we had those, I would surely be handing out gold stars to @Cerealmike for this 'post of the day', which I'd like to highlight and commend for its exceptional clarity and presentation. If you don't get many replies to this it certainly won't be because the question wasn't clear ! So just popped in to say 'great job' there. Hope you don't find that massively condescending, but it really is a good example of a question well asked, and I am nerdy enough to appreciate these things, even without my moderation trousers on ! 
     

    CBR 

    Share this post


    Link to post
    Share on other sites

    What you're looking for is a specialized algorithm.  However if you don't want to get your hands dirty with Python building a sudoku algorithm then I would still take inspiration from Sudoku and build a simpler solution that depending on how you approach it may or may not result in additional manual work.

     

    The idea is simple.  Build some blocks first that you know won't have neighbors of the same type.  Then clone those blocks!

     

    At first you might be thinking "But that's going to be even more manual labour than just selecting!".  Not necessarily, hear me out, apart form throwing objects into a couple of cloners it could be all procedural provided you have enough "posters" to clone.

     

    I would recommend at least 3x3 as it ensures you have no same neighbors to all sides, but you could even do 2x2 grids if you're really short on objects to clone.  With a 3x3 you can in theory do this down to just 3 different "posters" but you could have to arrange them in the same pattern as a Sudoku for that manually!  i.e.,

     

    1 2 3

    2 3 1

    3 1 2

     

    Then the four rotations + order change to give you quite a few variations.  The patterning would still be pretty obvious but better than just straight random.  2x2 Would make for even more obvious patterning with less than 4 things to clone.  But I think this approach can scale pretty well even down to few objects to clone.

    Ideally I'd try to have at least 9 different posters though.  Then you take your grid of 9 posters and clone the grids, using a random value to select the grid cloned using the "Modify Clone" parameter in an Effector.

    You could make this a little simpler and a little more procedural by using a "Sort" randomness on the smaller grid component - Sort uses a card deck shuffle  approach to randomness, so unique clones should not end up next to each other.  Remember to set the Min/Max values to 0-100% in the Effector for this to work properly!  You could then use two of those small grids to generate all your sub grids by making use of the Blend mode of a parent Cloner, if you include the Effector modifying the small grid in the hierarchy being cloned and duplicate it with a different seed the Blend mode will handle the generation of all your variations.  Drive the parent Cloner's "Modify Clone" value with it's own Random Effector or Field and you're good to go.


    I've attached a scene showing how to do this.  This should result in you having a much reduced chance of groups of three (and no chance of 3 in a row).  Groups of 2 will still show up though, but hopefully less often, bear in mind that with this algorithm the corners of the sub-blocks are the weak point here as you could end up in theory with 4 that all happen to have the same object in that one corner.  Hopefully that won't happen that often (it's a pretty low probability) and you could either just try changing the seeds or random effector settings, or manually selecting and using another effector to modify the clone value a bit further to fix that.  Best of all this approach keeps things algorithmic and at the same time relatively simple.

    wallofposters.c4d

    Share this post


    Link to post
    Share on other sites

    Join the conversation

    You can post now and register later. If you have an account, sign in now to post with your account.

    Guest
    Reply to this topic...

    ×   Pasted as rich text.   Paste as plain text instead

      Only 75 emoji are allowed.

    ×   Your link has been automatically embedded.   Display as a link instead

    ×   Your previous content has been restored.   Clear editor

    ×   You cannot paste images directly. Upload or insert images from URL.

    Sign in to follow this  

    • Recently Browsing   0 members

      No registered users viewing this page.

    Latest Topics

    Latest Comments

    ×
    ×
    • Create New...