Commit 2bf89ef
Smart Filters: Add const property support - consts in GLSL defined blocks that are settable at design time (#17479)
With this change, consts in fragment shaders of blocks defined using
GLSL can be annotated to be treated as properties on the resulting
block. Those properties can be set before runtime creation and then are
baked into the shader as consts. The properties are annotated for the
Smart Filter Editor to see and display in the property pane on the right
when a block instance is selected. The optimizer is updated to know that
such consts cannot be consolidated into a single const for all instances
of that block type, although regular unannotated consts will still be
consolidated.
The syntax for the annotation can either be:
```
// { "property": true }
const float mode = 1.0;
```
and this will show a text box in the Smart Filter Editor:
<img width="569" height="150" alt="image"
src="https://github.com/user-attachments/assets/c7b9f77f-2f0e-4018-9daf-c6067ba52139"
/>
Or you can supply a list of options for the value:
```
// { "property": { "options": { "Normal": 0, "Crazy": 1, "Odd": 2 } } }
const float mode = 1.0;
```
and this will show a drop down in the Smart Filter Editor:
<img width="550" height="155" alt="image"
src="https://github.com/user-attachments/assets/9f564e6d-57fe-422f-98f6-a3be16f7e619"
/>
This change also updates the serialization of CustomShaderBlocks to
include the values of these properties in the data section:
```
{
"name": "Example",
"uniqueId": 34,
"blockType": "ConstPropertyExample",
"namespace": "Test",
"comments": null,
"data": {
"customProperties": [
{
"name": "mode",
"value": 1
}
]
},
"outputTextureOptions": {
"ratio": 1,
"format": 5,
"type": 0
}
}
```
Note: this change is backwards compatible.
---------
Co-authored-by: AmoebaChant <[email protected]>1 parent 8f13e90 commit 2bf89ef
File tree
21 files changed
+699
-158
lines changed- packages
- dev
- smartFilterBlocks/src/blocks/babylon/demo/effects
- smartFilters
- src
- blockFoundation
- editorUtils
- optimization
- serialization
- v1
- utils
- buildTools
- test/unit
- tools
- smartFiltersEditorControl/src/graphSystem/properties
- smartFiltersEditor/src
- blockRegistration
21 files changed
+699
-158
lines changedLines changed: 39 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | | - | |
3 | | - | |
4 | | - | |
5 | | - | |
6 | | - | |
7 | | - | |
8 | | - | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
38 | 40 | | |
Lines changed: 19 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
14 | 15 | | |
15 | 16 | | |
16 | 17 | | |
| |||
40 | 41 | | |
41 | 42 | | |
42 | 43 | | |
43 | | - | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
56 | 55 | | |
57 | 56 | | |
58 | 57 | | |
| |||
62 | 61 | | |
63 | 62 | | |
64 | 63 | | |
65 | | - | |
66 | | - | |
| 64 | + | |
67 | 65 | | |
68 | 66 | | |
69 | 67 | | |
| |||
73 | 71 | | |
74 | 72 | | |
75 | 73 | | |
76 | | - | |
77 | 74 | | |
78 | 75 | | |
79 | 76 | | |
| |||
92 | 89 | | |
93 | 90 | | |
94 | 91 | | |
95 | | - | |
96 | 92 | | |
97 | | - | |
98 | 93 | | |
99 | 94 | | |
100 | 95 | | |
| |||
183 | 178 | | |
184 | 179 | | |
185 | 180 | | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
186 | 197 | | |
187 | 198 | | |
188 | 199 | | |
| |||
204 | 215 | | |
205 | 216 | | |
206 | 217 | | |
207 | | - | |
208 | 218 | | |
209 | | - | |
| 219 | + | |
210 | 220 | | |
211 | 221 | | |
Lines changed: 51 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
Lines changed: 80 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
7 | | - | |
| 7 | + | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
13 | 15 | | |
14 | 16 | | |
15 | 17 | | |
| |||
95 | 97 | | |
96 | 98 | | |
97 | 99 | | |
| 100 | + | |
98 | 101 | | |
99 | 102 | | |
100 | | - | |
| 103 | + | |
101 | 104 | | |
102 | 105 | | |
103 | | - | |
| 106 | + | |
104 | 107 | | |
105 | 108 | | |
106 | 109 | | |
107 | 110 | | |
108 | 111 | | |
109 | 112 | | |
| 113 | + | |
110 | 114 | | |
111 | 115 | | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
112 | 127 | | |
113 | 128 | | |
114 | 129 | | |
| |||
119 | 134 | | |
120 | 135 | | |
121 | 136 | | |
| 137 | + | |
122 | 138 | | |
123 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
124 | 147 | | |
125 | 148 | | |
126 | 149 | | |
| |||
144 | 167 | | |
145 | 168 | | |
146 | 169 | | |
| 170 | + | |
147 | 171 | | |
148 | 172 | | |
149 | 173 | | |
| |||
153 | 177 | | |
154 | 178 | | |
155 | 179 | | |
| 180 | + | |
156 | 181 | | |
157 | 182 | | |
158 | 183 | | |
159 | 184 | | |
160 | 185 | | |
| 186 | + | |
| 187 | + | |
161 | 188 | | |
162 | 189 | | |
163 | 190 | | |
164 | 191 | | |
165 | 192 | | |
166 | | - | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
167 | 196 | | |
168 | 197 | | |
169 | 198 | | |
170 | 199 | | |
171 | 200 | | |
172 | 201 | | |
173 | 202 | | |
174 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
175 | 249 | | |
176 | 250 | | |
177 | 251 | | |
| |||
0 commit comments