Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Studio Chat / Voxel Map on base Marching Cubes with AGK

Author
Message
cgw
4
Years of Service
User Offline
Joined: 29th Oct 2019
Location:
Posted: 17th Nov 2021 18:52 Edited at: 17th Nov 2021 19:09
Do you think AppGameKit can pull Marching Cubes?
Taking into account that all computation takes place in the main 1 thread.
For example, what is Marching Cubes:
https://www.youtube.com/watch?v=M3iI2l0ltbE
https://en.wikipedia.org/wiki/Marching_cubes
PartTimeCoder
AGK Tool Maker
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location: London UK
Posted: 17th Nov 2021 23:24
I think sure AppGameKit can pull it off using memblocks, it would be slow and clunkily but for 1 time level generation it certainly can be done, way above my current skill level though, I have not done anything with memblocks and 3D.

I wish I had half the skill of Sebastian Lague, some of his stuff just blows me away.

also wish AppGameKit had some raylib like 3D drawing functions ... like DrawTriangle3D(Vector3 v1, Vector3 v2, Vector3 v3, Color color), constructing geometry on the fly would be child's play!
Open Source plugins
Cl - DnD Plugin
Buy Me A Coffee
cgw
4
Years of Service
User Offline
Joined: 29th Oct 2019
Location:
Posted: 18th Nov 2021 17:47 Edited at: 18th Nov 2021 18:19
You can create functions Tier1 for AppGameKit, like this to make building a Marching Cubes map easy. I think it will be popular (if it's easy.).

Examples: ------------------------------------------------------------------------------------------
I'm not an expert but something like that:

Wrote a function and got a chunk landscape.
idChunk = MarchingCubesChunk(chunk number, Height, Length, Width, Size, Color, texture or gradient texture, UV texture offset X, texture offset Y, shader, thread 1 (main) or 2 threads (in a separate thread))

Here's a video of how it's done.
https://www.youtube.com/playlist?list=PLVsTSlfj0qsWt0qafrT6blp5yvchzO4ee
Here is the code for how to do it.
https://github.com/b3agz/how-to-make-7-days-to-die-in-unity
or Sebastian Lague
https://github.com/SebLague/Marching-Cubes

Save chunk or load chunk or Map.
SaveChunkTOFile(File, number, idChunk) // Save the chunk to a file.
idChunk = LoadChunkFromFile(File, number) // Load Chunk from file
SaveMapToFile(File, number, idMap) // Save Map to File.
idMap = LoadMapFromFile(File, number) // Load map from file.

Then a function that will connect these chunks into a single whole, to generate and smooth the boundaries of the chunk.
idMap = MarchingCubesMap(idChunk, CeedMap, PositionXYZ, RotationXYZ, SmoothID).

Smoothing chunks.
SmoothID=SmoothChunk(idChunkCenter, idChunkLeft, idChunkRight, idChunkFore, idChunkBack, idChunkLF , idChunkRF , idChunkLB , idChunkFB)

Then a function to dig into this chunk.
DigCubeMap(PlayerCameraId, Ray, Size, Object, Distance) // Dig blocks and calculate adjacent ones.
BuryCubeMap(PlayerCameraId, Ray, Size, Object, Distance) // Bury blocks and calculate adjacent ones.
infoCube[]=GetCubeMapInfo(PlayerCameraId, Ray) // Get info, block type, texture, block rotation.
infoChunk[]=GetChunkMapInfo(idChunk) // Get information, About chunk, Position x, y, z, rotate x, y, z, idChunk.
infoMap[]=GetChunkMapInfo(idMap) // Get information about the map. How many cubes, How many cubes of a certain type, how many cubes of this texture, map position of the first chunk. etc.

Delete chunk
DeleteChunk (idChunk)
Remove the Map.
DeleteMap (idMap)
Move Map.
MoveMap (idMap, x, y, z).
Change Chunk.
ChangeChunk(idMap,chunk number, Height, Length, Width, Size, Color, texture or gradient texture, UV texture offset X, texture offset Y, shader, thread 1 (main) or 2 threads (in a separate thread)))
Change the map.
ChangeMap (idMap, Height, Color, texture or gradient texture, UV texture offset X, texture offset Y, shader, thread 1 (main) or 2 threads (in a separate thread)), CeedMap, PositionXYZ, RotationXYZ, SmoothID)

Then a function to generate textures on the map randomly.
MarchingCubesGenerateTexture(ChunkID, generateTextureCeed, Noise, Texture, UVX,UVY)
Then a function to generate textures on the map manually.
MarchingCubesPutTexture(ChunkID, x,y,z, UVX,UVY, Texture)

Perlin_noise(,,,)
https://en.wikipedia.org/wiki/Perlin_noise

------------------------------------------------------------------------------------------

Example Real Games on Marching Cubes:
But these games require a minimum of 2 Core
Empyrion – Galactic Survival
7 Days to Die
ASTRONEER
Stationeers
Space Engineers
No Man’s Sky
Hydroneer


Or You. it is not interesting?
Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Nov 2021 20:01 Edited at: 18th Nov 2021 20:03
this stuff is beyond my grasp but is THIS and THIS pertinent?



Quote: "it is not interesting?"

it is
cgw
4
Years of Service
User Offline
Joined: 29th Oct 2019
Location:
Posted: 18th Nov 2021 23:24 Edited at: 18th Nov 2021 23:50
Quote: "this stuff is beyond my grasp but is THIS and THIS pertinent?"

but these are just voxel cubes in minecraft, last century.
but i talk about the Marching Cube

