ShadowTest.bv.lua 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. function EnablePositionalLights()
  13. SetImguiValue('Red', true)
  14. SetImguiValue('Intensity##Positional', 500.0)
  15. IdleFrames(1)
  16. SetImguiValue('Green', true)
  17. SetImguiValue('Height##Positional', 4.0)
  18. SetImguiValue('Intensity##Positional', 400.0)
  19. IdleFrames(1)
  20. SetImguiValue('Blue', true)
  21. SetImguiValue('Intensity##Positional', 500.0)
  22. IdleFrames(1)
  23. end
  24. function DisablePositionalLights()
  25. SetImguiValue('Red', true)
  26. SetImguiValue('Intensity##Positional', 0.0)
  27. IdleFrames(1)
  28. SetImguiValue('Green', true)
  29. SetImguiValue('Intensity##Positional', 0.0)
  30. IdleFrames(1)
  31. SetImguiValue('Blue', true)
  32. SetImguiValue('Intensity##Positional', 0.0)
  33. end
  34. function TestDirectionalLight()
  35. DisablePositionalLights()
  36. -- Set Camera
  37. ArcBallCameraController_SetHeading(DegToRad(90.0))
  38. ArcBallCameraController_SetPitch(DegToRad(-45.0))
  39. ArcBallCameraController_SetDistance(6.0)
  40. ArcBallCameraController_SetPan(Vector3(0.9, 2.4, -1.0))
  41. -- Set quality highest
  42. SetImguiValue('Size##Directional', '2048')
  43. SetImguiValue('4', true) -- cascade count
  44. IdleFrames(1)
  45. CaptureScreenshot(g_testCaseFolder .. '/directional_initial.png')
  46. -- Directional Light Manual Cascade Split
  47. SetImguiValue('Debug Coloring', true)
  48. SetImguiValue('Automatic Cascade Split', false)
  49. IdleFrames(1)
  50. SetImguiValue('FarDepth 0', 3.0)
  51. IdleFrames(1)
  52. SetImguiValue('FarDepth 1', 5.0)
  53. IdleFrames(1)
  54. SetImguiValue('FarDepth 2', 6.0)
  55. IdleFrames(1)
  56. CaptureScreenshot(g_testCaseFolder .. '/directional_manual_cascade.png')
  57. -- Directional Light Automatic Cascade Split
  58. SetImguiValue('Automatic Cascade Split', true)
  59. IdleFrames(1)
  60. SetImguiValue('Ratio', 0.25)
  61. IdleFrames(1)
  62. CaptureScreenshot(g_testCaseFolder .. '/directional_auto_cascade.png')
  63. -- Directional Light Cascade Position Correction
  64. SetImguiValue('Cascade Position Correction', true)
  65. IdleFrames(1)
  66. CaptureScreenshot(g_testCaseFolder .. '/directional_cascade_correction.png')
  67. SetImguiValue('Cascade Position Correction', false)
  68. -- Directional Light Cascade Position Correction
  69. SetImguiValue('Use Fullscreen Blur', true)
  70. IdleFrames(1)
  71. CaptureScreenshot(g_testCaseFolder .. '/directional_fullscreen_blur.png')
  72. SetImguiValue('Use Fullscreen Blur', false)
  73. -- Directional Light PCF low
  74. SetImguiValue('Debug Coloring', false)
  75. SetImguiValue('Filter Method##Directional', 'PCF')
  76. SetImguiValue('Filtering # ##Directional', 4)
  77. IdleFrames(1)
  78. CaptureScreenshot(g_testCaseFolder .. '/directional_pcf_low.png')
  79. -- Directional Light PCF high
  80. SetImguiValue('Filtering # ##Directional', 64)
  81. IdleFrames(1)
  82. CaptureScreenshot(g_testCaseFolder .. '/directional_pcf_high.png')
  83. -- Directional Light ESM
  84. SetImguiValue('Filter Method##Directional', 'ESM')
  85. IdleFrames(1)
  86. CaptureScreenshot(g_testCaseFolder .. '/directional_esm.png')
  87. -- Directional Light ESM+PCF
  88. SetImguiValue('Filter Method##Directional', 'ESM+PCF')
  89. IdleFrames(1)
  90. CaptureScreenshot(g_testCaseFolder .. '/directional_esm_pcf.png')
  91. end
  92. function TestDiskLights()
  93. SetImguiValue('Disk', true)
  94. IdleFrames(1)
  95. -- Disabling directional light
  96. SetImguiValue('Intensity##Directional', 0.0)
  97. EnablePositionalLights()
  98. CaptureScreenshot(g_testCaseFolder .. '/spot_initial.png')
  99. -- Positional Light Disabling Shadow for Red
  100. SetImguiValue('Red', true)
  101. SetImguiValue('Enable Shadow', false)
  102. IdleFrames(1)
  103. CaptureScreenshot(g_testCaseFolder .. '/spot_no_red_shadow.png')
  104. -- Positional Light Various Shadowmap Sizes
  105. SetImguiValue('Red', true)
  106. SetImguiValue('Enable Shadow', true)
  107. IdleFrames(1)
  108. SetImguiValue('Size##Positional', '2048')
  109. IdleFrames(1)
  110. SetImguiValue('Green', true)
  111. SetImguiValue('Size##Positional', '1024')
  112. IdleFrames(1)
  113. SetImguiValue('Blue', true)
  114. SetImguiValue('Size##Positional', '512')
  115. IdleFrames(1)
  116. CaptureScreenshot(g_testCaseFolder .. '/spot_shadowmap_size.png')
  117. -- Positional Light Various Filter Methods
  118. SetImguiValue('Red', true)
  119. SetImguiValue('Filter Method##Positional', 'PCF')
  120. IdleFrames(1)
  121. SetImguiValue('Filtering # ##Positional', 64)
  122. IdleFrames(1)
  123. SetImguiValue('Green', true)
  124. SetImguiValue('Filter Method##Positional', 'ESM')
  125. IdleFrames(1)
  126. IdleFrames(1)
  127. SetImguiValue('Blue', true)
  128. SetImguiValue('Filter Method##Positional', 'ESM+PCF')
  129. IdleFrames(1)
  130. SetImguiValue('Filtering # ##Positional', 64)
  131. IdleFrames(1)
  132. CaptureScreenshot(g_testCaseFolder .. '/spot_filter_method.png')
  133. end
  134. function TestPointLights()
  135. SetImguiValue('Point', true)
  136. IdleFrames(1)
  137. SetImguiValue('Intensity##Directional', 0.0)
  138. IdleFrames(1)
  139. EnablePositionalLights()
  140. CaptureScreenshot(g_testCaseFolder .. '/point_lights.png')
  141. end
  142. g_testCaseFolder = 'Shadow'
  143. Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder .. g_testCaseFolder))
  144. OpenSample('Features/Shadow')
  145. ResizeViewport(800, 600)
  146. SelectImageComparisonToleranceLevel("Level H")
  147. SetImguiValue('Auto Rotation##Directional', false)
  148. SetImguiValue('Auto Rotation##Positional', false)
  149. -- Initial
  150. SetImguiValue('Direction##Directional', 0.0)
  151. SetImguiValue('Base Direction##Positional', 0.0)
  152. IdleFrames(1)
  153. CaptureScreenshot(g_testCaseFolder .. '/initial.png')
  154. TestDirectionalLight()
  155. TestPointLights()
  156. TestDiskLights()
  157. OpenSample(nil)