While playing around writing some procedural rogue like dungeon generators, I thought it would be fun to voxelise them so that they could be viewed in 3d. Here are some early results:
Tag Archives: 3D
Minecraft 4K C++ Port
A while ago I discovered Minecraft4k, a java demo written by Notch fitting into a 4kb object file. He used software raycasting to rasterize a large 3d array of voxels. The original demo can be played here as an applet:
https://mojang.com/notch/j4k/minecraft4k/
At the same time I found that Notch had made a Javascript port of the same basic engine, minus user input.
One awesome thing about these two demos is that all of the textures are synthesized proceduraly for space saving reasons.
Seeing his work, I got a strong urge to port the code to C++ and SDL.
Grab the source code here:
Retro CRT Shader
extern number time; vec4 effect( vec4 color, Image tex, vec2 tex_uv, vec2 pix_uv ) { // per row offset float f = sin( tex_uv.y * 320.f * 3.14f ); // scale to per pixel float o = f * (0.35f / 320.f); // scale for subtle effect float s = f * .03f + 0.97f; // scan line fading float l = sin( time * 32.f )*.03f + 0.97f; // sample in 3 colour offset float r = Texel( tex, vec2( tex_uv.x+o, tex_uv.y+o ) ).x; float g = Texel( tex, vec2( tex_uv.x-o, tex_uv.y+o ) ).y; float b = Texel( tex, vec2( tex_uv.x , tex_uv.y-o ) ).z; // combine as return vec4( r*0.7f, g, b*0.9f, l ) * s; }