Skip to content

Commit

Permalink
Update fidelity tests (google#630)
Browse files Browse the repository at this point in the history
* updated environment

* fixed fidelity layout

* removed ROOM_PADDING

* reduced exposure to match filament background

* removed filament patch

* Revert "removed filament patch"

This reverts commit 863c14b.

* updated filament patch

* updated goldens
  • Loading branch information
elalish authored and Christopher Joel committed Jun 19, 2019
1 parent 9e0bdfb commit 4255398
Show file tree
Hide file tree
Showing 92 changed files with 116 additions and 125 deletions.
Binary file added examples/assets/lightroom_14b.hdr
Binary file not shown.
49 changes: 29 additions & 20 deletions scripts/update-screenshots.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ const filamentScreenshotScript =
const backgroundImageRe = /background-image\="([^"]+)"/;
const modelSourceRe = /src\="([^"]+)"/

let rendererWhitelist = null;
let scenarioWhitelist = null;

if (process.argv.length > 2) {
rendererWhitelist = new Set();
scenarioWhitelist = new Set();

for (let i = 2; i < process.argv.length; i++) {
rendererWhitelist.add(process.argv[i]);
scenarioWhitelist.add(process.argv[i]);
}
}

Expand Down Expand Up @@ -72,8 +72,8 @@ const updateScreenshots = async (config) => {
const {name, file} = golden;
const filePath = path.resolve(scenarioDirectory, file);

if (rendererWhitelist != null && !rendererWhitelist.has(name)) {
console.log(`⏭ Skipping ${name}...`);
if (scenarioWhitelist != null && !scenarioWhitelist.has(slug)) {
console.log(`⏭ Skipping ${slug}...`);
continue;
}

Expand All @@ -96,14 +96,25 @@ const updateScreenshots = async (config) => {

break;
case 'Filament':
await screenshotFromScript(scenario, scenarioDirectory, filePath, name, filamentScreenshotScript);
await screenshotFromScript(
scenario,
scenarioDirectory,
filePath,
name,
filamentScreenshotScript);
break;
}
}
}
};

