> ## Documentation Index
> Fetch the complete documentation index at: https://docs.claviscage.app/llms.txt
> Use this file to discover all available pages before exploring further.

# Path-Traced Rendering

> Create photorealistic renders of your hydrate structures

<Info>
  <Icon icon="crown" iconType="solid" color="#facc15" /> **PRO Feature** - Path-traced rendering requires a PRO subscription. [Upgrade to PRO](https://www.claviscage.app/login) for access.
</Info>

Clavis PRO includes a GPU WebGL path tracer for creating publication-quality images with physically motivated lighting, shadows, depth of field, denoising, and configurable output frames. The **Render Resource** selector shows GPU WebGL as the default browser path-tracer resource and exposes the gated CPU still-image fallback when the browser supports Worker and ImageData.

The CPU still-image fallback is deterministic and still PNG only. It is designed as a browser-local safety path for simple static output, not as parity with GPU WebGL path tracing.

## Output Frame and Resolution

The **RENDER** tab lets you choose exact output width and height. New sessions start with a lighter 1280 × 720 16:9 default for faster first path-traced previews, while 1080p remains available as an explicit higher-cost preset. Use common presets or type custom dimensions, then enable Preview Mode to see the render frame over the live scene.

Drag Frame mode is the primary crop-adjustment action. It defines the exact crop rectangle drawn in the scene viewport. Output aspect follows the drawn frame: the output WIDTH/HEIGHT follow that crop aspect without increasing the current pixel area, and the path-traced camera uses the same normalized crop via camera view offsets. Centered Preview Mode frames are also resolved from the yellow viewport frame before export, so portrait or square renders keep the same composition shown on screen instead of stretching the camera. Use **RESET 16:9** to return to a full, centered 1280 × 720 frame.

## Render Resource

Use **Render Resource** to confirm which backend will handle the export:

| Resource            | Availability      | Notes                                                                                                 |
| ------------------- | ----------------- | ----------------------------------------------------------------------------------------------------- |
| **GPU WebGL**       | Default           | Uses the browser WebGL path tracer with lighting, DoF, denoising, and path-traced materials           |
| **CPU Path Tracer** | Runtime supported | Requires browser Worker and ImageData support; intended for still PNG output within CPU render limits |

The Render Resource and Browser GPU Status cards show summary-first status so you can see whether the GPU WebGL path is active or whether CPU still-image fallback is available, explicitly disabled, unsupported, running, or cancelable.

## Features

### Global Illumination

Path tracing simulates light bounces to produce soft shadows, ambient occlusion, and realistic material response.

### Depth of Field

Create professional-looking renders with adjustable focus and aperture:

| Setting            | Description                                                                   |
| ------------------ | ----------------------------------------------------------------------------- |
| **Focus Distance** | Distance to the focal plane                                                   |
| **F-Stop**         | Lower values create stronger blur; higher values keep more of the scene sharp |
| **Click-to-Focus** | Click an atom in Focus Mode to set the focus point                            |
| **Drag Aperture**  | Drag vertically in Focus Mode to adjust f-stop interactively                  |

### Lighting

Use **SET LIGHT** to click-position the main light direction in the scene. The light indicator shows the active direction during preview.

### Denoising

Enable denoising to reduce noise at lower sample counts. Use moderate denoise values for final figures to avoid blurring fine structural details.

### Preview parity

Path-traced export rebuilds the scene for physically based rendering, but it preserves the key scientific visualization controls from Preview Mode: atom size/opacity, stick width, cage opacity/width, occupied-cage emphasis, H-bond width/opacity, PBC box visibility, and occupied guest highlights including guest atom size and guest bond width.

CHILL+ is carried into path-traced output. Classified water oxygens retain their class colors, class visibility filters apply to complete water molecules, non-water residues remain available, and the classified O–O network uses the active width, opacity, and per-class or override color in the GPU path tracer. The CPU still-image fallback also carries the classified colors, visibility, and network geometry, subject to the CPU backend's simpler material model.

### Large molecular scenes

Path tracing remains substantially more expensive than the live WebGL viewport because it must build a triangle acceleration structure before sampling. For systems above 100,000 atoms, Clavis automatically uses adaptive 8-triangle atom geometry and combines covalent bonds into batched meshes. This prevents the former per-atom clone-and-merge and per-bond mesh explosion, but a 194,957-atom ball-and-stick scene still contains several million triangles after atoms and bonds are included.

For a first large-scene render, use 256–640 px, 64 samples, and the GPU WebGL resource. Hide scientifically irrelevant residues or CHILL+ water classes before rendering, and increase resolution or samples only after the low-resolution composition succeeds. A **Standard image** remains the appropriate fast export when global illumination is not required.

Before allocating render geometry, Clavis estimates atom, bond, CHILL+, and overlay memory. GPU scenes above the browser safety ceiling stop with reduction guidance instead of attempting an unbounded allocation. The CPU fallback uses the same 25,000-primitive ceiling as its worker and rejects larger scenes before constructing and cloning the worker payload.

Bond preflight follows contiguous residue blocks rather than globally merging every repeated GRO residue number. Atom, pair-check, and bond-count ceilings reject malformed or bond-heavy blocks before quadratic enumeration can bypass the scene-memory guard.

## Presets

| Preset        | Best for                                                    |
| ------------- | ----------------------------------------------------------- |
| **DEFAULT**   | Glossy, presentation-friendly renders                       |
| **OSPRAY AO** | Matte ambient-occlusion style for clean publication figures |

## Best Practices

1. Compose the camera first, then set the render frame.
2. Start with low samples for previewing and increase samples for final export.
3. Use OSPRAY AO for clean structural figures.
4. Keep atom/layer opacity intentional; transparent atoms affect the path-traced output.
5. For depth of field, click a scientifically meaningful atom or cage center and use lower f-stop values sparingly.

## Export

Click **EXPORT** after the path-traced render converges. The downloaded PNG uses the configured output dimensions and includes `_pathtraced` in the filename.

## Troubleshooting

<AccordionGroup>
  <Accordion title="Render looks grainy">
    Increase the sample count or enable denoising. For final static images, 256+ samples usually gives a cleaner result.
  </Accordion>

  <Accordion title="No depth of field visible">
    Ensure DoF is enabled, choose a lower f-stop, and confirm the focus distance or click-to-focus point is set correctly.
  </Accordion>

  <Accordion title="Render is too slow">
    Reduce output dimensions, samples, or ray bounces. Large scenes automatically use adaptive atoms and batched bonds, but BVH construction and sampling still scale with the visible scene. Start at 256–640 px and 64 samples, hide irrelevant layers, and use Standard image for quick drafts.
  </Accordion>

  <Accordion title="The crop is not what I expected">
    Enable Preview Mode and check the yellow render frame before export. Centered frames and Drag Frame selections are both applied as viewport-normalized camera crops; use RESET 16:9 if you want the full centered frame again.
  </Accordion>

  <Accordion title="Render reports background-only output">
    Background-only output means the export camera did not capture any molecule pixels, or the scene had no renderable geometry. Use the recovery panel actions such as Center Frame or Reset 16:9, then confirm atoms/bonds/PBC/cages are visible inside the yellow Preview Mode crop. Large or distant scenes use camera-distance-aware clipping so valid visible scenes should not be clipped out of the path-traced export.
  </Accordion>
</AccordionGroup>
