Volume Coordinate Modifier



Volume Coordinate proces changes coordinate of volume box from Cartesian one to some othe ones.

Spherical coordinates are implemented as predefined transformation.

Spherical coordinates

(x, y, z) would be remaped to (phi, theta, r) coordinate, interpreted as z-stacked Equirectangular projection map.

R min/max

Remap (0,1) z range to (min,max) r range.
If min is set greater than 0, data would be projected to a spherical shell.

Custom coordinates



(x, y, z) would be remapped to arbitrary coordinates, via custom function in GLSL defined by by user.

Parameters

You can send up to 3 parameters to custom functions.
Three component of parameter group "Custom" would be send to GLSL function.

Edit cusom function

If Text Editor Panel is opened, custom function would be send to the editor by clicking edit button.

Following is a sample of custom function for deform coordinates.



This sample deforms the coordinates sinusoidally.



The custum function
vec3 GetDeformedCoord(vec3 vecOrg){}
defined here is called from main shader.
The input argument vec3 vecOrg is original 3D texture coordinates.
The function returns projected 3D texture coordinates by vec3 type.

parameter

A string #p0#, #p1#, #p2# is replaced by three parameters stated above.
In above sample, a variable float p0 is set to parameter #p0#

MACRO used in volume shader

GTRIM

if GTRIM is defined and is set to 1, texture coordinate outside the range [0-1] would be discared.
Otherwise, the texture would be repeated to all direction.

GUSEMATRIX

if GUSEMATRIX is undefined or is set to 0, gradient of 3D Textureis is calculated directly by the difference of slightly different (deformed) texture coordinate.
if GUSEMATRIX is set to 1, it is calculated by multiplying user defined matrix to the gradient of texture in (original) coordinates.
#define GUSEMATRIX 1
mat3 GetDeformNormalMatrix(vec3 vecOrg, vec3 deformedCoord){
	return mat3(1, 0, 0, 0, 1, 0, 0, 0, 1);
}
User derined matrix for gradient is defined by a function mat3 GetFrformed Matrix(vec3 vecOrg, vec3 deformedCoord), where vecOrg is original 3D texture coordinates and deformedCoord is deformed 3D texture coordinates.

return
inserted by FC2 system