https://youtu.be/3QtViVKiPo4

Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 18th Nov 2021 23:32
i saw "voxel" and "map" and thought minecraft. dunno the techs behind them.

Quote: "these are just voxel cubes in minecraft, last century."

+
your link wrote: "Marching cubes is a computer graphics algorithm, published in the 1987"

= i'll shuffle along, now.
Bored of the Rings
User Banned
Posted: 24th Nov 2021 06:40
wow , this takes me back to the 80's pre - scientist days. download the triangulation table to prevent headache with the configs
https://gist.github.com/simon-tiger/35326223888cd52c9d7890b6327d93f5

this will give you which edges to join to form the triangles. might play around with this again. array within an array within an array springs to mind. good luck
Professional Programmer, languages: SAS, C++, SQL, PL-SQL, DBPro, Purebasic, JavaScript, others
Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 4th Dec 2021 01:55
Well specifically you're looking for Interpolated Isosurface Generation., as Marching Cubes more specifically refers to the form of Ray Marching that is employed to produce said given results.
Typically in Ray Marching we'd use a Spherical Area., to reduce the overall processing requirements for checking Ray Hits.

i.e. instead of checking along an infinite Ray Vector until a Collision is detected., we check a specific Volume (Spherical Radius from the initial Ray Point); and when one is detected., we Half the Distance and Sphere to then Check Again; with this being done X number of passes providing a close approximation on Ray Hits with Surfaces.
As noted this is typically called "Ray Marching"... now with Cube Marching we're doing an almost identical approach., difference being that we're specifically handling it as an Rudimentary Binary Space Partition; where we're taking an Octree approach.

i.e. We check within a Cube (Square) Volume., and if we get a "Positive" Result; well then we Divide the Volume into Equal Volumes that we then once again perform our Check.
The result being that the Geometry we produce is accurate to the Division Level of the Volume... this as a note due to using Cubes is what gives it that "Voxel" look., but it's not actually Voxels; still you'll find this is the basis for a Voxel Rasteriser, such-as what the Matrox Graphics Processors use to support in the Late-90s; but there are only 2 games that I know of that every actually used Voxel Engines.

(Shiney Enterainment) Messiah and (LucasArt) Outlander

Now while it would be possible to write AppGameKit Script and use Mesh Memblocks to produce the Triangles for Rendering... good luck on any decent performance.
Your best bet is to use GLSL Shaders (actually more ideally you want Compute Shaders, but AppGameKit doesn't support them "Out-of-the-Box")

There are quite a few ShaderToy Shaders using Ray Marching to generate Volumetric Isosurface Data... as noted the difference between Cube and Ray Marching is quite literally the Volume being used (Cube and Sphere) but otherwise these are identical techniques.
Cube Marching tends to offer better performance because you don't strictly need to use Rays (as instead you can use Octree / K-Tree / etc. as a Binary Space Partition approach); the trade-off is however going to be Ray Marching looks very organic & natural where-as Cube Marching produces a crude "Voxel" look within a Triangle Raster Pipeline.
janbo
15
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 10th Dec 2021 23:18 Edited at: 10th Dec 2021 23:23
Video of a side project from over a yeahr ago:


I messed up the chunk part in the cubemarching terrain which I later got working in my Minecraft like terrain:


I experimented with all features AppGameKit Tier1 could offer so i made the noise calculations in AppGameKit, made an addin do the noise calculations with multithreading and made a shader that produces a 3d noise texture as a 2d tile sheet which i then read via memblocks.
I tried to optimise my vertex creation via memblock code as good as i can and i honestly came pretty far.
I had lighting using BFS, some caves, digging and building different block types, loading in chunks but at the end it was to slow to create anything openworld like.
The reason is building the chunks and calculating the noise stuff is to slow in Tier1 cause of all the calculations and iterations on a single thread.
Not sure how manny parts you could outsource to multithreading if you'd do it in Tier2 so might be worht a try...but not me( not now)

If you just want a terrain that can be altered without an infinite world and no 3d noise go for it and copy that table
sedrok
9
Years of Service
User Offline
Joined: 12th Feb 2015
Location:
Posted: 12th Dec 2021 19:09 Edited at: 12th Dec 2021 19:12
let's do it

code to start from:

I think hard part is to BuildMesh() with memblocks

sedrok
9
Years of Service
User Offline
Joined: 12th Feb 2015
Location:
Posted: 12th Dec 2021 23:14
all code except buildmesh

buildmesh function help needed


sedrok
9
Years of Service
User Offline
Joined: 12th Feb 2015
Location:
Posted: 13th Dec 2021 18:46
have some result:



1)need calculate normals
normal = cross product of two vectors forming a trtiangle
2)UV and texture


Attachments

Login to view attachments
sedrok
9
Years of Service
User Offline
Joined: 12th Feb 2015
Location:
Posted: 14th Dec 2021 10:26 Edited at: 14th Dec 2021 10:29
convert to agk current result
source - https://github.com/b3agz/how-to-make-7-days-to-die-in-unity/blob/master/01-marching-cubes/Marching.cs



work done from previous
1) RecalcNormals:
(from https://forum.thegamecreators.com/thread/224705)


2) Coloring
3) shaders from Voxel Engine

Virtual Nomad
Moderator
18
Years of Service
Recently Online
Joined: 14th Dec 2005
Location: SF Bay Area, USA

Login to post a reply

Server time is: 2024-03-28 22:35:42
Your offset time is: 2024-03-28 22:35:42