├── README.md ├── RTKops.PNG ├── demo.PNG ├── raymarchToolkit6_23.toe ├── refl.PNG ├── rtkDem.PNG ├── rtkDemo.PNG └── textures.PNG /README.md: -------------------------------------------------------------------------------- 1 | [![DOI](https://zenodo.org/badge/205948014.svg)](https://zenodo.org/badge/latestdoi/205948014) 2 | 3 | # TDraymarchToolkit 4 | A Raymarch Toolkit for TouchDesigner 5 | ![alt text](demo.PNG) 6 | 7 | ![alt text](refl.PNG) 8 | 9 | ## Requirements 10 | TouchDesigner 099. Currently tested with: 11 | 2019.33020 12 | 13 | ## Usage: 14 | press shift+right click to open op create dialog for RTK. Place some ops, create a standard TouchDesigner render TOP, camera COMP and Light COMP to make use of RTKs render OP. 15 | 16 | ## Limitations/known Issues: 17 | - You cannot rename OPs without running into problems. 18 | - only one light supported 19 | - interpolation between 3 or more materials is broken. 20 | - the total maximum number of parameters is set to 100 and hard-coded at the moment. It is very easy to change that and will be adjustable soon. (Just in case you try to build something large [which I don't recommend at this point] and it breaks because of that[index error on ```params``` array.]) 21 | 22 | ## Working with textures 23 | The RTK Component has a parameter ```Textures Comp```. Here a bas Comp is expected. in this component a number of TOPs can be placed. These should be named ```textureN``` where ```N``` is a number. When you add a texture, the ```reload textures``` pulse parameter of the RTK Component needs to be pulsed. 24 | 25 | ![alt text](RTKops.PNG) 26 | 27 | ## Make your own OPs 28 | Please note that there is quite a big library of SDF functions included in this project (see references below). It is located at ```/project1/RTK/hg_sdf1```. Most if the stuff there is not yet implemented as an OP in this toolkit and its very simple to do that. You can simply make a new OP that just uses one of the functions from the lib (see for example the fGDF-op). 29 | 30 | Also, if you make new OPs, consider sharing them/making a pull request. 31 | 32 | Let's go through an example, we want to create an OP that can only translate in Y for some reason. 33 | 1. Go to ```/project1/RTK/operators```. Here you can find all the ops that where created so far. 34 | 2. Copy one of them. Copy something simple and similar to what you want to achieve, for example the ```Translate``` OP. 35 | 3. Rename your new OP. We'll rename it ```translateY```. 36 | 4. Make your changes: 37 | - Rewrite the function now located at ```/project1/RTK/operators/translateY/processfun```. We will change it to contain the code: 38 | ``` 39 | Sdf thismap(vec3 p){ 40 | p.y -= @Translate; 41 | return inputOp1(p); 42 | } 43 | ``` 44 | 45 | Please note: Your function needs to take a vec3 and return a Sdf. Variables beginning with ```@``` are going to be parsed to reference the components custom parameters. ```inputOP1``` will be parsed to reference the OP's input. 46 | The Sdf struct currently contains the following: 47 | ``` 48 | struct Sdf 49 | { 50 | float x; // distance 51 | float y; // material ID 52 | bool reflect; // do reflection for this? 53 | bool refract; // do refraction for this? 54 | float material2; // in case of interpolating, the second material 55 | float interpolant; // in case of interpolating, the interpolation value 56 | }; 57 | ``` 58 | 59 | 60 | - customize your component to have exactly the right parameters. In our case we delete the original Transformxyz and add a float named ```Translate```. Only Floats and XYZ type parameters are supported at the moment. 61 | 62 | 5. go to ```/project1/RTK/operators/translateY/filterSetup``` and run the ```filterSetup``` script. 63 | 6. Add your new op to the menu: go to ```/project1/RTK/menu/menu``` and add an entry in the ```table1``` in the corresponding column. It needs to be exactly the name of your new op. 64 | 65 | ## New Materials 66 | Creating a new material is similar to creating a new OP. 67 | Copy for example the simple mat. Adjust the ```material``` text DAT inside. You can use all the stuff that is in the comment in the top line. For example ```ref``` contains the reflection color or ```refraction``` contains the refracted color(transparency color). 68 | If you want to use refraction or refraction, you also have to modify the material's ```process fun``` text DAT so e.g. ```res.refract = true```. 69 | After all that, rename the OP, run the ```filterSetup``` script as with a filter OP *and* run the ```matSetup/matSetupScript```. 70 | 71 | 72 | ## References 73 | Thanks to [MERCURY](http://mercury.sexy), (their [library](http://mercury.sexy/hg_sdf) is included here) and [Inigo Quilez](https://www.iquilezles.org/index.html) for all the good articles and formulas. Please check MERCURY's licence. 74 | -------------------------------------------------------------------------------- /RTKops.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hrtlacek/TDraymarchToolkit/052d2e526dca2141375da2f4261b7b30c86c2f84/RTKops.PNG -------------------------------------------------------------------------------- /demo.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hrtlacek/TDraymarchToolkit/052d2e526dca2141375da2f4261b7b30c86c2f84/demo.PNG -------------------------------------------------------------------------------- /raymarchToolkit6_23.toe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hrtlacek/TDraymarchToolkit/052d2e526dca2141375da2f4261b7b30c86c2f84/raymarchToolkit6_23.toe -------------------------------------------------------------------------------- /refl.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hrtlacek/TDraymarchToolkit/052d2e526dca2141375da2f4261b7b30c86c2f84/refl.PNG -------------------------------------------------------------------------------- /rtkDem.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hrtlacek/TDraymarchToolkit/052d2e526dca2141375da2f4261b7b30c86c2f84/rtkDem.PNG -------------------------------------------------------------------------------- /rtkDemo.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hrtlacek/TDraymarchToolkit/052d2e526dca2141375da2f4261b7b30c86c2f84/rtkDemo.PNG -------------------------------------------------------------------------------- /textures.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/hrtlacek/TDraymarchToolkit/052d2e526dca2141375da2f4261b7b30c86c2f84/textures.PNG --------------------------------------------------------------------------------