Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 37 additions & 9 deletions docs/howtos/layers/surface.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,10 @@ layer first, then explore the GUI controls.

The surface layer allows you to display a precomputed surface mesh that is
defined by an `NxD` array of `N` vertices in `D` coordinates, an `Mx3` integer
array of the indices of the triangles making up the faces of the surface, and a
length `N` list of values to associate with each vertex to use alongside a
colormap.
array of the indices of the triangles making up the faces of the surface, and,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since there are several long components and one optional, changing to a bulleted list would reduce cognitive load for reader.

optionally, a length `N` list of values to associate with each vertex to use
alongside a colormap. If you omit the vertex values, napari uses a length `N`
array of ones.
Comment on lines +37 to +39
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.


## A simple example

Expand Down Expand Up @@ -79,6 +80,13 @@ viewer.close()
Once you have created a `surface` layer programmatically, the following GUI
controls are available in the viewer:

Controls related to `contrast limits`, `auto-contrast`, `gamma`, and
`colormap` are only available when the surface color is computed from
`vertex_values`. If you provide `vertex_colors`, napari uses those colors
Comment on lines +83 to +85
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Controls related to `contrast limits`, `auto-contrast`, `gamma`, and
`colormap` are only available when the surface color is computed from
`vertex_values`. If you provide `vertex_colors`, napari uses those colors
When the surface color is computed from `vertex_values`, controls related to `contrast limits`, `auto-contrast`, `gamma`, and
`colormap` are unavailable. If you provide `vertex_colors`, napari uses those colors

Is vertex_colors a vertex_value?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so this is IMO a bigger problem that I can address in the PR.
vertex_values is really the 3rd element of the data tuple, but it seems to be used throughout the docs and examples as if it were a real argument.
On the other hand, vertex_colors is an argument to Surface that overrides anything set in that third element of the data tuple.
I'll take another overall swing at the wording -- I think bulleting the tuple elements like above will probably help with this :)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No problem. I just didn't know the answer. Keep it simple now with just the bullets.

directly and disables those controls because they no longer affect rendering.
When a texture is present, napari multiplies the texture by the underlying
surface color.

- **Buttons**
- Pan/zoom - ![image: Pan/zoom tool](../../_static/images/pan-zoom-tool.png) is the default
mode of the layer and supports panning and zooming. Press the `1` key when the
Expand Down Expand Up @@ -116,12 +124,27 @@ help(napari.Viewer.add_surface)

## Surface data

The data for a `surface` layer is defined by a 3-tuple of its vertices, faces,
and vertex values. The vertices are an `NxD` array of `N` vertices in `D`
coordinates. The faces are an `Mx3` integer array of the indices of the
triangles making up the faces of the surface. The vertex values are a length `N`
list of values to associate with each vertex to use alongside a colormap. This
3-tuple is accessible through the `layer.data` property.
The data for a `surface` layer can be given as either a 2-tuple
`(vertices, faces)` or a 3-tuple `(vertices, faces, vertex_values)`. The
vertices are an `NxD` array of `N` vertices in `D` coordinates. The faces are
an `Mx3` integer array of the indices of the triangles making up the faces of
the surface. The optional vertex values are a length `N` list of scalar values
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here as above.

to associate with each vertex for colormap-based rendering. If you omit
`vertex_values`, napari fills them with ones, so the default underlying surface
color is white.
Comment on lines +127 to +134
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a bullet list for sentences after the first.

Suggested change
The data for a `surface` layer can be given as either a 2-tuple
`(vertices, faces)` or a 3-tuple `(vertices, faces, vertex_values)`. The
vertices are an `NxD` array of `N` vertices in `D` coordinates. The faces are
an `Mx3` integer array of the indices of the triangles making up the faces of
the surface. The optional vertex values are a length `N` list of scalar values
to associate with each vertex for colormap-based rendering. If you omit
`vertex_values`, napari fills them with ones, so the default underlying surface
color is white.
The data for a `surface` layer can be given as either a 2-tuple
`(vertices, faces)` or a 3-tuple `(vertices, faces, vertex_values)`.
- The vertices are an `NxD` array of `N` vertices in `D` coordinates.
- The faces are an `Mx3` integer array of the indices of the triangles
making up the faces of the surface.
- The optional vertex values are a length `N` list of scalar values
to associate with each vertex for colormap-based rendering.
If you omit `vertex_values`, napari fills them with ones, so the default underlying surface color is white.


## How surface colors are computed

- `vertex_values` are mapped through the selected `colormap`. `contrast limits`,
`auto-contrast`, and `gamma` all operate on this scalar-coloring path.
- `vertex_colors` provide direct per-vertex colors and override any color that
would otherwise come from `vertex_values`. When `vertex_colors` are present,
the GUI disables the scalar-coloring controls because they do not affect the
rendered surface.
- `texture` plus `texcoords` multiplies the texture color by the underlying
surface color. If that underlying color comes from `vertex_values`, the
scalar-coloring controls still affect the result. If it comes from
`vertex_colors`, they do not.

## 3D rendering

Expand Down Expand Up @@ -176,3 +199,8 @@ what values get applied the minimum and maximum of the colormap and follow the
same principles as the `contrast_limits` described in the
[image layer guide](layers-image). They are also accessible through the same keyword
arguments, properties, and GUI layer controls as in the image layer.

These controls only apply when the surface is colored from `vertex_values`.
That includes textured surfaces whose texture is multiplied by a color derived
from `vertex_values`. They do not apply when the surface is colored directly by
`vertex_colors`.
Loading