DynamicMaterialTest.bv.lua 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. ----------------------------------------------------------------------------------------------------
  2. --
  3. -- Copyright (c) Contributors to the Open 3D Engine Project.
  4. -- For complete copyright and license terms please see the LICENSE at the root of this distribution.
  5. --
  6. -- SPDX-License-Identifier: Apache-2.0 OR MIT
  7. --
  8. --
  9. --
  10. ----------------------------------------------------------------------------------------------------
  11. RunScript("scripts/TestEnvironment.luac")
  12. g_testCaseFolder = 'DynamicMaterialTest'
  13. Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder .. g_testCaseFolder))
  14. OpenSample('RPI/DynamicMaterialTest')
  15. ResizeViewport(1024, 768)
  16. -- We need to lock the frame time to get deterministic timing of the screenshots for consistency between runs
  17. LockFrameTime(1/10)
  18. function SetDefaultLatticeConfiguration()
  19. NoClipCameraController_SetPosition(Vector3(10., -10, 20))
  20. NoClipCameraController_SetHeading(DegToRad(0))
  21. NoClipCameraController_SetPitch(DegToRad(-30))
  22. SetImguiValue('##LatticeWidth', 5)
  23. SetImguiValue('##LatticeHeight', 5)
  24. SetImguiValue('##LatticeDepth', 5)
  25. end
  26. function TakeScreenshotSeries(filenamePrefix)
  27. SelectImageComparisonToleranceLevel("Level H")
  28. -- There could be variation in how long prior activities took so reset the clock for each series of screenshots
  29. SetImguiValue('Reset Clock', true)
  30. IdleFrames(1) -- Consume ImGui changes, to ensure the clock is reset before pausing
  31. -- Note we pause while taking the screenshot so that IO delays won't impact the timing of the sample
  32. SetImguiValue("Pause", true)
  33. IdleFrames(1) -- Give extra time to make sure any material changes are applied, especially in case an asset hot-load causes the material to reinitialize itself.
  34. CaptureScreenshot(g_testCaseFolder .. '/' .. filenamePrefix .. '_A.png')
  35. SetImguiValue("Pause", false)
  36. -- Let the animation run for 1 second
  37. IdleSeconds(1.0)
  38. SetImguiValue("Pause", true)
  39. IdleFrames(1) -- Give extra time to make sure any material changes are applied, especially in case an asset hot-load causes the material to reinitialize itself.
  40. CaptureScreenshot(g_testCaseFolder .. '/' .. filenamePrefix .. '_B.png')
  41. SetImguiValue("Pause", false)
  42. end
  43. SetDefaultLatticeConfiguration()
  44. TakeScreenshotSeries("01_defaultsetup")
  45. NoClipCameraController_SetPosition(Vector3(22, -25, 30))
  46. NoClipCameraController_SetHeading(DegToRad(0))
  47. NoClipCameraController_SetPitch(DegToRad(-9))
  48. SetImguiValue('##LatticeWidth', 10)
  49. SetImguiValue('##LatticeHeight', 10)
  50. SetImguiValue('##LatticeDepth', 6)
  51. TakeScreenshotSeries("02_manyentities")
  52. SetDefaultLatticeConfiguration()
  53. SetImguiValue('Lua Functor Test Material', true)
  54. TakeScreenshotSeries("03_luafunctor")
  55. IdleFrames(1) -- Avoid a "Not all scripted ImGui actions were consumed" error message for the last "Pause" command
  56. UnlockFrameTime()
  57. OpenSample(nil)