View Full Version : River of M&Ms ad question
TechnicallyArtistic 02-18-2006, 11:21 AM I was wondering if anybody know how they did this effect in the river of M&Ms ad?
http://dot.balius.com/Site/Videos/789E64F7-2F42-4743-B90A-AEE70E1B5E7F.html (%20http://dot.balius.com/Site/Videos/789E64F7-2F42-4743-B90A-AEE70E1B5E7F.html)
I'm pretty sure the M&Ms are particles, they made a dynamic plane that rippled, had a color ramp of some kind on it that rippled out like that and the sprites refference the color they were over and changed to that. So does anybody know how they got the M&Ms to reference the color off the plane?
-Evil The Cat
|
|
cosku
02-18-2006, 06:12 PM
That can be done in a couple of different ways, but for the solution you describe, I did something similar in the past.
What I did was create a closestPointOnSurface node, rename it to "cps",
then wrote a global procedure to check a given particle's position, find the closestPointOnSurface on the plane, check the UV coordinates of that point on the plane, then check the current color of that point.
It is something like this:
(first, connect nurbsPlaneShape1.worldSpace[0] to cps.inputSurface )
global proc partColor(string $particleName, int $particleID, string $objName)
{
//get particle position
vector $particlePos = `particle -id $particleID -at position -q $particleName`;
//convert particle position into UV
setAttr cps.inputPositionX ($particlePos.x);
setAttr cps.inputPositionY ($particlePos.y);
setAttr cps.inputPositionZ ($particlePos.z);
//get UV
float $U = `getAttr cps.parameterU`;
float $V = `getAttr cps.parameterV`;
//get color at that UV
// file1 is my texture file I applied, so you'll change it to your ramp etc
vector $color = `colorAtPoint -u $U -v $V -o RGB file1`;
float $R = $color.x;
float $G = $color.y;
float $B = $color.z;
//then assign the color to that particle
particle -e -id $particleID -at rgbPP -vectorValue $R $G $B $particleName;
}
Then, you can call that in the particle's runtime expression as such:
$id = id ;
partColor particle1 $id nurbsPlane1;
Also if you've emitted the particles off the plane directly, then you can store their parentUV positions, and skip the whole closestPointOnSurface part, which is the part that actually slows the calculation a lot (but if you use cPs, that means you can move the particles around and they'll still obey the nearest color on the plane).
Good luck.
TechnicallyArtistic
02-18-2006, 08:27 PM
Thanks. I'm pretty sure that's what I've been looking for.
The part that sucks is I'm not actually using it for particles though. I have to find some way to dye a stripe into some hair on a head. Probably paint effects. Anyway, this is the first step I figure in trying to figure something out. If you've got any other ideas on that though, I'd love to hear.
-Evil The Cat
TechnicallyArtistic
02-19-2006, 11:28 AM
Ok, I had an after thought and anybody that can tell me the underlieing how of that script would be helpful. Well, more thant the script, how the partickes sample the uv data off the plane to get the colors assigned to them. Because I'm hoping to take that same principal and apply it to something else other than particles.
I'm really trying to figure out if there's some way I can take that, and then based off of a hairs length, I can figure out the ratio of one color to another for the stripe and or the transition point. Or have the ramp sample the colors off of the surface and figure out how to make a ramp that would match that patren and apply it to each hair... each ramp being different per a hair... but that might be a little too out there still..
Anyway, just brain storming. Anybody else with any ideas feel free to contribute, even if you don't have all the answers yet.
- Evil The Cat
thematt
02-19-2006, 01:18 PM
nice one Cosku thanks for that..can be helpfull sometime.
cheers
apoc519
02-20-2006, 02:51 AM
doh, nevermind...
cosku
02-20-2006, 09:54 PM
Heya.
Alright, this is what I came up with.
http://coskuozdemir.com/cgtalk/coloring.jpg
There, I created a 3d-crater texture, the top big cube has the texture applied to it.
Then I created 1000 little cubes, sampled the 3d texture for each cube, and applied the corresponding color to all.
Here is the scene file that you can play with:
http://coskuozdemir.com/cgtalk/coloring_cubes.ma
(If you go play it back and then rewind, it cleanes up all the little cubes, the expressions
for that is in the sceneControl locator).
To create the cubes, this is the expression:
/////////////////// creating the cubes ///////////////////
for ( $i = 1 ; $i < 1000 ; $i++)
{
select cube; string $name[] = `duplicate -rr`;
vector $loc = sphrand(10);
move -a -ws ($loc.x) ($loc.y) ($loc.z);
parent $name[0] cubeGroup ;
}
/////////////////////////////////////////////////////////////
Then, to color the cubes with the 3d-crater shader, you run:
/////////////////// coloring the cubes ///////////////////
select -r cubeGroup;
string $cubes[] = `listRelatives`;
for ( $box in $cubes )
{
string $shaderName = `shadingNode -asShader lambert`;
select -r $box;
hyperShade -assign $shaderName;
vector $loc = `xform -q -t -ws $box`;
setAttr crater1.rcx ($loc.x);
setAttr crater1.rcy ($loc.y);
setAttr crater1.rcz ($loc.z);
vector $color = `getAttr crater1.outColor`;
setAttr ($shaderName+".color") -type double3 ($color.x) ($color.y) ($color.z);
}
/////////////////////////////////////////////////////////////////
As I said, the scene file cleanes up the cubes on rewind, but I'm lazy to clean up
the lambert shaders that I create for each cube. For that, you can either do
File->Optimize scene , or do add a similar expression that cleans them up like
sceneControl locator does.
Once you have that part done and you got familiar with the whole idea, you'll just
have to animate your texture, and run the coloring expressions every frame.
Let me know if any part of this is confusing.
Cheers.
-cosku
razorback
02-22-2006, 07:55 PM
setAttr cps.inputPositionX ($particlePos.x);
setAttr cps.inputPositionY ($particlePos.y);
setAttr cps.inputPositionZ ($particlePos.z);
Hey Cosku,
Thanks for the script. Very useful. Just tried it out, but to get it to work, I needed to change the quoted lines to
setAttr cps.inPositionX ($particlePos.x);
setAttr cps.inPositionY ($particlePos.y);
setAttr cps.inPositionZ ($particlePos.z);
Sorry to hijack, but I dunno if you guys here can help out with a related problem here (http://forums.cgsociety.org/showthread.php?t=321008).
Does anyone have a link to the ad, as the link posted at the start does not work. This looks really interesting, so I would like to be able to understand what you guys are trying to do, but I have not been able to find the ad myself
TechnicallyArtistic
02-23-2006, 05:46 AM
I posted the stream to my site. No idea where the feed is coming from, so hopefully it stays up.
http://home.earthlink.net/~evil_the_cat/River_of_Chocolate_30_300K-5.mov (http://home.earthlink.net/%7Eevil_the_cat/River_of_Chocolate_30_300K-5.mov)
-Evil The Cat
AndersEgleus
02-23-2006, 07:45 AM
setAttr crater1.rcx ($loc.x);
setAttr crater1.rcy ($loc.y);
setAttr crater1.rcz ($loc.z);
vector $color = `getAttr crater1.outColor`;Wow! I didn't know you could sample 3d textures by setting refPointCamera (I've tried the same technique before using refPointObject but it didn't work). Works great for setting per particle attributes in particle expressions and everything. I'm gonna use this a lot from now on. Just too bad it's a bit slow though. Thanks cosku!
cosku
02-26-2006, 02:04 AM
Hey Anders,
My pleasure :)
It really is a bummer that its slow (especially for anything in runtime).
I usually use that to initially define/draw my particles, and then set initial state.
Then it doesn't really matter if its that slow :P
There's also Julian Mann's plugin that samples textures, but you gotta compile it
(or get the compiled version and install an old maya version just for that :P )
Its a lot faster as it saves all the slow setAttr-getAttr calls.
The source is available at:
http://www.highend3d.com/maya/downloads/plugins/rendering/misc/2937.html
Cheers
-cosku
CGTalk Moderation
02-26-2006, 02:04 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.