| 123456789101112131415161718192021222324252627282930313233343536 |
- <!DOCTYPE html><html lang="en"><head><meta charset="UTF-8"><!--[if IE]><meta http-equiv="X-UA-Compatible" content="IE=edge"><![endif]--><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="Asciidoctor 1.5.4"><meta name="keywords" content="documentation, sdk, tool, texture, material"><title>jMonkeyEngine SDK: Procedural Textures with NeoTexture</title><link rel="stylesheet" href="./asciidoctor.css">
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
- <link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"></head><body class="article toc2 toc-left"><div id="header"><div id="toolbar"><a href="https://github.com/jMonkeyEngine/wiki/edit/master/src/docs/asciidoc/sdk/neotexture.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/sdk/"><i class="fa fa-plus-square" aria-hidden="true"></i></a><input dir="auto" style="position: relative; vertical-align: top;" spellcheck="false" autocomplete="off" class="searchbox__input aa-input" id="doc-search" name="search" placeholder="Search in the doc" required="required" type="search"><i class="fa fa-sort-down" aria-hidden="true"></i></div><h1>jMonkeyEngine SDK: Procedural Textures with NeoTexture</h1><div class="details"><span class="author" id="author"></span><br><span id="revnumber">version ,</span> <span id="revdate">2016/03/17 20:48</span></div><div id="toc" class="toc2"><div id="toctitle">Table of Contents</div><ul class="sectlevel1"><li><a href="#creating-and-editing-a-neotexture-file">Creating and Editing a NeoTexture file</a></li><li><a href="#adding-the-neotexture-libraries-to-your-project">Adding the NeoTexture libraries to your project</a></li><li><a href="#loading-tgr-files-as-material">Loading tgr files as material</a></li><li><a href="#using-tgr-files-like-normal-textures-in-j3m-files">Using tgr files like normal textures in j3m files</a></li></ul></div></div><div id="content"><div id="preamble"><div class="sectionbody"><div class="paragraph"><p>The NeoTextureEditor allows creating tiled textures procedurally using a simple node interface for generating images, blending them, creating normal maps and much more. You can directly load the .tgr files as a material or export the generated images as .png files and use them in a jMonkeyEngine-based game.</p></div>
- <div class="paragraph"><p>Textures usually make up most of the size of a game distribution. This is why NeoTexture is not only an editor, but also a library that generates textures from .tgr files. Use the library to load .tgr files directly in jME3 as a material, without having to export the textures before. This means high-quality textures for your models, but just tiny description files in your distribution.</p></div></div></div>
- <div class="sect1"><h2 id="creating-and-editing-a-neotexture-file">Creating and Editing a NeoTexture file</h2><div class="sectionbody"><div style="text-align: right;" class="imageblock"><div class="content"><img src="../wp-uploads/2010/10/neotexture-300x189.jpg" alt="neotexture-300x189.jpg" width="" height=""></div></div>
- <div class="olist arabic"><ol class="arabic"><li><p>Right-click the <code>assets/Textures</code> directory and choose New… > Other.</p></li><li><p>In the New File Wizard, choose NeoTexture > Empty NeoTextureFile and click Next.</p></li><li><p>Give the file a name, for exmaple <code>neoMaterial</code>.</p></li><li><p>A new file <code>neoMaterial.tgr</code> is created in the Textures directory and opens in the NeoTexture Editor.</p></li></ol></div>
- <div class="paragraph"><p>Edit the .tgr file and create your procedural texture: (<a href="http://neotextureedit.sourceforge.net/">Learn more about creating Procedural Textures here</a>)</p></div>
- <div class="olist arabic"><ol class="arabic"><li><p>Drag any pattern from the left bar to the editor area.</p></li><li><p>Right-click the editor area and paste a NormalMap filter node.</p></li><li><p>Connect the green output mark of the pattern with the red input mark of the filter. +This generates a Normal Map that can be used as bump map.</p></li></ol></div></div></div>
- <div class="sect1"><h2 id="adding-the-neotexture-libraries-to-your-project">Adding the NeoTexture libraries to your project</h2><div class="sectionbody"><div class="paragraph"><p>To use NeoTexture tgr files directly in your application, you have to add the NeoTexture libraries to your project:</p></div>
- <div class="olist arabic"><ol class="arabic"><li><p>Right-click your project and select “Properties</p></li><li><p>Go to the “Libraries section of the properties window</p></li><li><p>Press “Add Library..</p></li><li><p>Select “NeoTexture-Libraries and press “add</p></li></ol></div></div></div>
- <div class="sect1"><h2 id="loading-tgr-files-as-material">Loading tgr files as material</h2><div class="sectionbody"><div style="text-align: right;" class="imageblock"><div class="content"><img src="../wp-uploads/2010/10/neotexture-2-300x149.jpg" alt="neotexture-2-300x149.jpg" width="" height=""></div></div>
- <div class="paragraph"><p>We want to use the procedural texture as a material based on <code>Lighting.j3md</code> (the default). We know that Lighting.j3md supports DiffuseMap, NormalMap, SpecularMap, and ParallaxMap.</p></div>
- <div class="olist arabic"><ol class="arabic"><li><p>Click the Normal Map filter to select it. We want to use it as the Normal Map of the texture.</p><div class="olist loweralpha"><ol class="loweralpha" type="a"><li><p>In the NeoTextures Properties window under <code>Export name</code>, enter the name of the texture layer as it would appear in a .j3m file, e.g. “NormalMap”.</p></li></ol></div></li><li><p>Click the pattern to select it. We want to (re)use it as Diffuse Map of the texture.</p><div class="olist loweralpha"><ol class="loweralpha" type="a"><li><p>In the NeoTextures Properties window under <code>Export name</code>, enter the name of the texture layer as it would appear in a .j3m file, e.g. “DiffuseMap”.</p></li></ol></div></li><li><p>Click the Save button in the NeoTextures Editor. The .tgr file is saved with two layers. (We could add SpecularMap and ParallaxMap the same way, if we wanted.)</p></li></ol></div>
- <div class="paragraph"><p>Let’s assign the newly created texture to a mesh to see what it looks like.</p></div>
- <div class="olist arabic"><ol class="arabic"><li><p>Open your Main.java file.</p></li><li><p>Choose Window→Palette to open the Palette. You will find two NeoTexture code snippets, one for adding the NeoTexture loader to the assetManager, and one for loading a NeoTexture material.</p></li><li><p>Drag&Drop one of each into the simpleInitApp() method of your application.</p></li><li><p>Adjust the .tgr file path names to match the file that we just created: “Materials/neoMaterial.tgr.</p></li></ol></div>
- <div class="paragraph"><p>Clean, build and run. You’re ready to load your procedural material!</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">assetManager.registerLoader(com.jme3.material.plugins.NeoTextureMaterialLoader.class,<span class="string"><span class="delimiter">"</span><span class="content">tgr</span><span class="delimiter">"</span></span>);
- NeoTextureMaterialKey key = <span class="keyword">new</span> NeoTextureMaterialKey(<span class="string"><span class="delimiter">"</span><span class="content">Materials/neoMaterial.tgr</span><span class="delimiter">"</span></span>);
- Material mat = assetManager.loadAsset(key);
- mat.setFloat(<span class="string"><span class="delimiter">"</span><span class="content">Shininess</span><span class="delimiter">"</span></span>,<span class="integer">12</span>); <span class="comment">/* Lighting.j3md has non-map parameters too that we can set. */</span>
- thing.setMaterial(mat);</code></pre></div></div>
- <div class="paragraph"><p>The default Material Definition for NeoTextures is <code>Lighting.j3md</code>, and it’s probably the one you will use most often. In case that you want to use additional texture parameters, other than DiffuseMap, SpecularMap, ParallaxMap, and NormalMap, you can switch to another Material Definition using setMaterialDef(), for instance:</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">key.setMaterialDef(<span class="string"><span class="delimiter">"</span><span class="content">Commons/MatDefs/Misc/ColoredTextured.j3md</span><span class="delimiter">"</span></span>);</code></pre></div></div>
- <div class="paragraph"><p>Remember that the layer names in the .tgr file must match the ones declared in the .j3md file. In our example of <code>ColoredTextured.j3md</code>, the .tgr file must contain a <code>ColorMap</code> and you need to set a RGBAColor.</p></div></div></div>
- <div class="sect1"><h2 id="using-tgr-files-like-normal-textures-in-j3m-files">Using tgr files like normal textures in j3m files</h2><div class="sectionbody"><div class="paragraph"><p>You can use the .tgr files like normal textures in j3m files, with a syntax like this:
- <code>Materials/neoMaterial?DiffuseMap.tgr</code>
- The part between the <code>?</code> and the suffix is the name of the node you want to load as a texture. If you dont supply a name, <code>texture</code> is used.</p></div>
- <div class="paragraph"><p>To be able to load these textures, you have to register a Locator and a Loader in the AssetManager, note that you can only register one loader per extension so you cannot load .tgr files as materials and as textures with the same assetManager.</p></div>
- <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">assetManager.registerLocator(<span class="string"><span class="delimiter">"</span><span class="content">/</span><span class="delimiter">"</span></span>, com.jme3.texture.plugins.NeoTextureLocator.class );
- assetManager.registerLoader(com.jme3.texture.plugins.NeoTextureLoader.class,<span class="string"><span class="delimiter">"</span><span class="content">tgr</span><span class="delimiter">"</span></span>);</code></pre></div></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2017-10-25 21:59:24 +00:00</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
- apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
- indexName: 'jmonkeyengine',
- inputSelector: '#doc-search',
- debug: false // Set debug to true if you want to inspect the dropdown
- });</script></body></html>
|