Natural slabs for smooth hills / valleys

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

Natural slabs for smooth hills / valleys

by MirceaKitsune » Mon Mar 11, 2013 15:32

This is something that always bothered me in MineCraft, and although it's a major change I believe MineTest can do it. I initially wanted to code it as a mod, but since I'm not good with the mapgen and would like to see it defaulted in MT, I thought to suggest it to someone who knows the world generator and ask who else supports the idea.

Both MC and MT lack smooth / walkable leveled terrain. The terrain is made out of full blocks, and to climb a hill you must jump on each block. I always wanted to see slabs added to the play... by occasionally spawning slab versions of each natural node. Dirt, sand, stone, gravel, etc. would exist as both blocks and slabs (half tall blocks). Slabs would only be spawned on the ground and its surface, and mixed with normal blocks to make hills and valleys smoother (as well as the floor of natural caves). The improvements would be visually smoother terrain, as well as allowing small hills to be walked on like stairs.

Here are two constructs I made to exemplify. The left stone build shows how a natural hill currently looks like, and the right one shows how its variant would look like using my suggestion. Once again, the interior of the right construction is full of stone blocks (no hollow spaces), slabs only existing where they are visible.

Image

Only problem I can think of is that you can't place things on slabs, so trees and flowers / grass cannot be spawned on top of slab dirt (at least currently). For trees that's ok since they can override natural slabs and erase them where the trunk comes. Kinda sucks for grass and flowers, but since neither grass or slabs would be frequent it shouldn't be noticeable. This feature would also require the mapgen to create hills twice wider horizontally, to make room for slab transitions... but of course not all parts of a hill would be smoothed with slabs since that would be boring.

I'm pretty sure this can be done with the current LUA API and possibly minor changes to the C++ mapgen. But would it work out otherwise, and do other players want this? Personally I'd love it, and I think it would be a huge improvement to the world.
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11

by jojoa1997 » Mon Mar 11, 2013 15:36

i said as default because it would be way quicker instead of a mod
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

User avatar
Traxie21
Member
 
Posts: 753
Joined: Mon Dec 31, 2012 10:48

by Traxie21 » Mon Mar 11, 2013 15:39

Y
E
S

It would take some adjusting to, but it would make terrain so much more lovable, variable, and smooth.

I vote default, with a toggle in minetest.conf
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Mon Mar 11, 2013 16:40

First:
MirceaKitsune wrote:MineTest

It is Minetest, not MineTest.

I am absolutely against this idea. Minetest consists of 1 m³ blocks and the main mapgen and most of the game elements should use this system. If you want smooth landscapes then you are wrong in Minetest.
Last edited by PilzAdam on Mon Mar 11, 2013 16:40, edited 1 time in total.
 

User avatar
BrandonReese
Member
 
Posts: 836
Joined: Wed Sep 12, 2012 00:44
GitHub: bremaweb
IRC: BrandonReese
In-game: BrandonReese

by BrandonReese » Mon Mar 11, 2013 17:02

I think it's an interesting idea to diversify the terrain.
 

ashenk69
Member
 
Posts: 230
Joined: Tue Jul 03, 2012 00:08

