Skip to content

BENTLEY_materials_line_style#89

Open
markschlosseratbentley wants to merge 32 commits intovendor-extensionsfrom
BENTLEY_materials_line_style
Open

BENTLEY_materials_line_style#89
markschlosseratbentley wants to merge 32 commits intovendor-extensionsfrom
BENTLEY_materials_line_style

Conversation

@markschlosseratbentley
Copy link

@markschlosseratbentley markschlosseratbentley commented Sep 11, 2025

Introduction

This PR describes an extension to glTF which meets the needs of Bentley Systems for styling line primitives with custom widths and patterning. It is written with the possibility of possible future extensibility in mind; line styling other than width and patterning could be easily included in this specification in the future.

Overview

Lines are fundamental elements in many 3D modeling and computer-aided design (CAD) environments. They are used to annotate two- and three-dimensional visualizations, with variations in width and dash patterns conveying semantic meaning or emphasis.

The BENTLEY_materials_line_style extension defines a method for describing the visual style of lines within glTF material. It enables authors to specify line thickness and a repeating dash pattern.

This extension introduces two primary properties controlling line appearance:

  • width: the pixel width of the rendered line
  • pattern: an unsigned integer whose bits represent a repeating on/off pattern along the line

@pmconne pmconne changed the title Elaborate and propose glTF extension BENTLEY_materials_line_style BENTLEY_materials_line_style Nov 13, 2025
@pmconne
Copy link

pmconne commented Nov 13, 2025

The glTF convention appears to be to name extensions based on the glTF object to which they apply. Rename to BENTLEY_material_line_style (singular "material").

@danielzhong danielzhong changed the title BENTLEY_materials_line_style BENTLEY_material_line_style Nov 13, 2025
Co-authored-by: Paul Connelly <22944042+pmconne@users.noreply.github.com>
danielzhong and others added 3 commits November 13, 2025 12:51
Co-authored-by: Paul Connelly <22944042+pmconne@users.noreply.github.com>
Co-authored-by: Paul Connelly <22944042+pmconne@users.noreply.github.com>
Co-authored-by: Paul Connelly <22944042+pmconne@users.noreply.github.com>
danielzhong and others added 3 commits December 8, 2025 15:29
Co-authored-by: Paul Connelly <22944042+pmconne@users.noreply.github.com>
Co-authored-by: Paul Connelly <22944042+pmconne@users.noreply.github.com>
Co-authored-by: Paul Connelly <22944042+pmconne@users.noreply.github.com>
danielzhong and others added 3 commits December 8, 2025 15:36
@pmconne pmconne requested a review from weegeekps December 9, 2025 14:10
@markschlosseratbentley
Copy link
Author

@weegeekps Can you let us know where we want to merge this PR and this PR (once we have full approval)?

  • To main branch of the Cesium/glTF fork?
  • To some other branch of the Cesium/glTF fork?

@weegeekps
Copy link
Collaborator

To some other branch of the Cesium/glTF fork?

It's going to be another branch, but I need to sort out exactly which branch. I've been swamped and haven't had many cycles to figure this out for you, but I will try to get an answer for you tomorrow.

@weegeekps
Copy link
Collaborator

@markschlosseratbentley Next week when I have a free moment, I will be creating a branch that will be where all of our vendor extensions live. There are a few things that I want to make sure we have set up for the branch, including branch protection rules, so I need to talk to our admins. I'll let you know as soon as I have the branch ready.

…rial.BENTLEY_materials_line_style.schema.json

Co-authored-by: Paul Connelly <22944042+pmconne@users.noreply.github.com>
@weegeekps weegeekps changed the base branch from main to vendor-extensions December 23, 2025 16:50
@weegeekps
Copy link
Collaborator

Since this is just a vendor extension, I changed the base from main to vendor-extensions.

@markschlosseratbentley
Copy link
Author

@weegeekps Recently, some discussion occurred about the necessity of enhancing itwinjs-core to allow the option for line patterns to be drawn such that the pattern begins at the line's origin rather than being calculated solely via screen pixel positions.

^This feature does not currently exist.

We were wondering if we should hold up this spec PR for that eventual feature (unscheduled as of now), or move to merge this spec as-is and potentially amend the spec later?

