AreaLightTest.bv.lua 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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 SetupPointLights()
  13. SetImguiValue('AreaLightSample/LightType/Point', true)
  14. SetImguiValue('AreaLightSample/Position Offset', Vector3(0.0, 0.0, 0.0))
  15. SetImguiValue('AreaLightSample/Radius', 1.0)
  16. end
  17. function SetupDiskLights()
  18. SetImguiValue('AreaLightSample/LightType/Disk', true)
  19. SetImguiValue('AreaLightSample/Position Offset', Vector3(0.0, 0.0, 0.0))
  20. SetImguiValue('AreaLightSample/Radius', 1.0)
  21. SetImguiValue('AreaLightSample/X rotation', -1.5)
  22. SetImguiValue('AreaLightSample/Y rotation', -0.125)
  23. end
  24. function SetupCapsuleLights()
  25. SetImguiValue('AreaLightSample/LightType/Capsule', true)
  26. SetImguiValue('AreaLightSample/Position Offset', Vector3(0.0, 0.0, 0.0))
  27. SetImguiValue('AreaLightSample/Radius', 0.5)
  28. SetImguiValue('AreaLightSample/Capsule Height', 2.0)
  29. SetImguiValue('AreaLightSample/Y rotation', -3.25)
  30. SetImguiValue('AreaLightSample/X rotation', -0.75)
  31. end
  32. function SetupQuadLights()
  33. SetImguiValue('AreaLightSample/LightType/Quad', true)
  34. SetImguiValue('AreaLightSample/Position Offset', Vector3(0.0, 0.0, 0.0))
  35. SetImguiValue('AreaLightSample/Emit Both Directions', false)
  36. SetImguiValue('AreaLightSample/Quad Dimensions', Vector2(1.0, 3.0))
  37. SetImguiValue('AreaLightSample/X rotation', 1.4)
  38. SetImguiValue('AreaLightSample/Y rotation', -2.25)
  39. SetImguiValue('AreaLightSample/Z rotation', -0.25)
  40. SetImguiValue('AreaLightSample/Use Fast Approximation', false)
  41. end
  42. function SetupQuadLightsDoubleSided()
  43. SetImguiValue('AreaLightSample/LightType/Quad', true)
  44. SetImguiValue('AreaLightSample/Position Offset', Vector3(0.0, -0.5, -1.25))
  45. SetImguiValue('AreaLightSample/Emit Both Directions', true)
  46. SetImguiValue('AreaLightSample/Quad Dimensions', Vector2(1.5, 0.6))
  47. SetImguiValue('AreaLightSample/X rotation', -1.45)
  48. SetImguiValue('AreaLightSample/Y rotation', -0.5)
  49. SetImguiValue('AreaLightSample/Z rotation', 0.85)
  50. SetImguiValue('AreaLightSample/Use Fast Approximation', false)
  51. end
  52. function SetupPolygonLights()
  53. SetImguiValue('AreaLightSample/LightType/Polygon', true)
  54. SetImguiValue('AreaLightSample/Position Offset', Vector3(0.0, 0.0, 0.0))
  55. SetImguiValue('AreaLightSample/Emit Both Directions', false)
  56. SetImguiValue('AreaLightSample/Star Points', 5)
  57. SetImguiValue('AreaLightSample/Star Min-Max Radius', Vector2(0.5, 1.0))
  58. SetImguiValue('AreaLightSample/X rotation', 0.5)
  59. SetImguiValue('AreaLightSample/Y rotation', -0.25)
  60. SetImguiValue('AreaLightSample/Z rotation', 0.75)
  61. end
  62. function SetupPolygonLightsDoubleSided()
  63. SetImguiValue('AreaLightSample/LightType/Polygon', true)
  64. SetImguiValue('AreaLightSample/Position Offset', Vector3(0.0, -0.5, -1.25))
  65. SetImguiValue('AreaLightSample/Emit Both Directions', true)
  66. SetImguiValue('AreaLightSample/Star Points', 32)
  67. SetImguiValue('AreaLightSample/Star Min-Max Radius', Vector2(0.5, 0.75))
  68. SetImguiValue('AreaLightSample/X rotation', -1.45)
  69. SetImguiValue('AreaLightSample/Y rotation', -0.5)
  70. SetImguiValue('AreaLightSample/Z rotation', 0.85)
  71. end
  72. function SetupQuadLightsApprox()
  73. SetupQuadLights()
  74. SetImguiValue('AreaLightSample/Use Fast Approximation', true)
  75. end
  76. function SetupQuadLightsDoubleSidedApprox()
  77. SetupQuadLightsDoubleSided()
  78. SetImguiValue('AreaLightSample/Use Fast Approximation', true)
  79. end
  80. function VaryRoughnessOnly()
  81. SetImguiValue('AreaLightSample/Vary Metallic Across Models', false)
  82. SetImguiValue('AreaLightSample/Vary Roughness Across Models', true)
  83. SetImguiValue('AreaLightSample/Min Max Roughness', Vector2(0.0, 1.0))
  84. end
  85. function VaryRoughnessNonMetallic()
  86. VaryRoughnessOnly()
  87. SetImguiValue('AreaLightSample/Metallic', 0.0)
  88. end
  89. function VaryRoughnessMetallic()
  90. VaryRoughnessOnly()
  91. SetImguiValue('AreaLightSample/Metallic', 1.0)
  92. end
  93. function VaryMetallicOnly()
  94. SetImguiValue('AreaLightSample/Vary Roughness Across Models', false)
  95. SetImguiValue('AreaLightSample/Vary Metallic Across Models', true)
  96. SetImguiValue('AreaLightSample/Roughness', 0.5)
  97. SetImguiValue('AreaLightSample/Min Max Metallic', Vector2(0.0, 1.0))
  98. end
  99. g_testCaseFolder = 'AreaLights'
  100. Print('Saving screenshots to ' .. NormalizePath(g_screenshotOutputFolder .. g_testCaseFolder))
  101. SelectImageComparisonToleranceLevel("Level E")
  102. OpenSample('Features/AreaLight')
  103. ResizeViewport(1600, 400)
  104. NoClipCameraController_SetPosition(Vector3(0.0, 0.0, 0.0))
  105. NoClipCameraController_SetFov(DegToRad(40.0))
  106. SetImguiValue('AreaLightSample/Count', 10)
  107. -- Make sure material / model has had a chance to load
  108. IdleSeconds(0.1)
  109. lightSetups =
  110. {
  111. point = SetupPointLights,
  112. disk = SetupDiskLights,
  113. capsule = SetupCapsuleLights,
  114. quad = SetupQuadLights,
  115. quad_double_sided = SetupQuadLightsDoubleSided,
  116. quad_approx = SetupQuadLightsApprox,
  117. quad_double_sided_approx = SetupQuadLightsDoubleSidedApprox,
  118. polygon = SetupPolygonLights,
  119. polygon_double_sided = SetupPolygonLightsDoubleSided,
  120. }
  121. materialSetups =
  122. {
  123. vary_rough_nonmetal = VaryRoughnessNonMetallic,
  124. vary_rough_metal = VaryRoughnessMetallic,
  125. vary_metal = VaryMetallicOnly,
  126. }
  127. -- Loop through all light setups and material setups taking screenshots.
  128. for lightName, lightSetupFunction in pairs(lightSetups)
  129. do
  130. lightSetupFunction()
  131. for materialName, materialSetupFunction in pairs(materialSetups)
  132. do
  133. materialSetupFunction()
  134. IdleFrames(1)
  135. CaptureScreenshot(g_testCaseFolder .. '/' .. lightName .. '_' .. materialName ..'.png')
  136. end
  137. end
  138. OpenSample(nil)