google / google/filament

material properties only work with direct assignment (`=`) but not with compound-assignment (e.g.: `*=`)

Open
#7,914 3 comments 0 reactions 1 assignee Claimed by @pixelflinger View on GitHub
enhancement low priority materials
Dominant language
C++
Stars
20.5k
Forks
2.3k
Avg merge
2d 16h
Merged PRs (30d)
74

Description

**Describe the bug**
`clipSpaceTransform` won't compile at all in `matc` for a `vertexDomain:device` shader ([docs](https://google.github.io/filament/Materials.html#materialdefinitions/vertexblock/materialvertexinputs), [previous discussion](https://github.com/google/filament/issues/1685#issuecomment-583622797)).

**To Reproduce**
1. `git clone git@github.com:google/filament.git`
2. `./build.sh release matc`
3. Minimal shader `test_direct_pixels.mat`:
```
material {
name: TestDirectPixels,
parameters: [
],
requires : [
uv0
],
blending : transparent,
vertexDomain : device,
shadingModel : unlit
}

vertex {
void materialVertex(inout MaterialVertexInputs material) {
material.clipSpaceTransform *= 0.3;
}
}

fragment {
void material(inout MaterialInputs material) {
prepareMaterial(material);
vec2 uv = getUV0();
material.baseColor = float4(0.0, 0.1, 0.4, 0.4);
}
}

```
5. ```./out/cmake-release/tools/matc/matc --api=metal --platform=mobile --output=./test_direct_pixels.filamat ./test_direct_pixels.mat```
6. `matc` compilation fails:
```
➜ filament git:(main) ✗ ./out/cmake-release/tools/matc/matc --api=metal --platform=mobile --output=./test_direct_pixels.filamat ./test_direct_pixels.mat
ERROR: Unable to parse vertex shader
ERROR: test_direct_pixels.mat:15: 'clipSpaceTransform' : no such field in structure 'material'
ERROR: test_direct_pixels.mat:15: '' : compilation terminated
ERROR: 2 compilation errors. No code generated.

Could not compile material ./test_direct_pixels.mat
```

**Expected behavior**
`matc` compilation should work, though it may have broken [here](https://github.com/google/filament/blob/af2ecf201f5b9116cba84d0c6ca0593fae1d52f1/RELEASE_NOTES.md?plain=1#L421)?

**Screenshots**
N/A

**Logs**
(see Step 6 above)

**Desktop (please complete the following information):**
- OS: macOS
- GPU: MacBook Pro Nov 2023
- Backend: Metal

**Smartphone (please complete the following information):**
- Device: N/A (offline `matc`)
- OS: N/A (offline `matc`)

**Additional context**
I'm looking to create a 2D quad, with 256 instances, and do efficient vertex transforms on the GPU.

Thanks as always team!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.