#include <vector>
#include "ShAttrib.hpp"
#include "ShColor.hpp"
#include "ShTexture.hpp"
#include "ShWorleyImpl.hpp"
Include dependency graph for ShWorley.hpp:
This graph shows which files directly or indirectly include this file:
Go to the source code of this file.
Namespaces | |
namespace | ShUtil |
Functions | |
template<typename P1, typename P2> | |
PropertyFactory< P1::NUM_PROPS+P2::NUM_PROPS, P1::DIM, typename P1::PropType > * | combine (const P1 *propFactory1, const P2 *propFactory2) |
template<int K, int D, typename T> | |
ShGeneric< K, T > | worley (const ShGeneric< D, T > &p, bool useTexture=true) |
Worley texture generator. This uses the DefaultGeneratorFactory and DistSqPropFactory TODO allow arbitrary distance function. | |
template<int K, int L, int P, int D, typename T> | |
void | worley (ShGeneric< K, T > result[], const ShGeneric< D, T > &p, const GeneratorFactory< P, D, T > *genFactory, const PropertyFactory< L, D, T > *propFactory) |
Worley texture generator. This uses a GeneratorFactory and PropertyFactory of your choice. | |
template<int K, int D, typename T> | |
ShProgram | shWorley (bool useTexture) |
Makes a shader that takes IN(1) ShTexCoord<D,T> texcoord; // texture lookup coordinates. | |
template<int K, int N, int P, int D, typename T> | |
ShProgram | shWorley (const GeneratorFactory< P, D, T > *genFactory, const PropertyFactory< N, D, T > *propFactory) |
A Worley texture is made by distributing a set of points in a space and taking a weighted sum of basis functions for the k-nearest neighbours of a lookup point p. These basis functions can be the distance itself from p to the adjacent generators (the typical Worley function), or any other information. For example, we can attach colour information or refraction indicies to the generators.
This Worley implementation is split into two parts. The first part is a Generator Factory that produces a fixed number of candidate generators around a lookup point p.
A Property Factory is attaches properties to each Generator. Currently, there is no internal Sh representation for a struct of Sh types, so properties are generated into a long N-tuple. The generators are sorted by the first component in the N-tuple, so this should typically be a distance.
In the future, when it's possible to "call" an ShProgram object directly, Property Factories should actually be ShProgram objects that take a integer cell position as an input and output the desired properties.
The worley function itself sorts the generators based on the first component in its properties and returns a N-tuple containing the weighted sum of all properties.
Definition in file ShWorley.hpp.
|
Makes a shader that takes IN(1) ShTexCoord<D,T> texcoord; // texture lookup coordinates. TODO make Output a struct of some kind when Sh supports structs OUT(0) ShAttrib<K, T> result[N]; // properties of k-nearest neighbours Definition at line 277 of file ShWorleyImpl.hpp. |