diff --git a/3d-style/shaders/model.fragment.glsl b/3d-style/shaders/model.fragment.glsl index 5efa7e16a3c..d542c70837c 100644 --- a/3d-style/shaders/model.fragment.glsl +++ b/3d-style/shaders/model.fragment.glsl @@ -24,6 +24,11 @@ in vec4 v_pos_light_view_1; in float v_depth_shadows; #endif +#ifdef OCCLUSION_TEXTURE_TRANSFORM +// offset[0], offset[1], scale[0], scale[1] +uniform vec4 u_occlusionTextureTransform; +#endif + #pragma mapbox: define-attribute highp vec3 normal_3f #pragma mapbox: define-attribute highp vec3 color_3f #pragma mapbox: define-attribute highp vec4 color_4f @@ -445,7 +450,13 @@ vec4 finalColor; // Ambient Occlusion float ao = 1.0; #if defined (HAS_TEXTURE_u_occlusionTexture) && defined(HAS_ATTRIBUTE_a_uv_2f) - ao = (texture(u_occlusionTexture, uv_2f).x - 1.0) * u_aoIntensity + 1.0; + +#ifdef OCCLUSION_TEXTURE_TRANSFORM + vec2 uv = uv_2f.xy * u_occlusionTextureTransform.zw + u_occlusionTextureTransform.xy; +#else + vec2 uv = uv_2f; +#endif + ao = (texture(u_occlusionTexture, uv).x - 1.0) * u_aoIntensity + 1.0; color *= ao; #endif // Emission diff --git a/test/ignores/all.js b/test/ignores/all.js index 42aadf35572..07e5f223898 100644 --- a/test/ignores/all.js +++ b/test/ignores/all.js @@ -187,7 +187,11 @@ const skip = [ "render-tests/model-layer/multiple-models-terrain", // The algorithm for raster colour gradient texels stretching needs an adjustment - "render-tests/raster-color/categorical" + "render-tests/raster-color/categorical", + + // Only implemented in native for now + "render-tests/model-layer/landmark-mbx-meshopt", + "render-tests/model-layer/landmark-mbx-meshopt-colors" ]; export default {todo, skip}; diff --git a/test/integration/models/landmark/mbx-meshopt/2951-6424-14.glb b/test/integration/models/landmark/mbx-meshopt/2951-6424-14.glb new file mode 100644 index 00000000000..3c64815e15f Binary files /dev/null and b/test/integration/models/landmark/mbx-meshopt/2951-6424-14.glb differ diff --git a/test/integration/models/landmark/mbx-meshopt/9327-4742-14.glb b/test/integration/models/landmark/mbx-meshopt/9327-4742-14.glb new file mode 100644 index 00000000000..09737bc2984 Binary files /dev/null and b/test/integration/models/landmark/mbx-meshopt/9327-4742-14.glb differ diff --git a/test/integration/render-tests/model-layer/landmark-mbx-meshopt-colors/expected.png b/test/integration/render-tests/model-layer/landmark-mbx-meshopt-colors/expected.png new file mode 100644 index 00000000000..570f2cbb679 Binary files /dev/null and b/test/integration/render-tests/model-layer/landmark-mbx-meshopt-colors/expected.png differ diff --git a/test/integration/render-tests/model-layer/landmark-mbx-meshopt-colors/style.json b/test/integration/render-tests/model-layer/landmark-mbx-meshopt-colors/style.json new file mode 100644 index 00000000000..d49f0b72063 --- /dev/null +++ b/test/integration/render-tests/model-layer/landmark-mbx-meshopt-colors/style.json @@ -0,0 +1,273 @@ +{ + "version": 8, + "metadata": { + "test": { + "allowed": 0.00025, + "width": 1024, + "height": 1024 + } + }, + "lights": [ + { + "type": "ambient", + "id": "test_ambient", + "properties": { + "color": "rgba(255, 255, 255, 1)", + "intensity": 0.5 + } + }, + { + "type": "directional", + "id": "test_directional", + "properties": { + "color": "rgba(255, 255, 255, 1)", + "intensity": 0.5 + } + } + ], + "sources": { + "file-system-tiles": { + "type": "batched-model", + "maxzoom": 14, + "tiles": [ + "local://models/landmark/mbx-meshopt/{x}-{y}-{z}.glb" + ] + } + }, + "pitch": 70, + "zoom": 18.00, + "bearing": 48, + "center": [ + -115.1571, + 36.1678 + ], + "layers": [ + { + "type": "background", + "paint": { + "background-color": "lightgray" + }, + "id": "land" + }, + { + "id": "building-models", + "minzoom": 14.0, + "paint": { + "model-ambient-occlusion-intensity": 0.75, + "model-color": [ + "match", + [ + "get", + "part" + ], + "roof", + [ + "hsl", + 22, + 82, + 90 + ], + "wall", + [ + "hsl", + 0, + 0, + 100 + ], + "window", + [ + "interpolate", + [ "linear" ], + [ "measure-light", "brightness" ], + 0, + [ + "hsl", + [ + "random", + 0.0, + 90.0, + [ + "id" + ] + ], + [ + "random", + 20.0, + 100.0, + [ + "id" + ] + ], + 87 + ], + 0.15, + [ + "hsl", + [ + "random", + 200.0, + 215.0, + [ + "id" + ] + ], + 100, + [ + "random", + 70.0, + 80.0, + [ + "id" + ] + ] + ] + ], + [ + "interpolate", + [ "linear" ], + [ "measure-light", "brightness" ], + 0.16, + [ + "hsla", + [ + "random", + 10.0, + 70.0, + [ + "id" + ] + ], + 55 + , + [ + "random", + 80.0, + 90.0, + [ + "id" + ] + ], + 1.0 + ], + 0.4, + "hsl(0, 100%, 100%)" + ] + ], + "model-color-mix-intensity": [ + "match", + [ + "get", + "part" + ], + "logo", + [ + "interpolate", + [ "linear" ], + [ "measure-light", "brightness" ], + 0.2, + 0, + 0.4, + 0.3 + ], + 1.0 + ], + "model-emissive-strength": [ + "match", + [ + "get", + "part" + ], + "door", + [ + "interpolate", + [ "linear" ], + [ "measure-light", "brightness" ], + 0.2, + 1.5, + 0.4, + 2.5 + ], + "logo", + 0.6, + "window", + [ + "random", + 0.5, + 0.8, + [ + "id" + ] + ], + 0.0 + ], + "model-height-based-emissive-strength-multiplier": [ + "match", + [ + "get", + "part" + ], + "window", + [ + "literal", + [ + 0.0, + 0.9, + 0, + 1, + 0.5 + ] + ], + [ + "literal", + [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + ] + ] + ], + "model-opacity": [ + "interpolate", + [ "linear" ], + [ "zoom" ], + 14.2, + 0.0, + 14.5, + 1.0 + ], + "model-roughness": [ + "match", + [ + "get", + "part" + ], + "window", + 0.0, + 1.0 + ], + "model-scale": [ + "interpolate", + [ "linear" ], + [ "zoom" ], + 14.2, + [ + 1.0, + 1.0, + 0.0 + ], + 14.5, + [ + 1.0, + 1.0, + 1.0 + ] + ], + "model-type": "common-3d" + }, + "source": "file-system-tiles", + "type": "model" + } + ] +} \ No newline at end of file diff --git a/test/integration/render-tests/model-layer/landmark-mbx-meshopt/expected.png b/test/integration/render-tests/model-layer/landmark-mbx-meshopt/expected.png new file mode 100644 index 00000000000..20dd0995b21 Binary files /dev/null and b/test/integration/render-tests/model-layer/landmark-mbx-meshopt/expected.png differ diff --git a/test/integration/render-tests/model-layer/landmark-mbx-meshopt/style.json b/test/integration/render-tests/model-layer/landmark-mbx-meshopt/style.json new file mode 100644 index 00000000000..f28bcc49c1a --- /dev/null +++ b/test/integration/render-tests/model-layer/landmark-mbx-meshopt/style.json @@ -0,0 +1,273 @@ +{ + "version": 8, + "metadata": { + "test": { + "allowed": 0.00025, + "width": 1024, + "height": 1024 + } + }, + "lights": [ + { + "type": "ambient", + "id": "test_ambient", + "properties": { + "color": "rgba(255, 255, 255, 1)", + "intensity": 0.5 + } + }, + { + "type": "directional", + "id": "test_directional", + "properties": { + "color": "rgba(255, 255, 255, 1)", + "intensity": 0.5 + } + } + ], + "sources": { + "file-system-tiles": { + "type": "batched-model", + "maxzoom": 14, + "tiles": [ + "local://models/landmark/mbx-meshopt/{x}-{y}-{z}.glb" + ] + } + }, + "pitch": 70, + "zoom": 17.85, + "bearing": 126, + "center": [ + 24.9412582, + 60.1710846 + ], + "layers": [ + { + "type": "background", + "paint": { + "background-color": "lightgray" + }, + "id": "land" + }, + { + "id": "building-models", + "minzoom": 14.0, + "paint": { + "model-ambient-occlusion-intensity": 0.75, + "model-color": [ + "match", + [ + "get", + "part" + ], + "roof", + [ + "hsl", + 22, + 82, + 90 + ], + "wall", + [ + "hsl", + 0, + 0, + 100 + ], + "window", + [ + "interpolate", + [ "linear" ], + [ "measure-light", "brightness" ], + 0, + [ + "hsl", + [ + "random", + 0.0, + 90.0, + [ + "id" + ] + ], + [ + "random", + 20.0, + 100.0, + [ + "id" + ] + ], + 87 + ], + 0.15, + [ + "hsl", + [ + "random", + 200.0, + 215.0, + [ + "id" + ] + ], + 100, + [ + "random", + 70.0, + 80.0, + [ + "id" + ] + ] + ] + ], + [ + "interpolate", + [ "linear" ], + [ "measure-light", "brightness" ], + 0.16, + [ + "hsla", + [ + "random", + 10.0, + 70.0, + [ + "id" + ] + ], + 55 + , + [ + "random", + 80.0, + 90.0, + [ + "id" + ] + ], + 1.0 + ], + 0.4, + "hsl(0, 100%, 100%)" + ] + ], + "model-color-mix-intensity": [ + "match", + [ + "get", + "part" + ], + "logo", + [ + "interpolate", + [ "linear" ], + [ "measure-light", "brightness" ], + 0.2, + 0, + 0.4, + 0.3 + ], + 1.0 + ], + "model-emissive-strength": [ + "match", + [ + "get", + "part" + ], + "door", + [ + "interpolate", + [ "linear" ], + [ "measure-light", "brightness" ], + 0.2, + 1.5, + 0.4, + 2.5 + ], + "logo", + 0.6, + "window", + [ + "random", + 0.5, + 0.8, + [ + "id" + ] + ], + 0.0 + ], + "model-height-based-emissive-strength-multiplier": [ + "match", + [ + "get", + "part" + ], + "window", + [ + "literal", + [ + 0.0, + 0.9, + 0, + 1, + 0.5 + ] + ], + [ + "literal", + [ + 1.0, + 1.0, + 1.0, + 1.0, + 1.0 + ] + ] + ], + "model-opacity": [ + "interpolate", + [ "linear" ], + [ "zoom" ], + 14.2, + 0.0, + 14.5, + 1.0 + ], + "model-roughness": [ + "match", + [ + "get", + "part" + ], + "window", + 0.0, + 1.0 + ], + "model-scale": [ + "interpolate", + [ "linear" ], + [ "zoom" ], + 14.2, + [ + 1.0, + 1.0, + 0.0 + ], + 14.5, + [ + 1.0, + 1.0, + 1.0 + ] + ], + "model-type": "common-3d" + }, + "source": "file-system-tiles", + "type": "model" + } + ] +} \ No newline at end of file