{"id":1881,"date":"2013-04-14T22:15:59","date_gmt":"2013-04-14T19:15:59","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=1881"},"modified":"2014-06-24T00:54:31","modified_gmt":"2014-06-23T21:54:31","slug":"heightmap-chunk","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2013\/04\/14\/heightmap-chunk\/","title":{"rendered":"Heightmap Chunk"},"content":{"rendered":"<p><a title=\"start webplayer demo\" href=\" http:\/\/unitycoder.com\/upload\/demos\/HeightMapChunkCraft1\/\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1882\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2013\/04\/14\/heightmap-chunk\/heighmap_chunks_minecraft_style_unity3d\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d.jpg?fit=680%2C379&amp;ssl=1\" data-orig-size=\"680,379\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"heighmap_chunks_minecraft_style_unity3d\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d.jpg?fit=680%2C379&amp;ssl=1\" class=\"alignnone size-full wp-image-1882\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d.jpg?resize=680%2C379\" alt=\"heighmap_chunks_minecraft_style_unity3d\" width=\"680\" height=\"379\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d.jpg?resize=300%2C167&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Saw this in the forums (<a title=\"http:\/\/forum.unity3d.com\/threads\/177831-MineCraft-style-game?p=1218902#post1218902\" href=\"http:\/\/forum.unity3d.com\/threads\/177831-MineCraft-style-game?p=1218902#post1218902\" target=\"_blank\">simpleminecraft<\/a>), sounds interesting!. Havent looked at their sources yet, but made own test version first..<\/p>\n<p><strong>Current version:<\/strong><br \/>\n&#8211; Single chunk..<br \/>\n&#8211; Chunk creator (random or perlin)<br \/>\n&#8211; 2D array for grid heights<br \/>\n&#8211; 3D array for grid cell types<br \/>\n&#8211; Using texture atlas (current texture is from some minecraft texture pack..)<br \/>\n&#8211; Using <a title=\"http:\/\/wiki.unity3d.com\/index.php\/GridMove\" href=\"http:\/\/wiki.unity3d.com\/index.php\/GridMove\" target=\"_blank\">grid movement<\/a> from unifywiki: player can move around, if target pos it not too high (modified the script so that it moves first up or down, if need to)<br \/>\n&#8211; Basic camera switch<br \/>\n&#8211; Basic Vertex color lightness calculation (if neighbours are higher, make this block darker..)<br \/>\n&#8211; Added better controls (w = move forwards, a\/d = move sideways, q\/e = rotate)<br \/>\n&#8211; Added basic laser effect for &#8220;cutting&#8221; a block in front<br \/>\n&#8211; Added basic terrain editing (press space to eat block in front of you, blocks above it will go down instantly..)<br \/>\n&#8211; GridMove was too sensitive, modified:<\/p>\n<pre class=\"brush: csharp; title: ; notranslate\" title=\"\">\r\n\/\/ before\r\ninput = new Vector2(Input.GetAxis(&quot;Horizontal&quot;), Input.GetAxis(&quot;Vertical&quot;));\r\n\/\/ after\r\ninput = new Vector2(Input.GetAxisRaw(&quot;Horizontal&quot;), Input.GetAxisRaw(&quot;Vertical&quot;));\r\n<\/pre>\n<p>&#8211; Added version 3.0 webplayer<br \/>\n&#8211; Added health guitexture (hearts, you can see it decrease when player digs ground..just for testing)<br \/>\n&#8211; Added some metal textures to player (low res <a title=\"http:\/\/unitycoder.com\/blog\/2013\/03\/23\/substance-resources-for-unity\/\" href=\"http:\/\/unitycoder.com\/blog\/2013\/03\/23\/substance-resources-for-unity\/\" target=\"_blank\">substances from here<\/a>)<br \/>\n&#8211; Added firepower guitexture (mousescroll to adjust it)<br \/>\n&#8211; Added basic cannon (rotates slowly towards mouse, taken from <a title=\"http:\/\/unitycoder.com\/blog\/2012\/01\/07\/deflector-proto\/\" href=\"http:\/\/unitycoder.com\/blog\/2012\/01\/07\/deflector-proto\/\" target=\"_blank\">deflector proto test<\/a>)<br \/>\n&#8211; Added basic shooting (rigidbody sphere) &amp; missile collision checker<br \/>\n&#8211; Adjusted fog color<\/p>\n<p><strong>TODO:<\/strong><br \/>\n&#8211; Better world generation (+biomes..)<br \/>\n&#8211; Fix rounding errors.. using Vector3()..values start to get away from exact 0.5 steps.. maybe this: <a title=\"http:\/\/answers.unity3d.com\/questions\/153224\/round-to-nearest-5.html\" href=\"http:\/\/answers.unity3d.com\/questions\/153224\/round-to-nearest-5.html\" target=\"_blank\">Rounding values to 0.5<\/a><br \/>\n&#8211; Collisions?<br \/>\n&#8211; Animate falling blocks?<br \/>\n&#8211; Multiple chunks<br \/>\n&#8211; Physics? (no need caves, so if you remove a block, other blocks from top of it should fall down)<br \/>\n&#8211; 2D version? (then could use the watersim fluids for it)<br \/>\n&#8211; Fake shadows, ao..etc (since we are in fixed grid..could be easier) *Some tools here: <a title=\"http:\/\/forum.unity3d.com\/threads\/126726-Per-vertex-AO-solver-%28and-goodies%29\" href=\"http:\/\/forum.unity3d.com\/threads\/126726-Per-vertex-AO-solver-%28and-goodies%29\" target=\"_blank\">VertexAo<\/a><br \/>\n&#8211; Use <a title=\"http:\/\/unitycoder.com\/blog\/2013\/04\/09\/a-pathfinder-2d-3d\/\" href=\"http:\/\/unitycoder.com\/blog\/2013\/04\/09\/a-pathfinder-2d-3d\/\" target=\"_blank\">3D A* pathfinder<\/a>!? (mouseclick target, then player moves there? or for enemies..)<br \/>\n&#8211; Add something to collect..coins..<br \/>\n&#8211; FPS view? Camera follow?<br \/>\n&#8211; 1 chunk is 1 room? (add teleport as a goal &gt;&gt;&gt; moves to next level after tasks are done?)<br \/>\n&#8211; Terrain mesh normals, tangents (<a title=\"http:\/\/answers.unity3d.com\/questions\/7789\/calculating-tangents-vector4.html\" href=\"http:\/\/answers.unity3d.com\/questions\/7789\/calculating-tangents-vector4.html\" target=\"_blank\">tangentsSolver<\/a>)<br \/>\n&#8211; Water block?<br \/>\n&#8211; Cap grid borders<br \/>\n&#8211; Grid visibility ?<br \/>\n&#8211; Health (lose health if fall from high)<br \/>\n&#8211; Better camera (dont go inside blocks)<br \/>\n&#8211; Enemies?<br \/>\n&#8211; Building something?<br \/>\n&#8211; Toolbar \/ inventory<\/p>\n<p><strong>Webplayer:<\/strong><br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/HeightMapChunkCraft1\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/HeightMapChunkCraft1\/\" target=\"_blank\"> http:\/\/unitycoder.com\/upload\/demos\/HeightMapChunkCraft1\/<\/a> (v3.0 updated: 19.4.2013 )<\/p>\n<p><strong>Download sources:<\/strong><br \/>\n<a title=\"https:\/\/github.com\/unitycoder\/PlanecraftMeshTerrain\" href=\"https:\/\/github.com\/unitycoder\/PlanecraftMeshTerrain\" target=\"_blank\"> https:\/\/github.com\/unitycoder\/PlanecraftMeshTerrain<\/a><\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#2:<\/strong> Randomized terrain<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d_2.jpg\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1883\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2013\/04\/14\/heightmap-chunk\/heighmap_chunks_minecraft_style_unity3d_2\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d_2.jpg?fit=1317%2C713&amp;ssl=1\" data-orig-size=\"1317,713\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"heighmap_chunks_minecraft_style_unity3d_2\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d_2.jpg?fit=1024%2C554&amp;ssl=1\" class=\"alignnone size-medium wp-image-1883\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d_2-300x162.jpg?resize=300%2C162\" alt=\"heighmap_chunks_minecraft_style_unity3d_2\" width=\"300\" height=\"162\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d_2.jpg?resize=300%2C162&amp;ssl=1 300w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d_2.jpg?resize=1024%2C554&amp;ssl=1 1024w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d_2.jpg?w=1317&amp;ssl=1 1317w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>(click to view)<\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#3:<\/strong> Vertex colors for darkening.. (using <a title=\"http:\/\/vertexcolors.com\/shared\/AEVertexGI.shader\" href=\"http:\/\/vertexcolors.com\/shared\/AEVertexGI.shader\" target=\"_blank\">vertex color shader from here<\/a>)<\/p>\n<p><strong><a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_vertexcolor_light_unity3d.jpg\" target=\"_blank\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_vertexcolor_light_unity3d-300x148.jpg?resize=300%2C148\" alt=\"heighmap_chunks_minecraft_style_vertexcolor_light_unity3d\" width=\"300\" height=\"148\" \/><\/a><\/strong>(click to view)<\/p>\n<p>&#8212;<\/p>\n<p><strong>Image#4:<\/strong> Version 3.0<\/p>\n<p><a href=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_tank_proto_unity3d.jpg\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1925\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2013\/04\/14\/heightmap-chunk\/heighmap_chunks_tank_proto_unity3d\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_tank_proto_unity3d.jpg?fit=1920%2C926&amp;ssl=1\" data-orig-size=\"1920,926\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"heighmap_chunks_tank_proto_unity3d\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_tank_proto_unity3d.jpg?fit=1024%2C493&amp;ssl=1\" class=\"alignnone size-medium wp-image-1925\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_tank_proto_unity3d-300x144.jpg?resize=300%2C144\" alt=\"heighmap_chunks_tank_proto_unity3d\" width=\"300\" height=\"144\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_tank_proto_unity3d.jpg?resize=300%2C144&amp;ssl=1 300w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_tank_proto_unity3d.jpg?resize=1024%2C493&amp;ssl=1 1024w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_tank_proto_unity3d.jpg?w=1920&amp;ssl=1 1920w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a>(click to view)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Saw this in the forums (simpleminecraft), sounds interesting!. Havent looked at their sources yet, but made own test version first.. Current version: &#8211; Single chunk.. &#8211; Chunk creator (random or perlin) &#8211; 2D array for grid heights &#8211; 3D array for grid cell types &#8211; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1882,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,3],"tags":[96,478,175,354,377,5,144],"class_list":["post-1881","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-array","tag-blocks","tag-chunk","tag-grid","tag-heightmap","tag-mesh","tag-minecraft"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2013\/04\/heighmap_chunks_minecraft_style_unity3d.jpg?fit=680%2C379&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-ul","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1881","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=1881"}],"version-history":[{"count":36,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1881\/revisions"}],"predecessor-version":[{"id":3027,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1881\/revisions\/3027"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/1882"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=1881"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=1881"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=1881"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}