testing 48x48x48 world and different scales

This commit is contained in:
Piotrek
2021-04-26 14:07:56 +02:00
parent 6206800df9
commit beea89699d
5 changed files with 9 additions and 7 deletions
+2 -2
View File
@@ -25,9 +25,9 @@ impl App {
let mut world_gen = WorldGen::new(); let mut world_gen = WorldGen::new();
let start = std::time::Instant::now(); let start = std::time::Instant::now();
for x in 0..32 { for x in 0..48 {
for y in 0..16 { for y in 0..16 {
for z in 0..32 { for z in 0..48 {
world_gen.generate(&mut renderer, Point3{x, y, z}); world_gen.generate(&mut renderer, Point3{x, y, z});
} }
} }
+1 -1
View File
@@ -3,7 +3,7 @@
pub const BLOCK_SIZE : usize = 32; // 32x32x32 block size pub const BLOCK_SIZE : usize = 32; // 32x32x32 block size
pub const BLOCK_TEX_SIZE : usize = 64; // 64x64 blocks in texture pub const BLOCK_TEX_SIZE : usize = 64; // 64x64 blocks in texture
pub const NODE_TEX_SIZE: usize = 32; // 32x32x32 nodes in texture pub const NODE_TEX_SIZE: usize = 48; // 32x32x32 nodes in texture
pub const NODE_TEX_LEN: usize = NODE_TEX_SIZE*NODE_TEX_SIZE*NODE_TEX_SIZE; // Number of u32 in node texture pub const NODE_TEX_LEN: usize = NODE_TEX_SIZE*NODE_TEX_SIZE*NODE_TEX_SIZE; // Number of u32 in node texture
Binary file not shown.
+2 -2
View File
@@ -13,7 +13,7 @@ HitResult castBricks(vec3 origin, vec3 start, vec3 dir, vec3 incAxis, uint addr)
// Change scale // Change scale
origin = start - origin; origin = start - origin;
origin += dir*0.00001; origin += dir*0.00001;
origin *= 32; origin *= BLOCK_SIZE;
// Same as in casting nodes // Same as in casting nodes
vec3 pos = floor(origin); vec3 pos = floor(origin);
@@ -35,7 +35,7 @@ HitResult castBricks(vec3 origin, vec3 start, vec3 dir, vec3 incAxis, uint addr)
// Hit point // Hit point
vec3 mini = (pos-origin+0.5 - raySign*0.5) * rayInv; vec3 mini = (pos-origin+0.5 - raySign*0.5) * rayInv;
float len = max(mini.x, max(mini.y, mini.z)); float len = max(mini.x, max(mini.y, mini.z));
vec3 hitPoint = (origin + dir * len) / 32.0 + o; vec3 hitPoint = (origin + dir * len) / BLOCK_SIZE + o;
// Normal vector (negate previous increment axis and mult by sign) // Normal vector (negate previous increment axis and mult by sign)
vec3 normal = -incAxis * raySign; vec3 normal = -incAxis * raySign;
+4 -2
View File
@@ -25,7 +25,8 @@ layout(set=3, binding=0) uniform Materials {
// Defines // Defines
#define EPSILON 0.00000001 #define EPSILON 0.00000001
#define NODE_TEX_SIZE 32 #define SCALE 1.0
#define NODE_TEX_SIZE 48
#define BLOCK_TEX_SIZE 64 #define BLOCK_TEX_SIZE 64
#define BLOCK_SIZE 32 #define BLOCK_SIZE 32
@@ -35,6 +36,7 @@ layout(set=3, binding=0) uniform Materials {
#include "shading.cginc" #include "shading.cginc"
#include "raycasting.cginc" #include "raycasting.cginc"
float seed; float seed;
float random(float s) { float random(float s) {
return fract(sin(seed++ + s)*43758.5453123); return fract(sin(seed++ + s)*43758.5453123);
@@ -61,7 +63,7 @@ vec3 solve()
// Calculate ray direction // Calculate ray direction
vec3 view_dir = (_ProjMatrixInv * vec4(vert_uv, 0, 1)).xyz; vec3 view_dir = (_ProjMatrixInv * vec4(vert_uv, 0, 1)).xyz;
vec3 rayDir = normalize(_ViewMatrix * vec4(view_dir,0)).xyz; vec3 rayDir = normalize(_ViewMatrix * vec4(view_dir,0)).xyz;
Ray primaryRay = Ray(_CamPos, rayDir); Ray primaryRay = Ray(_CamPos / SCALE, rayDir);
// Raycast // Raycast
HitResult primary = castNodes(primaryRay, 100); HitResult primary = castNodes(primaryRay, 100);