# Voxel Raymarching
## Summary
GPU accelerated approach to visualize volumetic data (3D textures). Based on a discrete traversal over data to find a collision with internal volume.
![](https://i.imgur.com/Zy3oxxZ.png)
## Reference
### ["Minecraft" on GPU](https://www.shadertoy.com/view/MtcGDH)
Very close example with rich post effects (fancy lighting, ambient occlusions)
![](https://i.imgur.com/DWpf9b3.jpg)
---
### [Branchless Voxel Raymarching](https://www.shadertoy.com/view/4dX3zl)
Most perfomant approach (as I know) achived by changing if-else blocks on pure math.
![](https://i.imgur.com/NHiKmF2.png)
---
### [Raymarching in Unity](https://github.com/hecomi/uRaymarching)
Open-source raymarching framework for Unity supports Standard shader and tightly integrated with Unity's rendering pipeline
![](https://i.imgur.com/BuFF6jW.png)
---
### [Improvement branchless](https://www.shadertoy.com/view/MdBGRm)
![](https://i.imgur.com/F1mBC6L.jpg)
---
## Requirements
1) Tight integration to Unity rendering (similar or same as uRaymarching did).
2) Rich parametrization (voxel size, volume dimension and etc)
3) Implementation of fancy effects: edge highligh, ao, fancy lighting.
4) Rendering in world space (obviously)
5) Multiple shader variants based on `#pragma multi_compile FANCY_LIGHTING_OFF FANCY_LIGHTING_ON`
6) **SUPPORT OF ORTHO PROJECTION AS WELL AS PERSPECTIVE**
## Roadmap
1) Draft implementation with hardcoded values
2) Integration with Standard shader
3) PBR params decoder from color data (*encoding convention is required!*)
4) Most important parametrization:
* Volume Size (bounds of providen volume)
* LOD (skip N pixel from providen texture)
5) Simple script to set `_Volume`, `_VolumeSize` and `transform.localScale` based on provided texture
6) Implementation of fancy effects
7) Rich parametrization
## Additional information:
To simplify process of developement I am highly recommended to few packages to your Unity project:
1) Install Unity 2018.1 or newer
2) Open `Packages/manifest.json` in your project
3) Add 2 extra dependencies:
```
"com.texture3d.preview": "git://github.com/alerdenisov/com.texture3d.preview.git",
"com.vox.importer": "git://github.com/alerdenisov/com.vox.importer.git"
```
5) Let unity resolve them
6) Open `Packages/vox Importer/vox` in Project tree
7) Use one of volumetric texture imported from MagicaVoxel builtin model.