by ashenk69 » Mon Mar 11, 2013 17:12

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
minetest.register_on_generated(function(minp, maxp, seed)
    default.generate_ore("slab:dirt_with_grass_slab", "default:dirt_with_grass", minp, maxp, seed+0, 1/2/2/2, 1, 1, -100,  100)
end
 

User avatar
VanessaE
Member
 
Posts: 3894
Joined: Sun Apr 01, 2012 12:38
GitHub: VanessaE
IRC: VanessaE
In-game: VanessaEzekowitz

by VanessaE » Mon Mar 11, 2013 17:20

I like the idea as well. We still get the blocky landscape, but smooth enough to simply walk on if the hills aren't too steep. Don't forget to use stairs and wall slabs to smooth out vertical surfaces/cliffs and sharp h/v transitions.
You might like some of my stuff:
Plantlife ~ More Trees ~ Home Decor ~ Pipeworks ~ HDX Textures (16-512px)
Tips (BTC): 13LdcdUFcNCFAm7HfvAXh5GHTjCnnQj6KE
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

by rubenwardy » Mon Mar 11, 2013 17:45

Good idea, but as with every thing, make it configurable

menu wrote:[ X ] Smooth Terrain
Last edited by rubenwardy on Mon Mar 11, 2013 17:45, edited 1 time in total.
 

User avatar
kaeza
Member
 
Posts: 2141
Joined: Thu Oct 18, 2012 05:00
GitHub: kaeza
IRC: kaeza diemartin blaaaaargh
In-game: kaeza

by kaeza » Mon Mar 11, 2013 17:54

I support this idea. Voted yes in default (obviously make this configurable).

rubenwardy wrote:Good idea, but as with every thing, make it configurable

menu wrote:[ X ] Smooth Terrain

Good, but at least have...
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
mg_flags = smooth, ...

in minetest.conf / world.mt
Last edited by kaeza on Mon Mar 11, 2013 17:55, edited 1 time in total.
Your signature is not the place for a blog post. Please keep it as concise as possible. Thank you!

Check out my stuff! | Donations greatly appreciated! PayPal | BTC: 1DFZAa5VtNG7Levux4oP6BuUzr1e83pJK2
 

Sokomine
Member
 
Posts: 2980
Joined: Sun Sep 09, 2012 17:31

by Sokomine » Mon Mar 11, 2013 18:27

Sounds like a very good idea! That will reduce the need to constantly jump around just to be able to move along. Also it will make the landscape more intresting/convincing. People who really don't want this option may still turn it off.
Maybe this could be a biome alongside with one intended for building? Where the landscape is a bit more flat than elsewhere?
A list of my mods can be found here.
 

rarkenin
Member
 
Posts: 668
Joined: Tue Nov 20, 2012 20:48

by rarkenin » Mon Mar 11, 2013 19:08

rubenwardy wrote:Good idea, but as with every thing, make it configurable

menu wrote:[ X ] Smooth Terrain


Or, make it that a special slab node is used for this, and depending on the setting, it will render as either a block or slab, so changes can be made in already-generated areas.
Admin pro tempore on 0gb.us:30000. Ask me if you have a problem, or just want help.
This is a signature virus. Add me to your signature so that I can multiply.
Now working on my own clone, Mosstest.
I guess I'm back for some time.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Mar 11, 2013 19:15

PilzAdam wrote:I am absolutely against this idea. Minetest consists of 1 m³ blocks and the main mapgen and most of the game elements should use this system. If you want smooth landscapes then you are wrong in Minetest.


It does consist of 1m blocks, but also of slabs / stairs and other nodeboxes which are part of Minetest just as much. I'm not suggesting we implement slabs since those exist for a long time... just defining dirt / sand ones and spawning them naturally in a correct pattern.

Otherwise that's not explaining why the idea would be bad. Being one of the main devs it would be useful to hear your point in more detail. Is it because of technical limitations, or artistic reasons? Like I said I'm not aware of anything that would make this impossible, since slabs can be defined for any material and the mapgen can spawn any node naturally.

As for making it customizable, that could be tricky since this would be done in LUA. But IIRC scripts can read settings from minetest.conf so it shouldn't be a problem. Fine by me, although I'd always keep it enabled and would suggest it being on by default.

rarkenin wrote:Or, make it that a special slab node is used for this, and depending on the setting, it will render as either a block or slab, so changes can be made in already-generated areas.


That would probably be buggy and not consistent. Sand and dirt slabs might be possible to craft as well, and this setting would cause them to change form and collision causing structures to break. If a setting is made, I'd suggest doing it in the mapgen to specify if slabs should be spawned naturally or not.
Last edited by MirceaKitsune on Mon Mar 11, 2013 19:18, edited 1 time in total.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Mar 11, 2013 19:47

Sorry for double posting. But since stone slabs already exist, I decided to manually place some and see how this would look in a naturally spawned situation. I think it looks pretty awesome, but here are a few screenshots for everyone to judge. Just noticed smooth lighting isn't working on slabs... not sure why but that's a general bug if anything.

Image

Image

Image
 

User avatar
PilzAdam
Member
 
Posts: 4026
Joined: Fri Jul 20, 2012 16:19
GitHub: PilzAdam
IRC: PilzAdam

by PilzAdam » Mon Mar 11, 2013 19:52

MirceaKitsune wrote:
PilzAdam wrote:I am absolutely against this idea. Minetest consists of 1 m³ blocks and the main mapgen and most of the game elements should use this system. If you want smooth landscapes then you are wrong in Minetest.


It does consist of 1m blocks, but also of slabs / stairs and other nodeboxes which are part of Minetest just as much. I'm not suggesting we implement slabs since those exist for a long time... just defining dirt / sand ones and spawning them naturally in a correct pattern.

Otherwise that's not explaining why the idea would be bad. Being one of the main devs it would be useful to hear your point in more detail. Is it because of technical limitations, or artistic reasons? Like I said I'm not aware of anything that would make this impossible, since slabs can be defined for any material and the mapgen can spawn any node naturally.

As for making it customizable, that could be tricky since this would be done in LUA. But IIRC scripts can read settings from minetest.conf so it shouldn't be a problem. Fine by me, although I'd always keep it enabled and would suggest it being on by default.

My point is that slabs go against the voxel idea, wich is one of the main aspects of Minetest.
We can simply add round blocks but they wouldnt fit the voxel idea. Slabs arent that bad but adding them to the mapgen is. The main idea of the mapgen is to form realistic looking landscapes only with voxels. Adding slabs would make them look even more realistic, but it is against the main idea behind this whole game.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Mar 11, 2013 20:16

PilzAdam wrote:My point is that slabs go against the voxel idea, wich is one of the main aspects of Minetest.
We can simply add round blocks but they wouldnt fit the voxel idea. Slabs arent that bad but adding them to the mapgen is. The main idea of the mapgen is to form realistic looking landscapes only with voxels. Adding slabs would make them look even more realistic, but it is against the main idea behind this whole game.


Thanks. I understand your point now, even if I don't share it. Voxel terrain is indeed the base of MineTest... its main use being that you can build and dig in any direction. Natural slabs wouldn't break that ability though, and IMO they would just spice up the existing block terrain and improve it. In a way such slabs would also work as voxels... only in one direction. Even marching cubes terrains consist of spheres which have various sizes at each floating point, allowing them to be dug smoothly (not quite good in this domain though). But if anything it would be a thing of principle, it wouldn't break functionality or purpose.

Different ways of achieving smooth terrain would be awesome as well, but I don't see any happening without greater efforts. I suggested a surface smoothing system some time ago, but it's probably a task too big for anyone to achieve. But that's probably a different story.

Another idea would be making natural blocks consumable, though this would require code changes and be a lot more complicated. So the more you dig a dirt block, the more it depletes and its surface lowers. Many mods could make use of such a thing, but in this case it probably couldn't be default and would take a lot of work and tweaking.
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Mon Mar 11, 2013 23:07

MirceaKitsune wrote:Another idea would be making natural blocks consumable, though this would require code changes and be a lot more complicated. So the more you dig a dirt block, the more it depletes and its surface lowers. Many mods could make use of such a thing, but in this case it probably couldn't be default and would take a lot of work and tweaking.

Don't liquids already break the voxel idea far worse than any half-block ever could? This idea has just recently been added for liquids ("finite liquids"), actually. Adding it as another use of "param1" or "param2" might not be a bad idea. It could go a long way toward giving us things like erosion, and will definitely help smooth out landscape, from mods if not from the basic mapgen.
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Mon Mar 11, 2013 23:33

prestidigitator wrote:Don't liquids already break the voxel idea far worse than any half-block ever could? This idea has just recently been added for liquids ("finite liquids"), actually. Adding it as another use of "param1" or "param2" might not be a bad idea. It could go a long way toward giving us things like erosion, and will definitely help smooth out landscape, from mods if not from the basic mapgen.


Yeah. If you look at it this way, slabs would also be voxels in this system. Just half-volume voxels and only placed at the top, but still used like any other voxel. Think of slabs as a 0.5 volume point and full blocks as a 1.0 point, if that makes sense. And since you can already place stone slabs in stone caves like I did in my earlier screenshots, the idea of voxel terrains is already broken or not broken as it is... not much difference that the mapgen does what the player can already do.
 

User avatar
Traxie21
Member
 
Posts: 753
Joined: Mon Dec 31, 2012 10:48

by Traxie21 » Mon Mar 11, 2013 23:37

When/if I ever get back to my computer, I will definately take a look at this.
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11

by jojoa1997 » Tue Mar 12, 2013 00:10

prestidigitator wrote:
MirceaKitsune wrote:Another idea would be making natural blocks consumable, though this would require code changes and be a lot more complicated. So the more you dig a dirt block, the more it depletes and its surface lowers. Many mods could make use of such a thing, but in this case it probably couldn't be default and would take a lot of work and tweaking.

Don't liquids already break the voxel idea far worse than any half-block ever could? This idea has just recently been added for liquids ("finite liquids"), actually. Adding it as another use of "param1" or "param2" might not be a bad idea. It could go a long way toward giving us things like erosion, and will definitely help smooth out landscape, from mods if not from the basic mapgen.
with erosion we would need to have rivers in mapgen just have a pond with flowing water to lower levels. that means rivers with less the work
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

User avatar
10twenty4
Member
 
Posts: 40
Joined: Tue Mar 12, 2013 20:54

by 10twenty4 » Thu Mar 14, 2013 02:23

I love the idea. It would add variety to the map, and help make Minetest something more than a direct Minecraft clone (perhaps that's what you want, but I'd rather see this game take on its own direction).

PilzAdam wrote:My point is that slabs go against the voxel idea, which is one of the main aspects of Minetest.
We can simply add round blocks but they wouldnt fit the voxel idea. Slabs arent that bad but adding them to the mapgen is. The main idea of the mapgen is to form realistic looking landscapes only with voxels. Adding slabs would make them look even more realistic, but it is against the main idea behind this whole game.


Slabs are essentially a half-voxel, so I fail to see what the issue is. Implementing them still maintains the voxel appearance, just at a slightly higher resolution. It's not like we're suggesting curved hills or angled ramps to connect blocks.
 

MEGASPARK
Member
 
Posts: 60
Joined: Mon Dec 17, 2012 02:34

by MEGASPARK » Thu Mar 14, 2013 08:11

+1 since your idea is taking a lot of time to do, but its still a good idea :D
I Live When I Dig
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Thu Mar 14, 2013 08:55

10twenty4 wrote:Slabs are essentially a half-voxel, so I fail to see what the issue is. Implementing them still maintains the voxel appearance, just at a slightly higher resolution. It's not like we're suggesting curved hills or angled ramps to connect blocks.

In fact they are a full voxel, just with a different voxture applied to them. ;-)
Last edited by prestidigitator on Thu Mar 14, 2013 09:00, edited 1 time in total.
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Fri Mar 15, 2013 10:48

