The Surcoat2Snow Macros
Scripted by Tim Nikias Wenclawiak - Homepage: www.NoLights.de
Last update: 8.07.2008
Contents
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: 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: |
Surcoat_Snow_Seed (260981) The seed for the random-streams
Surcoat_Snow_MinRadius (.1) Minimum-Radius for the snow
Surcoat_Snow_WallInfluence (2) Distance until which walls influence the stacking effect
Surcoat_Snow_DebugSampleCount (0) Amount of samples for debug/progression-notes (0 is off) |
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 Snowfile_Display Snowfile_Modify Snowdata2Float_HeightAdd Snowdata2Float_HeightMod Surcoat2Snow_Defaults() Snowfile_Display_SkyMod |