<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: dong pandit</title>
    <description>The latest articles on DEV Community by dong pandit (@dong_pandit_af9770455a07f).</description>
    <link>https://dev.to/dong_pandit_af9770455a07f</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4250762%2Fb4bfc180-f608-44e5-b014-e0cdabe3f8cd.png</url>
      <title>DEV Community: dong pandit</title>
      <link>https://dev.to/dong_pandit_af9770455a07f</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dong_pandit_af9770455a07f"/>
    <language>en</language>
    <item>
      <title>Why a 200 KB GLB Can Still Blow Your WebGL Texture Budget (And When 512px Files Grow Larger on Disk)</title>
      <dc:creator>dong pandit</dc:creator>
      <pubDate>Wed, 18 Nov 2026 01:16:06 +0000</pubDate>
      <link>https://dev.to/dong_pandit_af9770455a07f/why-a-200-kb-glb-can-still-blow-your-webgl-texture-budget-and-when-512px-files-grow-larger-on-disk-1n5k</link>
      <guid>https://dev.to/dong_pandit_af9770455a07f/why-a-200-kb-glb-can-still-blow-your-webgl-texture-budget-and-when-512px-files-grow-larger-on-disk-1n5k</guid>
      <description>&lt;p&gt;&lt;em&gt;Originally published at &lt;a href="https://scenecrate.com/guides/gltf-vs-glb-for-web-games" rel="noopener noreferrer"&gt;SceneCrate — glTF vs GLB for Web and Three.js Games&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://scenecrate.com/free-3d-game-assets" rel="noopener noreferrer"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2F68jhhcg8ig2fnx1j13f7.webp" alt="Sunward Outpost 3D Scene" width="800" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When preparing 3D assets for a browser game, two misconceptions cause most production surprises:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Assuming multi-file &lt;code&gt;.gltf&lt;/code&gt; and binary &lt;code&gt;.glb&lt;/code&gt; behave the same way under strict browser Content Security Policies and asset CDNs.&lt;/li&gt;
&lt;li&gt;Treating the &lt;code&gt;.glb&lt;/code&gt; download size on disk as a proxy for GPU texture memory (VRAM) on mobile browsers and integrated graphics.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Here is what we measured while building nine walkable &lt;strong&gt;CC0 1.0&lt;/strong&gt; Three.js test scenes and a deterministic static-prop validation pipeline.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. Multi-file &lt;code&gt;.gltf&lt;/code&gt; vs self-contained &lt;code&gt;.glb&lt;/code&gt; in the browser
&lt;/h2&gt;

&lt;p&gt;Both &lt;code&gt;.gltf&lt;/code&gt; and &lt;code&gt;.glb&lt;/code&gt; store the exact same Khronos glTF 2.0 scene graph, PBR materials, and right-handed &lt;code&gt;+Y&lt;/code&gt; up metre coordinates. Only the container differs:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;&lt;code&gt;.gltf&lt;/code&gt;&lt;/strong&gt; file is human-readable JSON referencing external &lt;code&gt;.bin&lt;/code&gt; geometry buffers and external &lt;code&gt;.png&lt;/code&gt;, &lt;code&gt;.jpg&lt;/code&gt;, or &lt;code&gt;.webp&lt;/code&gt; image files via relative paths (or inflating JSON size by ~33% if buffers are embedded as &lt;code&gt;data:&lt;/code&gt; base64 URIs).&lt;/li&gt;
&lt;li&gt;A &lt;strong&gt;&lt;code&gt;.glb&lt;/code&gt;&lt;/strong&gt; file packs a 12-byte binary header, a padded JSON chunk, and a raw &lt;code&gt;BIN&lt;/code&gt; chunk holding vertex buffers and compressed image bytes in one self-contained file.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Multi-file &lt;code&gt;.gltf&lt;/code&gt; is convenient in local Git/Blender iteration when sharing one texture directory across dozens of WIP meshes. At runtime in a browser game, however, external sidecar files multiply failure modes: broken relative paths behind versioned CDNs, partial HTTP cache misses leaving half-textured meshes, and no single atomic SHA-256 hash to verify before parsing.&lt;/p&gt;