Another thing that MIGHT help with smoother looking terrain: the current noise functions Minetest uses are not Perlin Noise, but a similar value-based pseudo-random noise generation function. (Unfortunately the second hit for "Perlin Noise" on Google perpetuates the myth that any such noise function is Perlin Noise.) True Perlin Noise (and its successor Simplex Noise) are gradient-based pseudo-random noise functions. The difference is somewhat subtle, but can definitely make a difference in the perceived quality of noise textures. Whether it makes as big a difference in map generation I am not sure.

Here is a patch I applied to the code (commit d10223254a in Git) to make "true" (gradient-based) Perlin Noise. I'm not sure whether the terrain is actually "smoother" or if it is psychological, so maybe others can help judge. ;-)

Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
diff --git a/src/noise.cpp b/src/noise.cpp
index 49b5f7e..0dcc117 100644
--- a/src/noise.cpp
+++ b/src/noise.cpp
@@ -37,22 +37,89 @@
 ///////////////////////////////////////////////////////////////////////////////
 
 
-//noise poly:  p(n) = 60493n^3 + 19990303n + 137612589
-float noise2d(int x, int y, int seed) {
+static inline int coordHash(int x, int y, int seed)
+{
     int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y
             + NOISE_MAGIC_SEED * seed) & 0x7fffffff;
     n = (n >> 13) ^ n;
     n = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
-    return 1.f - (float)n / 0x40000000;
+    return n;
 }
 
