A new version of Cineversity has been launched. This legacy site and its tutorials will remain accessible for a limited transition period

Visit the New Cineversity
   
 
shader assignment controlled by mograph?
Posted: 09 April 2012 07:58 PM   [ Ignore ]  
Avatar
Total Posts:  121
Joined  2010-11-01

Just wondering if theres any way to get mograph to affect which shader is assigned.  Say i’m cloning a model and its got a scratch map on it to make it look beaten up.  They all look the same and i want to get some variation in there.  If i had 10 scratch maps to use but didn’t want to have 10 duplicate models under the cloner, each with a different shader assigned, could it be done?  I’m using quite a high res object and it seems a bit excess to have 10 + identical models under a cloner just to have a different shader attached (even more so if i had more like 20+ scratch map variations).

Was wondering if it could be done using expresso, or maybe more of a python effector thingy?

Profile
 
 
Posted: 09 April 2012 08:11 PM   [ Ignore ]   [ # 1 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Rich,

(edit: I misunderstood the idea of 10 or 20 scratch images, I thought the clone starts clean and get in contact with an object, and becomes so more scratches, in this way all the clones look clean except the ones that have been “triggered”. /edit)

Besides any solutions where you animate the Texture Tag>Material field, which blends from one to another Material (or a Layer Shader with animated Mask-Layers,) I would do the following:

Set up a MultiShader with your ten Textures. Then set up a e.g., Plain Effector to change the brightness of the clones. The Multi Shader can then pick up that information and you get your texture sequence animated. This animation can be done with the falloff or with anything that allows the change of influence of that Effector.

I tested it here with a little sphere, but it should work as well with larger textures.

All the best

Sasssi

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 09 April 2012 08:21 PM   [ Ignore ]   [ # 2 ]  
Avatar
Total Posts:  121
Joined  2010-11-01

Thanks Dr Sassi,

haha, its been so long since i used multishader i forgot about it.  I feel stupid!  Thanks : )

Profile
 
 
Posted: 09 April 2012 09:56 PM   [ Ignore ]   [ # 3 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

You’re welcome Rich,
please think of “feeling stupid” like an oxymoron, a real stupid wouldn’t notice at all. ;o)

There are a lot of ways, but each of them would require a larger knowledge of the project. Like a Proximal shader with a second object to trigger it, or the Vertex Map shader or perhaps some other options…

Have a good one

Sassi

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 10 April 2012 06:33 AM   [ Ignore ]   [ # 4 ]  
Avatar
Total Posts:  121
Joined  2010-11-01

Thats true indeed.  Thanks dr Sassi.

However i’ve realised theres more to my problem that i first thought, so have included a cut down scene to make it simple.  I’ve got a cube and a cylinder being cloned with a gradient shader tag colouring the clones with a shader effector.  However for the clone shader i’m using a multishader in the colour channel and inside each of those multishader textures i’m using a layered texture. 

the layered texture consists of the mograph colour shader and a different texture screened ontop of it.  Hopefully this will make sense when you see the scene.

So the problem is that this works but by using index ratio in the multishader all the textures are repeated uniformly (i want them to be distributed completely randomly).  And i also need the colour of the cube clones to come from the gradient shader via the multishader but keep the cylinder clone black.  And this mean’s i can’t use the colour brightness in the multishader because i would have to use completely different colours on the clones to start with.

Does that make any sense?

Theres a challenge for you! : )  I think theres probably a better way to do it, but i can’t think what it is

I made this scene at work and our version there is r13.
http://dl.dropbox.com/u/9994187/Problem.zip

Profile
 
 
Posted: 10 April 2012 05:18 PM   [ Ignore ]   [ # 5 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Rich,

If you like to have the colors randomly, why bother with the gradient.

If you like to use the MG-colors, you can’t use them for anything else, as long as they need to work independently.

ID’s works not for Grid structures. You have to use a linear or Radial and get the Grid via Matrix>Inheritance back to the Cloner. But then each clone has his own ID, based on the Cloner object setting.

Back to your problem, the main idea was to not have too much geometry in your scene. In any case you will have the geometry generated from the cloner. So, don’t worry too much about that anyway. My suggestion to not go from one solution into the next problem into the next remedy, into the next problem, etc., Use one Original and use Instances as Child then, As the Cylinder needs to be black that should work, at least in my tests here. I placed the objects outside under a null to make them invisible, but had the cube and the cylinder in the instance. Then as before, select a method to trigger the “Sort” not Blend or Iterate (Cloner Object)

All the best

Sassi

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 10 April 2012 07:21 PM   [ Ignore ]   [ # 6 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

P.S. how about the idea to get a linear ID solution and get the random color based on the ID with a Colorizer? 
So far I understand that the “Grunge Texture” is the only thing that needs to be changed, and the colors stick to the clones, even randomly distributed initially.
The colors comes then from a Colorizer on top of the MG Color ID mode use. Example is attached. 01 color changes 02, color does not change

File Attachments
CV2_r13_drs_12_MGtc_01.zip  (File Size: 243KB - Downloads: 239)
CV2_r13_drs_12_MGtc_02.zip  (File Size: 253KB - Downloads: 235)
 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 10 April 2012 09:44 PM   [ Ignore ]   [ # 7 ]  
Avatar
Total Posts:  121
Joined  2010-11-01

Thanks Dr Sassi,

thats some great ideas, hadn’t thought of using the instance object - very clever work around : )

In answer to your question

Dr.Sassi - 10 April 2012 05:18 PM

If you like to have the colors randomly, why bother with the gradient.

I don’t actually want the colours to be random - i need the colours to be controlled exactly by the gradient - as i wish to animate the texture across the clones.  However i do want the scratch textures to be assigned randomly with the multishader or some other method.

Maybe my last scene was a little too simplistic, yes the original reason that i didn’t want lots of copies of the object under the cloner was because it was actually a dynamics setup with a hinge being blown in the wind.  I’ve included my real scene here, and wondering if you wouldn’t mind giving me your advice on this setup instead?  Sorry for not giving it earlier, but was trying to keep it simple for the sake of explaining things. 

So the setup is similar as before (with the multishader), however the clone is a dynamic hinge being blown by the wind.  Also the main colour is coming from the shader effect, which is being driven by the plane (which in turn is animated).  I need the colour to come from this as i want complete freedom to animate it around.

For a minute i thought the instance idea you suggested would work, but of course being its using dynamics, the instances don’t calculate it accurately.

Maybe the best way is the most obvious (have many duplicate setups of the dynamics system under the main cloner), but thought i’d give it one last try to see if it could be done with just a multishader.  Sometimes its good to see if you can do something a certain way in mograph, for the learning process! 

Thanks again, your posts are always very inspiring : )

New file
http://dl.dropbox.com/u/9994187/test2.zip

Profile
 
 
Posted: 10 April 2012 09:48 PM   [ Ignore ]   [ # 8 ]  
Avatar
Total Posts:  121
Joined  2010-11-01

ps in my scene the multishader is used in both the colour channels and the luminance channel.  Incase theres any confusion, the luminance channel could be turned off for testing ideas.

PPs also just saw your other post with your attached files, thanks very much, will download them and have a look now!

Profile
 
 
Posted: 10 April 2012 10:53 PM   [ Ignore ]   [ # 9 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hey Rich,

I have edited my first answer. I thought the scratch/grunge maps should be a progress of scratching (damage) the clones. You just want to have a variety of them randomly in the scene, but not randomized colors.

Take the ID set up, so you can work with the color as you do so far with the rotating plane. I think that is the critical point, we have used the color already, which leaves us with the ID only.

The ID is then used in an extra MG-Color shader. The readout of that shader would be black to gray to white. With The Colorizer you can pick just a little part out of that gradient and turn it into white, the rest stays black, no gray. The Colorizer is set to Interpolation none,  so the transition can be set e.g., from 25% to 30%. This gives you then a Layer mask. Only 25% to 30% gray from the MG Color shader result into white and allows the image to be seen.

Note that I have messed up the Spline (interface) in the first MG Color (ID) shader. Spline Presets>Custom, then in the formula field just an x, and for the points e.g., 12. then select all and pull on one handle, select less and do more “damage” (random) to the curve, to get more variety. All splines are connected via XPresso, so they are the same (Set Driver/Set Driven (Absolute) on the spline animation parameter) This allows not for variety.

I used the Random Effector here to keep it simple.

BTW, thanks for the stripped version first, that is normally the way to go, as it helps more often to solve it.


Thats all

Good luck

Sassi

File Attachments
CV2_r13_drs_12_MGtc_03.zip  (File Size: 146KB - Downloads: 262)
 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile
 
 
Posted: 11 April 2012 07:50 AM   [ Ignore ]   [ # 10 ]  
Avatar
Total Posts:  121
Joined  2010-11-01

Ah thanks so much, great idea.  I didn’t even realise you could adjust the index id with the spline. 

Thanks for the help, gonna get back on this and will post a link to the project when its finally done : )

Profile
 
 
Posted: 11 April 2012 06:58 PM   [ Ignore ]   [ # 11 ]  
Administrator
Avatar
Total Posts:  12043
Joined  2011-03-04

Hi Rich,

It is nice, isn’t it. The ID stays the same, but the gray value can be changed in relation to the ID. In this way a things can have all kind of results.

All the best

Sassi

 Signature 

Dr. Sassi V. Sassmannshausen Ph.D.
Cinema 4D Mentor since 2004
Maxon Master Trainer, VES, DCS

Photography For C4D Artists: 200 Free Tutorials.
https://www.youtube.com/user/DrSassiLA/playlists

NEW:

NEW: Cineversity [CV4]

Profile