ParallaxTest.bv.lua 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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 = 'ParallaxTest'
  13. Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder .. g_testCaseFolder))
  14. OpenSample('Features/Parallax')
  15. ResizeViewport(1600, 900)
  16. SelectImageComparisonToleranceLevel("Level I")
  17. -- Test with PDO off...
  18. SetImguiValue('Lighting/Auto Rotation', false)
  19. SetImguiValue('Lighting/Direction', DegToRad(110))
  20. SetImguiValue('Parallax Setting/Heightmap Scale', 0.05)
  21. SetImguiValue('Parallax Setting/Enable Pdo', false)
  22. IdleFrames(2)
  23. CaptureScreenshot(g_testCaseFolder .. '/screenshot_1.png')
  24. -- Test alternate UV streams...
  25. -- Purpose of 2 shots
  26. -- First: regression test verifying using the 2nd UV is stable
  27. -- Second: diff test that compares UV0 (direct tangent) to UV1 (generated tangent), UV values are the same
  28. -- Because we don't have the ability to pick the image we want to compare so far,
  29. -- the expected image of the second test is copied from screenshot_1.png
  30. SetImguiValue('Parallax Setting/UV', "UV1")
  31. IdleFrames(2)
  32. CaptureScreenshot(g_testCaseFolder .. '/screenshot_2ndUv_1.png')
  33. CaptureScreenshot(g_testCaseFolder .. '/screenshot_2ndUv_2.png')
  34. SetImguiValue('Parallax Setting/UV', "UV0")
  35. -- Test with PDO on, also Plane rotated...
  36. SetImguiValue('Parallax Setting/Enable Pdo', true)
  37. SetImguiValue('Plane Setting/Rotation', DegToRad(45))
  38. IdleFrames(1)
  39. CaptureScreenshot(g_testCaseFolder .. '/screenshot_2.png')
  40. -- Algorithm "Relief", also Directional Light at 120 degrees and uv parameters changed
  41. ArcBallCameraController_SetHeading(DegToRad(120))
  42. SetImguiValue('Parallax Setting/Algorithm', "Relief")
  43. SetImguiValue('Plane Setting/Center U', 0.8)
  44. SetImguiValue('Plane Setting/Center V', 0.4)
  45. SetImguiValue('Plane Setting/Tile U', 1.5)
  46. SetImguiValue('Plane Setting/Tile V', 1.8)
  47. SetImguiValue('Plane Setting/Offset U', 0.5)
  48. SetImguiValue('Plane Setting/Offset V', 0.6)
  49. SetImguiValue('Plane Setting/Rotation UV', 275)
  50. SetImguiValue('Plane Setting/Scale UV', 0.6)
  51. IdleFrames(1)
  52. CaptureScreenshot(g_testCaseFolder .. '/screenshot_3.png')
  53. -- Algorithm Contact Refinement, also Directional Light at 240 degrees with uv parameters changed again
  54. ArcBallCameraController_SetHeading(DegToRad(240))
  55. SetImguiValue('Parallax Setting/Algorithm', "ContactRefinement")
  56. SetImguiValue('Plane Setting/Center U', -0.5)
  57. SetImguiValue('Plane Setting/Center V', -0.4)
  58. SetImguiValue('Plane Setting/Tile U', 0.9)
  59. SetImguiValue('Plane Setting/Tile V', 0.8)
  60. SetImguiValue('Plane Setting/Offset U', -0.8)
  61. SetImguiValue('Plane Setting/Offset V', -0.6)
  62. SetImguiValue('Plane Setting/Rotation UV', 138)
  63. SetImguiValue('Plane Setting/Scale UV', 1.6)
  64. IdleFrames(1)
  65. CaptureScreenshot(g_testCaseFolder .. '/screenshot_4.png')
  66. -- Algorithm "POM", switch to Spot Light 0 degree, also Plate rotated again
  67. ArcBallCameraController_SetHeading(DegToRad(0))
  68. SetImguiValue('Lighting/Spot Light', true)
  69. SetImguiValue('Parallax Setting/Algorithm', "POM")
  70. SetImguiValue('Plane Setting/Rotation', DegToRad(135))
  71. IdleFrames(1)
  72. CaptureScreenshot(g_testCaseFolder .. '/screenshot_5.png')
  73. -- Algorithm "Relief", also Spot Light rotated with uv parameters changed again
  74. ArcBallCameraController_SetHeading(DegToRad(120))
  75. SetImguiValue('Parallax Setting/Algorithm', "Relief")
  76. SetImguiValue('Plane Setting/Center U', -0.8)
  77. SetImguiValue('Plane Setting/Center V', -0.7)
  78. SetImguiValue('Plane Setting/Tile U', 1.1)
  79. SetImguiValue('Plane Setting/Tile V', 0.9)
  80. SetImguiValue('Plane Setting/Offset U', 0.3)
  81. SetImguiValue('Plane Setting/Offset V', 0.2)
  82. SetImguiValue('Plane Setting/Rotation UV', 125)
  83. SetImguiValue('Plane Setting/Scale UV', 0.3)
  84. IdleFrames(1)
  85. CaptureScreenshot(g_testCaseFolder .. '/screenshot_6.png')
  86. -- Algorithm "Contact Refinement" Spot Light rotated again, with uv parameter changed again
  87. ArcBallCameraController_SetHeading(DegToRad(240))
  88. SetImguiValue('Parallax Setting/Algorithm', "ContactRefinement")
  89. SetImguiValue('Plane Setting/Center U', 0.1)
  90. SetImguiValue('Plane Setting/Center V', 0.6)
  91. SetImguiValue('Plane Setting/Tile U', 1.3)
  92. SetImguiValue('Plane Setting/Tile V', 1.2)
  93. SetImguiValue('Plane Setting/Offset U', -0.5)
  94. SetImguiValue('Plane Setting/Offset V', -0.3)
  95. SetImguiValue('Plane Setting/Rotation UV', 74)
  96. SetImguiValue('Plane Setting/Scale UV', 1.3)
  97. IdleFrames(1)
  98. CaptureScreenshot(g_testCaseFolder .. '/screenshot_7.png')
  99. -- Test offset
  100. ArcBallCameraController_SetHeading(DegToRad(-135))
  101. ArcBallCameraController_SetPitch(DegToRad(-25))
  102. SetImguiValue('Lighting/Directional Light', true)
  103. SetImguiValue('Lighting/Direction', DegToRad(350))
  104. SetImguiValue('Parallax Setting/Heightmap Scale', 0.1)
  105. SetImguiValue('Parallax Setting/Offset', -0.1)
  106. IdleFrames(1)
  107. CaptureScreenshot(g_testCaseFolder .. '/screenshot_8_offset.png')
  108. -- Test offset clipping
  109. ArcBallCameraController_SetPitch(DegToRad(-15)) -- Use a harsh angle as that could reveal artifacts we've seen in the past and fixed.
  110. SetImguiValue('Parallax Setting/Offset', 0.05)
  111. SetImguiValue('Parallax Setting/Show Clipping', true)
  112. IdleFrames(1)
  113. CaptureScreenshot(g_testCaseFolder .. '/screenshot_9_offsetClipping.png')
  114. -- Testing a specific case where offset clamping was not calculated correctly, and clamped a bit below the surface instead of right on the surface.
  115. SetImguiValue('Parallax Setting/Offset', 0.06)
  116. SetImguiValue('Parallax Setting/Heightmap Scale', 0.1)
  117. SetImguiValue('Parallax Setting/Algorithm', "Steep")
  118. SetImguiValue('Parallax Setting/Show Clipping', true)
  119. CaptureScreenshot(g_testCaseFolder .. '/screenshot_10_offsetClippingSteep.png')
  120. -- Test some different combinations that might result in divide-by-0 related crashes (which did happen at one point)
  121. SetImguiValue('Parallax Setting/Offset', 0.0)
  122. IdleFrames(1)
  123. SetImguiValue('Parallax Setting/Heightmap Scale', 0.01)
  124. IdleFrames(1)
  125. SetImguiValue('Parallax Setting/Heightmap Scale', 0.0)
  126. IdleFrames(1)
  127. SetImguiValue('Parallax Setting/Offset', 0.01)
  128. IdleFrames(1)
  129. SetImguiValue('Parallax Setting/Offset', -0.01)
  130. IdleFrames(1)
  131. ArcBallCameraController_SetPitch(DegToRad(0))
  132. IdleFrames(1)
  133. -- Testing a specific camera and light angle that caused almost all geometry to render as black
  134. OpenSample('Features/Parallax') -- Reset the sample
  135. SetImguiValue('Lighting/Auto Rotation', false)
  136. SetImguiValue('Lighting/Direction', 1.18682396)
  137. ArcBallCameraController_SetHeading(1.95481825)
  138. ArcBallCameraController_SetPitch(-0.169443831)
  139. ArcBallCameraController_SetDistance(6.000000)
  140. IdleFrames(1)
  141. CaptureScreenshot(g_testCaseFolder .. '/screenshot_11_problematicAngle.png')
  142. OpenSample(nil)