The Surcoat2Snow Macros

Scripted by Tim Nikias Wenclawiak - Homepage: www.NoLights.de

Last update: 8.07.2008

Contents
Introduction
Technique
Usage
Snow-Parameters
Customizing the snow
List of Macros

This set of macros provides several means to visualize sample-sets generated with the Surcoat macros with snow. There are three possibilities to do this, so you should choose whichever best fits the current project.

In regard to copyrights: this set of macros was written by me in my spare time. All I require is that you give credit where you feel credit is due, and drop me a note to let me have a look at what you've achieved with my macros. :-)
If, however, you make money with them, that's a no-no without my consent!


The easiest approach to simulating snow is just dropping it from the sky. But that tends to be reather unrealistic, as snow doesn't drop in straight lines, but gets thrown around by the wind. It also stacks along walls.

Instead of simulating snowfall, I figured it'd be easier to just coat the object with snow, and then remove those samples that shouldn't be there, as well as enlargen those in height which are close to walls.

This is done with a rather simple method: from every sample, I shoot a few rays outwards and check if it can actually see the sky and isn't underneath some surface, and if it is, check if it is within some threshold where snow might still land if wind blows it somewhere. If the sample is close to a wall, it'll get elongated: the basic visualization is done with blobs, and instead of placing big snowballs, I use cylinders and give the samples a height.

Overall, this technique of removing unnecessary samples workes rather nice so far, at least for a simple basis to further modify using the other Surcoat-Macro-"Tools".



Converting Surcoat-Samples to snow is as easy as calling the Surcoat2Snowfile-Macro, which has just three parameters:
The filename of the samples to load, the filename for the converted samples, and the original object the samples were placed upon, as it is needed for further sampling to determine size and validity of the samples.

Of course, there are a few parameters you should declare before calling the macro to adjust the snow to your liking, and they are listed below under Snow-Parameters.

Additionally, you may call Snowfile_Modify, a macro which needs two parameters: the filename of already converted snow-samples, and a new filename to save to. The macro itself calls upon two macros, Snowdata2Float_HeightAdd and Snowdata2Float_HeightMod, both of which have four parameters and return a single float-value. HeightAdd should return 0 or larger, as it is supposed to ADD height to a sample, and HeightMod should return a positive value, or 1 as default, as the return-value is used to multiply the former height with in order to MODIFY the height.

Note that these two macros should be declared by you to customize the end-results of the snow. The four parameters are Position, Normal, Radius and Height, all of which you may use to generate the return-values. It's best to take a look at "snow_ex.pov", the example scene-file I provide which uses some simple vturbulence to randomize the end-results a little.

Finally, you may visualize the snow with the macro called Snowfile_Display, which returns a blob-object and thus needs five parameters:
The filename of the snow-samples to visualize, the threshold for the blob-object, a radius for each sample, a strength for each sample, and a height-modifier (1 should be default, other values scale the height).



Surcoat_Snow_Seed (260981) The seed for the random-streams
Surcoat_Snow_Sky (y) The direction for the height of the stacked snow

Surcoat_Snow_MinRadius (.1) Minimum-Radius for the snow
Surcoat_Snow_MaxRadius (.3) Maximum-Radius for the snow
Surcoat_Snow_MaxHeight (1.5) Maximum-Height for stacked snow

Surcoat_Snow_WallInfluence (2) Distance until which walls influence the stacking effect
Surcoat_Snow_Samples_Radius (10) Samples to determine the radius
Surcoat_Snow_Samples_Hemisphere (50) Samples to determine walls

Surcoat_Snow_DebugSampleCount (0) Amount of samples for debug/progression-notes (0 is off)
Surcoat_Snow_StackMethod (0) Weighting-method for the stacking/wall-effects



The easiest way to modify the snow is, of course, to simply change the parameters used for its creation. However, the methods are "hard-coded", and the results are fairly smooth and just based on the immediate surrounding. If you want more control, you can make use of two macros: Snowdata2Float_HeightAdd and Snowdata2Float_HeightMod. Both use a snow-sample's position, normal, radius and height as parameters, and based on these, you return a value to be added to the height (for the HeightAdd-Macro) or a multiplier for the height (for the HeightMod-Macro).

To convert the "standard" snow-samples into your "customized" ones, simple call Snowfile_Modify with the filename of the snow-samples to load and the filename to which you want to save your customized snow. Thus, you modify the appearance AFTER the surcoat-samples have been run through the standard-process of "snowifying". I've also only supplied macros for the height because I figured that the radius-check I do to avoid physically improper, largely overhanging snow wouldn't (or shouldn't) be replaced, but you may of course just dive into the source-code of Snowfile_Modify, as it should be glaringly obvious how to add that into the modifying process once you look at the macro itself.

There's an additional macro called Snowfile_Display_SkyMod, which can be used to modify the sky-vector for the snow's cylindrical components. Note, however, that the sky-vector is actually just saved once in a snowfile, and the SkyMod-Macro is parsed for every sample at "display"-time, the results aren't saved to disk.



Surcoat2Snowfile
(Surcoat_Sample_File,Snow_Sample_File,Sampled_Object)
The original surcoat-samples will be converted and saved to the Snow_Sample_File. For the conversion, the original object from which she surcoat-samples were taken needs to be declared for the various sampling processes to determine height and radius for the snow-samples.

Snowfile_Display
(Snow_Sample_File,Blob_Threshold,Blob_Radius,Blob_Strength,Sample_HeightModifier)
The snow-samples will be visualized with a blob, hence the various blob-related parameters. The radius is actually just a multiplier for the sample's actual radius, which was determined during the conversion process made with Surcoat2Snowfile. The height-modifier is a multiplier which may be used to vary the saved height when displaying the snow.

Snowfile_Modify
(Surcoat_Sample_File,Surcoat_Sample_ModifiedFile)
Parses through a snowfile and applies Snowdata2Float_HeightAdd and Snowdata2Float_HeightMod to each sample and saves the results to Surcoat_Sample_ModifiedFile, which is a proper Snowfile: thus, you may apply several modifying steps if you wish.

Snowdata2Float_HeightAdd
(Sample_Position,Sample_Normal,Sample_Radius,Sample_Height)
This macro is just a basis for your customized modifying procedure. The parameters are those of a sample and should be used to return a value larger than 0 to add to a snow-sample's height.

Snowdata2Float_HeightMod
(Sample_Position,Sample_Normal,Sample_Radius,Sample_Height)
This macro is just a basis for your customized modifying procedure. The parameters are those of a sample and should be used to return a value in the vicinity to 1 to multiply with a snow-sample's height.

Surcoat2Snow_Defaults()
Reloads the original, non-modifying versions of Snowdata2Float_HeightAdd and -HeightMod. Just like a reset-switch to ensure that modifying steps don't overlap in case you forget to declare one macro when just using the other.

Snowfile_Display_SkyMod
(Total_Sky,Sample_Position,Sample_Normal)
When using Snowfile_Display, this macro will be called for every sample to customize the sky-vector. The results aren't saved to disk and thus need to be reparsed everytime.