|06-06-2013, 02:22 PM||#1|
Jonathan de Blok
Join Date: Mar 2003
Voluminance Cloud Script
I was going to make this a commercial one but screw that I'll up a proper release to scriptspot later.
A short video showing an older version but the process is the same: http://vimeo.com/59950346
Script attached, including a mat lib that gives you the the 'mr_card' shader for very fast rendering of sprites in MR.
Please share if you made something nice with it, enjoy!
Pick Mesh / Pick Light
This is your starting point, you pick a mesh that will form the base shape for your cloud and a light source you want to use for illumination. Best is to use a mesh that is mostly uniform in polygon size and avoid long thin faces. Start with a low/medium res object to quickly get a feel for all the different parameters, for default clouds a hires base shape is not even necessary. The light source is only used for it’s position, intensity and color can be setup independently for more artistic freedom.
Note: the mesh will be collapsed to an EditablePoly to speedup calculations, a backup of your mesh will be created called “<originalname>_backup’ and will it will be hidden automatically.
Light & Luminance color
‘Light color’ will determine the color of the cloud where light hits it directly, this color is then darkened by the amount of volume the light ray travels through. The amount of darkening per traveled volume is set by the ‘Absorption’ factor explained later on.
‘Luminance color’ is for the secondary component of the lighting model. After calculating the light intensity at each vertex, using the absorption model, they will affecting all surrounding vertices within a given radius using the ‘Luminance color’ and distance to calculate the additional secondary light influence.
Mesh & Sprite material
Here you can pick two materials, one that will be assigned to the bae mesh and one for the sprites. Maxscript doesn’t support drag&drop so you’ll have to pick them manually. The basic idea for the basemesh is to have the calculated vertexcolors set as a self-illumination map. The sprites will be textured by their own vertex colors and a radial opacity map resulting in little ‘puff’ textures. For a quick start the basic setup for both materials is included as a material library.
Load & save preset
Create presets for all adjustable parameters. The presets are normal ini files and can be edited manually if needed, you can for example safely remove lines from these files and only have the remaining parameters loaded.
Determines how much light is absorbed per distance traveled inside the volume of the base-mesh. Low values will make the cloud more absorbing , higher values will let light travel further.
For selected faces only
This will only do calculation for the selected faces. You can use this to quickly setup a small parts of the base-mesh and when content with the results do it for the whole mesh. Internally the intensities for each face center is calculated and these values are then averaged over the vertexes and stored as vertex colors. So each vertex that belongs to a selected face will be affected when this option is checked.
Each vertex can be thought of as an omni lightsource emitting it’s vertex color to all the surrounding vertices within a spherical volume using the given radius.
A simple multiplier to weigh the amount of luminance used.
For selected verts only
Only calculate the luminance for selected vertices when checked. Use this to quickly setup luminance for a small area, when content with the results uncheck and calculate for the whole cloud.
Doing luminance calculations is ‘destructive’, as in it overwrites the current vertexcolors. So while setting it up you can automatically recalculate the absorption step so you’ll start with the same original vertex colors each time.
Cover mesh in sprites
The total number of sprites distributed of the surface
Absolute sprite size when placed on the surface. When using a random offset size can vary depending on distance to surface. If that offset is 0 all sprites will have the size given here.
Relative sprite size at max distance. When using a random offset this size will determine the sprite’s size at maximum distance.
Relative size variation, independent of offset.
Offset max dist
Sprites will be places between the surface and a random offset along the face’s normal.
A bias of 0 will result in a uniform offset distribution between the surface and the offset, values >0 will pull the offset average closer the surface.
On selected faces only
Add sprites to selected faces only. Use in combination with the ‘Count * (% selected faces)’ parameter to quickly setup a small area that will be representative as if you would have covered the entire mesh.
Count * (% selected faces)
Checking this option will make sure you get the same sprite density when you’re applying sprites only to a small area of selected faces as if you would cover the whole mesh is sprites. So if you have on 10th of the faces selected you’ll only get a 10th of the given ‘count’.
Add sprites (don’t replace)
When checked existing sprites are left in place and addition sprites are added. Use this to patch small areas that need more sprites.
Last edited by jonadb : 06-06-2013 at 02:30 PM.
|06-06-2013, 04:47 PM||#3|
Makkah, Saudi Arabia
Join Date: Jun 2010
Thank you very much,
There's just a problem for max 2012 users, the mat file...
is it possible that you provide a compatible mat file for max 2012...
Last edited by boumay : 06-06-2013 at 06:50 PM.
|06-06-2013, 06:01 PM||#4|
Join Date: Apr 2013
Amazing work, straight to my essential scripts folder, it's times like this that makes me happy that I'm a Max user, thank you so much for sharing this with us.
All I need now is a couple of wwii fighter planes blasting through my clouds...
|06-11-2013, 03:38 PM||#9|
I created a teapot, used that as my mesh object. I loaded your mat lib (tyvm) and set the materials in the tool. When I render, I see the fake SSS happen but the perimeter of my sprites are not transparent and look "jaggedee". Also, should I be using the max standard renderer or MR?
|06-11-2013, 04:45 PM||#10|
Jonathan de Blok
Join Date: Mar 2003
I've put a simple renderable example file in my dropbox: https://dl.dropboxusercontent.com/u/1457762/example.zip
If you open the SME you can see both materials for MR and one for scanline. Add some noise to it for more realism.
MR is faster when turning FG off and using the opacity-card shader, scanline is quicker for simpler clouds. And a teapot is not really nice geometry for a cloud, the sprites are distributed randomly per face, so a cluster of small faces will get a higher sprite density compared to a the bigger faces. So model your basemesh so that is has a somewhat uniform polygon size.
edit: and a small 'bug' is that the material you set in the UI only gets applied when (re)generating the sprites, setting it after generation has no effect
Last edited by jonadb : 06-11-2013 at 04:50 PM.
|06-19-2013, 07:34 AM||#11|
Motion Graphics / 3D Artist
Join Date: Jun 2010
This is a really handy script! Thanks for sharing Jonathan!
Michael Wentworth-Bell | 3D Artist & VR Designer | Melbourne, Australia
Espire 1: My VR Stealth game - CGTalk thread
|06-19-2013, 07:34 AM||#12|
Join Date: Sep 2003
Thread automatically closed
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.
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
|Thread Closed share thread|
|Thread Tools||Search this Thread|