Show HN: A simple infinite world in WebGL
erkaman.github.io
erkaman.github.io
As for the implementation, it is not very difficult stuff; I divide up the world into chunks(just like in Minecraft), and as the camera traverses the world, the chunks that become out of range are thrown away and are no longer rendered. And in the far away horizon I keep adding new chunks, to give the illusion that the world is infinite.
So it is not very complicated stuff; the source code is only ~450LOC, which can be found here: https://github.com/Erkaman/wireframe-world/blob/gh-pages/wir.... It is relatively well-commented, so it should be easy to understand, I hope.
Is there any particular reason you did this?
Funny when I read the word "glitching" I assumed it would be a framerate hitch, which might be cause by GC, but I did a quick timeline grab and it seems OK for desktop. Collects about 12MB every 10-12 seconds. That might have more of an impact on mobile of course, especially Android.
I'm having that kind of issue with a game I'm working on - in my case I'm being way too cowboy about creating and throwing away JS objects for particles (only in 2D on a canvas) and it's causing GC framerate glitches on Android.
WebGL in a nutshell.
[1]: https://github.com/mikolalysenko/regl/blob/gh-pages/dist/reg...
* https://stratfordct.bandcamp.com/album/airglow-memory-bank
* http://stratfordct.bandcamp.com/album/stratford-ct-melior
* http://stratfordct.bandcamp.com/album/stratford-ct-lux-aesti...
* http://stratfordct.bandcamp.com/album/stratford-ct-secret-se...
* http://stratfordct.bandcamp.com/album/stratford-ct-1-yr-anni...
https://www.youtube.com/watch?v=_YWMGuh15nE
(Quite realistic terrain generated by a 4 kilobyte binary, along with music. Source code and its discussion here: https://news.ycombinator.com/item?id=11848097)
He also wrote ShaderToy...
I posted this previously but I didn't want to distract from your submission, so I made my own submission to a similar thing I created: https://news.ycombinator.com/item?id=12183383
So the change would be to use 'linear' or 'nearest'. It's actually the mipmaps that are making things look blurry. Basically, the graphics card is scaling down the image and scaling it back up, which makes it blurry.
Does anyone have some good resources on getting started with WebGL or graphics programming in general? I know the libraries (like Three.JS) but I wouldn't know where to start or how to use them. I see Three.JS being used in fancy websites all the time now and would like to stay up to date.
Source code: https://github.com/dlubarov/webgl-infinite-terrain-demo
It's also Perlin noise, but with multiple layers and finer granularity, so it appears more detailed. You can control the camera with WASD and the mouse.
Your cool little project reminds me of this: https://www.youtube.com/watch?v=c6nY0QkG9nQ
Are these caused by some z-buffer issues caused by increasingly large coordinates?
Seen it before while trying to create an infinite city in WebGL. I ended up creating a world offset for each sector, and every time the camera's position was more than a sector length, reposition the camera in the scene and adjust the sector offsets. May not be the best solution, but it was quick and worked.
demo.js:10655 Uncaught SyntaxError: Unexpected token {
Tested on Chromium 48.0.2564.116, available under Fedora.
Can someone tell me if Dubstep has jumped the shark yet? Does anyone even still say 'jumped the shark'?
/me shuffles off to play The Dead Kennedys on his 8-track...