-
-float noise3d(int x, int y, int z, int seed) {
+static inline int coordHash(int x, int y, int z, int seed)
+{
     int n = (NOISE_MAGIC_X * x + NOISE_MAGIC_Y * y + NOISE_MAGIC_Z * z
             + NOISE_MAGIC_SEED * seed) & 0x7fffffff;
     n = (n >> 13) ^ n;
     n = (n * (n * n * 60493 + 19990303) + 1376312589) & 0x7fffffff;
-    return 1.f - (float)n / 0x40000000;
+    return n;
+}
+
+static inline float coordNoiseVal(int xi, float xf, int yi, float yf, int seed)
+{
+    int h = coordHash(xi, yi, seed);
+
+    int comps = h%2;
+    int signs = h/3;
+
+    float u, v;
+    switch (comps)
+    {
+        case 0:
+            u = 0.666667f*xf; v = 1.33333f*yf; break;
+        case 1:
+            u = 1.33333f*xf; v = 0.666667f*yf; break;
+    }
+    if (signs & 0x1)
+    {
+        u = -u;
+    }
+    if (signs & 0x2)
+    {
+        v = -v;
+    }
+
+    return u + v;
+}
+
+static inline float coordNoiseVal(int xi, float xf, int yi, float yf, int zi, float zf, int seed)
+{
+    int h = coordHash(xi, yi, zi, seed);
+
+    int comps = h%3;
+    int signs = h/3;
+
+    float u, v;
+    switch (comps)
+    {
+        case 0:
+            u = xf; v = yf; break;
+        case 1:
+            u = xf; v = zf; break;
+        case 2:
+            u = yf; v = zf; break;
+    }
+    if (signs & 0x1)
+    {
+        u = -u;
+    }
+    if (signs & 0x2)
+    {
+        v = -v;
+    }
+
+    return u + v;
+}
+
+
+//noise poly:  p(n) = 60493n^3 + 19990303n + 137612589
+float noise2d(int x, int y, int seed) {
+    return 1.f - (float)coordHash(x, y, seed) / 0x40000000;
+}
+
+
+float noise3d(int x, int y, int z, int seed) {
+    return 1.f - (float)coordHash(x, y, z, seed) / 0x40000000;
 }
 
 
@@ -96,99 +163,43 @@ float triLinearInterpolation(
 }
 
 
-#if 0
-float triLinearInterpolation(
-        float v000, float v100, float v010, float v110,
-        float v001, float v101, float v011, float v111,
-        float x, float y, float z)
-{
-    /*float tx = easeCurve(x);
-    float ty = easeCurve(y);
-    float tz = easeCurve(z);*/
-    float tx = x;
-    float ty = y;
-    float tz = z;
-    return(
-        v000 * (1 - tx) * (1 - ty) * (1 - tz) +
-        v100 * tx * (1 - ty) * (1 - tz) +
-        v010 * (1 - tx) * ty * (1 - tz) +
-        v110 * tx * ty * (1 - tz) +
-        v001 * (1 - tx) * (1 - ty) * tz +
-        v101 * tx * (1 - ty) * tz +
-        v011 * (1 - tx) * ty * tz +
-        v111 * tx * ty * tz
-    );
-}
-#endif
-
-
-#if 0
 float noise2d_gradient(float x, float y, int seed)
 {
-    // Calculate the integer coordinates
-    int x0 = (x > 0.0 ? (int)x : (int)x - 1);
-    int y0 = (y > 0.0 ? (int)y : (int)y - 1);
-    // Calculate the remaining part of the coordinates
-    float xl = x - (float)x0;
-    float yl = y - (float)y0;
-    // Calculate random cosine lookup table indices for the integer corners.
-    // They are looked up as unit vector gradients from the lookup table.
-    int n00 = (int)((noise2d(x0, y0, seed)+1)*8);
-    int n10 = (int)((noise2d(x0+1, y0, seed)+1)*8);
-    int n01 = (int)((noise2d(x0, y0+1, seed)+1)*8);
-    int n11 = (int)((noise2d(x0+1, y0+1, seed)+1)*8);
-    // Make a dot product for the gradients and the positions, to get the values
-    float s = dotProduct(cos_lookup[n00], cos_lookup[(n00+12)%16], xl, yl);
-    float u = dotProduct(-cos_lookup[n10], cos_lookup[(n10+12)%16], 1.-xl, yl);
-    float v = dotProduct(cos_lookup[n01], -cos_lookup[(n01+12)%16], xl, 1.-yl);
-    float w = dotProduct(-cos_lookup[n11], -cos_lookup[(n11+12)%16], 1.-xl, 1.-yl);
-    // Interpolate between the values
-    return biLinearInterpolation(s,u,v,w,xl,yl);
-}
-#endif
+    int xi = myfloor(x);
+    int yi = myfloor(y);
+    float xf = x - xi;
+    float yf = y - yi;
 
+    float v00 = coordNoiseVal(xi,   xf,      yi,   yf,      seed);
+    float v10 = coordNoiseVal(xi+1, xf-1.0f, yi,   yf,      seed);
+    float v01 = coordNoiseVal(xi,   xf,      yi+1, yf-1.0f, seed);
+    float v11 = coordNoiseVal(xi+1, xf-1.0f, yi+1, yf-1.0f, seed);
 
-float noise2d_gradient(float x, float y, int seed)
-{
-    // Calculate the integer coordinates
-    int x0 = myfloor(x);
-    int y0 = myfloor(y);
-    // Calculate the remaining part of the coordinates
-    float xl = x - (float)x0;
-    float yl = y - (float)y0;
-    // Get values for corners of square
-    float v00 = noise2d(x0, y0, seed);
-    float v10 = noise2d(x0+1, y0, seed);
-    float v01 = noise2d(x0, y0+1, seed);
-    float v11 = noise2d(x0+1, y0+1, seed);
-    // Interpolate
-    return biLinearInterpolation(v00,v10,v01,v11,xl,yl);
+    return biLinearInterpolation(v00, v10, v01, v11, xf, yf);
 }
 
 
 float noise3d_gradient(float x, float y, float z, int seed)
 {
-    // Calculate the integer coordinates
-    int x0 = myfloor(x);
-    int y0 = myfloor(y);
-    int z0 = myfloor(z);
-    // Calculate the remaining part of the coordinates
-    float xl = x - (float)x0;
-    float yl = y - (float)y0;
-    float zl = z - (float)z0;
-    // Get values for corners of cube
-    float v000 = noise3d(x0,     y0,     z0,     seed);
-    float v100 = noise3d(x0 + 1, y0,     z0,     seed);
-    float v010 = noise3d(x0,     y0 + 1, z0,     seed);
-    float v110 = noise3d(x0 + 1, y0 + 1, z0,     seed);
-    float v001 = noise3d(x0,     y0,     z0 + 1, seed);
-    float v101 = noise3d(x0 + 1, y0,     z0 + 1, seed);
-    float v011 = noise3d(x0,     y0 + 1, z0 + 1, seed);
-    float v111 = noise3d(x0 + 1, y0 + 1, z0 + 1, seed);
-    // Interpolate
+    int xi = myfloor(x);
+    int yi = myfloor(y);
+    int zi = myfloor(z);
+    float xf = x - xi;
+    float yf = y - yi;
+    float zf = z - zi;
+
+    float v000 = coordNoiseVal(xi,   xf,      yi,   yf,      zi,   zf,      seed);
+    float v100 = coordNoiseVal(xi+1, xf-1.0f, yi,   yf,      zi,   zf,      seed);
+    float v010 = coordNoiseVal(xi,   xf,      yi+1, yf-1.0f, zi,   zf,      seed);
+    float v110 = coordNoiseVal(xi+1, xf-1.0f, yi+1, yf-1.0f, zi,   zf,      seed);
+    float v001 = coordNoiseVal(xi,   xf,      yi,   yf,      zi+1, zf-1.0f, seed);
+    float v101 = coordNoiseVal(xi+1, xf-1.0f, yi,   yf,      zi+1, zf-1.0f, seed);
+    float v011 = coordNoiseVal(xi,   xf,      yi+1, yf-1.0f, zi+1, zf-1.0f, seed);
+    float v111 = coordNoiseVal(xi+1, xf-1.0f, yi+1, yf-1.0f, zi+1, zf-1.0f, seed);
+
     return triLinearInterpolation(v000, v100, v010, v110,
-                                  v001, v101, v011, v111,
-                                  xl, yl, zl);
+                                  v001, v101, v011, v111,
+                                  xf, yf, zf);
 }
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11

