ShadowTest.bv.lua 5.7 KB

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