@forgeax/engine-shader 0.1.25 → 0.1.27

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forgeax/engine-shader",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "license": "Apache-2.0",
@@ -22,12 +22,12 @@
22
22
  "LICENSE"
23
23
  ],
24
24
  "dependencies": {
25
- "@forgeax/engine-rhi": "0.1.25",
26
- "@forgeax/engine-types": "0.1.25",
25
+ "@forgeax/engine-rhi": "0.1.27",
26
+ "@forgeax/engine-types": "0.1.27",
27
27
  "@webgpu/types": "^0.1.71"
28
28
  },
29
29
  "devDependencies": {
30
- "@forgeax/engine-vite-plugin-shader": "0.1.25"
30
+ "@forgeax/engine-vite-plugin-shader": "0.1.27"
31
31
  },
32
32
  "forgeax": {
33
33
  "metrics": {
@@ -77,15 +77,15 @@ describe('built-in MaterialAsset sources', () => {
77
77
  ] as const)('keeps the Standard user-region ABI before Skylight in %s', (file) => {
78
78
  const text = source(file);
79
79
  const bindings = [
80
- 'baseColorSampler',
80
+ 'baseColorTexture_sampler',
81
81
  'baseColorTexture',
82
- 'metallicRoughnessSampler',
82
+ 'metallicRoughnessTexture_sampler',
83
83
  'metallicRoughnessTexture',
84
- 'normalSampler',
84
+ 'normalTexture_sampler',
85
85
  'normalTexture',
86
- 'emissiveSampler',
86
+ 'emissiveTexture_sampler',
87
87
  'emissiveTexture',
88
- 'occlusionSampler',
88
+ 'occlusionTexture_sampler',
89
89
  'occlusionTexture',
90
90
  'transmissionSampler',
91
91
  'transmissionTexture',
@@ -95,7 +95,7 @@ describe('built-in MaterialAsset sources', () => {
95
95
  ];
96
96
  let previous = -1;
97
97
  for (const name of bindings) {
98
- const index = text.indexOf(`var ${name}`);
98
+ const index = new RegExp(`\\bvar\\s+${name}\\s*:`).exec(text)?.index ?? -1;
99
99
  expect(index, `${file} must declare ${name}`).toBeGreaterThan(previous);
100
100
  previous = index;
101
101
  }
@@ -67,11 +67,11 @@ fn composeProbeDiffuse(
67
67
  //
68
68
  // @group(0) @binding(0) view uniform (see common.wgsl)
69
69
  // @group(1) @binding(0) material uniform
70
- // @group(1) @binding(1) baseColorSampler sampler
70
+ // @group(1) @binding(1) baseColorTexture_sampler sampler
71
71
  // @group(1) @binding(2) baseColorTexture texture_2d<f32>
72
- // @group(1) @binding(3) metallicRoughnessSampler sampler
72
+ // @group(1) @binding(3) metallicRoughnessTexture_sampler sampler
73
73
  // @group(1) @binding(4) metallicRoughnessTexture texture_2d<f32>
74
- // @group(1) @binding(5) normalSampler sampler
74
+ // @group(1) @binding(5) normalTexture_sampler sampler
75
75
  // @group(1) @binding(6) normalTexture texture_2d<f32>
76
76
  // @group(1) @binding(9..15) Skylight (irradiance / prefilter / brdfLut +
77
77
  // samplers) + skylight uniform (intensity)
@@ -106,15 +106,15 @@ fn composeProbeDiffuse(
106
106
  // from the root ParamSchema during material composition. Keeping the ABI out
107
107
  // of this template prevents a second handwritten interface from drifting from
108
108
  // the runtime UBO writer.
109
- @group(1) @binding(1) var baseColorSampler : sampler;
109
+ @group(1) @binding(1) var baseColorTexture_sampler : sampler;
110
110
  @group(1) @binding(2) var baseColorTexture : texture_2d<f32>;
111
- @group(1) @binding(3) var metallicRoughnessSampler : sampler;
111
+ @group(1) @binding(3) var metallicRoughnessTexture_sampler : sampler;
112
112
  @group(1) @binding(4) var metallicRoughnessTexture : texture_2d<f32>;
113
- @group(1) @binding(5) var normalSampler : sampler;
113
+ @group(1) @binding(5) var normalTexture_sampler : sampler;
114
114
  @group(1) @binding(6) var normalTexture : texture_2d<f32>;
115
- @group(1) @binding(9) var emissiveSampler : sampler;
115
+ @group(1) @binding(9) var emissiveTexture_sampler : sampler;
116
116
  @group(1) @binding(10) var emissiveTexture : texture_2d<f32>;
117
- @group(1) @binding(11) var occlusionSampler : sampler;
117
+ @group(1) @binding(11) var occlusionTexture_sampler : sampler;
118
118
  @group(1) @binding(12) var occlusionTexture : texture_2d<f32>;
119
119
  #ifdef TRANSMISSION_AVAILABLE
120
120
  @group(1) @binding(13) var transmissionSampler : sampler;
@@ -185,11 +185,11 @@ fn materialTextureFilteringWitness() {
185
185
  let transmission = transmissionTexture;
186
186
  let thickness = thicknessTexture;
187
187
  #endif
188
- let baseWitness = textureSample(base, baseColorSampler, vec2<f32>(0.0));
189
- let metallicRoughnessWitness = textureSample(metallicRoughness, metallicRoughnessSampler, vec2<f32>(0.0));
190
- let normalWitness = textureSample(normal, normalSampler, vec2<f32>(0.0));
191
- let emissiveWitness = textureSample(emissive, emissiveSampler, vec2<f32>(0.0));
192
- let occlusionWitness = textureSample(occlusion, occlusionSampler, vec2<f32>(0.0));
188
+ let baseWitness = textureSample(base, baseColorTexture_sampler, vec2<f32>(0.0));
189
+ let metallicRoughnessWitness = textureSample(metallicRoughness, metallicRoughnessTexture_sampler, vec2<f32>(0.0));
190
+ let normalWitness = textureSample(normal, normalTexture_sampler, vec2<f32>(0.0));
191
+ let emissiveWitness = textureSample(emissive, emissiveTexture_sampler, vec2<f32>(0.0));
192
+ let occlusionWitness = textureSample(occlusion, occlusionTexture_sampler, vec2<f32>(0.0));
193
193
  #ifdef CLEARCOAT_TEXTURE_AVAILABLE
194
194
  let clearcoatWitness = textureSample(clearcoat, clearcoatSampler, vec2<f32>(0.0));
195
195
  #endif
@@ -1054,7 +1054,7 @@ fn fs_temporal(in : TemporalVsOut) -> @location(0) vec4<f32> {
1054
1054
  material.baseColor.a * temporalVertexAlpha(in),
1055
1055
  material.alphaCutoff,
1056
1056
  baseColorTexture,
1057
- baseColorSampler,
1057
+ baseColorTexture_sampler,
1058
1058
  material.baseColorTextureCoordinatesTransform,
1059
1059
  material.baseColorTextureCoordinatesMetadata,
1060
1060
  in.currentClip,
@@ -83,11 +83,11 @@ fn reflection_probe_sampling_contract(
83
83
  // + 4 channel selectors f32
84
84
  // + emissive vec3 + emissiveIntensity
85
85
  // + uv/alpha/specularColor = 104 B)
86
- // @group(1) @binding(1) baseColorSampler sampler
86
+ // @group(1) @binding(1) baseColorTexture_sampler sampler
87
87
  // @group(1) @binding(2) baseColorTexture texture_2d<f32>
88
- // @group(1) @binding(3) metallicRoughnessSampler sampler
88
+ // @group(1) @binding(3) metallicRoughnessTexture_sampler sampler
89
89
  // @group(1) @binding(4) metallicRoughnessTexture texture_2d<f32>
90
- // @group(1) @binding(5) normalSampler sampler
90
+ // @group(1) @binding(5) normalTexture_sampler sampler
91
91
  // @group(1) @binding(6) normalTexture texture_2d<f32>
92
92
  // @group(1) @binding(9..15) Skylight (irradiance / prefilter / brdfLut +
93
93
  // samplers) + skylight uniform (intensity)
@@ -132,15 +132,15 @@ fn reflection_probe_sampling_contract(
132
132
  // from the root ParamSchema during composition. Keeping the ABI out of this
133
133
  // template prevents a second handwritten interface from drifting from the
134
134
  // runtime UBO writer.
135
- @group(1) @binding(1) var baseColorSampler : sampler;
135
+ @group(1) @binding(1) var baseColorTexture_sampler : sampler;
136
136
  @group(1) @binding(2) var baseColorTexture : texture_2d<f32>;
137
- @group(1) @binding(3) var metallicRoughnessSampler : sampler;
137
+ @group(1) @binding(3) var metallicRoughnessTexture_sampler : sampler;
138
138
  @group(1) @binding(4) var metallicRoughnessTexture : texture_2d<f32>;
139
- @group(1) @binding(5) var normalSampler : sampler;
139
+ @group(1) @binding(5) var normalTexture_sampler : sampler;
140
140
  @group(1) @binding(6) var normalTexture : texture_2d<f32>;
141
- @group(1) @binding(9) var emissiveSampler : sampler;
141
+ @group(1) @binding(9) var emissiveTexture_sampler : sampler;
142
142
  @group(1) @binding(10) var emissiveTexture : texture_2d<f32>;
143
- @group(1) @binding(11) var occlusionSampler : sampler;
143
+ @group(1) @binding(11) var occlusionTexture_sampler : sampler;
144
144
  @group(1) @binding(12) var occlusionTexture : texture_2d<f32>;
145
145
  #ifdef TRANSMISSION_AVAILABLE
146
146
  @group(1) @binding(13) var transmissionSampler : sampler;
@@ -209,11 +209,11 @@ fn materialTextureFilteringWitness() {
209
209
  #ifdef CLEARCOAT_NORMAL_TEXTURE_AVAILABLE
210
210
  let clearcoatNormal = clearcoatNormalTexture;
211
211
  #endif
212
- let baseWitness = textureSample(base, baseColorSampler, vec2<f32>(0.0));
213
- let metallicRoughnessWitness = textureSample(metallicRoughness, metallicRoughnessSampler, vec2<f32>(0.0));
214
- let normalWitness = textureSample(normal, normalSampler, vec2<f32>(0.0));
215
- let emissiveWitness = textureSample(emissive, emissiveSampler, vec2<f32>(0.0));
216
- let occlusionWitness = textureSample(occlusion, occlusionSampler, vec2<f32>(0.0));
212
+ let baseWitness = textureSample(base, baseColorTexture_sampler, vec2<f32>(0.0));
213
+ let metallicRoughnessWitness = textureSample(metallicRoughness, metallicRoughnessTexture_sampler, vec2<f32>(0.0));
214
+ let normalWitness = textureSample(normal, normalTexture_sampler, vec2<f32>(0.0));
215
+ let emissiveWitness = textureSample(emissive, emissiveTexture_sampler, vec2<f32>(0.0));
216
+ let occlusionWitness = textureSample(occlusion, occlusionTexture_sampler, vec2<f32>(0.0));
217
217
  #ifdef CLEARCOAT_TEXTURE_AVAILABLE
218
218
  let clearcoatWitness = textureSample(clearcoat, clearcoatSampler, vec2<f32>(0.0));
219
219
  #endif
@@ -1263,7 +1263,7 @@ fn fs_temporal(in : TemporalVsOut) -> @location(0) vec4<f32> {
1263
1263
  material.baseColor.a * temporalVertexAlpha(in),
1264
1264
  material.alphaCutoff,
1265
1265
  baseColorTexture,
1266
- baseColorSampler,
1266
+ baseColorTexture_sampler,
1267
1267
  material.baseColorTextureCoordinatesTransform,
1268
1268
  material.baseColorTextureCoordinatesMetadata,
1269
1269
  in.currentClip,
@@ -34,27 +34,27 @@ fn surfaceNormal(input : SurfaceInput, encoded : vec4<f32>, normalScale : f32) -
34
34
  fn evaluate_surface(input : SurfaceInput) -> SurfaceData {
35
35
  let baseSample = textureSample(
36
36
  baseColorTexture,
37
- baseColorSampler,
37
+ baseColorTexture_sampler,
38
38
  surfaceUv(input, material.baseColorTextureCoordinatesTransform, material.baseColorTextureCoordinatesMetadata) * material.baseColorTextureCoordinatesMetadata.zw,
39
39
  );
40
40
  let metallicRoughnessSample = textureSample(
41
41
  metallicRoughnessTexture,
42
- metallicRoughnessSampler,
42
+ metallicRoughnessTexture_sampler,
43
43
  surfaceUv(input, material.metallicRoughnessTextureCoordinatesTransform, material.metallicRoughnessTextureCoordinatesMetadata) * material.metallicRoughnessTextureCoordinatesMetadata.zw,
44
44
  );
45
45
  let normalSample = textureSample(
46
46
  normalTexture,
47
- normalSampler,
47
+ normalTexture_sampler,
48
48
  surfaceUv(input, material.normalTextureCoordinatesTransform, material.normalTextureCoordinatesMetadata) * material.normalTextureCoordinatesMetadata.zw,
49
49
  );
50
50
  let emissiveSample = textureSample(
51
51
  emissiveTexture,
52
- emissiveSampler,
52
+ emissiveTexture_sampler,
53
53
  surfaceUv(input, material.emissiveTextureCoordinatesTransform, material.emissiveTextureCoordinatesMetadata) * material.emissiveTextureCoordinatesMetadata.zw,
54
54
  );
55
55
  let occlusionSample = textureSample(
56
56
  occlusionTexture,
57
- occlusionSampler,
57
+ occlusionTexture_sampler,
58
58
  surfaceUv(input, material.occlusionTextureCoordinatesTransform, material.occlusionTextureCoordinatesMetadata) * material.occlusionTextureCoordinatesMetadata.zw,
59
59
  );
60
60
  let vertexColor = input.vertexColor;
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@
23
23
  export type { ManifestEntry, ParamSchemaEntry } from '@forgeax/engine-types';
24
24
 
25
25
  import type { MaterialAsset, MaterialParameter, MaterialValue } from '@forgeax/engine-types';
26
+ import { standardSurfaceParameters } from '@forgeax/engine-types';
26
27
  import { STANDARD_PBR_ALPHA_CUTOFF_DEFAULT } from './material-schemas.js';
27
28
 
28
29
  export { MATERIAL_PARAM_TYPES } from '@forgeax/engine-types';
@@ -204,7 +205,10 @@ export function createBuiltinMaterialAsset(kind: BuiltinMaterialKind): MaterialA
204
205
  },
205
206
  },
206
207
  ],
207
- parameters: BUILTIN_PARAMETERS[kind],
208
+ parameters:
209
+ kind === 'standard'
210
+ ? standardSurfaceParameters(BUILTIN_PARAMETERS[kind])
211
+ : BUILTIN_PARAMETERS[kind],
208
212
  values: BUILTIN_VALUES[kind],
209
213
  };
210
214
  }
@@ -0,0 +1,9 @@
1
+ #define_import_path forgeax_material::opaque_surface
2
+ #import forgeax_material::surface_v1::{SurfaceInput, SurfaceData}
3
+
4
+ // The default depth coverage requires no material values or lighting model.
5
+ // Cutout materials select their shared Surface explicitly on every Pass.
6
+ fn evaluate_surface(input: SurfaceInput) -> SurfaceData {
7
+ return SurfaceData(vec3<f32>(1.0), input.geometricNormalWS, 0.0, 1.0,
8
+ vec3<f32>(0.0), 1.0, 1.0, 0.0);
9
+ }