by jojoa1997 » Fri Mar 15, 2013 11:13

i just read about voxels and actually a smooth sphere is a voxel. A voxel is anything that takes up space or has a volume so in reality minetest could be only smooth things because everything is a voxel. It is just the public that has made a slang version of voxel.
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Fri Mar 15, 2013 17:44

jojoa1997 wrote:i just read about voxels and actually a smooth sphere is a voxel. A voxel is anything that takes up space or has a volume so in reality minetest could be only smooth things because everything is a voxel. It is just the public that has made a slang version of voxel.

Hmm. Not sure where you read that, but it's not QUITE right. A "voxel" is the volume equivalent of a "pixel", hence the mash-up "volume-pixel -> voxel". In that sense a voxel really is supposed to be tileable in 3-space and treated like an atomic unit. However, there's no reason you can't render them using mathematically derived meshes, textures, etc. That's why I made up the term "voxture" above for node boxes: they act in a sense like a 3D/volumetric texture by choosing which parts of a voxel are solid and renderable. By simply storing a node type and using types to apply such data to many nodes across the map (as opposed to storing explicit mesh data for every piece of the map, for example) it is still definitely a voxel-based approach.
 

User avatar
jojoa1997
Member
 
Posts: 2890
Joined: Thu Dec 13, 2012 05:11