&lt;p&gt;In our Three.js viewer, every asset must be a strictly self-contained &lt;code&gt;.glb&lt;/code&gt;. We check the 12-byte GLB header upfront before spinning up any parser or worker:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;isValidGlbHeader&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nc"&gt;Uint8Array&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;fullByteLength&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;byteLength&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kt"&gt;boolean&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;byteLength&lt;/span&gt; &lt;span class="o"&gt;&amp;lt;&lt;/span&gt; &lt;span class="mi"&gt;12&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;DataView&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;buffer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;byteOffset&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;bytes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;byteLength&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;magic&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUint32&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// 0x46546c67 === 'glTF'&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUint32&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// glTF 2.0&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;view&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUint32&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  &lt;span class="c1"&gt;// exact byte length&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;magic&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mh"&gt;0x46546c67&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;version&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="n"&gt;fullByteLength&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At runtime, our &lt;code&gt;LoadingManager.setURLModifier&lt;/code&gt; rejects any external network URL and permits only internal &lt;code&gt;blob:&lt;/code&gt; URLs created from the verified buffer.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Strict CSP gotcha:&lt;/strong&gt; When &lt;code&gt;GLTFLoader&lt;/code&gt; decodes embedded PNG/JPEG/WebP buffers inside a &lt;code&gt;.glb&lt;/code&gt;, it creates internal &lt;code&gt;blob:&lt;/code&gt; object URLs. If your HTTP &lt;code&gt;Content-Security-Policy&lt;/code&gt; locks down &lt;code&gt;default-src 'self'&lt;/code&gt;, you &lt;strong&gt;must&lt;/strong&gt; allow &lt;code&gt;blob:&lt;/code&gt; in both &lt;code&gt;img-src&lt;/code&gt; and &lt;code&gt;connect-src&lt;/code&gt;—otherwise embedded GLB textures silently fail and render pure white in production.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  2. Network bytes != GPU texture memory (VRAM)
&lt;/h2&gt;

&lt;p&gt;PNG, JPEG, and WebP compression inside a &lt;code&gt;.glb&lt;/code&gt; only shrink &lt;strong&gt;network transfer bytes&lt;/strong&gt;. Unless your pipeline transcodes GPU block-compressed KTX2 (&lt;code&gt;KHR_texture_basisu&lt;/code&gt;), standard 2D images expand into uncompressed &lt;code&gt;RGBA8&lt;/code&gt; pixels (4 bytes per pixel) when uploaded to WebGL:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;512 × 512 RGBA8&lt;/strong&gt; = &lt;strong&gt;1 MiB&lt;/strong&gt; base level (~1.33 MiB with mipmaps)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;1024 × 1024 RGBA8&lt;/strong&gt; = &lt;strong&gt;4 MiB&lt;/strong&gt; base level (~5.33 MiB with mipmaps)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;2048 × 2048 RGBA8&lt;/strong&gt; = &lt;strong&gt;16 MiB&lt;/strong&gt; base level (~21.3 MiB with mipmaps)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;4096 × 4096 RGBA8&lt;/strong&gt; = &lt;strong&gt;64 MiB&lt;/strong&gt; base level (~85.3 MiB with mipmaps)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Put BaseColor, Normal, Roughness/Metallic, and Occlusion maps at 4K on a single raw mesh, and one decorative prop consumes over &lt;strong&gt;300 MiB of VRAM&lt;/strong&gt; regardless of whether its &lt;code&gt;.glb&lt;/code&gt; downloaded in 4 MB.&lt;/p&gt;

