ParallaxTest.bv.lua 6.8 KB

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