by jojoa1997 » Fri Mar 15, 2013 19:30

prestidigitator wrote:
jojoa1997 wrote:i just read about voxels and actually a smooth sphere is a voxel. A voxel is anything that takes up space or has a volume so in reality minetest could be only smooth things because everything is a voxel. It is just the public that has made a slang version of voxel.

Hmm. Not sure where you read that, but it's not QUITE right. A "voxel" is the volume equivalent of a "pixel", hence the mash-up "volume-pixel -> voxel". In that sense a voxel really is supposed to be tileable in 3-space and treated like an atomic unit. However, there's no reason you can't render them using mathematically derived meshes, textures, etc. That's why I made up the term "voxture" above for node boxes: they act in a sense like a 3D/volumetric texture by choosing which parts of a voxel are solid and renderable. By simply storing a node type and using types to apply such data to many nodes across the map (as opposed to storing explicit mesh data for every piece of the map, for example) it is still definitely a voxel-based approach.
yes i knew that but what i was think of was a sphere is made of a ton of tiny voxels. just like i thought of making a map where you have a tnt block and then you are the energy inside of it.
Coding;
1X coding
3X debugging
12X tweaking to be just right
 

prestidigitator
Member
 
Posts: 632
Joined: Thu Feb 21, 2013 23:54

by prestidigitator » Fri Mar 15, 2013 22:11