&lt;p&gt;Even more counterintuitive: &lt;strong&gt;lowering pixel caps to save VRAM does not always shrink &lt;code&gt;.glb&lt;/code&gt; file bytes on disk.&lt;/strong&gt; Across the three static props in our CC0 reference library:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Prop&lt;/th&gt;
&lt;th&gt;Triangles (Both Tiers)&lt;/th&gt;
&lt;th&gt;Standard (&lt;code&gt;1024 px&lt;/code&gt; cap)&lt;/th&gt;
&lt;th&gt;Lightweight (&lt;code&gt;512 px&lt;/code&gt; cap)&lt;/th&gt;
&lt;th&gt;Base RGBA8 VRAM Change&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Moss stone&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;80&lt;/td&gt;
&lt;td&gt;1.31 MiB (&lt;code&gt;1,373,976 B&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;320.3 KiB (&lt;code&gt;327,988 B&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;4× lower per &lt;code&gt;1024 → 512&lt;/code&gt; map&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Oak barrel&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;1,244&lt;/td&gt;
&lt;td&gt;113.5 KiB (&lt;code&gt;116,180 B&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;207.7 KiB (&lt;code&gt;212,700 B&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;4× lower per &lt;code&gt;1024 → 512&lt;/code&gt; map&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Shipping crate&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;12&lt;/td&gt;
&lt;td&gt;54.2 KiB (&lt;code&gt;55,452 B&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;118.1 KiB (&lt;code&gt;120,944 B&lt;/code&gt;)&lt;/td&gt;
&lt;td&gt;4× lower per &lt;code&gt;1024 → 512&lt;/code&gt; map&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;On high-frequency noisy textures (&lt;code&gt;Moss stone&lt;/code&gt;), downsampling &lt;code&gt;1024 → 512&lt;/code&gt; shrank compressed bytes ~4× as expected. On compact procedural textures (&lt;code&gt;Oak barrel&lt;/code&gt; and &lt;code&gt;Shipping crate&lt;/code&gt;), resampling introduced smooth intermediate pixel gradients that encoded into more PNG/JPEG bytes on disk—yet on a memory-constrained mobile browser, the &lt;code&gt;512 px&lt;/code&gt; tier still saves 75% of decoded texture memory per resized map.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. Material counts drive WebGL draw calls in both formats
&lt;/h2&gt;

&lt;p&gt;Switching from &lt;code&gt;.gltf&lt;/code&gt; to &lt;code&gt;.glb&lt;/code&gt; merges files on disk, &lt;strong&gt;not&lt;/strong&gt; draw calls on the GPU. Every distinct material primitive in a loaded glTF scene submits a separate WebGL draw call unless your engine batches or instances them.&lt;/p&gt;

&lt;p&gt;Compare two enterable buildings in our test library:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Mossgate Passage (&lt;code&gt;stone-gateway&lt;/code&gt;)&lt;/strong&gt; renders &lt;strong&gt;105,945 triangles&lt;/strong&gt; using just &lt;strong&gt;2 baked PBR atlas materials&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Sunward Outpost (&lt;code&gt;desert-outpost&lt;/code&gt;)&lt;/strong&gt; renders &lt;strong&gt;8,538 triangles&lt;/strong&gt; across &lt;strong&gt;15 distinct materials&lt;/strong&gt; (&lt;code&gt;2,136&lt;/code&gt; triangles / &lt;code&gt;15&lt;/code&gt; materials in Lightweight).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For individual static props placed dozens of times across a level, keep material budgets tight: our automated static-prop gates cap Standard deliveries at &lt;code&gt;&amp;lt;= 15,000&lt;/code&gt; triangles / &lt;code&gt;1024 px&lt;/code&gt; / &lt;code&gt;4&lt;/code&gt; materials (&lt;code&gt;8 MiB&lt;/code&gt; max) and Lightweight deliveries at &lt;code&gt;&amp;lt;= 5,000&lt;/code&gt; triangles / &lt;code&gt;512 px&lt;/code&gt; / &lt;code&gt;2&lt;/code&gt; materials (&lt;code&gt;3 MiB&lt;/code&gt; max).&lt;/p&gt;




&lt;h2&gt;
  
  
  4. Pre-ship GLB checklist for browser games
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Header &amp;amp; self-containment:&lt;/strong&gt; Verify magic &lt;code&gt;0x46546C67&lt;/code&gt;, version &lt;code&gt;2&lt;/code&gt;, exact byte length, and zero external buffer/image URIs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Track VRAM separately from zip bytes:&lt;/strong&gt; Audit texture pixel dimensions (&lt;code&gt;width × height × 4 × 1.33&lt;/code&gt;) alongside HTTP download size.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Metre scale &amp;amp; grounding:&lt;/strong&gt; Confirm &lt;code&gt;+Y&lt;/code&gt; up metre dimensions with the base resting at &lt;code&gt;y = 0&lt;/code&gt; next to a &lt;code&gt;1.7 m&lt;/code&gt; player capsule.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Explicit collision:&lt;/strong&gt; Pair closed convex props with a conservative box, enterable doorways with local wall boxes, and sloped ground with a shared heightfield.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Clean WebGL disposal:&lt;/strong&gt; Traverse removed hierarchies and call &lt;code&gt;.dispose()&lt;/code&gt; on geometries, materials, and textures on level unload.&lt;/li&gt;
&lt;/ol&gt;




&lt;p&gt;If you want to inspect the &lt;code&gt;.glb&lt;/code&gt; buffers, &lt;code&gt;report.json&lt;/code&gt; metrics, and runnable local Three.js harnesses directly, all nine scene packs are free to download under &lt;strong&gt;CC0 1.0&lt;/strong&gt; (no sign-in required) at &lt;a href="https://scenecrate.com/free-3d-game-assets" rel="noopener noreferrer"&gt;SceneCrate Free 3D Game Assets&lt;/a&gt;, and the full guide series is at &lt;a href="https://scenecrate.com/guides" rel="noopener noreferrer"&gt;scenecrate.com/guides&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>threejs</category>
      <category>webgl</category>
      <category>gamedev</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
