| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702 |
- <!DOCTYPE html>
- <html class="writer-html5" lang="en" data-content_root="./">
- <head>
- <meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
- <meta name="viewport" content="width=device-width, initial-scale=1.0" />
- <title>Tools — bgfx 1.136.9083 documentation</title>
- <link rel="stylesheet" type="text/css" href="_static/pygments.css?v=03e43079" />
- <link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=e59714d7" />
-
- <script src="_static/jquery.js?v=5d32c60e"></script>
- <script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
- <script src="_static/documentation_options.js?v=f601d78d"></script>
- <script src="_static/doctools.js?v=9bcbadda"></script>
- <script src="_static/sphinx_highlight.js?v=dc90522c"></script>
- <script src="_static/js/theme.js"></script>
- <link rel="index" title="Index" href="genindex.html" />
- <link rel="search" title="Search" href="search.html" />
- <link rel="next" title="Internals" href="internals.html" />
- <link rel="prev" title="API Reference" href="bgfx.html" />
- </head>
- <body class="wy-body-for-nav">
- <div class="wy-grid-for-nav">
- <nav data-toggle="wy-nav-shift" class="wy-nav-side">
- <div class="wy-side-scroll">
- <div class="wy-side-nav-search" >
-
-
- <a href="index.html" class="icon icon-home">
- bgfx
- </a>
- <div role="search">
- <form id="rtd-search-form" class="wy-form" action="search.html" method="get">
- <input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
- <input type="hidden" name="check_keywords" value="yes" />
- <input type="hidden" name="area" value="default" />
- </form>
- </div>
- </div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
- <ul class="current">
- <li class="toctree-l1"><a class="reference internal" href="overview.html">Overview</a></li>
- <li class="toctree-l1"><a class="reference internal" href="build.html">Building</a></li>
- <li class="toctree-l1"><a class="reference internal" href="examples.html">Examples</a></li>
- <li class="toctree-l1"><a class="reference internal" href="bgfx.html">API Reference</a></li>
- <li class="toctree-l1 current"><a class="current reference internal" href="#">Tools</a><ul>
- <li class="toctree-l2"><a class="reference internal" href="#geometry-compiler-geometryc">Geometry Compiler (geometryc)</a></li>
- <li class="toctree-l2"><a class="reference internal" href="#geometry-viewer-geometryv">Geometry Viewer (geometryv)</a></li>
- <li class="toctree-l2"><a class="reference internal" href="#shader-compiler-shaderc">Shader Compiler (shaderc)</a><ul>
- <li class="toctree-l3"><a class="reference internal" href="#defines">Defines</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#predefined-uniforms">Predefined Uniforms</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#vertex-shader-attributes">Vertex Shader Attributes</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#options">Options</a></li>
- <li class="toctree-l3"><a class="reference internal" href="#building-shaders">Building shaders</a></li>
- </ul>
- </li>
- <li class="toctree-l2"><a class="reference internal" href="#texture-compiler-texturec">Texture Compiler (texturec)</a></li>
- <li class="toctree-l2"><a class="reference internal" href="#texture-viewer-texturev">Texture Viewer (texturev)</a></li>
- </ul>
- </li>
- <li class="toctree-l1"><a class="reference internal" href="internals.html">Internals</a></li>
- <li class="toctree-l1"><a class="reference internal" href="license.html">License</a></li>
- </ul>
- </div>
- </div>
- </nav>
- <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
- <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
- <a href="index.html">bgfx</a>
- </nav>
- <div class="wy-nav-content">
- <div class="rst-content">
- <div role="navigation" aria-label="Page navigation">
- <ul class="wy-breadcrumbs">
- <li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
- <li class="breadcrumb-item active">Tools</li>
- <li class="wy-breadcrumbs-aside">
- </li>
- </ul>
- <hr/>
- </div>
- <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
- <div itemprop="articleBody">
-
- <section id="tools">
- <h1>Tools<a class="headerlink" href="#tools" title="Link to this heading"></a></h1>
- <section id="geometry-compiler-geometryc">
- <h2>Geometry Compiler (geometryc)<a class="headerlink" href="#geometry-compiler-geometryc" title="Link to this heading"></a></h2>
- <p>Converts Wavefront .obj, or glTF 2.0 mesh files to a format which is optimized for use with bgfx.</p>
- <p>Usage:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">geometryc</span> <span class="o">-</span><span class="n">f</span> <span class="o"><</span><span class="ow">in</span><span class="o">></span> <span class="o">-</span><span class="n">o</span> <span class="o"><</span><span class="n">out</span><span class="o">></span>
- </pre></div>
- </div>
- <p>Supported input file formats:</p>
- <blockquote>
- <div><table class="docutils align-default">
- <thead>
- <tr class="row-odd"><th class="head"><p>Format</p></th>
- <th class="head"><p>Description</p></th>
- </tr>
- </thead>
- <tbody>
- <tr class="row-even"><td><p>.obj</p></td>
- <td><p>Wavefront</p></td>
- </tr>
- <tr class="row-odd"><td><p>.gltf</p></td>
- <td><p>glTF 2.0</p></td>
- </tr>
- <tr class="row-even"><td><p>.glb</p></td>
- <td><p>glTF 2.0</p></td>
- </tr>
- </tbody>
- </table>
- </div></blockquote>
- <p>Options:</p>
- <blockquote>
- <div><dl class="option-list">
- <dt><kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></dt>
- <dd><p>Display this help and exit.</p>
- </dd>
- <dt><kbd><span class="option">-v</span>, <span class="option">--version</span></kbd></dt>
- <dd><p>Output version information and exit.</p>
- </dd>
- <dt><kbd><span class="option">-f <var><file path></var></span></kbd></dt>
- <dd><p>Input’s file path.</p>
- </dd>
- <dt><kbd><span class="option">-o <var><file path></var></span></kbd></dt>
- <dd><p>Output’s file path.</p>
- </dd>
- <dt><kbd><span class="option">-s</span>, <span class="option">--scale <var><num></var></span></kbd></dt>
- <dd><p>Scale factor.</p>
- <dl class="option-list">
- <dt><kbd><span class="option">--ccw</span></kbd></dt>
- <dd><p>Front face is counter-clockwise winding order.</p>
- </dd>
- <dt><kbd><span class="option">--flipv</span></kbd></dt>
- <dd><p>Flip texture coordinate V.</p>
- </dd>
- <dt><kbd><span class="option">--obb <var><num></var></span></kbd></dt>
- <dd><div class="line-block">
- <div class="line">Number of steps for calculating oriented bounding box.</div>
- <div class="line">Defaults to 17.</div>
- <div class="line">Less steps = less precise OBB.</div>
- <div class="line">More steps = slower calculation.</div>
- </div>
- </dd>
- <dt><kbd><span class="option">--packnormal <var><num></var></span></kbd></dt>
- <dd><div class="line-block">
- <div class="line">Normal packing.</div>
- <div class="line">0 - unpacked 12 bytes. (default)</div>
- <div class="line">1 - packed 4 bytes.</div>
- </div>
- </dd>
- <dt><kbd><span class="option">--packuv <var><num></var></span></kbd></dt>
- <dd><div class="line-block">
- <div class="line">Texture coordinate packing.</div>
- <div class="line">0 - unpacked 8 bytes. (default)</div>
- <div class="line">1 - packed 4 bytes.</div>
- </div>
- </dd>
- <dt><kbd><span class="option">--tangent</span></kbd></dt>
- <dd><p>Calculate tangent vectors. (packing mode is the same as normal)</p>
- </dd>
- <dt><kbd><span class="option">--barycentric</span></kbd></dt>
- <dd><p>Adds barycentric vertex attribute. (Packed in bgfx::Attrib::Color1)</p>
- </dd>
- </dl>
- </dd>
- <dt><kbd><span class="option">-c</span>, <span class="option">--compress</span></kbd></dt>
- <dd><p>Compress indices.</p>
- <p>–[l/r]h-up+[y/z] Coordinate system. Defaults to ‘–lh-up+y’ — Left-Handed +Y is up.</p>
- </dd>
- </dl>
- </div></blockquote>
- </section>
- <section id="geometry-viewer-geometryv">
- <h2>Geometry Viewer (geometryv)<a class="headerlink" href="#geometry-viewer-geometryv" title="Link to this heading"></a></h2>
- <p>A geometry viewer.</p>
- </section>
- <section id="shader-compiler-shaderc">
- <h2>Shader Compiler (shaderc)<a class="headerlink" href="#shader-compiler-shaderc" title="Link to this heading"></a></h2>
- <p>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.</p>
- <p>Some differences between bgfx’s shaderc flavor of GLSL and vanilla GLSL:</p>
- <ul class="simple">
- <li><p><code class="docutils literal notranslate"><span class="pre">bool/int</span></code> uniforms are not allowed; all uniforms must be <code class="docutils literal notranslate"><span class="pre">float</span></code>.</p></li>
- <li><p>Attributes and varyings can only be accessed from <code class="docutils literal notranslate"><span class="pre">main()</span></code>.</p></li>
- <li><p><code class="docutils literal notranslate"><span class="pre">SAMPLER2D/3D/CUBE/etc.</span></code> macros replace the <code class="docutils literal notranslate"><span class="pre">sampler2D/3D/Cube/etc.</span></code> tokens.</p></li>
- <li><p><code class="docutils literal notranslate"><span class="pre">vec2/3/4_splat(<value>)</span></code> replaces the <code class="docutils literal notranslate"><span class="pre">vec2/3/4(<value>)</span></code> constructor.
- <code class="docutils literal notranslate"><span class="pre">vec2/3/4</span></code> constructors with multiple values are still valid.</p></li>
- <li><p><code class="docutils literal notranslate"><span class="pre">mtxFromCols/mtxFromRows</span></code> must be used for constructing matrices.</p></li>
- <li><p><code class="docutils literal notranslate"><span class="pre">mul(x,</span> <span class="pre">y)</span></code> must be used when multiplying vectors with matrices.</p></li>
- <li><p>A <code class="docutils literal notranslate"><span class="pre">varying.def.sc</span></code> file must be used to define input/output semantics and types,
- instead of using <code class="docutils literal notranslate"><span class="pre">attribute/in</span></code> and <code class="docutils literal notranslate"><span class="pre">varying/in/out</span></code>.
- This file cannot include comments, and typically only one is necessary.</p></li>
- <li><p><code class="docutils literal notranslate"><span class="pre">$input/$output</span></code> tokens corresponding to inputs and outputs defined in
- <code class="docutils literal notranslate"><span class="pre">varying.def.sc</span></code> must be used at the beginning of shader.</p></li>
- </ul>
- <section id="defines">
- <h3>Defines<a class="headerlink" href="#defines" title="Link to this heading"></a></h3>
- <p>Shader Compiler also has the following default defines (default value is set to 0):</p>
- <blockquote>
- <div><table class="docutils align-default">
- <thead>
- <tr class="row-odd"><th class="head"><p>Define symbol</p></th>
- <th class="head"><p>Description</p></th>
- <th class="head"><p>Option</p></th>
- </tr>
- </thead>
- <tbody>
- <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">BX_PLATFORM_ANDROID</span></code></p></td>
- <td><p>Android platform</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--platform</span> <span class="pre">android</span></code></p></td>
- </tr>
- <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">BX_PLATFORM_EMSCRIPTEN</span></code></p></td>
- <td><p>Emscripten platform</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--platform</span> <span class="pre">asm.js</span></code></p></td>
- </tr>
- <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">BX_PLATFORM_IOS</span></code></p></td>
- <td><p>iOS platform</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--platform</span> <span class="pre">ios</span></code></p></td>
- </tr>
- <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">BX_PLATFORM_LINUX</span></code></p></td>
- <td><p>Linux platform</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--platform</span> <span class="pre">linux</span></code></p></td>
- </tr>
- <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">BX_PLATFORM_OSX</span></code></p></td>
- <td><p>macOS platform</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--platform</span> <span class="pre">osx</span></code></p></td>
- </tr>
- <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">BX_PLATFORM_PS4</span></code></p></td>
- <td><p>PlayStation 4 platform</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--platform</span> <span class="pre">orbis</span></code></p></td>
- </tr>
- <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">BX_PLATFORM_WINDOWS</span></code></p></td>
- <td><p>Windows platform</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--platform</span> <span class="pre">windows</span></code></p></td>
- </tr>
- <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">BX_PLATFORM_XBOXONE</span></code></p></td>
- <td><p><em>Not implemented</em></p></td>
- <td></td>
- </tr>
- <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">BGFX_SHADER_LANGUAGE_GLSL</span></code></p></td>
- <td><p>GLSL profile</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">-p</span> <span class="pre">NNN</span></code> and <code class="docutils literal notranslate"><span class="pre">-p</span> <span class="pre">NNN_es</span></code></p></td>
- </tr>
- <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">BGFX_SHADER_LANGUAGE_HLSL</span></code></p></td>
- <td><p>HLSL profile</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">-p</span> <span class="pre">s_N_N</span></code></p></td>
- </tr>
- <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">BGFX_SHADER_LANGUAGE_METAL</span></code></p></td>
- <td><p>Metal profile</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">-p</span> <span class="pre">metal</span></code></p></td>
- </tr>
- <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">BGFX_SHADER_LANGUAGE_PSSL</span></code></p></td>
- <td><p>PSSL profile</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">-p</span> <span class="pre">pssl</span></code></p></td>
- </tr>
- <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">BGFX_SHADER_LANGUAGE_SPIRV</span></code></p></td>
- <td><p>SPIR-V profile</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">-p</span> <span class="pre">spirv</span></code> and <code class="docutils literal notranslate"><span class="pre">-p</span> <span class="pre">spirvNN-NN</span></code></p></td>
- </tr>
- <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">BGFX_SHADER_TYPE_COMPUTE</span></code></p></td>
- <td><p>Compute shader</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--type</span> <span class="pre">compute</span></code> or <code class="docutils literal notranslate"><span class="pre">--type</span> <span class="pre">c</span></code></p></td>
- </tr>
- <tr class="row-even"><td><p><code class="docutils literal notranslate"><span class="pre">BGFX_SHADER_TYPE_FRAGMENT</span></code></p></td>
- <td><p>Fragment shader</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--type</span> <span class="pre">fragment</span></code> or <code class="docutils literal notranslate"><span class="pre">--type</span> <span class="pre">f</span></code></p></td>
- </tr>
- <tr class="row-odd"><td><p><code class="docutils literal notranslate"><span class="pre">BGFX_SHADER_TYPE_VERTEX</span></code></p></td>
- <td><p>Vertex shader</p></td>
- <td><p><code class="docutils literal notranslate"><span class="pre">--type</span> <span class="pre">vertex</span></code> or <code class="docutils literal notranslate"><span class="pre">--type</span> <span class="pre">v</span></code></p></td>
- </tr>
- </tbody>
- </table>
- </div></blockquote>
- </section>
- <section id="predefined-uniforms">
- <h3>Predefined Uniforms<a class="headerlink" href="#predefined-uniforms" title="Link to this heading"></a></h3>
- <blockquote>
- <div><table class="docutils align-default">
- <thead>
- <tr class="row-odd"><th class="head"><p>Type</p></th>
- <th class="head"><p>Name</p></th>
- <th class="head"><p>Description</p></th>
- </tr>
- </thead>
- <tbody>
- <tr class="row-even"><td><p>vec4</p></td>
- <td><p>u_viewRect</p></td>
- <td><div class="line-block">
- <div class="line">View rectangle.</div>
- <div class="line"><code class="docutils literal notranslate"><span class="pre">u_viewRect.xy</span></code> - xy offset in screen space.</div>
- <div class="line"><code class="docutils literal notranslate"><span class="pre">u_viewRect.zw</span></code> - width/height size in screen space.</div>
- </div>
- </td>
- </tr>
- <tr class="row-odd"><td><p>vec4</p></td>
- <td><p>u_viewTexel</p></td>
- <td><div class="line-block">
- <div class="line">Screen-to-texel space conversion.</div>
- <div class="line"><code class="docutils literal notranslate"><span class="pre">u_viewTexel.xy</span> <span class="pre">=</span> <span class="pre">1.0/u_viewRect.zw;</span></code></div>
- </div>
- </td>
- </tr>
- <tr class="row-even"><td><p>mat4</p></td>
- <td><p>u_view</p></td>
- <td><p>Transform world-to-view space.</p></td>
- </tr>
- <tr class="row-odd"><td><p>mat4</p></td>
- <td><p>u_invView</p></td>
- <td><p>Transform view-to-world space.</p></td>
- </tr>
- <tr class="row-even"><td><p>mat4</p></td>
- <td><p>u_proj</p></td>
- <td><p>Transform view-to-clip space.</p></td>
- </tr>
- <tr class="row-odd"><td><p>mat4</p></td>
- <td><p>u_invProj</p></td>
- <td><p>Transform clip-to-view space.</p></td>
- </tr>
- <tr class="row-even"><td><p>mat4</p></td>
- <td><p>u_viewProj</p></td>
- <td><p>Transform world-to-clip space.</p></td>
- </tr>
- <tr class="row-odd"><td><p>mat4</p></td>
- <td><p>u_invViewProj</p></td>
- <td><p>Transform clip-to-world space.</p></td>
- </tr>
- <tr class="row-even"><td><p>mat4[N]</p></td>
- <td><p>u_model</p></td>
- <td><p>Transform local-to-world space array.</p></td>
- </tr>
- <tr class="row-odd"><td><p>mat4</p></td>
- <td><p>u_modelView</p></td>
- <td><p>Transform local-to-view space.</p></td>
- </tr>
- <tr class="row-even"><td><p>mat4</p></td>
- <td><p>u_invModelView</p></td>
- <td><p>Transform view-to-local space.</p></td>
- </tr>
- <tr class="row-odd"><td><p>mat4</p></td>
- <td><p>u_modelViewProj</p></td>
- <td><p>Transform local-to-clip space.</p></td>
- </tr>
- <tr class="row-even"><td><p>float</p></td>
- <td><p>u_alphaRef</p></td>
- <td><div class="line-block">
- <div class="line">The reference value to which incoming alpha</div>
- <div class="line">values are compared.</div>
- </div>
- </td>
- </tr>
- </tbody>
- </table>
- </div></blockquote>
- <p>For more info, see the <a class="reference external" href="https://github.com/bkaradzic/bgfx/blob/master/src/bgfx_shader.sh">shader helper macros</a>.</p>
- </section>
- <section id="vertex-shader-attributes">
- <h3>Vertex Shader Attributes<a class="headerlink" href="#vertex-shader-attributes" title="Link to this heading"></a></h3>
- <p><code class="docutils literal notranslate"><span class="pre">$input</span></code> tokens for vertex shader can be only following:</p>
- <blockquote>
- <div><table class="docutils align-default">
- <thead>
- <tr class="row-odd"><th class="head"><p>Attribute</p></th>
- <th class="head"><p>bgfx::Attrib::Enum</p></th>
- </tr>
- </thead>
- <tbody>
- <tr class="row-even"><td><p>a_position</p></td>
- <td><p>Position</p></td>
- </tr>
- <tr class="row-odd"><td><p>a_normal</p></td>
- <td><p>Normal</p></td>
- </tr>
- <tr class="row-even"><td><p>a_tangent</p></td>
- <td><p>Tangent</p></td>
- </tr>
- <tr class="row-odd"><td><p>a_bitangent</p></td>
- <td><p>Bitangent</p></td>
- </tr>
- <tr class="row-even"><td><p>a_color0</p></td>
- <td><p>Color0</p></td>
- </tr>
- <tr class="row-odd"><td><p>a_color1</p></td>
- <td><p>Color1</p></td>
- </tr>
- <tr class="row-even"><td><p>a_color2</p></td>
- <td><p>Color2</p></td>
- </tr>
- <tr class="row-odd"><td><p>a_color3</p></td>
- <td><p>Color3</p></td>
- </tr>
- <tr class="row-even"><td><p>a_indices</p></td>
- <td><p>Indices</p></td>
- </tr>
- <tr class="row-odd"><td><p>a_weight</p></td>
- <td><p>Weight</p></td>
- </tr>
- <tr class="row-even"><td><p>a_texcoord0</p></td>
- <td><p>TexCoord0</p></td>
- </tr>
- <tr class="row-odd"><td><p>a_texcoord1</p></td>
- <td><p>TexCoord1</p></td>
- </tr>
- <tr class="row-even"><td><p>a_texcoord2</p></td>
- <td><p>TexCoord2</p></td>
- </tr>
- <tr class="row-odd"><td><p>a_texcoord3</p></td>
- <td><p>TexCoord3</p></td>
- </tr>
- <tr class="row-even"><td><p>a_texcoord4</p></td>
- <td><p>TexCoord4</p></td>
- </tr>
- <tr class="row-odd"><td><p>a_texcoord5</p></td>
- <td><p>TexCoord5</p></td>
- </tr>
- <tr class="row-even"><td><p>a_texcoord6</p></td>
- <td><p>TexCoord6</p></td>
- </tr>
- <tr class="row-odd"><td><p>a_texcoord7</p></td>
- <td><p>TexCoord7</p></td>
- </tr>
- </tbody>
- </table>
- </div></blockquote>
- <p>In <code class="docutils literal notranslate"><span class="pre">varying.def.sc</span></code>, instance buffer input must use <code class="docutils literal notranslate"><span class="pre">i_dataN</span></code> as identifier where <code class="docutils literal notranslate"><span class="pre">N</span></code> is the index
- of the attribute in the buffer. Type must be <code class="docutils literal notranslate"><span class="pre">vec4</span></code>, and the stride must be multiple of 16.
- The semantic must be <code class="docutils literal notranslate"><span class="pre">TEXCOORDN</span></code> with a decreasing index starting from <code class="docutils literal notranslate"><span class="pre">TEXCOORD7</span></code>.</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">vec4</span> <span class="n">i_data0</span> <span class="p">:</span> <span class="n">TEXCOORD7</span><span class="p">;</span>
- <span class="n">vec4</span> <span class="n">i_data1</span> <span class="p">:</span> <span class="n">TEXCOORD6</span><span class="p">;</span>
- <span class="n">vec4</span> <span class="n">i_data2</span> <span class="p">:</span> <span class="n">TEXCOORD5</span><span class="p">;</span>
- <span class="n">vec4</span> <span class="n">i_data3</span> <span class="p">:</span> <span class="n">TEXCOORD4</span><span class="p">;</span>
- <span class="n">vec4</span> <span class="n">i_data4</span> <span class="p">:</span> <span class="n">TEXCOORD3</span><span class="p">;</span>
- </pre></div>
- </div>
- </section>
- <section id="options">
- <h3>Options<a class="headerlink" href="#options" title="Link to this heading"></a></h3>
- <p>Options:</p>
- <blockquote>
- <div><dl class="option-list">
- <dt><kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></dt>
- <dd><p>Display this help and exit.</p>
- </dd>
- <dt><kbd><span class="option">-v</span>, <span class="option">--version</span></kbd></dt>
- <dd><p>Output version information and exit.</p>
- </dd>
- <dt><kbd><span class="option">-f <var><file path></var></span></kbd></dt>
- <dd><p>Input’s file path.</p>
- </dd>
- <dt><kbd><span class="option">-i <var><include path></var></span></kbd></dt>
- <dd><p>Include path. (for multiple paths use -i multiple times)</p>
- </dd>
- <dt><kbd><span class="option">-o <var><file path></var></span></kbd></dt>
- <dd><p>Output’s file path.</p>
- </dd>
- <dt><kbd><span class="option">--bin2c <var><array name></var></span></kbd></dt>
- <dd><p>Generate C header file. If array name is not specified base file name will be used as name.</p>
- </dd>
- <dt><kbd><span class="option">--depends</span></kbd></dt>
- <dd><p>Generate makefile style depends file.</p>
- </dd>
- <dt><kbd><span class="option">--platform <var><platform></var></span></kbd></dt>
- <dd><p>Target platform.</p>
- </dd>
- <dt><kbd><span class="option">-p</span>, <span class="option">--profile <var><profile></var></span></kbd></dt>
- <dd><p>Shader model.
- Defaults to GLSL.</p>
- </dd>
- <dt><kbd><span class="option">--preprocess</span></kbd></dt>
- <dd><p>Only pre-process.</p>
- </dd>
- <dt><kbd><span class="option">--define <var><defines></var></span></kbd></dt>
- <dd><p>Add defines to preprocessor. (semicolon separated)</p>
- </dd>
- <dt><kbd><span class="option">--raw</span></kbd></dt>
- <dd><p>Do not process shader. No preprocessor, and no glsl-optimizer. (GLSL only)</p>
- </dd>
- <dt><kbd><span class="option">--type <var><type></var></span></kbd></dt>
- <dd><p>Shader type.
- Can be ‘vertex’, ‘fragment, or ‘compute’.</p>
- </dd>
- <dt><kbd><span class="option">--varyingdef <var><file path></var></span></kbd></dt>
- <dd><p>A varying.def.sc’s file path.</p>
- </dd>
- <dt><kbd><span class="option">--verbose</span></kbd></dt>
- <dd><p>Be verbose.</p>
- </dd>
- </dl>
- </div></blockquote>
- <p>(Vulkan, DirectX and Metal):</p>
- <blockquote>
- <div><dl class="option-list">
- <dt><kbd><span class="option">--debug</span></kbd></dt>
- <dd><p>Debug information.</p>
- </dd>
- </dl>
- </div></blockquote>
- <p>(DirectX only):</p>
- <blockquote>
- <div><dl class="option-list">
- <dt><kbd><span class="option">--disasm</span></kbd></dt>
- <dd><p>Disassemble a compiled shader.</p>
- </dd>
- <dt><kbd><span class="option">-O <var><level></var></span></kbd></dt>
- <dd><p>Set optimization level.
- Can be 0–3.</p>
- </dd>
- <dt><kbd><span class="option">--Werror</span></kbd></dt>
- <dd><p>Treat warnings as errors.</p>
- </dd>
- </dl>
- </div></blockquote>
- </section>
- <section id="building-shaders">
- <h3>Building shaders<a class="headerlink" href="#building-shaders" title="Link to this heading"></a></h3>
- <p>Shaders can be compiled for all renderers by using the <code class="docutils literal notranslate"><span class="pre">shaderc</span></code> tool.
- A Makefile to simplify building shaders is provided in the <a class="reference external" href="https://github.com/bkaradzic/bgfx/tree/master/examples">bgfx examples</a>.
- D3D shaders can be only compiled on Windows.</p>
- </section>
- </section>
- <section id="texture-compiler-texturec">
- <h2>Texture Compiler (texturec)<a class="headerlink" href="#texture-compiler-texturec" title="Link to this heading"></a></h2>
- <p>Convert PNG, TGA, DDS, KTX, and PVR textures into bgfx-supported texture formats.</p>
- <p>Usage:</p>
- <div class="highlight-default notranslate"><div class="highlight"><pre><span></span><span class="n">texturec</span> <span class="o">-</span><span class="n">f</span> <span class="o"><</span><span class="ow">in</span><span class="o">></span> <span class="o">-</span><span class="n">o</span> <span class="o"><</span><span class="n">out</span><span class="o">></span> <span class="p">[</span><span class="o">-</span><span class="n">t</span> <span class="o"><</span><span class="n">texture</span> <span class="nb">format</span><span class="o">></span><span class="p">]</span>
- </pre></div>
- </div>
- <p>Supported file formats:</p>
- <blockquote>
- <div><table class="docutils align-default">
- <thead>
- <tr class="row-odd"><th class="head"><p>Format</p></th>
- <th class="head"><p>In/Out</p></th>
- <th class="head"><p>Description</p></th>
- </tr>
- </thead>
- <tbody>
- <tr class="row-even"><td><p>.bmp</p></td>
- <td><p>(input)</p></td>
- <td><p>Windows Bitmap.</p></td>
- </tr>
- <tr class="row-odd"><td><p>.dds</p></td>
- <td><p>(input, output)</p></td>
- <td><p>Direct Draw Surface.</p></td>
- </tr>
- <tr class="row-even"><td><p>.exr</p></td>
- <td><p>(input, output)</p></td>
- <td><p>OpenEXR.</p></td>
- </tr>
- <tr class="row-odd"><td><p>.gif</p></td>
- <td><p>(input)</p></td>
- <td><p>Graphics Interchange Format.</p></td>
- </tr>
- <tr class="row-even"><td><p>.jpg</p></td>
- <td><p>(input)</p></td>
- <td><p>JPEG Interchange Format.</p></td>
- </tr>
- <tr class="row-odd"><td><p>.hdr</p></td>
- <td><p>(input, output)</p></td>
- <td><p>Radiance RGBE.</p></td>
- </tr>
- <tr class="row-even"><td><p>.ktx</p></td>
- <td><p>(input, output)</p></td>
- <td><p>Khronos Texture.</p></td>
- </tr>
- <tr class="row-odd"><td><p>.png</p></td>
- <td><p>(input, output)</p></td>
- <td><p>Portable Network Graphics.</p></td>
- </tr>
- <tr class="row-even"><td><p>.psd</p></td>
- <td><p>(input)</p></td>
- <td><p>Photoshop Document.</p></td>
- </tr>
- <tr class="row-odd"><td><p>.pvr</p></td>
- <td><p>(input)</p></td>
- <td><p>PowerVR.</p></td>
- </tr>
- <tr class="row-even"><td><p>.tga</p></td>
- <td><p>(input)</p></td>
- <td><p>Truevision TGA.</p></td>
- </tr>
- </tbody>
- </table>
- </div></blockquote>
- <p>Options:</p>
- <dl>
- <dt>Options:</dt><dd><dl class="option-list">
- <dt><kbd><span class="option">-h</span>, <span class="option">--help</span></kbd></dt>
- <dd><p>Help.</p>
- </dd>
- <dt><kbd><span class="option">-v</span>, <span class="option">--version</span></kbd></dt>
- <dd><p>Version information only.</p>
- </dd>
- <dt><kbd><span class="option">-f <var><file path></var></span></kbd></dt>
- <dd><p>Input file path.</p>
- </dd>
- <dt><kbd><span class="option">-o <var><file path></var></span></kbd></dt>
- <dd><p>Output file path.</p>
- </dd>
- <dt><kbd><span class="option">-t <var><format></var></span></kbd></dt>
- <dd><p>Output format type (BC1/2/3/4/5, ETC1, PVR14, etc.).</p>
- </dd>
- <dt><kbd><span class="option">-q <var><quality></var></span></kbd></dt>
- <dd><p>Encoding quality (default, fastest, highest).</p>
- </dd>
- <dt><kbd><span class="option">-m</span>, <span class="option">--mips</span></kbd></dt>
- <dd><p>Generate mip-maps.
- –mipskip <N> Skip <N> number of mips.</p>
- </dd>
- <dt><kbd><span class="option">-n</span>, <span class="option">--normalmap</span></kbd></dt>
- <dd><p>Input texture is normal map. (Implies –linear)</p>
- <dl class="option-list">
- <dt><kbd><span class="option">--equirect</span></kbd></dt>
- <dd><p>Input texture is equirectangular projection of cubemap.</p>
- </dd>
- <dt><kbd><span class="option">--strip</span></kbd></dt>
- <dd><p>Input texture is horizontal or vertical strip of cubemap.</p>
- </dd>
- <dt><kbd><span class="option">--sdf</span></kbd></dt>
- <dd><p>Compute SDF texture.</p>
- </dd>
- <dt><kbd><span class="option">--ref <var><alpha></var></span></kbd></dt>
- <dd><p>Alpha reference value.</p>
- </dd>
- <dt><kbd><span class="option">--iqa</span></kbd></dt>
- <dd><p>Image Quality Assessment</p>
- </dd>
- <dt><kbd><span class="option">--pma</span></kbd></dt>
- <dd><p>Premultiply alpha into RGB channel.</p>
- </dd>
- <dt><kbd><span class="option">--linear</span></kbd></dt>
- <dd><p>Input and output texture is linear color space (gamma correction won’t be applied).</p>
- </dd>
- <dt><kbd><span class="option">--max <var><max size></var></span></kbd></dt>
- <dd><p>Maximum width/height (image will be scaled down and
- aspect ratio will be preserved)</p>
- </dd>
- <dt><kbd><span class="option">--radiance <var><model></var></span></kbd></dt>
- <dd><p>Radiance cubemap filter. (Lighting model: Phong, PhongBrdf, Blinn, BlinnBrdf, GGX)</p>
- </dd>
- <dt><kbd><span class="option">--as <var><extension></var></span></kbd></dt>
- <dd><p>Save as.</p>
- </dd>
- <dt><kbd><span class="option">--formats</span></kbd></dt>
- <dd><p>List all supported formats.</p>
- </dd>
- <dt><kbd><span class="option">--validate</span></kbd></dt>
- <dd><p><strong>DEBUG</strong> Validate that output image produced matches after loading.</p>
- </dd>
- </dl>
- </dd>
- </dl>
- </dd>
- </dl>
- </section>
- <section id="texture-viewer-texturev">
- <h2>Texture Viewer (texturev)<a class="headerlink" href="#texture-viewer-texturev" title="Link to this heading"></a></h2>
- <p>A texture viewer.</p>
- </section>
- </section>
- </div>
- </div>
- <footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
- <a href="bgfx.html" class="btn btn-neutral float-left" title="API Reference" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
- <a href="internals.html" class="btn btn-neutral float-right" title="Internals" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
- </div>
- <hr/>
- <div role="contentinfo">
- <p>© Copyright 2010-2025, Branimir Karadžić.</p>
- </div>
-
- </footer>
- </div>
- </div>
- </section>
- </div>
- <script>
- jQuery(function () {
- SphinxRtdTheme.Navigation.enable(true);
- });
- </script>
- </body>
- </html>
|