Raymarcher Technical & APi Documentation
Raymarcher Volume Utilities - RMVolumeUtils
Namespace: Raymarcher.Utilities
Raymarcher contains a volume utilities library (RMVolumeUtils) that allows you to work with volumes in the Raymarcher.
The library includes common volume resolutions, conversions from world to volume space, and more.
// Returns all common volume resolutions
public static CommonVolumeResolution[] GetAllCommonVolumeResolutions { get; }

// Returns a common volume resolution as an integer
public static int GetCommonVolumeResolution(CommonVolumeResolution commonVolumeResolution)
// Try to get a common volume resolution from the given 3D render texture. Returns true if the given 3D render texture matches the Raymarcher's common volume resolution
public static bool TryGetCommonVolumeResolutionFromRT3D(RenderTexture entryRT3D, out CommonVolumeResolution outCommonVolumeResolution)
// Try to get a common volume resolution from the given 3D texture. Returns true if the given 3D texture matches the Raymarcher's common volume resolution
public static bool TryGetCommonVolumeResolutionFromTex3D(Texture3D entryTex3D, out CommonVolumeResolution outCommonVolumeResolution)

// Convert a world-space float value to a volume-space float value
public static float ConvertWorldToVolumeSpace(float worldSpaceValueEntry, int volumeResolution, float volumeSize)
// Convert a volume-space float value to a world-space float value
public static float ConvertVolumeToWorldSpace(float volumeSpaceValueEntry, int volumeResolution, float volumeSize)

// Convert a world-space vector to a volume-space vector position. If the unclampedCoords is true, you might get a vector which is out of volume bounds
public static Vector3 ConvertWorldToVolumeSpace(Vector3 worldSpacePosition, RMSdf_VolumeBoxBase targetVolumeBox, int volumeResolution, bool unclampedCoords = false)
// Convert a world-space vector to a volume-space vector position. If the unclampedCoords is true, you might get a vector which is out of volume bounds
public static Vector3 ConvertWorldToVolumeSpace(Vector3 worldSpacePosition, int volumeResolution, Vector3 volumeWorldPosition, Quaternion volumeWorldRotation, Vector3 volumeLocalScale, float volumeSize, bool unclampedCoords = false)

// Convert a volume-space vector to a world-space vector position
public static Vector3 ConvertVolumeToWorldSpace(Vector3 volumeSpaceCoords, int volumeResolution, Vector3 volumeWorldPosition, Quaternion volumeWorldRotation, Vector3 volumeLocalScale, float volumeSize)

// Convert a world-space vector to a volume-space vector position wrapped with modulo operator - if the position is out of the volume bounds, the position will repeat within the volume bounds 'mirrored' or 'non-mirrored'
public static Vector3 ConvertWorldToVolumeSpaceModuloWrap(Vector3 worldSpacePosition, RMSdf_VolumeBoxBase targetVolumeBox, int volumeResolution, bool mirrored = true)