Page 1 of 2

Particles for Scattering

Posted: Mon Jan 27, 2014 10:51 am
by cyrillweiss
Hi

For Scattering some vegetation (Trees, Gras, ect.) I would like to use particles instances as suggested by TBFX:
http://render.otoy.com/forum/viewtopic.php?f=28&t=37902

Now, how to get the particles over the ground? I see three possibilities about that:

- use the object as an emitter "emit particles from object", without any force. That way I've got the particles on the hole area, but may have to delete some particles, which are too much
- use an emitter and let the particles fall on to the object (high friction)
- set the object live to use the particle tool for painting on to it. But for a random distribution the painting gets volumetric, which isn't what I want and the live object hasn't got influence on that.

Or is there a script, which might spread the particles on to the object? (kind of spraying the particles randomly on to the object)

Best regards
Cyrill

Re: Particles for Scattering

Posted: Mon Jan 27, 2014 2:23 pm
by ivankio
This can be a not so short matter. I really recommend this DVD:
http://www.thegnomonworkshop.com/store/ ... uZprxBTvHU

Although longer than a forum answer, it is still a considerably short time to watch, but prepared me for issues I didn't even had in mind from start (like we want to spread trees straight up, grass patches according to surface normal).

Nothing like TBFX's composition, but in my test with Octane I managed this: http://www.animaokio.com/imgs/grama (scroll to play). Spent more time modeling the patches. The spreading gets really easy.

If you are not up to get the DVD, ask again and I'll try to summarize.

Re: Particles for Scattering

Posted: Mon Jan 27, 2014 3:35 pm
by ivankio
Well, I guess it does fit in a forum answer :P

I assume you know how to:
A- emit from object;
B- map emission if wanted;
C- setup an instancer.
Extra tip: set the emitter rate very high (1000000 particles/sec) and tune the particles MAX COUNT to achieve a good density already in the first frame.

Now to setup the particles... (everything not commented out should go in your particle creation expression, if you do not want the particles to be rotated along surface normal, edit accordingly).

Code: Select all

///////////////////////////////////////////
// Preliminary setup

// Load plugin nearestPointOnMesh (installed with Maya, just disabled by default)

// Set INSTANCER rotation order to YXZ

// add particle attributes:
// rotationPP			vector		map to rotation
// randomRotationY		float
// aimDir			vector		map to aim Direction
// aimUp			vector		map to aim Axis
// customScale			vector		map to Scale
// customID			float		map to objectID


///////////////////////////////////////////
// Particle's creation expression
// !!!!!! remember to replace bellow "particleShape1" and "pPlane1" properly. pPlane1 is emitting surface.

// Set the orient axis for the instance
particleShape1.aimUp = <<0,1,0>>;

// random rotation for Y axis
particleShape1.randomRotationY = rand(360);

//// Orient to normal for grass patches. Most plants you'll want growing according to world up.
// get surface normal at particle position (needs the plugin to be loaded)
vector $p = particleShape1.position;
vector $normal = `nearestPointOnMesh -ip ($p.x) ($p.y) ($p.z) -normal -q pPlane1`;
// orient the instance
particleShape1.aimDir = $normal;

// solve each angle, convert to degrees
float $rotX = rad_to_deg( atan2( ($normal.z), ($normal.y) ) );
float $rotZ = rad_to_deg( asin( -($normal.x) ) );

// assign random rotation in Y
particleShape1.rotationPP = << $rotX, particleShape1.randomRotationY, $rotZ >>;

// random scale if you will, set the values
particleShape1.customScale = rand(1,3);

// number of instance sources to assign (if 4 sources, use max of 3.999)
particleShape1.customID = rand(0, 3.999);
Unfortunately Maya particles does not prevent very close overlap. You can't delete a maya individual particle from it's particle array but you can move it through component editor or set it's visibility to off.

Re: Particles for Scattering

