2
0

tools.rst 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. Tools
  2. =====
  3. Geometry Compiler (geometryc)
  4. -----------------------------
  5. Converts Wavefront .obj, or glTF 2.0 mesh file to format optimal for using with bgfx.
  6. Usage::
  7. geometryc -f <in> -o <out>
  8. Supported input file formats:
  9. ====== ============================
  10. Format Description
  11. ====== ============================
  12. .obj Wavefront
  13. .gltf glTF 2.0
  14. .glb glTF 2.0
  15. ====== ============================
  16. Options:
  17. -h, --help Help.
  18. -v, --version Version information only.
  19. -f <file path> Input file path.
  20. -o <file path> Output file path.
  21. -s, --scale <num> Scale factor.
  22. --ccw Front face is counter-clockwise winding order.
  23. --flipv Flip texture coordinate V.
  24. --obb <num> Number of steps for calculating oriented bounding box.
  25. Default value is 17. Less steps less precise OBB is.
  26. More steps slower calculation.
  27. --packnormal <num> Normal packing.
  28. 0 - unpacked 12 bytes (default).
  29. 1 - packed 4 bytes.
  30. --packuv <num> Texture coordinate packing.
  31. 0 - unpacked 8 bytes (default).
  32. 1 - packed 4 bytes.
  33. --tangent Calculate tangent vectors (packing mode is the same as normal).
  34. --barycentric Adds barycentric vertex attribute (packed in bgfx::Attrib::Color1).
  35. -c, --compress Compress indices.
  36. --[l/r]h-up+[y/z] Coordinate system. Default is '--lh-up+y' Left-Handed +Y is up.
  37. Geometry Viewer (geometryv)
  38. ---------------------------
  39. Geometry viewer.
  40. Shader Compiler (shaderc)
  41. -------------------------
  42. bgfx cross-platform shader language is based on GLSL syntax. It's uses
  43. ANSI C preprocessor to transform GLSL like language syntax into HLSL.
  44. This technique has certain drawbacks, but overall it's simple and allows
  45. quick authoring of cross-platform shaders.
  46. Some differences between bgfx's shaderc flavor of GLSL and regular GLSL:
  47. - No ``bool/int`` uniforms, all uniforms must be ``float``.
  48. - Attributes and varyings can be accessed only from ``main()``
  49. function.
  50. - Must use ``SAMPLER2D/3D/CUBE/etc.`` macros instead of
  51. ``sampler2D/3D/Cube/etc.`` tokens.
  52. - Must use ``vec2/3/4_splat(<value>)`` instead of
  53. ``vec2/3/4(<value>)``.
  54. - Must use ``mtxFromCols/mtxFromRows`` when constructing matrices in shaders.
  55. - Must use ``mul(x, y)`` when multiplying vectors and matrices.
  56. - Must use ``varying.def.sc`` to define input/output semantic and
  57. precission instead of using ``attribute/in`` and ``varying/in/out``.
  58. - ``$input/$output`` tokens must appear at the begining of shader.
  59. For more info see `shader helper
  60. macros <https://github.com/bkaradzic/bgfx/blob/master/src/bgfx_shader.sh>`__.
  61. Options:
  62. -h, --help Help.
  63. -v, --version Version information only.
  64. -f <file path> Input file path.
  65. -i <include path> Include path (for multiple paths use -i multiple times).
  66. -o <file path> Output file path.
  67. --bin2c <array name> Generate C header file. If array name is not specified base file name will be used as name.
  68. --depends Generate makefile style depends file.
  69. --platform <platform> Target platform.
  70. -p, --profile <profile> Shader model (default GLSL).
  71. --preprocess Preprocess only.
  72. --define <defines> Add defines to preprocessor (semicolon separated).
  73. --raw Do not process shader. No preprocessor, and no glsl-optimizer (GLSL only).
  74. --type <type> Shader type (vertex, fragment, compute)
  75. --varyingdef <file path> Path to varying.def.sc file.
  76. --verbose Verbose.
  77. Options (DX9 and DX11 only):
  78. --debug Debug information.
  79. --disasm Disassemble compiled shader.
  80. -O <level> Optimization level (0, 1, 2, 3).
  81. --Werror Treat warnings as errors.
  82. Building shaders
  83. ~~~~~~~~~~~~~~~~
  84. Shaders must be compiled for all renderers by using `shaderc` tool. Makefile to simplify building
  85. shaders is provided in examples. D3D shaders can be only compiled on Windows.
  86. Texture Compiler (texturec)
  87. ---------------------------
  88. Convert PNG, TGA, DDS, KTX, PVR texture into bgfx supported texture formats.
  89. Usage::
  90. texturec -f <in> -o <out> [-t <texture format>]
  91. Supported file formats:
  92. ====== ================ ============================
  93. Format In/Out Description
  94. ====== ================ ============================
  95. .bmp (input) Windows Bitmap.
  96. .dds (input, output) Direct Draw Surface.
  97. .exr (input, output) OpenEXR.
  98. .gif (input) Graphics Interchange Format.
  99. .jpg (input) JPEG Interchange Format.
  100. .hdr (input, output) Radiance RGBE.
  101. .ktx (input, output) Khronos Texture.
  102. .png (input, output) Portable Network Graphics.
  103. .psd (input) Photoshop Document.
  104. .pvr (input) PowerVR.
  105. .tga (input) Truevision TGA.
  106. ====== ================ ============================
  107. Options:
  108. -h, --help Help.
  109. -v, --version Version information only.
  110. -f <file path> Input file path.
  111. -o <file path> Output file path.
  112. -t <format> Output format type (BC1/2/3/4/5, ETC1, PVR14, etc.).
  113. -q <quality> Encoding quality (default, fastest, highest).
  114. -m, --mips Generate mip-maps.
  115. --mipskip <N> Skip <N> number of mips.
  116. -n, --normalmap Input texture is normal map. (Implies --linear)
  117. --equirect Input texture is equirectangular projection of cubemap.
  118. --strip Input texture is horizontal strip of cubemap.
  119. --sdf Compute SDF texture.
  120. --ref <alpha> Alpha reference value.
  121. --iqa Image Quality Assessment
  122. --pma Premultiply alpha into RGB channel.
  123. --linear Input and output texture is linear color space (gamma correction won't be applied).
  124. --max <max size> Maximum width/height (image will be scaled down and aspect ratio will be preserved).
  125. --radiance <model> Radiance cubemap filter. (Lighting model: Phong, PhongBrdf, Blinn, BlinnBrdf, GGX)
  126. --as <extension> Save as.
  127. --formats List all supported formats.
  128. --validate **DEBUG** Validate that output image produced matches after loading.
  129. Texture Viewer (texturev)
  130. -------------------------
  131. Texture viewer.