<?xml version="1.0"?>
<rss version="2.0"><channel><title>Documentation: Documentation</title><link>https://w3dhub.com/forum/documentation/w3d-engine-documentation/?d=1</link><description>Documentation: Documentation</description><language>en</language><item><title>How to work with PBR Materials in W3D 5.1</title><link>https://w3dhub.com/forum/documentation/w3d-engine-documentation/how-to-work-with-pbr-materials-in-w3d-51-r126/</link><description><![CDATA[<p>
	<strong>Introduction</strong>
</p>

<p>
	W3D 5.1 supports Metallic Roughness <strong>Physically Based Rendering</strong>, or PBR for short. PBR means that the visual properties of a surface are physically plausible, as such that realistic results are possible under all lighting conditions. If this sounds alien to you, then check out this brief introduction to PBR on YouTube, by GarageFarm Academy: 
</p>

<div class="ipsEmbeddedVideo" contenteditable="false">
	<div>
		<iframe allowfullscreen="" frameborder="0" height="113" title="PBR Explained in 3 Minutes - Physically Based Rendering" width="200" data-embed-src="https://www.youtube-nocookie.com/embed/_ZbkOZNgwNk?feature=oembed"></iframe>
	</div>
</div>

<p>
	<em>(Note: W3D 5.1 does not support Height maps, but future versions may.)</em>
</p>

<p>
	For instructions on how to use any of the software mentioned in this guide, please use the documentation provided by these tools, or look up some basic tutorials on how to use them. It shouldn't take anyone long to get a basic understanding of these tools, and most seasoned artists already know how to use them.
</p>

<p>
	In order to make PBR look correct in W3D, you will need to configure your project for it and this includes implementing Image Based Lighting, or IBL for short. This guide will cover the basics of how to implement PBR correctly, how to export your texture maps, and how to apply them to your models.
</p>

<p>
	 
</p>

<p>
	<strong>&gt;&gt;&gt; Step 1: Configuring Your Project and Using IBL</strong>
</p>

<p>
	Go to your project INI file directory, and locate <em>RendererFeatures.ini</em>. If this file does not exist, then create it.
</p>

<p>
	Add the following parameters and set them as true:
</p>

<pre class="ipsCode prettyprint lang-html prettyprinted"><span class="pln">SpecularEnabled=true
PbrIBLDiffuseEnabled=true
PbrIBLSpecularEnabled=true</span></pre>

<p>
	Next, we need to create an IBL file to correctly light the environment. 
</p>

<p>
	For this, you will need to obtain or create a HDRI skybox file. You may need to invest into licencing some, but I will attach an example for you to work with, here: <a class="ipsAttachLink" data-fileext="7z" data-fileid="34123" href="https://w3dhub.com/forum/applications/core/interface/file/attachment.php?id=34123&amp;key=138afc61b933c2dbf57fd0c07b937b54" rel="">HDRI-Sky-Example.7z</a>
</p>

<p>
	You will need to generate the correct files out of this HDRI skybox texture. We do this using an open source application called IBL Baker. Grab it from their Github page, here (Note: Click the green <em>Code</em> button and select <em>Download ZIP</em>): <a href="https://github.com/derkreature/IBLBaker" rel="external nofollow">https://github.com/derkreature/IBLBaker</a>
</p>

<p>
	Open the application by running <em>IBLBaker.exe</em> in the <em>bin64</em> directory. This will load an example scene. Next, click <em>Load Environment</em> and select your HDRI file. 
</p>

<p>
	Configure the <em>Specular Resolution</em> to 1024, and the <em>Diffuse Resolution</em> to 512. Leave the rest as default. Select <em>Save Environment</em> to export the files we need. Note: There is a slight oddity with the application, it may not export anything unless you pre-select another file (could be anything) within the <em>Export</em> directory. If your <em>Export</em> folder remains empty after saving, try selecting a random file first before pressing <em>Save</em> in the Windows Explorer menu.
</p>

<p>
	<img alt="iblbaker.png.eb76ccdb7a4f2eeb76ec9d6fba22475c.png" class="ipsImage ipsImage_thumbnailed" data-fileid="34125" data-ratio="74.15" width="1354" src="https://w3dhub.com/forum/uploads/monthly_2024_09/iblbaker.png.eb76ccdb7a4f2eeb76ec9d6fba22475c.png" />
</p>

<p>
	Now, go into the <em>Export</em> directory, and you should see several files. Some for <em>MDR</em>, and some for <em>HDR</em>. Delete all the files containing <em>MDR</em>, as well as the <em>Brdf</em> file, as we do not use these. What you should be left with is the following 3 files (where xx is the name you gave it):
</p>

<table border="1" cellpadding="1" cellspacing="1" style="width:267px;">
	<tbody>
		<tr>
			<td style="width:154px;">
				xx DiffuseHDR
			</td>
			<td style="width:109px;">
				size: 15 MB
			</td>
		</tr>
		<tr>
			<td style="width:154px;">
				xx SpecularHDR
			</td>
			<td style="width:109px;">
				size: 64 MB
			</td>
		</tr>
		<tr>
			<td style="width:154px;">
				xx EnvHDR
			</td>
			<td style="width:109px;">
				size: 256 MB
			</td>
		</tr>
	</tbody>
</table>

<p>
	Name these files as such:
</p>

<ul>
	<li>
		xx DiffuseHDR -&gt; ibl_diffuse
	</li>
	<li>
		xx SpecularHDR -&gt; ibl_specular
	</li>
	<li>
		xx EnvHDR -&gt; env
	</li>
	<li>
		Additionally, download this <a class="ipsAttachLink" data-fileext="7z" data-fileid="34124" href="https://w3dhub.com/forum/applications/core/interface/file/attachment.php?id=34124&amp;key=5ddbe6532ddfcc25e7d9d17829644f36" rel="">ibl_brdf_lut.7z</a> file and alongside the above files, place them inside your .dat file of preference.
	</li>
