Skip to content
Browse files

cool stuff

  • Loading branch information...
1 parent edd4275 commit 636b9d61f5771fafb25623bf93495aa75b230bd7 @jwagner committed
Showing with 16 additions and 7 deletions.
  1. +1 −1 shaders/voxel.frag
  2. +4 −3 src/main.js
  3. +11 −3 src/voxel.js
View
2 shaders/voxel.frag
@@ -13,7 +13,7 @@ uniform vec3 sunDirection;
uniform vec3 eye;
void main(){
- float light = max(dot(vNormal, sunDirection), 0.0)*0.8*vAmbient*0.025;
+ float light = max(dot(vNormal, sunDirection), 0.0)*0.8+0.2;
vec3 view = vPosition-eye;
vec3 shaded = vColor*light;
gl_FragColor = vec4(shaded, length(view));
View
7 src/main.js
@@ -42,13 +42,14 @@ var loader = new Loader(),
graph = new scene.Graph(),
mousecontroller = new MouseController(input, null),
debug = getHashValue('debug', '0') !== '0',
+ seed = getHashValue('seed', '0'),
debug_element = $('#debug'),
camera, player;
var cube, cube2;
function prepareScene(){
window.world = new voxel.World({width: 8, height: 4, depth: 8, chunk_size: 32, scale: 0.5});
- voxel.random_world(window.world, 'seed');
+ voxel.random_world(window.world, seed);
//voxel.flat_world(window.world, 10);
window.renderer = new glvoxel.Renderer(window.world);
@@ -120,7 +121,7 @@ function prepareScene(){
}, [camera]);
window.camera = camera;
camera.position[0] = 4*32*0.5;
- camera.position[1] = 3*32*0.5;
+ camera.position[1] = 5*32*0.5;
camera.position[2] = 8*32*0.5;
player = new Player(window.world);
player.setPosition(camera.position);
@@ -157,7 +158,7 @@ clock.ontick = function (td) {
if(input.keys.SPACE){
player.acceleration[1] += 20;
}
- //player.acceleration[1] -= 10;
+ player.acceleration[1] -= 10;
vec3.scale(player.velocity, 0.99);
View
14 src/voxel.js
@@ -270,10 +270,18 @@ voxel.flat_world = function(world, height){
};
voxel.random_world = function(world, seed) {
- var random = new Alea(seed);
- var simplex = new SimplexNoise(random);
+ var random = new Alea(seed),
+ simplex = new SimplexNoise(random),
+ w = world.width*world.chunk_size,
+ h = world.height*world.chunk_size,
+ d = world.depth*world.chunk_size;
voxel.init_world(world, function(x, y, z) {
- var density = simplex.noise3D(x/32, y/32, z/32)-y/15;
+
+ var xd = x-w*0.25,
+ yd = y-h*0.25,
+ zd = z-d*0.25,
+ distance = Math.sqrt(xd*xd+yd*yd*yd+zd*zd)*0.05;
+ density = simplex.noise3D(x/32, y/32, z/32)-distance;
if(density > -0.75){
return 3;
}

0 comments on commit 636b9d6

Please sign in to comment.
Something went wrong with that request. Please try again.