Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a test for alpha masking on vertex colors #146

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4

- name: Install glTF Validator
run: |
Expand All @@ -21,7 +21,7 @@ jobs:
./gltf_validator -r -a ./Models/

- name: Upload Validation Reports
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: validation-reports
path: |
Expand Down
84 changes: 84 additions & 0 deletions Models/VertexColorAlphaClipTest/README.body.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
## Screenshot

![screenshot](screenshot/screenshot-large.jpg)

## Description

This model tests what happens when vertex colors contain alpha values and a material uses `alphaCutoff`. The above screenshot shows what this model looks like when the test passes.

## Common Problems

### Problem: Noisy alpha clipping

![screenshot](screenshot/fail_alphaClipNoise.jpg)

The two middle cubes (yellow and green) show a lot of fragment noise in the above screenshot. Here's a zoomed-in view to show detail on the green cube:

![screenshot](screenshot/fail_noise_detail.png)

The exact reason this noise is present can vary by rendering engine implementation, platform, and GPU in use. It's possible that discarding masked fragments too early in a shader (prior to gradients and texture lookup usage) may be a contributing factor in some implementations.

### Problem: No alpha mask

![screenshot](screenshot/fail_noAlphaCutoff.jpg)

The above screenshot shows a renderer that is not doing any alpha masking against vertex color alpha values. In this case, a large red "X" appears over the left-most sample that is intended to be left blank. This indicates a test failure.

### Problem: Incorrect alpha comparison

![screenshot](screenshot/fail_noEquality.jpg)

In the above screenshot, the two middle cubes are missing, indicating that when the alpha value exactly matches the `alphaCutoff`, the result is clipped.

The glTF specification [Alpha Coverage section](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#alpha-coverage) has this to say:

> When `alphaMode` is set to `MASK` the `alphaCutoff` property specifies the cutoff threshold. If the alpha value is greater than or equal to the `alphaCutoff` value then it is rendered as fully opaque, otherwise, it is rendered as fully transparent.

The specification makes special mention of the equality case presented here by the two middle cubes in yellow and green. They should be rendered fully opaque. So a rendering similar to the above screenshot with the missing middle cubes is a test failure.

## Label Text

In case the text on the labels is hard to read or needs translation, it is reproduced below:

### Far left sample

```
THIS SPACE INTENTIONALLY LEFT BLANK

There should not be an X here.
```

```
Blank space
COLOR_0.a = 0.48
alphaCutoff = 0.5
(less than)
```

### Second sample, yellow box

```
Solid Box
COLOR_0.a = 0.5
alphaCutoff = 0.5
(equal)
```

### Third sample, green box

```
Solid Box
COLOR_0.a = 1.0
alphaCutoff = 1.0
(equal)
```

### Far right sample, blue box

```
Solid Box
COLOR_0.a = 0.51
alphaCutoff = 0.5
(greater than)
```

Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added Models/VertexColorAlphaClipTest/glTF/PlainGrid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Loading