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