Your feedback is always valuable. Thanks.

cc @ggetz

@weegeekps
Copy link
Collaborator

We were wondering if we should hold up this spec PR for that eventual feature (unscheduled as of now), or move to merge this spec as-is and potentially amend the spec later?

@markschlosseratbentley Better to hold if we are going to make changes.

@danielzhong
Copy link

@weegeekps
We’d love your input on the extension shape. For the fix in iTwin/itwinjs-core#8922, we currently store line width + dash pattern on the material, but stable dash alignment needs a per-vertex cumulativeDistance attribute on the primitive (line-type or tessellated line mesh).

Few options:

  1. Keep BENTLEY_materials_line_style on material for width/pattern, and define a separate primitive-level extension to declare the cumulative distance attribute (e.g. BENTLEY_lines_cumulative_distance on MeshPrimitive/attributes)?
  2. Or extend BENTLEY_materials_line_style so it can be applied both to material (width/pattern) and primitive (attribute metadata)?
  3. Or move all line-style info to primitive (non-ideal but consistent)?

More details:
iTwin/itwinjs-core#8922 (comment)

Copy link
Collaborator

@weegeekps weegeekps left a comment

Choose a reason for hiding this comment

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

The best path forward for you right now is:

  • Define a new attribute semantic in this extension for storing the cumulative distance per vertex on the primitive.
  • Keep the material schema as is.
  • Add an additional schema for the primitive. This schema can be without properties and is meant as an indicator that the primitive is using your attribute semantic. This schema must be named mesh.primitive.BENTLEY_materials_line_style.schema.json.

More than willing to walk through any of this with you if something isn't completely clear.

Comment on lines 26 to 31
"cumulativeDistance": {
"type": "integer",
"description": "Accessor index containing per-vertex cumulative distance along the line string.",
"minimum": 0,
"gltf_detailedDescription": "When this extension is applied to a line-type MeshPrimitive, `cumulativeDistance` supplies the accessor index for per-vertex cumulative distance from the start of the line string, expressed in model/world units. The accessor must be SCALAR with a floating-point component type, and its count must match the primitive's vertex count."
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

You won't want this here. A semantic is required instead.

"extras": {}
},
"required": []
} No newline at end of file
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nitpick: please include a newline at the end of the file.

Many tools will not properly read JSON that is not POSIX compliant and POSIX compliance requires the newline.

| `0xF0F0` | 1111000011110000 | dashed line |
| `0xC3C3` | 1100001111000011 | custom pattern |

### Cumulative Distance (Primitive)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Since this is a per-vertex attribute you need to add a semantic for it. Check out this part of the recent KHR_gaussian_splatting extension to see how we defined the custom attributes there.

Each custom attribute must be prefixed appropriately for the extension, so in this case you'd use the full semantic BENTLEY_materials_line_style:CUMULATIVE_DISTANCE. You need to consider what data types could be packed in the attribute with this semantic. The easiest is probably float but if you want this to compress appropriately with meshopt or similar, you need to consider adding normalized integer types as well. Reach out directly to me if you need me to sit down and run step by step through this with you.

Once this stuff is defined and decided on, you can pack your data into the glTF as you normally would with any attribute.

Choose a reason for hiding this comment

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

@pmconne Do you think normalized integer types would be enough for representing cumulative distance in world space? I'm currently using float, I'm not sure whether normalized integer types is enough across all use cases .

Copy link

@pmconne pmconne Jan 29, 2026

Choose a reason for hiding this comment

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

It will depend on the use case. For example, by default when encoding glTF for tiles, we quantize all vertex positions as 16 bit integers, because our tiler ensures that level of precision is compatible with the tile's LOD. For certain tiles (e.g., large leaf nodes) and certain ordinary (arbitrarily-large, non-LOD) glTF models, doing so could introduce precision issues, so we encode vertex positions as floats instead. Cumulative distances should be quantized (or not) to the same range as the vertex positions. I agree with @weegeekps that the spec should support both floats and normalized integers.

*This section is non-normative.*

Because many graphics APIs do not support line primitives with a width larger than 1, tessellation is generally required to draw wide lines.

Copy link
Author

@markschlosseratbentley markschlosseratbentley Jan 29, 2026

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants