2022-04-01 05:22:38 +03:00
|
|
|
|
Tools
|
|
|
|
|
=====
|
|
|
|
|
|
|
|
|
|
Geometry Compiler (geometryc)
|
|
|
|
|
-----------------------------
|
|
|
|
|
|
2022-04-04 22:57:00 +03:00
|
|
|
|
Converts Wavefront .obj, or glTF 2.0 mesh files to a format which is optimized for use with bgfx.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
|
|
|
|
Usage::
|
|
|
|
|
|
|
|
|
|
geometryc -f <in> -o <out>
|
|
|
|
|
|
|
|
|
|
Supported input file formats:
|
|
|
|
|
|
|
|
|
|
====== ============================
|
|
|
|
|
Format Description
|
|
|
|
|
====== ============================
|
|
|
|
|
.obj Wavefront
|
|
|
|
|
.gltf glTF 2.0
|
|
|
|
|
.glb glTF 2.0
|
|
|
|
|
====== ============================
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
2022-04-04 22:57:00 +03:00
|
|
|
|
-h, --help Display this help and exit.
|
|
|
|
|
-v, --version Output version information and exit.
|
2022-04-06 14:30:18 +03:00
|
|
|
|
-f <file path> Input's file path.
|
|
|
|
|
-o <file path> Output's file path.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
-s, --scale <num> Scale factor.
|
2022-09-02 18:10:33 +03:00
|
|
|
|
|
|
|
|
|
--ccw Front face is counter-clockwise winding order.
|
|
|
|
|
|
|
|
|
|
--flipv Flip texture coordinate V.
|
|
|
|
|
|
|
|
|
|
--obb <num> | Number of steps for calculating oriented bounding box.
|
|
|
|
|
| Defaults to 17.
|
|
|
|
|
| Less steps = less precise OBB.
|
|
|
|
|
| More steps = slower calculation.
|
|
|
|
|
|
|
|
|
|
--packnormal <num> | Normal packing.
|
|
|
|
|
| 0 - unpacked 12 bytes. (default)
|
|
|
|
|
| 1 - packed 4 bytes.
|
|
|
|
|
|
|
|
|
|
--packuv <num> | Texture coordinate packing.
|
|
|
|
|
| 0 - unpacked 8 bytes. (default)
|
|
|
|
|
| 1 - packed 4 bytes.
|
|
|
|
|
|
|
|
|
|
--tangent Calculate tangent vectors. (packing mode is the same as normal)
|
|
|
|
|
|
|
|
|
|
--barycentric Adds barycentric vertex attribute. (Packed in bgfx::Attrib::Color1)
|
|
|
|
|
|
2022-04-01 05:22:38 +03:00
|
|
|
|
-c, --compress Compress indices.
|
2022-09-02 18:10:33 +03:00
|
|
|
|
|
2022-04-06 14:30:18 +03:00
|
|
|
|
--[l/r]h-up+[y/z] Coordinate system. Defaults to '--lh-up+y' — Left-Handed +Y is up.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
|
|
|
|
Geometry Viewer (geometryv)
|
|
|
|
|
---------------------------
|
|
|
|
|
|
2022-04-04 22:57:00 +03:00
|
|
|
|
A geometry viewer.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
|
|
|
|
Shader Compiler (shaderc)
|
|
|
|
|
-------------------------
|
|
|
|
|
|
2022-04-04 22:57:00 +03:00
|
|
|
|
Shader Compiler is used to compile bgfx's cross-platform shader language, which based on GLSL.
|
|
|
|
|
It uses an ANSI C pre-processor to transform the GLSL-like language into HLSL.
|
|
|
|
|
This method has certain drawbacks,
|
|
|
|
|
but overall it's simple and allows for quick authoring of cross-platform shaders.
|
|
|
|
|
|
|
|
|
|
Some differences between bgfx's shaderc flavor of GLSL and vanilla GLSL:
|
|
|
|
|
|
|
|
|
|
- ``bool/int`` uniforms are not allowed; all uniforms must be ``float``.
|
|
|
|
|
- Attributes and varyings can only be accessed from ``main()``.
|
|
|
|
|
- ``SAMPLER2D/3D/CUBE/etc.`` macros replace the ``sampler2D/3D/Cube/etc.`` tokens.
|
|
|
|
|
- ``vec2/3/4_splat(<value>)`` replaces the ``vec2/3/4(<value>)`` constructor.
|
|
|
|
|
``vec2/3/4`` constructors with multiple values are still valid.
|
|
|
|
|
- ``mtxFromCols/mtxFromRows`` must be used for constructing matrices.
|
|
|
|
|
- ``mul(x, y)`` must be used when multiplying vectors with matrices.
|
|
|
|
|
- A ``varying.def.sc`` file must be used to define input/output semantics and types,
|
|
|
|
|
instead of using ``attribute/in`` and ``varying/in/out``.
|
|
|
|
|
This file cannot include comments, and typically only one is necessary.
|
|
|
|
|
- ``$input/$output`` tokens corresponding to inputs and outputs defined in
|
Fix typos (#2839)
Found via `codespell -q 3 -S ./3rdparty,*.ttf -L attribut,ba,clude,conly,indext,inout,lod,nclude,retur,struc,unknwn,utput`
2022-07-13 00:21:31 +03:00
|
|
|
|
``varying.def.sc`` must be used at the beginning of shader.
|
2022-04-04 22:57:00 +03:00
|
|
|
|
|
2022-09-02 18:10:33 +03:00
|
|
|
|
Defines
|
|
|
|
|
~~~~~~~
|
2022-09-02 17:08:22 +03:00
|
|
|
|
|
2022-09-02 18:10:33 +03:00
|
|
|
|
Shader Compiler also has the following default defines (default value is set to 0):
|
|
|
|
|
|
|
|
|
|
=============================== ======================= ========================================
|
|
|
|
|
Define symbol Description Option
|
|
|
|
|
=============================== ======================= ========================================
|
2022-09-02 17:08:22 +03:00
|
|
|
|
``BX_PLATFORM_ANDROID`` Android platform ``--platform android``
|
|
|
|
|
``BX_PLATFORM_EMSCRIPTEN`` Emscripten platform ``--platform asm.js``
|
|
|
|
|
``BX_PLATFORM_IOS`` iOS platform ``--platform ios``
|
|
|
|
|
``BX_PLATFORM_LINUX`` Linux platform ``--platform linux``
|
|
|
|
|
``BX_PLATFORM_OSX`` macOS platform ``--platform osx``
|
|
|
|
|
``BX_PLATFORM_PS4`` PlayStation 4 platform ``--platform orbis``
|
|
|
|
|
``BX_PLATFORM_WINDOWS`` Windows platform ``--platform windows``
|
|
|
|
|
``BX_PLATFORM_XBOXONE`` *Not implemented*
|
2022-09-02 18:10:33 +03:00
|
|
|
|
------------------------------- ----------------------- ----------------------------------------
|
2022-09-02 17:08:22 +03:00
|
|
|
|
``BGFX_SHADER_LANGUAGE_GLSL`` GLSL profile ``-p NNN`` and ``-p NNN_es``
|
|
|
|
|
``BGFX_SHADER_LANGUAGE_HLSL`` HLSL profile ``-p s_N_N``
|
|
|
|
|
``BGFX_SHADER_LANGUAGE_METAL`` Metal profile ``-p metal``
|
|
|
|
|
``BGFX_SHADER_LANGUAGE_PSSL`` PSSL profile ``-p pssl``
|
|
|
|
|
``BGFX_SHADER_LANGUAGE_SPIRV`` SPIR-V profile ``-p spirv`` and ``-p spirvNN-NN``
|
2022-09-02 18:10:33 +03:00
|
|
|
|
------------------------------- ----------------------- ----------------------------------------
|
2022-09-02 17:08:22 +03:00
|
|
|
|
``BGFX_SHADER_TYPE_COMPUTE`` Compute shader ``--type compute`` or ``--type c``
|
|
|
|
|
``BGFX_SHADER_TYPE_FRAGMENT`` Fragment shader ``--type fragment`` or ``--type f``
|
|
|
|
|
``BGFX_SHADER_TYPE_VERTEX`` Vertex shader ``--type vertex`` or ``--type v``
|
2022-09-02 18:10:33 +03:00
|
|
|
|
=============================== ======================= ========================================
|
|
|
|
|
|
|
|
|
|
Predefined Uniforms
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
======= =================== ====================================================================
|
|
|
|
|
Type Name Description
|
|
|
|
|
======= =================== ====================================================================
|
|
|
|
|
vec4 u_viewRect | View rectangle.
|
|
|
|
|
| ``u_viewRect.xy`` - xy offset in screen space.
|
|
|
|
|
| ``u_viewRect.zw`` - width/height size in screen space.
|
|
|
|
|
vec4 u_viewTexel | Screen-to-texel space conversion.
|
|
|
|
|
| ``u_viewTexel.xy = 1.0/u_viewRect.zw;``
|
|
|
|
|
mat4 u_view Transform world-to-view space.
|
|
|
|
|
mat4 u_invView Transform view-to-world space.
|
|
|
|
|
mat4 u_proj Transform view-to-clip space.
|
|
|
|
|
mat4 u_invProj Transform clip-to-view space.
|
|
|
|
|
mat4 u_viewProj Transform world-to-clip space.
|
|
|
|
|
mat4 u_invViewProj Transform clip-to-world space.
|
|
|
|
|
mat4[N] u_model Transform local-to-world space array.
|
|
|
|
|
mat4 u_modelView Transform local-to-view space.
|
|
|
|
|
mat4 u_modelViewProj Transform local-to-clip space.
|
|
|
|
|
float u_alphaRef | The reference value to which incoming alpha
|
|
|
|
|
| values are compared.
|
|
|
|
|
======= =================== ====================================================================
|
2022-09-02 17:08:22 +03:00
|
|
|
|
|
2022-04-04 22:57:00 +03:00
|
|
|
|
For more info, see the `shader helper macros
|
|
|
|
|
<https://github.com/bkaradzic/bgfx/blob/master/src/bgfx_shader.sh>`__.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
2023-05-19 09:04:27 +03:00
|
|
|
|
Vertex Shader Attributes
|
|
|
|
|
~~~~~~~~~~~~~~~~~~~~~~~~
|
|
|
|
|
|
|
|
|
|
``$input`` tokens for vertex shader can be only following:
|
|
|
|
|
|
|
|
|
|
================ ===================
|
|
|
|
|
Attribute bgfx::Attrib::Enum
|
|
|
|
|
================ ===================
|
|
|
|
|
a_position Position
|
|
|
|
|
a_normal Normal
|
|
|
|
|
a_tangent Tangent
|
|
|
|
|
a_bitangent Bitangent
|
|
|
|
|
a_color0 Color0
|
|
|
|
|
a_color1 Color1
|
|
|
|
|
a_color2 Color2
|
|
|
|
|
a_color3 Color3
|
|
|
|
|
a_indices Indices
|
|
|
|
|
a_weight Weight
|
|
|
|
|
a_texcoord0 TexCoord0
|
|
|
|
|
a_texcoord1 TexCoord1
|
|
|
|
|
a_texcoord2 TexCoord2
|
|
|
|
|
a_texcoord3 TexCoord3
|
|
|
|
|
a_texcoord4 TexCoord4
|
|
|
|
|
a_texcoord5 TexCoord5
|
|
|
|
|
a_texcoord6 TexCoord6
|
|
|
|
|
a_texcoord7 TexCoord7
|
|
|
|
|
================ ===================
|
|
|
|
|
|
|
|
|
|
In ``varying.def.sc``, instance buffer input must use ``i_dataN`` as identifier where ``N`` is the index
|
|
|
|
|
of the attribute in the buffer. Type must be ``vec4``, and the stride must be multiple of 16.
|
|
|
|
|
The semantic must be ``TEXCOORDN`` with a decreasing index starting from ``TEXCOORD7``.
|
|
|
|
|
|
|
|
|
|
::
|
|
|
|
|
|
|
|
|
|
vec4 i_data0 : TEXCOORD7;
|
|
|
|
|
vec4 i_data1 : TEXCOORD6;
|
|
|
|
|
vec4 i_data2 : TEXCOORD5;
|
|
|
|
|
vec4 i_data3 : TEXCOORD4;
|
|
|
|
|
vec4 i_data4 : TEXCOORD3;
|
|
|
|
|
|
|
|
|
|
Options
|
|
|
|
|
~~~~~~~
|
|
|
|
|
|
2022-04-01 05:22:38 +03:00
|
|
|
|
Options:
|
2022-04-04 22:57:00 +03:00
|
|
|
|
|
|
|
|
|
-h, --help Display this help and exit.
|
|
|
|
|
-v, --version Output version information and exit.
|
2022-04-06 14:30:18 +03:00
|
|
|
|
-f <file path> Input's file path.
|
2022-04-04 22:57:00 +03:00
|
|
|
|
-i <include path> Include path. (for multiple paths use -i multiple times)
|
2022-04-06 14:30:18 +03:00
|
|
|
|
-o <file path> Output's file path.
|
2022-04-04 22:57:00 +03:00
|
|
|
|
--bin2c <array name> Generate C header file. If array name is not specified base file name will be used as name.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
--depends Generate makefile style depends file.
|
2022-04-06 14:30:18 +03:00
|
|
|
|
--platform <platform> Target platform.
|
2022-04-04 22:57:00 +03:00
|
|
|
|
-p, --profile <profile> Shader model.
|
2022-09-02 18:10:33 +03:00
|
|
|
|
Defaults to GLSL.
|
2022-04-04 22:57:00 +03:00
|
|
|
|
--preprocess Only pre-process.
|
|
|
|
|
--define <defines> Add defines to preprocessor. (semicolon separated)
|
|
|
|
|
--raw Do not process shader. No preprocessor, and no glsl-optimizer. (GLSL only)
|
|
|
|
|
--type <type> Shader type.
|
2022-09-02 18:10:33 +03:00
|
|
|
|
Can be 'vertex', 'fragment, or 'compute'.
|
2022-04-04 22:57:00 +03:00
|
|
|
|
--varyingdef <file path> A varying.def.sc's file path.
|
|
|
|
|
--verbose Be verbose.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
2023-11-06 22:14:29 +03:00
|
|
|
|
(Vulkan, DirectX and Metal):
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
|
|
|
|
--debug Debug information.
|
2023-11-06 22:14:29 +03:00
|
|
|
|
|
|
|
|
|
(DirectX only):
|
|
|
|
|
|
2022-04-04 22:57:00 +03:00
|
|
|
|
--disasm Disassemble a compiled shader.
|
|
|
|
|
-O <level> Set optimization level.
|
2022-09-02 18:10:33 +03:00
|
|
|
|
Can be 0–3.
|
|
|
|
|
--Werror Treat warnings as errors.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
|
|
|
|
Building shaders
|
|
|
|
|
~~~~~~~~~~~~~~~~
|
|
|
|
|
|
2022-04-04 22:57:00 +03:00
|
|
|
|
Shaders can be compiled for all renderers by using the ``shaderc`` tool.
|
|
|
|
|
A Makefile to simplify building shaders is provided in the `bgfx examples
|
|
|
|
|
<https://github.com/bkaradzic/bgfx/tree/master/examples>`__.
|
|
|
|
|
D3D shaders can be only compiled on Windows.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
|
|
|
|
Texture Compiler (texturec)
|
|
|
|
|
---------------------------
|
|
|
|
|
|
2022-04-04 22:57:00 +03:00
|
|
|
|
Convert PNG, TGA, DDS, KTX, and PVR textures into bgfx-supported texture formats.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
|
|
|
|
Usage::
|
|
|
|
|
|
|
|
|
|
texturec -f <in> -o <out> [-t <texture format>]
|
|
|
|
|
|
|
|
|
|
Supported file formats:
|
|
|
|
|
|
|
|
|
|
====== ================ ============================
|
|
|
|
|
Format In/Out Description
|
|
|
|
|
====== ================ ============================
|
|
|
|
|
.bmp (input) Windows Bitmap.
|
|
|
|
|
.dds (input, output) Direct Draw Surface.
|
|
|
|
|
.exr (input, output) OpenEXR.
|
|
|
|
|
.gif (input) Graphics Interchange Format.
|
|
|
|
|
.jpg (input) JPEG Interchange Format.
|
|
|
|
|
.hdr (input, output) Radiance RGBE.
|
|
|
|
|
.ktx (input, output) Khronos Texture.
|
|
|
|
|
.png (input, output) Portable Network Graphics.
|
|
|
|
|
.psd (input) Photoshop Document.
|
|
|
|
|
.pvr (input) PowerVR.
|
|
|
|
|
.tga (input) Truevision TGA.
|
|
|
|
|
====== ================ ============================
|
|
|
|
|
|
|
|
|
|
Options:
|
|
|
|
|
|
2022-09-02 18:10:33 +03:00
|
|
|
|
Options:
|
|
|
|
|
-h, --help Help.
|
|
|
|
|
-v, --version Version information only.
|
|
|
|
|
-f <file path> Input file path.
|
|
|
|
|
-o <file path> Output file path.
|
|
|
|
|
-t <format> Output format type (BC1/2/3/4/5, ETC1, PVR14, etc.).
|
|
|
|
|
-q <quality> Encoding quality (default, fastest, highest).
|
|
|
|
|
-m, --mips Generate mip-maps.
|
|
|
|
|
--mipskip <N> Skip <N> number of mips.
|
|
|
|
|
-n, --normalmap Input texture is normal map. (Implies --linear)
|
|
|
|
|
|
|
|
|
|
--equirect Input texture is equirectangular projection of cubemap.
|
|
|
|
|
|
|
|
|
|
--strip Input texture is horizontal or vertical strip of cubemap.
|
|
|
|
|
|
|
|
|
|
--sdf Compute SDF texture.
|
|
|
|
|
|
|
|
|
|
--ref <alpha> Alpha reference value.
|
|
|
|
|
|
|
|
|
|
--iqa Image Quality Assessment
|
|
|
|
|
|
|
|
|
|
--pma Premultiply alpha into RGB channel.
|
|
|
|
|
|
|
|
|
|
--linear Input and output texture is linear color space (gamma correction won't be applied).
|
|
|
|
|
|
|
|
|
|
--max <max size> Maximum width/height (image will be scaled down and
|
|
|
|
|
aspect ratio will be preserved)
|
|
|
|
|
|
|
|
|
|
--radiance <model> Radiance cubemap filter. (Lighting model: Phong, PhongBrdf, Blinn, BlinnBrdf, GGX)
|
|
|
|
|
|
|
|
|
|
--as <extension> Save as.
|
|
|
|
|
|
|
|
|
|
--formats List all supported formats.
|
|
|
|
|
|
|
|
|
|
--validate **DEBUG** Validate that output image produced matches after loading.
|
2022-04-01 05:22:38 +03:00
|
|
|
|
|
|
|
|
|
Texture Viewer (texturev)
|
|
|
|
|
-------------------------
|
|
|
|
|
|
2022-04-04 22:57:00 +03:00
|
|
|
|
A texture viewer.
|