DynamicMaterialTest.bv.lua 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. g_screenshotOutputFolder = ResolvePath('@user@/Scripts/Screenshots/DynamicMaterialTest/')
  12. Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder))
  13. OpenSample('RPI/DynamicMaterialTest')
  14. ResizeViewport(1024, 768)
  15. -- We need to lock the frame time to get deterministic timing of the screenshots for consistency between runs
  16. LockFrameTime(1/10)
  17. function SetDefaultLatticeConfiguration()
  18. NoClipCameraController_SetPosition(Vector3(10., -10, 20))
  19. NoClipCameraController_SetHeading(DegToRad(0))
  20. NoClipCameraController_SetPitch(DegToRad(-30))
  21. SetImguiValue('##LatticeWidth', 5)
  22. SetImguiValue('##LatticeHeight', 5)
  23. SetImguiValue('##LatticeDepth', 5)
  24. end
  25. function TakeScreenshotSeries(filenamePrefix)
  26. SelectImageComparisonToleranceLevel("Level H")
  27. -- There could be variation in how long prior activities took so reset the clock for each series of screenshots
  28. SetImguiValue('Reset Clock', true)
  29. IdleFrames(1) -- Consume ImGui changes, to ensure the clock is reset before pausing
  30. -- Note we pause while taking the screenshot so that IO delays won't impact the timing of the sample
  31. SetImguiValue("Pause", true)
  32. 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.
  33. CaptureScreenshot(g_screenshotOutputFolder .. filenamePrefix .. '_A.png')
  34. SetImguiValue("Pause", false)
  35. -- Let the animation run for 1 second
  36. IdleSeconds(1.0)
  37. SetImguiValue("Pause", true)
  38. 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.
  39. CaptureScreenshot(g_screenshotOutputFolder .. filenamePrefix .. '_B.png')
  40. SetImguiValue("Pause", false)
  41. end
  42. SetDefaultLatticeConfiguration()
  43. TakeScreenshotSeries("01_defaultsetup")
  44. NoClipCameraController_SetPosition(Vector3(22, -25, 30))
  45. NoClipCameraController_SetHeading(DegToRad(0))
  46. NoClipCameraController_SetPitch(DegToRad(-9))
  47. SetImguiValue('##LatticeWidth', 10)
  48. SetImguiValue('##LatticeHeight', 10)
  49. SetImguiValue('##LatticeDepth', 6)
  50. TakeScreenshotSeries("02_manyentities")
  51. SetDefaultLatticeConfiguration()
  52. SetImguiValue('Lua Functor Test Material', true)
  53. TakeScreenshotSeries("03_luafunctor")
  54. IdleFrames(1) -- Avoid a "Not all scripted ImGui actions were consumed" error message for the last "Pause" command
  55. UnlockFrameTime()
  56. OpenSample(nil)