VolumeSources        

This page gives a detailed description of the available data sources with which scenes are created.

Each source (And so also whole CSG-trees!) can be serialized to a discrete, compressed 3D HalfFloat file by using the function serialize().

Content Sources

Each source of this type is a concrete shape which can be a leave of the combination sources of the following chapter or to be used stand alone.

HalfFloatGridSource

Header: OgreVolumeHalfFloatGridSource.h
Constructor: HalfFloatGridSource(const String &serializedVolumeFile, const bool trilinearValue = true, const bool trilinearGradient = false, const bool sobelGradient = false)

  • serializedVolumeFile: Which volume serialization to get the data from.
  • trilinearValue Whether to use trilinear filtering (true) or nearest neighbour (false) for the value.
  • trilinearGradient Whether to use trilinear filtering (true) or nearest neighbour (false) for the gradient.
  • sobelGradient Whether to add a bit of blur to the gradient like in a sobel filter.

Description:
The HalfFloatGridSourceis used to load a scalar grid of density data from a serialized volume created with the serialize()-function of the base class.
The first parameter serializedVolumeFile references the serialization file to be used which is loaded using the resource system. When a density is queried, the coordinate normally doesn't lie exactly on the scalar grid, so it must be interpolated. So the two parameters trilinearValue and trilinearGradient decide, whether to use the fast nearest neighbor interpolation or a more costly trilinear interpolation. The last parameter sobelGradient decides, whether to calculate the gradient like in the original MC paper via central differences or with Sobel filter. The later can be used to smooth out some noise in the density grid.
Each of the later three flags increases the loading time of the volume and control the quality to some kind. The given default configuration is a recommendation giving a good compromise between loading time and quality.

TextureSource

Header: OgreVolumeTextureSource.h
Constructor: TextureSource(const String &volumeTextureName, const Real worldWidth, const Real worldHeight, const Real worldDepth, const bool trilinearValue = true, const bool trilinearGradient = false, const bool sobelGradient = false)

  • volumeTextureName: Which volume texture to get the data from.
  • worldWidth The world width.
  • worldHeight The world height.
  • worldDepth The world depth.
  • trilinearValue Whether to use trilinear filtering (true) or nearest neighbour (false) for the value.
  • trilinearGradient Whether to use trilinear filtering (true) or nearest neighbour (false) for the gradient.
  • sobelGradient Whether to add a bit of blur to the gradient like in a sobel filter.

Description:
The TextureSource is used to load a scalar grid of density data from a 3D texture, normally in .dds-Format. Each Pixel is interpreted as 32 bit float. Such textures can be produced for example with the commercial editor Acropora from Voxelogic.
The first parameter volumeTextureName references the texture file to be used which is loaded using the resource system. As the world was created with a specific size, the next three parameters give the original world dimensions. When a density is queried, the coordinate normally doesn't lie exactly on the scalar grid, so it must be interpolated. So the two parameters trilinearValue and trilinearGradient decide, whether to use the fast nearest neighbor interpolation or a more costly trilinear interpolation. The last parameter sobelGradient decides, whether to calculate the gradient like in the original MC paper via central differences or with Sobel filter. The later can be used to smooth out some noise in the density grid.
Each of the later three flags increases the loading time of the volume and control the quality to some kind. The given default configuration is a recommendation giving a good compromise between loading time and quality.

CSGSphereSource

Header: OgreVolumeCSGSource.h
Constructor: CSGSphereSource(const Real r, const Vector3 &center)

  • r: The sphere radius.
  • center: The center coordinate of the sphere.

Description:
A simple sphere.
sphere.png

CSGPlaneSource

Header: OgreVolumeCSGSource.h
Constructor: CSGPlaneSource(const Real d, const Vector3 &normal)

  • d: The distance of the plane to the coordinate system origin.
  • normal: The normal of the plane.

Description:
A plane.
plane.png

CSGCubeSource

Header: OgreVolumeCSGSource.h
Constructor: CSGCubeSource(const Vector3 &min, const Vector3 &max)

  • min: The lower, left, rear coordinate of the cube.
  • max: The upper, right, front coordinate of the cube.

Description:
A cube. The rounded corners are due to the current dual marching cubes implementation.
cube.png

Combination Sources

With this sources, it's possible to create a tree combining the content sources in various ways. You create a tree where the leaves are the content sources. The inner nodes combine them until the final scene is reached with the root node. See the volume CSG sample for a complete code example.

CSGUnionSource

Header: OgreVolumeCSGSource.h
Constructor: CSGUnionSource(const Source *a, const Source *b)

  • a: The first source of the operation.
  • b: The second source of the operation.

Description:
Builds the union of the given sources.
union.png

CSGIntersectionSource

Header: OgreVolumeCSGSource.h
Constructor: CSGIntersectionSource(const Source *a, const Source *b)

  • a: The first source of the operation.
  • b: The second source of the operation.

Description:
Builds the intersection of the given sources.
intersection.png

CSGDifferenceSource

Header: OgreVolumeCSGSource.h
Constructor: CSGDifferenceSource(const Source *a, const Source *b)

  • a: The first source of the operation.
  • b: The second source of the operation.

Description:
Builds the difference of source a minus source b. The jaggy edges are due to the current dual marching cubes implementation.
difference.png

CSGNegateSource

Header: OgreVolumeCSGSource.h
Constructor: CSGNegateSource(const Source *src)

  • src: The source of the operation.

Description:
Negates the given source. The image is a single, inverted sphere with a wireframe material to make it more visible.
negation.png

CSGScaleSource

Header: OgreVolumeCSGSource.h
Constructor: CSGScaleSource(const Source *src, const Real scale)

  • src: The source of the operation.
  • scale: The scalefactor.

Description:
Scales the given source.

CSGNoiseSource

Header: OgreVolumeCSGSource.h
Constructor: CSGNoiseSource(const Source *src, Real *frequencies, Real *amplitudes, size_t numOctaves, long seed)

  • src: The source of the operation.
  • frequencies: The frequencies as array of the added octaves.
  • amplitudes: The amplitudes as array of the added octaves.
  • numOctaves: The amount of octaves.
  • seed: The initial seed for the random generator.

Constructor 2: CSGNoiseSource(const Source *src, Real *frequencies, Real *amplitudes, size_t numOctaves)

  • src: The source of the operation.
  • frequencies: The frequencies as array of the added octaves.
  • amplitudes: The amplitudes as array of the added octaves.
  • numOctaves: The amount of octaves.

Description:
Adds SimplexNoise to the given source. The second constructor takes the current time as random seed.
noise.png

Additional Sources

This are utility sources which can be handy in some situations.

CacheSource

Header: OgreVolumeCacheSource.h
Constructor: CacheSource(const Source *src)

  • *src: The source to be cached

Description:
This source can be used to reduce the loading time of complex CSG scenes. Just give it the source to cache and it will cache repeatly requested values and so speeding up the loading time where in some situations, values and gradients of the same coordinate are requested. The given source must have a certain complexity to gain any advantage of the cache as it introduces some overhead when internally maintaining the cache.