Log In  

At first, I saw a demo where a student implement a voxelspace algorithm with compute shaders. Voxelspace is a tech invented in the '90s by Kyle Freeman at Novalogic to render landscape. Games like Comanche, Deltaforce used it. It was based on heightmap and voxels, not polygon. I don't know much about shaders, but I know it is better at rendering polygons. So... I try to understand how all this work and here is the result: my voxelspace implementation on Pico 8

With freds72 optimization

Cart #voxelspace_ykk-2 | 2019-10-15 | Code ▽ | Embed ▽ | No License

first release
Cart #voxelspace_ykk-1 | 2019-10-13 | Code ▽ | Embed ▽ | No License

Here is an implementation of voxelspace rendering algorithm, with a little perlin noise map generation. Features :

  • Generate a 128x128 height map in memory,
  • Generate a color map base on height with some noise (I could also use height difference to better show cliffs and flat grounds, maybe latter),
  • colors fadding with distance
  • We can move, with player one controls, zoom map with X (or M), strafe with player 2 left and right (s,f)

I don't know where it will go, or if it will become a game, but here is my work :D Have fun tweaking or exploring !

for a more advance experience, you can check electricgryphon work https://www.lexaloffle.com/bbs/?uid=10844

P#68841 2019-10-13 19:50 ( Edited 2019-10-15 21:46)

:: dw817

Pretty good ! Now make a type of flight-simulator or something.

P#68846 2019-10-13 20:38

Works very well with the new colors!

Minor perf tips:

  • reuse the yb array (avoid GC)
  • use shl instead of x width
  • move cos/sin calc out of the column loop
    (at the very least, avoid calculating them twice!)
  • sx/sy are used only once in the inner loop, it is faster to use rxdx/rxdy
P#68869 2019-10-14 10:31 ( Edited 2019-10-14 10:46)

Thanks ! Thanks for the tips, too ! I tried them and it saves 8% more cpu, with shl for the most. That allow distance to be pushed to 50 instead of 44 with same quality.

P#68880 2019-10-14 18:07

I got down to 0.6863 cpu at startup pos :]

Minor perf tips +

  • band(xxx,0x3fff) is useless for numbers in 0-0x7f range
  • bor(x,y) is faster than x+y when you don't want carry
P#68881 2019-10-14 19:12 ( Edited 2019-10-15 06:12)

Well done ! The bor trick work well in this case, as Y will never walk on X bits :)

I don't get what you want to say with "band(xxx,0x3fff) is for numbers in 0-0x7f range"

I use band(xxx,0x7f) to keep integers in 0-127 range and band(xxx,0x3fff) in 0-16383

So the expression I started from

   local idx=

became (because width=128, and hlen=128*128),

   local idx=

and now with your tips:

   local idx=


In this case, that's crazy fast !
edit: fix 3rd step :)

P#68884 2019-10-14 20:24 ( Edited 2019-10-15 21:48)

fixed comment

P#68897 2019-10-15 17:19

My last word: 0.6535 :]
Previous perf tips +

Cart #nokowuzedo-0 | 2019-10-16 | Code ▽ | Embed ▽ | No License

P#68944 2019-10-16 19:48 ( Edited 2019-10-16 19:59)

I tried to use yb on 0x4300 user memory, but it was not faster, and I got a strange behaviour with negative values, but I obviously have missed something :D

Thanks a lot for digging !

EDIT : you have the same issue, maybe a poke4 could help

P#68945 2019-10-16 20:06 ( Edited 2019-10-16 20:14)

[Please log in to post a comment]

Follow Lexaloffle:        
Generated 2020-08-11 07:26 | 0.030s | 4194k | Q:71