sky.html 6.1 KB

123456789101112131415161718192021222324
  1. <!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"><title>How to add a Sky to your Scene</title><link rel="stylesheet" href="./asciidoctor.css">
  2. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.5.0/css/font-awesome.min.css">
  3. <link rel="stylesheet" href="./coderay-asciidoctor.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.css"><link rel="stylesheet" href="/home/travis/build/jMonkeyEngine/wiki/build/asciidoc/html5/jme3/advanced/twemoji-awesome.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/jme3/advanced/sky.adoc"><i class="fa fa-pencil-square" aria-hidden="true"></i></a><a href="https://github.com/jMonkeyEngine/wiki/new/master/src/docs/asciidoc/jme3/advanced/"><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"></div><h1>How to add a Sky to your Scene</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="#adding-the-sky">Adding the Sky</a></li><li><a href="#creating-the-textures">Creating the Textures</a></li></ul></div></div><div id="content"><div id="preamble"><div class="sectionbody"><div class="paragraph"><p>Here is an example for how you add a static horizon (a background landscape and a sky) to a scene.
  4. Having a discernable horizon with a suitable landscape (or space, or ocean, or whatever) in the background makes scenes look more realistic than just a single-colored &#8220;sky&#8221; background.</p></div></div></div>
  5. <div class="sect1"><h2 id="adding-the-sky">Adding the Sky</h2><div class="sectionbody"><div class="paragraph"><p>Adding a sky is extremely easy using the <code>com.jme3.util.SkyFactory</code>.</p></div>
  6. <div class="listingblock"><div class="content"><pre class="CodeRay highlight"><code data-lang="java">getRootNode().attachChild(SkyFactory.createSky(getAssetManager(), <span class="string"><span class="delimiter">&quot;</span><span class="content">Textures/Sky/Bright/BrightSky.dds</span><span class="delimiter">&quot;</span></span>, SkyFactory.EnvMapType.CubeMap));</code></pre></div></div>
  7. <div class="paragraph"><p>To add a sky you need to supply:</p></div>
  8. <div class="olist arabic"><ol class="arabic"><li><p>The assetManager object to use</p></li><li><p>A cube or sphere map texture of the sky</p></li><li><p>Set the map type: <a href="https://javadoc.jmonkeyengine.org/v3.3.0-beta1/com/jme3/util/SkyFactory.EnvMapType.html">SkyFactory.EnvMapType</a>. In this instance, CubeMap.</p></li></ol></div>
  9. <div class="paragraph"><p>Internally, the SkyFactory calls the following methods:</p></div>
  10. <div class="olist arabic"><ol class="arabic"><li><p><code>sky.setQueueBucket(Bucket.Sky);</code> makes certain the sky is rendered in the right order, behind everything else.</p></li><li><p><code>sky.setCullHint(Spatial.CullHint.Never);</code> makes certain that the sky is never culled.</p></li><li><p>The SkyFactory uses the internal jME3 material definition <code>Sky.j3md</code>. This Material definition works with sphere and cube maps.</p></li></ol></div></div></div>
  11. <div class="sect1"><h2 id="creating-the-textures">Creating the Textures</h2><div class="sectionbody"><div class="paragraph"><p>As the sky texture we use the sample BrightSky.dds file from jme3test-test-data.</p></div>
  12. <div class="paragraph"><p>How to create a sky textures?</p></div>
  13. <div class="ulist"><ul><li><p>There are many tools out there that generate cube and sphere maps.<br>
  14. Examples for landscape texture generators are Terragen or Bryce.</p></li><li><p>The actual texture size does not matter, as long as you add the Sky Geometry to the Sky bucket: Everything in the sky bucket will always be infinitely far away behind everything else, and never intersect with your scene.<br>
  15. Of course the higher the resolution, the better it will look. On the other hand, if the graphic is too big, it will slow the game down.</p></li><li><p>A box or sphere map is the simplest solution. But you can use any Node as sky, even complex sets of geometries and quads with animated clouds, blinking stars, city skylines, etc.</p></li><li><p>JME3 supports cube maps in PNG, JPG, or (compressed) DDS format.</p></li></ul></div>
  16. <div class="paragraph"><p>Box or Sphere?</p></div>
  17. <div class="ulist"><ul><li><p>If you have access to cube map textures, then use a SkyBox</p><div class="ulist"><ul><li><p><a href="http://1.bp.blogspot.com/_uVsWqMqIGQU/SN0IZEE117I/AAAAAAAAAPs/4lfHx1Erdqg/s1600/skybox">SkyBox examples</a></p></li></ul></div></li><li><p>If you have access to sphere map textures – specially projected sky images that fit inside a sphere – then you use a SkySphere or SkyDome.</p><div class="ulist"><ul><li><p><a href="http://wiki.delphigl.com/index.php/Datei:Skysphere.jpg">SkySphere example</a></p></li></ul></div></li></ul></div>
  18. <div class="paragraph"><p>For more information on Skymap creation see:</p></div>
  19. <div class="ulist"><ul><li><p><a href="../../jme3/advanced/free_skymaps.html">How to create free skymaps</a></p></li><li><p><a href="../../jme3/external/blender.html#skybox-baking">SkyBox baking</a></p></li></ul></div></div></div></div><div id="footer"><div id="footer-text">Version <br>Last updated 2019-12-20 23:30:51 +00:00</div></div><script type="text/javascript" src="https://cdn.jsdelivr.net/docsearch.js/2/docsearch.min.js"></script><script>docsearch({
  20. apiKey: 'a736b6d93de805e26ec2f49b55013fbd',
  21. indexName: 'jmonkeyengine',
  22. inputSelector: '#doc-search',
  23. debug: false // Set debug to true if you want to inspect the dropdown
  24. });</script></body></html>