Sure, you could make a sphere out of voxels. Might be fun to create a moon or death star or something in the sky. :-) I have a wands mod (to be released in the near future) with some wands that affect all voxels inside or touching a spherical volume centered at the wand's target point. The "Wand of Destruction" creates huge spherical craters.

Anyway, back to using interesting nodes for slopes and shapes...

A "stair":
  • produces a "slope" of 1:2 (from the node before the stair to the node after it, elevation increases by +1) to almost 1:1 (N stairs in sequence increase elevation by N over N+1 nodes);
  • occupies 3/4 the volume of the voxel (for anti-aliasing);
  • slopes very much in one direction only (not useful unless the horizontal component of the gradient of the surface you are dealing with points in a direction close to one of the primary x or z axes).

In contrast, a "slab":
  • produces a "slope" of 0 (if the nodes before and after it are also slabs), 1:4 (if the node before it is lower and the node after it is a slab), or 1:2 (if the node before it is lower and the node after it is higher);
  • occupies 1/2 the volume of the voxel (for anti-aliasing);
  • can slope either way or not at all in both the x and z directions.

You could also create interesting combinations of the two.

Fun stuff. Heh.
Last edited by prestidigitator on Fri Mar 15, 2013 22:16, edited 1 time in total.
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Wed Mar 20, 2013 11:30

http://forum.minetest.net/viewtopic.php?id=4739
there seems to be a connection...
 

User avatar
MirceaKitsune
Member
 
Posts: 809
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune

by MirceaKitsune » Wed Mar 20, 2013 12:52

Mito551 wrote:http://forum.minetest.net/viewtopic.php?id=4739
there seems to be a connection...


Nice topic... good to see more discussion on this. And yes, I agree the idea that terrain smoothness would be a great thing for MT to have that MC didn't.
 

User avatar
Mito551
Member
 
Posts: 1271
Joined: Sat Jun 16, 2012 15:03

by Mito551 » Wed Mar 20, 2013 16:17

 

Next

Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 34 guests

cron