# SlangPy Examples

Welcome to SlangPy examples! Here you'll find well written and documented examples of how to use SlangPy, plus any sample code from the [documentation](https://slangpy.shader-slang.org).

## Standalone Samples

| Name                                                                              | Output                                                        | Description                                                                                                                                                                                                                                           |
| -------                                                                           | ------------                                                  | -----------------------------------------                                                                                                                                                                                                             |
| [signed_distance_field](signed_distance_field/readme.md)                          | <img src="signed_distance_field/output.png" height="100">     | Use of SlangPy to generate a signed distance field and execute multiple eikonal passes to obtain accurate distance away from the zero point.                                                                                                          |
| [toy-restir](toy-restir/README.md)                                                | <img src="toy-restir/toy-restir.png" height="100">            | Uses ReSTIR to render the view of an animated 2D toy scene                                                                                                 
| [Simplified Splatting](simplified-splatting/README.md)                            | <img src="simplified-splatting/simple-splat-ex.png" height="100"> | A simplified implementation of 3D Gaussian Splatting for educational purposes


## Documentation Samples

| Name                                                                              | Description                                                                                                                                                                                                                                           |
| -------                                                                           | -----------------------------------------                                                                                                                                                                                                             |
| [autodiff](https://slangpy.shader-slang.org/en/latest/autodiff.html)              | Basic auto-diff examples, demonstrating how to evaluate a polynomial then run a backwards pass to calculate its gradients.                                                                                                                            |
| [broadcasting](https://slangpy.shader-slang.org/en/latest/broadcasting.html)      | Examples of how broadcasting works in SlangPy.                                                                                                                                                                                                        |
| [buffers](https://slangpy.shader-slang.org/en/latest/buffers.html)                | NDBuffer creation/use.                                                                                                                                                                                                                                |
| [first_function](https://slangpy.shader-slang.org/en/latest/firstfunctions.html)  | Most basic use of SlangPy to call a single function.                                                                                                                                                                                                  |
| [generators](https://slangpy.shader-slang.org/en/latest/generators.html)          | Demonstrates use of call id, thread id and grid generators.                                                                                                                                                                                           |
| [mapping](https://slangpy.shader-slang.org/en/latest/mapping.html)                | Examples of how to use the ``.map`` modifier to map input dimensions to different call dimensions.                                                                                                                                                    |
| [nested](https://slangpy.shader-slang.org/en/latest/nested.html)                  | Shows how to use Python dictionaries to pass nested data in SOA form.                                                                                                                                                                                 |
| [pytorch](https://slangpy.shader-slang.org/en/latest/pytorch.html)                | Example of use of PyTorch integration to evaluate and back propagate through a polynomial.                                                                                                                                                            |
| [textures](https://slangpy.shader-slang.org/en/latest/textures.html)              | Simple manipulation of texture data using SlangPy.                                                                                                                                                                                                    |
| [type_methods](https://slangpy.shader-slang.org/en/latest/typemethods.html)       | Use of InstanceList, InstanceBuffer and get_this to invoke methods of a type.                                                                                                                                                                         |




