summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/worley.h
diff options
context:
space:
mode:
authorBrendan Hickey <brendan@bhickey.net>2012-09-16 01:09:49 -0700
committerBrendan Hickey <brendan@bhickey.net>2012-12-30 19:06:13 -0800
commit51d65a72a231f63d3ba523b2f953bd09464351d5 (patch)
treee4aef7f5cf0993894a64d54bdc91f96e21b03e7c /crawl-ref/source/worley.h
parent6783c3696236768d6d505bca012d4bb84294abd2 (diff)
downloadcrawl-ref-51d65a72a231f63d3ba523b2f953bd09464351d5.tar.gz
crawl-ref-51d65a72a231f63d3ba523b2f953bd09464351d5.zip
"And I will make you a raging river"
Fuzzed up the Abyss River with some perlin noise. Grabbed a free perlin noise implementation, crudely ported it to C/C++.
Diffstat (limited to 'crawl-ref/source/worley.h')
-rw-r--r--crawl-ref/source/worley.h73
1 files changed, 73 insertions, 0 deletions
diff --git a/crawl-ref/source/worley.h b/crawl-ref/source/worley.h
new file mode 100644
index 0000000000..c8660507f2
--- /dev/null
+++ b/crawl-ref/source/worley.h
@@ -0,0 +1,73 @@
+/* Copyright 1994, 2002 by Steven Worley
+
+ Permission is hereby granted, free of charge, to any person
+ obtaining a copy of this software and associated documentation files
+ (the "Software"), to deal in the Software without restriction,
+ including without limitation the rights to use, copy, modify, merge,
+ publish, distribute, sublicense, and/or sell copies of the Software,
+ and to permit persons to whom the Software is furnished to do so,
+ subject to the following conditions:
+
+ The above copyright notice and this permission notice shall be
+ included in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+ A detailed description and application examples can be found in the
+ 1996 SIGGRAPH paper "A Cellular Texture Basis Function" and
+ especially in the 2002 book "Texturing and Modeling, a Procedural
+ Approach, 3rd edition." There is also extra information on the web
+ site http://www.worley.com/cellular.html .
+
+ If you do find interesting uses for this tool, and especially if
+ you enhance it, please drop me an email at steve@worley.com.
+*/
+
+
+
+/* Worley()
+
+ An implementation of the key cellular texturing basis
+ function. This function is hardwired to return an average F_1 value
+ of 1.0. It returns the <n> most closest feature point distances
+ F_1, F_2, .. F_n the vector delta to those points, and a 32 bit
+ seed for each of the feature points. This function is not
+ difficult to extend to compute alternative information such as
+ higher order F values, to use the Manhattan distance metric, or
+ other fun perversions.
+
+ <at> The input sample location.
+ <max_order> Smaller values compute faster. < 5, read the book to extend it.
+ <F> The output values of F_1, F_2, ..F[n] in F[0], F[1], F[n-1]
+ <delta> The output vector difference between the sample point and the n-th
+ closest feature point. Thus, the feature point's location is the
+ hit point minus this value. The DERIVATIVE of F is the unit
+ normalized version of this vector.
+ <ID> The output 32 bit ID number which labels the feature point. This
+ is useful for domain partitions, especially for coloring flagstone
+ patterns.
+
+ This implementation is tuned for speed in a way that any order > 5
+ will likely have discontinuous artifacts in its computation of F5+.
+ This can be fixed by increasing the internal points-per-cube
+ density in the source code, at the expense of slower
+ computation. The book lists the details of this tuning. */
+#ifndef WORLEY_H
+#define WORLEY_H
+namespace worley
+{
+struct noise_datum
+{
+ double distance[2];
+ uint32_t id[2];
+};
+
+noise_datum noise(double x, double y, double z);
+}
+#endif /* WORLEY_H */