├── LICENSE ├── README.md └── UnityHeightmapBaker.blend /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Unity Heightmap Baker 2 | A small Blendfile that enables you to bake .raw terrain heightmaps for unity. 3 | 4 | Youtube Link: https://youtu.be/53KAZO0cimw 5 | 6 | Disclaimer: This is neither a fully developed Blender Addon, nor a very clean solution. But it seems to work and it is fast. So i hope it will assist you in your terrain creation process. 7 | 8 | ## Usage 9 | 10 | To use the baker open the blendfile. After that you may put anything inside the Baking Volume. Everything that is outside of it will not be included in the heightmap. By default it contains a plane with a multires modifier, that is ready for sculpting and a monkey mesh for demonstration purposes. After creating your terrain simply press the "Run Script" Button on the bottom right. Blender will most likely freeze for a couple of seconds and a file called "Heightmap.raw" will appear in the folder that contains your blendfile. 11 | 12 | In unity import the .raw image, and set the following values: 13 | - Depth: 16bit 14 | - Width/Height: like set in Blender (1025 by default) Must be power of two plus one! 15 | - Byte Order: Windows 16 | - Flip vertically: false 17 | - Terrain Size: By deafult the "Y" axis should be half as big as "X" and "Z" 18 | 19 | ## Modification 20 | 21 | Here are some modifications you may make to adjust the blendfile to your needs: 22 | 23 | To adjust the resolution of the heightmap, just change the resolution in your scene renderer settings in Blender. Be aware that unity requires the resolution to be a power of two plus one. 24 | 25 | To change the filepath or name of the output open the python script and change the corresponding String in line 8. 26 | 27 | To change the height of your baking volume move the camera up by that amount, go to the world settings -> Mist Pass and add your heightchange to the "Depth" value. You may also change the BakingVolume mesh, but it is more of a reminder than a necessity. Also take the heightchange into consideration when importing to unity. 28 | 29 | If you dont want to bake it, but use an image, you can also comment out the rendering line in the script (line 14) and plug your own image into the viewer node. The script will interpret the red channel of the image as your height. 30 | 31 | You can also use your GPU to render the image, but i experienced some weird bugs when doing that, so it is set to CPU by deafult. But just try it out. 32 | -------------------------------------------------------------------------------- /UnityHeightmapBaker.blend: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Mezaka/UnityHeightmapBaker/66b537b6dd29f68e83727cef448c475b4f9301a8/UnityHeightmapBaker.blend --------------------------------------------------------------------------------