const screenshotFromScript = async (scenario, scenarioDirectory, filePath, name, script) => {
const screenshotFromScript =
async (
scenario,
scenarioDirectory,
filePath,
name,
script) => {
const testHtmlPath = path.join(scenarioDirectory, 'index.html');

const html = (await fs.readFile(testHtmlPath)).toString();
Expand All @@ -118,8 +129,7 @@ const screenshotFromScript = async (scenario, scenarioDirectory, filePath, name,
const {width, height} = scenario.dimensions;

if (modelSource == null) {
warn(`Could not determine model source for ${
scenario.slug}; skipping...`);
warn(`Could not determine model source for ${scenario.slug}; skipping...`);
return;
}

Expand All @@ -131,11 +141,11 @@ const screenshotFromScript = async (scenario, scenarioDirectory, filePath, name,
const backgroundImagePath =
path.resolve(path.dirname(testHtmlPath), backgroundImage);

const modelSourcePath =
path.resolve(path.dirname(testHtmlPath), modelSource);
const modelSourcePath = path.resolve(path.dirname(testHtmlPath), modelSource);

await new Promise((resolve, reject) => {
console.log(`🖌️ Rendering ${name} screenshot for ${scenario.slug}...`);
console.log(
`🖌️ Rendering ${name} screenshot for ${scenario.slug}...`);

const childProcess = spawn(
script,
Expand Down Expand Up @@ -171,13 +181,12 @@ const screenshotFromScript = async (scenario, scenarioDirectory, filePath, name,
}
});
});


}

updateScreenshots(require(path.join(fidelityTestDirectory, 'config.json')))
.then(() => exit(0))
.catch((error) => {
console.error(error);
exit(1);
});
updateScreenshots(
require(path.join(fidelityTestDirectory, 'config.json')))
.then(() => exit(0))
.catch((error) => {
console.error(error);
exit(1);
});
2 changes: 1 addition & 1 deletion src/test/fidelity/components/rendering-scenario.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ h2 {
.screenshot > img {
max-width: 256px;
flex: 1 1 auto;
flex: 0 0 0;
}
.check {
Expand Down
40 changes: 20 additions & 20 deletions src/test/fidelity/filament.patch
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
diff --git a/samples/CMakeLists.txt b/samples/CMakeLists.txt
index e404a08..9a9d33f 100644
index fda3649..b4fc03f 100644
--- a/samples/CMakeLists.txt
+++ b/samples/CMakeLists.txt
@@ -250,6 +250,7 @@ if (NOT ANDROID)
@@ -256,6 +256,7 @@ if (NOT ANDROID)
add_assimp_demo(lightbulb)
add_assimp_demo(material_sandbox)
add_assimp_demo(sample_full_pbr)
+ add_assimp_demo(gltf_renderer)

add_filamesh_demo(sample_cloth)
add_filamesh_demo(sample_normal_map)
@@ -258,6 +259,7 @@ if (NOT ANDROID)
@@ -265,6 +266,7 @@ if (NOT ANDROID)

# Sample app specific
target_link_libraries(frame_generator PRIVATE imageio)
+ target_link_libraries(gltf_renderer PRIVATE imageio)
target_link_libraries(suzanne PRIVATE suzanne-resources)
target_link_libraries(gltf_viewer PRIVATE gltf-resources gltfio)
endif()
target_link_libraries(gltf_baker PRIVATE gltf-resources gltfio imageio)
diff --git a/samples/app/Config.h b/samples/app/Config.h
index 8efe32d..a57cfda 100644
index 5145573..f141dab 100644
--- a/samples/app/Config.h
+++ b/samples/app/Config.h
@@ -26,6 +26,9 @@ struct Config {
Expand All @@ -30,55 +30,55 @@ index 8efe32d..a57cfda 100644
+ int height = 768;
+ std::string outputPath;
filament::Engine::Backend backend = filament::Engine::Backend::OPENGL;
bool resizeable = true;
};

diff --git a/samples/app/FilamentApp.cpp b/samples/app/FilamentApp.cpp
index 200d2d2..796b0d5 100644
index b2d5c52..fbe5139 100644
--- a/samples/app/FilamentApp.cpp
+++ b/samples/app/FilamentApp.cpp
@@ -68,9 +68,23 @@ void FilamentApp::run(const Config& config, SetupCallback setupCallback,
@@ -72,10 +72,23 @@ void FilamentApp::run(const Config& config, SetupCallback setupCallback,
CleanupCallback cleanupCallback, ImGuiCallback imguiCallback,
PreRenderCallback preRender, PostRenderCallback postRender,
size_t width, size_t height) {
+ run(config, nullptr, setupCallback, cleanupCallback, imguiCallback,
+ preRender, postRender, width, height);
+ run(config, nullptr, setupCallback, cleanupCallback, imguiCallback,
+ preRender, postRender, width, height);
+}
+
+void FilamentApp::run(const Config& config,
+ WindowCreatedCallback configureWindow, SetupCallback setupCallback,
+ CleanupCallback cleanupCallback, ImGuiCallback imguiCallback,
+ PreRenderCallback preRender, PostRenderCallback postRender,
+ size_t width, size_t height) {
+
mWindowTitle = config.title;
std::unique_ptr<FilamentApp::Window> window(
new FilamentApp::Window(this, config, config.title, width, height));

+ if (configureWindow) {
+ configureWindow(window->mWindow);
+ configureWindow(window->mWindow);
+ }
+
mDepthMaterial = Material::Builder()
.package(RESOURCES_DEPTHVISUALIZER_DATA, RESOURCES_DEPTHVISUALIZER_SIZE)
.build(*mEngine);
@@ -294,6 +308,7 @@ void FilamentApp::run(const Config& config, SetupCallback setupCallback,
@@ -304,6 +317,7 @@ void FilamentApp::run(const Config& config, SetupCallback setupCallback,
break;
case SDL_WINDOWEVENT:
switch (event.window.event) {
+ case SDL_WINDOWEVENT_SIZE_CHANGED:
case SDL_WINDOWEVENT_RESIZED:
window->resize();
break;
@@ -432,7 +447,7 @@ FilamentApp::Window::Window(FilamentApp* filamentApp,
@@ -445,7 +459,7 @@ FilamentApp::Window::Window(FilamentApp* filamentApp,
: mFilamentApp(filamentApp) {
const int x = SDL_WINDOWPOS_CENTERED;
const int y = SDL_WINDOWPOS_CENTERED;
- const uint32_t windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE | SDL_WINDOW_ALLOW_HIGHDPI;
+ const uint32_t windowFlags = SDL_WINDOW_ALLOW_HIGHDPI;
mWindow = SDL_CreateWindow(title.c_str(), x, y, (int) w, (int) h, windowFlags);

// Create the Engine after the window in case this happens to be a single-threaded platform.
- uint32_t windowFlags = SDL_WINDOW_SHOWN | SDL_WINDOW_ALLOW_HIGHDPI;
+ uint32_t windowFlags = SDL_WINDOW_ALLOW_HIGHDPI;
if (config.resizeable) {
windowFlags |= SDL_WINDOW_RESIZABLE;
}
diff --git a/samples/app/FilamentApp.h b/samples/app/FilamentApp.h
index dfa2474..f54b99a 100644
index 0f19251..45ffa82 100644
--- a/samples/app/FilamentApp.h
+++ b/samples/app/FilamentApp.h
@@ -48,6 +48,7 @@ class MeshAssimp;
Expand Down
9 changes: 1 addition & 8 deletions src/test/fidelity/gltf_renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,6 @@ static void cleanup(Engine* engine, View* view, Scene* scene) {
}

const float FRAMED_HEIGHT = 10.0f;
const float ROOM_PADDING_SCALE = 1.01f;
const float FOV = 45.0f;

static float roomDepth = 0.0f;
Expand Down Expand Up @@ -202,8 +201,6 @@ static void setup(Engine* engine, View* view, Scene* scene) {
float scale = std::min(roomSize.x / modelSize.x, roomSize.y / modelSize.y);
scale = std::min(scale, roomSize.z / modelSize.z);

scale /= ROOM_PADDING_SCALE;

modelCenter *= scale;

float3 center = (roomCenter - modelCenter);
Expand All @@ -213,11 +210,7 @@ static void setup(Engine* engine, View* view, Scene* scene) {
tcm.setTransform(
rooti, mat4f::translation(center) * mat4f::scaling(float3(scale)));

if (modelSize.y >= modelSize.x && modelSize.y >= modelSize.z) {
roomDepth = std::max(modelSize.x, modelSize.z) * scale * ROOM_PADDING_SCALE;
} else {
roomDepth = std::abs(roomSize.z);
}
roomDepth = std::max(modelSize.x, modelSize.z) * scale;

// NOTE(cdata): Leaving these in here for future debugging purposes
/*
Expand Down
8 changes: 4 additions & 4 deletions src/test/three-components/ModelScene-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
import {Matrix4, Mesh, Object3D, SphereBufferGeometry, Vector3} from 'three';

import ModelViewerElementBase, {$canvas} from '../../model-viewer-base.js';
import ModelScene, {ROOM_PADDING_SCALE} from '../../three-components/ModelScene.js';
import ModelScene from '../../three-components/ModelScene.js';
import Renderer from '../../three-components/Renderer.js';
import {assetPath} from '../helpers.js';

Expand Down Expand Up @@ -85,7 +85,7 @@ suite('ModelScene', () => {
const aspect = width / height;
scene.setSize(width, height);

expect(scene.framedHeight).to.be.equal(ROOM_PADDING_SCALE * 10 / aspect);
expect(scene.framedHeight).to.be.equal(10 / aspect);
});

test('scales when Z-bound', () => {
Expand All @@ -97,7 +97,7 @@ suite('ModelScene', () => {
const aspect = width / height;
scene.setSize(width, height);

expect(scene.framedHeight).to.be.equal(ROOM_PADDING_SCALE * 10 / aspect);
expect(scene.framedHeight).to.be.equal(10 / aspect);
});

test('scales when Y-bound', () => {
Expand All @@ -108,7 +108,7 @@ suite('ModelScene', () => {
const height = 1000;
scene.setSize(width, height);

expect(scene.framedHeight).to.be.equal(ROOM_PADDING_SCALE * 10);
expect(scene.framedHeight).to.be.equal(10);
});

test('model is not scaled', () => {
Expand Down
13 changes: 1 addition & 12 deletions src/three-components/ModelScene.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,15 +37,6 @@ export const IlluminationRole: {[index: string]: IlluminationRole} = {
Secondary: 'secondary'
};

// The model is sized to the room, and if too perfect of a fit,
// the front of the model becomes clipped by the near plane. Rather than
// change the near plane or camera's position (if we wanted to implement a
// visible "room" in the future where framing needs to be precise), we shrink
// the room by a little bit so it's always slightly bigger than the model.
// TODO(#527): this description has been incorrect for awhile (this is not
// how the near plane is set) so this should probably be removed for simplicity.
export const ROOM_PADDING_SCALE = 1.01;

const AMBIENT_LIGHT_LOW_INTENSITY = 0.0;
const DIRECTIONAL_LIGHT_LOW_INTENSITY = 2.0;

Expand Down Expand Up @@ -242,9 +233,7 @@ export default class ModelScene extends Scene {
Math.max(modelMaxY - this.target.y, this.target.y - modelMinY);

this.modelDepth = 2 * Math.max(boxHalfX, boxHalfZ);
this.framedHeight = ROOM_PADDING_SCALE *
Math.max(2 * boxHalfY, this.modelDepth / this.aspect);
this.modelDepth *= ROOM_PADDING_SCALE;
this.framedHeight = Math.max(2 * boxHalfY, this.modelDepth / this.aspect);
}
}

Expand Down
Binary file modified test/fidelity/alpha-blend-litmus/filament-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/fidelity/alpha-blend-litmus/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<model-viewer src="../../../examples/assets/alpha-blend-litmus.glb"
camera-orbit="0 90deg auto"
experimental-pmrem
exposure="0.9"
background-image="../../../examples/assets/quick_4k.png"
exposure="0.8"
background-image="../../../examples/assets/lightroom_14b.hdr"
style="width: 768px; height: 768px;">
</model-viewer>
<p>This model demonstrates the alpha blending behavior of a semi-transparent "container" object surrounding several opaque objects.</p>
Expand Down
Binary file modified test/fidelity/alpha-blend-litmus/model-viewer-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fidelity/basic-astronaut/model-viewer-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fidelity/damaged-helmet-hdr-pmrem/filament-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/fidelity/damaged-helmet-hdr-pmrem/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<model-viewer src="../../../examples/assets/DamagedHelmet/DamagedHelmet.gltf"
camera-orbit="0 90deg auto"
background-image="../../../examples/assets/aircraft_workshop_01_4k.hdr"
exposure="0.9"
exposure="0.8"
experimental-pmrem
style="width: 768px; height: 768px;">
</model-viewer>
Expand Down
Binary file modified test/fidelity/damaged-helmet-hdr-pmrem/model-viewer-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion test/fidelity/damaged-helmet-solid-color-pmrem/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<model-viewer src="../../../examples/assets/glTF-Sample-Models/2.0/DamagedHelmet/glTF/DamagedHelmet.gltf"
camera-orbit="0 90deg auto"
background-color="#BEA6CC"
exposure="0.9"
exposure="0.8"
experimental-pmrem
style="width: 768px; height: 768px;">
</model-viewer>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fidelity/khronos-2CylinderEngine/filament-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/fidelity/khronos-2CylinderEngine/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<body>
<model-viewer src="../../../examples/assets/glTF-Sample-Models/2.0/2CylinderEngine/glTF/2CylinderEngine.gltf"
camera-orbit="0 90deg auto"
background-image="../../../examples/assets/pillars_4k.hdr"
exposure="0.9"
background-image="../../../examples/assets/lightroom_14b.hdr"
exposure="0.8"
experimental-pmrem
style="width: 1024px; height: 768px;">
</model-viewer>
Expand Down
Binary file modified test/fidelity/khronos-2CylinderEngine/model-viewer-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/fidelity/khronos-AlphaBlendModeTest/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<body>
<model-viewer src="../../../examples/assets/glTF-Sample-Models/2.0/AlphaBlendModeTest/glTF/AlphaBlendModeTest.gltf"
camera-orbit="0 90deg auto"
background-image="../../../examples/assets/pillars_4k.hdr"
exposure="0.9"
background-image="../../../examples/assets/lightroom_14b.hdr"
exposure="0.8"
experimental-pmrem
style="width: 1024px; height: 768px;">
</model-viewer>
Expand Down
Binary file modified test/fidelity/khronos-AntiqueCamera/filament-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/fidelity/khronos-AntiqueCamera/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<body>
<model-viewer src="../../../examples/assets/glTF-Sample-Models/2.0/AntiqueCamera/glTF/AntiqueCamera.gltf"
camera-orbit="0 90deg auto"
background-image="../../../examples/assets/pillars_4k.hdr"
exposure="0.9"
background-image="../../../examples/assets/lightroom_14b.hdr"
exposure="0.8"
experimental-pmrem
style="width: 512px; height: 1024px;">
</model-viewer>
Expand Down
Binary file modified test/fidelity/khronos-AntiqueCamera/model-viewer-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fidelity/khronos-Avocado/filament-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/fidelity/khronos-Avocado/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<body>
<model-viewer src="../../../examples/assets/glTF-Sample-Models/2.0/Avocado/glTF/Avocado.gltf"
camera-orbit="0 90deg auto"
background-image="../../../examples/assets/pillars_4k.hdr"
exposure="0.9"
background-image="../../../examples/assets/lightroom_14b.hdr"
exposure="0.8"
experimental-pmrem
style="width: 768px; height: 768px;">
</model-viewer>
Expand Down
Binary file modified test/fidelity/khronos-Avocado/model-viewer-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fidelity/khronos-BoomBox/filament-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/fidelity/khronos-BoomBox/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@
<body>
<model-viewer src="../../../examples/assets/glTF-Sample-Models/2.0/BoomBox/glTF/BoomBox.gltf"
camera-orbit="0 90deg auto"
background-image="../../../examples/assets/pillars_4k.hdr"
exposure="0.9"
background-image="../../../examples/assets/lightroom_14b.hdr"
exposure="0.8"
experimental-pmrem
style="width: 768px; height: 768px;">
</model-viewer>
Expand Down
Binary file modified test/fidelity/khronos-BoomBox/model-viewer-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified test/fidelity/khronos-BoxVertexColors/filament-golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4255398

Please sign in to comment.