# shader-slang/optix-examples architecture

> Architecture diagram of the GitHub repository shader-slang/optix-examples, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shader-slang/optix-examples
- Repository: https://github.com/shader-slang/optix-examples

## Overview

This repository is a set of progressive OptiX 7 ray-tracing examples using Slang for shading. The learning path moves from a minimal OptiX program through ray generation, window display, mesh and shader-binding-table data, multiple objects, imported models, textures, and shadow rays. In the windowed examples, the application calls the renderer and displays its downloaded pixels; model loading is a separate stage in the later examples. Sampled source and the SOURCE INDEX support these links, but do not expose every renderer-to-OptiX call, so those runtime details are omitted.

Main entry points: [`common/glfWindow/GLFWindow.cpp`](https://github.com/shader-slang/optix-examples/blob/main/common/glfWindow/GLFWindow.cpp) (Camera window), [`example02_pipelineAndRayGen/SampleRenderer.cpp`](https://github.com/shader-slang/optix-examples/blob/main/example02_pipelineAndRayGen/SampleRenderer.cpp) (Ray generation), [`example07_firstRealModel/SampleRenderer.cpp`](https://github.com/shader-slang/optix-examples/blob/main/example07_firstRealModel/SampleRenderer.cpp) (Imported model), [`example08_addingTextures/SampleRenderer.cpp`](https://github.com/shader-slang/optix-examples/blob/main/example08_addingTextures/SampleRenderer.cpp) (Textured model)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_launch["Examples 01–03"]
  node_hello["OptiX starter<br/>[main.cpp]"]
  node_raygen["Ray generation<br/>[SampleRenderer.cpp]"]
  node_windowed["Windowed output<br/>[SampleRenderer.cpp]"]
end

subgraph group_geometry["Geometry and SBT"]
  node_triangle["Triangle mesh<br/>[SampleRenderer.cpp]"]
  node_sbt["SBT data<br/>[SampleRenderer.cpp]"]
  node_multiple["Multiple objects<br/>[SampleRenderer.cpp]"]
end

subgraph group_scene["Models and materials"]
  node_realmodel["Imported model<br/>[SampleRenderer.cpp]"]
  node_textures["Textured model<br/>[SampleRenderer.cpp]"]
  node_shadows["Shadow rays<br/>[SampleRenderer.cpp]"]
end

subgraph group_render["Rendering support"]
  node_window["Camera window<br/>[GLFWindow.cpp]"]
  node_modelload["OBJ and textures<br/>[Model.cpp]"]
  node_imagewrite["Image output<br/>[stb_image_write.h]"]
  node_cuda["CUDA buffers<br/>[CUDABuffer.h]"]
  node_launchparams["Launch parameters<br/>[LaunchParams.h]"]
end

node_user(("Example user"))

node_user -.->|"runs"| node_hello
node_user -.->|"runs"| node_raygen
node_user -.->|"runs"| node_windowed
node_user -.->|"runs"| node_triangle
node_user -.->|"runs"| node_sbt
node_user -.->|"runs"| node_multiple
node_user -.->|"runs"| node_realmodel
node_user -.->|"runs"| node_textures
node_user -.->|"runs"| node_shadows
node_raygen -->|"writes pixels"| node_imagewrite
node_windowed -->|"uses window"| node_window
node_triangle -->|"uses window"| node_window
node_sbt -->|"uses window"| node_window
node_multiple -->|"uses window"| node_window
node_realmodel -->|"uses window"| node_window
node_textures -->|"uses window"| node_window
node_shadows -->|"uses window"| node_window
node_realmodel -.->|"loads model"| node_modelload
node_textures -.->|"loads model"| node_modelload
node_shadows -.->|"loads model"| node_modelload
node_raygen -->|"uses buffers"| node_cuda
node_raygen -->|"uses parameters"| node_launchparams
node_triangle -.->|"extends renderer"| node_raygen
node_sbt -.->|"extends renderer"| node_triangle
node_multiple -.->|"extends renderer"| node_sbt
node_realmodel -.->|"extends renderer"| node_multiple
node_textures -.->|"extends renderer"| node_realmodel
node_shadows -.->|"extends renderer"| node_textures

click node_hello "https://github.com/shader-slang/optix-examples/blob/main/example01_helloOptix/main.cpp"
click node_raygen "https://github.com/shader-slang/optix-examples/blob/main/example02_pipelineAndRayGen/SampleRenderer.cpp"
click node_windowed "https://github.com/shader-slang/optix-examples/blob/main/example03_inGLFWindow/SampleRenderer.cpp"
click node_triangle "https://github.com/shader-slang/optix-examples/blob/main/example04_firstTriangleMesh/SampleRenderer.cpp"
click node_sbt "https://github.com/shader-slang/optix-examples/blob/main/example05_firstSBTData/SampleRenderer.cpp"
click node_multiple "https://github.com/shader-slang/optix-examples/blob/main/example06_multipleObjects/SampleRenderer.cpp"
click node_realmodel "https://github.com/shader-slang/optix-examples/blob/main/example07_firstRealModel/SampleRenderer.cpp"
click node_textures "https://github.com/shader-slang/optix-examples/blob/main/example08_addingTextures/SampleRenderer.cpp"
click node_shadows "https://github.com/shader-slang/optix-examples/blob/main/example09_shadowRays/SampleRenderer.cpp"
click node_window "https://github.com/shader-slang/optix-examples/blob/main/common/glfWindow/GLFWindow.cpp"
click node_modelload "https://github.com/shader-slang/optix-examples/blob/main/example08_addingTextures/Model.cpp"
click node_imagewrite "https://github.com/shader-slang/optix-examples/blob/main/common/3rdParty/stb_image_write.h"
click node_cuda "https://github.com/shader-slang/optix-examples/blob/main/example02_pipelineAndRayGen/CUDABuffer.h"
click node_launchparams "https://github.com/shader-slang/optix-examples/blob/main/example02_pipelineAndRayGen/LaunchParams.h"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_hello,node_raygen,node_windowed,node_user toneBlue
class node_triangle,node_sbt,node_multiple toneAmber
class node_realmodel,node_textures,node_shadows toneMint
class node_window,node_modelload,node_imagewrite,node_cuda,node_launchparams toneRose
```

## Components

### Examples 01–03

- [OptiX starter](https://github.com/shader-slang/optix-examples/blob/main/example01_helloOptix/main.cpp): `example01_helloOptix/main.cpp`
- [Ray generation](https://github.com/shader-slang/optix-examples/blob/main/example02_pipelineAndRayGen/SampleRenderer.cpp): `example02_pipelineAndRayGen/SampleRenderer.cpp`
- [Windowed output](https://github.com/shader-slang/optix-examples/blob/main/example03_inGLFWindow/SampleRenderer.cpp): `example03_inGLFWindow/SampleRenderer.cpp`

### Geometry and SBT

- [Triangle mesh](https://github.com/shader-slang/optix-examples/blob/main/example04_firstTriangleMesh/SampleRenderer.cpp): `example04_firstTriangleMesh/SampleRenderer.cpp`
- [SBT data](https://github.com/shader-slang/optix-examples/blob/main/example05_firstSBTData/SampleRenderer.cpp): `example05_firstSBTData/SampleRenderer.cpp`
- [Multiple objects](https://github.com/shader-slang/optix-examples/blob/main/example06_multipleObjects/SampleRenderer.cpp): `example06_multipleObjects/SampleRenderer.cpp`

### Models and materials

- [Imported model](https://github.com/shader-slang/optix-examples/blob/main/example07_firstRealModel/SampleRenderer.cpp): `example07_firstRealModel/SampleRenderer.cpp`
- [Textured model](https://github.com/shader-slang/optix-examples/blob/main/example08_addingTextures/SampleRenderer.cpp): `example08_addingTextures/SampleRenderer.cpp`
- [Shadow rays](https://github.com/shader-slang/optix-examples/blob/main/example09_shadowRays/SampleRenderer.cpp): `example09_shadowRays/SampleRenderer.cpp`

### Rendering support

- [Camera window](https://github.com/shader-slang/optix-examples/blob/main/common/glfWindow/GLFWindow.cpp): `common/glfWindow/GLFWindow.cpp`
- [OBJ and textures](https://github.com/shader-slang/optix-examples/blob/main/example08_addingTextures/Model.cpp): `example08_addingTextures/Model.cpp`
- [Image output](https://github.com/shader-slang/optix-examples/blob/main/common/3rdParty/stb_image_write.h): `common/3rdParty/stb_image_write.h`
- [CUDA buffers](https://github.com/shader-slang/optix-examples/blob/main/example02_pipelineAndRayGen/CUDABuffer.h): `example02_pipelineAndRayGen/CUDABuffer.h`
- [Launch parameters](https://github.com/shader-slang/optix-examples/blob/main/example02_pipelineAndRayGen/LaunchParams.h): `example02_pipelineAndRayGen/LaunchParams.h`

### Other components

- **Example user**

## Connections

- Example user → OptiX starter: runs
- Example user → Ray generation: runs
- Example user → Windowed output: runs
- Example user → Triangle mesh: runs
- Example user → SBT data: runs
- Example user → Multiple objects: runs
- Example user → Imported model: runs
- Example user → Textured model: runs
- Example user → Shadow rays: runs
- Ray generation → Image output: writes pixels
- Windowed output → Camera window: uses window
- Triangle mesh → Camera window: uses window
- SBT data → Camera window: uses window
- Multiple objects → Camera window: uses window
- Imported model → Camera window: uses window
- Textured model → Camera window: uses window
- Shadow rays → Camera window: uses window
- Imported model → OBJ and textures: loads model
- Textured model → OBJ and textures: loads model
- Shadow rays → OBJ and textures: loads model
- Ray generation → CUDA buffers: uses buffers
- Ray generation → Launch parameters: uses parameters
- Triangle mesh → Ray generation: extends renderer
- SBT data → Triangle mesh: extends renderer
- Multiple objects → SBT data: extends renderer
- Imported model → Multiple objects: extends renderer
- Textured model → Imported model: extends renderer
- Shadow rays → Textured model: extends renderer
