CreateShaderVariantListDocumentFromShader.py 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. """
  2. Copyright (c) Contributors to the Open 3D Engine Project.
  3. For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. import os
  7. import sys
  8. import GenerateShaderVariantListUtil
  9. def main():
  10. print("==== Begin shader variant script ==========================================================")
  11. if len(sys.argv) != 2:
  12. print("The script requires a .shader file as input argument")
  13. return
  14. inputPath = sys.argv[1]
  15. _, extension = os.path.splitext(inputPath)
  16. if extension != ".shader":
  17. print("The input argument for the script is not a valid .shader file")
  18. return
  19. # Create shader variant list document
  20. documentId = azlmbr.atomtools.AtomToolsDocumentSystemRequestBus(
  21. azlmbr.bus.Broadcast,
  22. 'CreateDocumentFromTypeName',
  23. 'Shader Variant List'
  24. )
  25. # Update shader variant list
  26. azlmbr.shadermanagementconsole.ShaderManagementConsoleDocumentRequestBus(
  27. azlmbr.bus.Event,
  28. 'SetShaderVariantListSourceData',
  29. documentId,
  30. GenerateShaderVariantListUtil.create_shadervariantlist_for_shader(inputPath)
  31. )
  32. print("==== End shader variant script ============================================================")
  33. if __name__ == "__main__":
  34. main()