Posted: Mon Jan 27, 2014 9:16 pm
by TBFX
ivankio wrote:Unfortunately Maya particles does not prevent very close overlap. You can't delete a maya individual particle from it's particle array but you can move it through component editor or set it's visibility to off.
Hi cyrillweiss,

Yes just follow ivankio's description it is almost identical to my method. I also use nParticles rather than the plain variety as this allows me to turn on particle self collisions and set the particle size to help avoid the overlapping mentioned above.

Also remember to set particle emission speed to 0 and turn of gravity so the particles will stay on the surface.

T.

Re: Particles for Scattering

Posted: Tue Jan 28, 2014 12:12 am
by ivankio
Wow, thanks for the tip, TBFX! It gets much more efficient instance count wise. I'm also being more in control of boundaries, but still not fully happy about it.

Do you mind sharing your thoughts about the patches you use? I made them circular with a falloff of density and height to blend well, but I'm having to choose between weak silhouettes or grass showing on top of boundary floor (using scale from 0.75 to 1.25).
nParticlesGrass.jpg

Re: Particles for Scattering

Posted: Tue Jan 28, 2014 12:54 am
by TBFX
ivankio wrote:Do you mind sharing your thoughts about the patches you use? I made them circular with a falloff of density and height to blend well, but I'm having to choose between weak silhouettes or grass showing on top of boundary floor (using scale from 0.75 to 1.25).
My grass patches were circular with just a little falloff, probably a bit less than yours, I also used temporary animated collision geo to push errant particles into place for cleaner boundaries and then reset the initial state.
Also, I was never getting the camera down close to any boundaries.

T.

Re: Particles for Scattering

Posted: Wed Mar 26, 2014 3:10 pm
by abstractmedia
Wow. This is awesome stuff, guys! :D

Re: Particles for Scattering

Posted: Mon Mar 31, 2014 8:02 pm
by abstractmedia
ivankio wrote:Wow, thanks for the tip, TBFX! It gets much more efficient instance count wise. I'm also being more in control of boundaries, but still not fully happy about it.

Do you mind sharing your thoughts about the patches you use? I made them circular with a falloff of density and height to blend well, but I'm having to choose between weak silhouettes or grass showing on top of boundary floor (using scale from 0.75 to 1.25).
nParticlesGrass.jpg
After reading this, and the other post and watching the Gnomon dvd Ivankio suggested. I decided to give it all a try over the weekend, and I have a couple questions.

I saw the image that had 52 billion polygons by TBFX in the other thread on this subject and was curious.
Is there something specific you are doing to keep your render time low with so many polygons?

Currently in my scene with just under 26 million polys my render is loading quickly into the GPU. But the image here was going to take 3 hours for 3000 samples.

Image

I am running on a 6gb Titan, i7 3930, with 32gb RAM.

Re: Particles for Scattering

Posted: Mon Mar 31, 2014 11:06 pm
by TBFX
abstractmedia wrote:I saw the image that had 52 billion polygons by TBFX in the other thread on this subject and was curious.Is there something specific you are doing to keep your render time low with so many polygons?
I'm not doing anything that special but I am rendering on 4x GTX580's which should be between 2 and 3 times faster than a single Titan plus my frames were only rendered to 1000 samples. So that would bring your 3 hours a frame down to around the same times I quoted for mine. Once you get to a certain complexity the render times don't change much as you add more in any given lighting scenario.

That scene was rendered using Path Tracing with Max Depth 4, caustic blur 0.1 and I also reduced the amount of specular on the grass shader to reduce noise as it was really not needed in such a wide shot. The scene was lit by the HDRI sky you see in the render (which conveniently had the sun behind some bright cloud) and a single plane emitter light set far enough back to act as the sun (although this scene was set up back before Octane had importance sampling for environments so it would now work with an HDRI that had the sun visible without the need for the emitter light).

T.

Re: Particles for Scattering

Posted: Mon Apr 07, 2014 4:00 pm
by abstractmedia
Alright! I appreciate the reply!