</ul>

<p>
	These files will act as your default IBL. You can also do an IBL environment per level, and to do this you repeat the process of making the above three files, but naming them with your level name as a prefix, for example: TS_TaintedLegacy_ibl_diffuse. Note: The ibl_brdf_lut file only needs to exist in your .dat structure.
</p>

<p>
	You can tune the IBL intensity by adjusting your level ambient lighting in Mammoth. Note: Mammoth doesn't understand IBL, so unfortunately you're working blind as of 5.1.
</p>

<p>
	That concludes the configuration phase.
</p>

<p>
	 
</p>

<p>
	<strong>&gt;&gt;&gt; Step 2: Implementing your PBR Assets</strong>
</p>

<p>
	You can create new PBR assets, or licence ones in various locations on the Internet. For this guide, lets say you licenced some PBR assets and you now wish to transport them to W3D. For this part I will assume you know how to handle geometry data.
</p>

<p>
	Locate the textures of the asset you wish to import. We need to figure out what texture packing format was used.
</p>

<p>
	Be on the look-out for these files:
</p>

<ul>
	<li>
		Albedo, also called Color
	</li>
	<li>
		Normal
	</li>
	<li>
		Occlusion
	</li>
	<li>
		Roughness
	</li>
	<li>
		Metallic
	</li>
	<li>
		Specularlevel
	</li>
	<li>
		Possible other maps you may encounter that we can use: opacity, emissive
	</li>
	<li>
		Other maps you may encounter, we do not support.
	</li>
</ul>

<p>
	Ideally, all these PBR textures are separate, but it is possible that some are pre-packaged, for example, this would often be the case when working with assets made for other game engines. Some packed textures may be named with ORM or ORT as a suffix, in these instanced you're looking at packed textures for Occlusion - Roughness - Metallic, or Occlusion - Roughness - Translucency, respectively. Naturally most of these pre-packed textures we cannot use, so you will need to use an image manipulation software such as Photoshop or GIMP to <em>Decompose</em> the RGB channels into separately exportable layers.
</p>

<p>
	Now that you have your individual texture files, it is time to package them. You can once again use image manipulation software such as Photoshop or GIMP to pack the textures, or you can use Adobe Substance Sampler to import them as a material, and then export them using Adobe Substance Painter. I would recommend the latter because it allows you to more easily iterate on the texture.
</p>

<p>
	<em>Note: If you obtained assets using a Specular-Glossiness PBR workflow as opposed to the Metallic-Roughness one W3D uses, then I strongly recommend the Adobe Substance route as it will automatically convert texture maps to whatever the output requires.</em>
</p>

<p>
	As an example, here is what your output template should look like in Adobe Substance Painter:
</p>

<p>
	<img alt="spec.png.6e49af506af240561fb995d0c9b0ff91.png" class="ipsImage ipsImage_thumbnailed" data-fileid="34128" data-ratio="70.52" width="1099" src="https://w3dhub.com/forum/uploads/monthly_2024_09/spec.png.6e49af506af240561fb995d0c9b0ff91.png" /><em>(Note: If you wish to include alpha, then simply create an additional template with alpha in the A channel of the base color map.)</em>
</p>

<p>
	Re-pack your textures as follows:
</p>

<ul>
	<li>
		Color map: YourTextureName - export as BC1 DDS. In case your texture contains alpha, use BC3 instead.
	</li>
	<li>
		Normal map: YourTextureName<strong>_nrm</strong> - export as BC5n. Please make sure you use a DirectX Normal map.
	</li>
	<li>
		PBR map: YourTextureName<strong>_spc</strong> - export as BC7. Ensure the following:
		<ul>
			<li>
				Red channel: Metallic
			</li>
			<li>
				Green channel: Roughness
			</li>
			<li>
				Blue channel: Occlusion
			</li>
			<li>
				Alpha channel: Specular Level
			</li>
		</ul>
	</li>
	<li>
		Emissive (if present): YourTextureName<strong>_emissive</strong> - export as BC1.
	</li>
</ul>

<p>
	Ensure you export using the highest DDS compression quality, or you will get very pixelated results. I also recommend exporting using Kaiser mipmaps for a bit better looking textures at distance. <em>Note: Using GIMP? Please use the Nvidia Texture Tools instead, as GIMP exports with very poor DDS compression, and doesn't support some of the formats we use.</em>
</p>

<p>
	Once the textures are ready in DDS format, open 3DS Max and create a new W3D material. Leave everything default except for:
</p>

<ul>
	<li>
		Shader -&gt; Sec Gradient -&gt; Enabled
	</li>
	<li>
		Textures -&gt; Publish &amp; Alpha Bitmap enabled.
	</li>
</ul>

<p>
	On the model itself, go to W3D Properties and:
</p>

<ul>
	<li>
		Enable Tangents
	</li>
	<li>
		Enable Always Dyn Light (note: If this is a dynamic object like a character or vehicle, you can skip this)
	</li>
</ul>

<p>
	Export your W3D file as you wish it, but make sure you enable <em>Export MikkTSpace-compliant Tangents</em> in the export menu. This is important, otherwise your assets will have various errors.
</p>

<p>
	Now simply load your asset into a level with the correct configurations, and... <em>it just works</em>.
</p>

<p>
	 
</p>

<p>
	Good luck!
</p>
]]></description><guid isPermaLink="false">126</guid><pubDate>Mon, 23 Sep 2024 19:34:55 +0000</pubDate></item></channel></rss>
