clean up; dimension support

This commit is contained in:
NULL511
2024-05-02 23:38:35 -04:00
parent c29d08a5f5
commit 81a937790c
14 changed files with 513 additions and 491 deletions

View File

@ -1,3 +1,5 @@
#define BLOCK_EMPTY 0
#define BLOCK_WATER 8
#define BLOCK_BEACON 1001

View File

@ -1,9 +1,16 @@
// LPV falloff curve
const float LpvBlockPower = 4.0;
// LPV block brightness scale
const float LpvBlockBrightness = 3.0;
vec4 SampleLpvNearest(const in ivec3 lpvPos) {
vec4 lpvSample = (frameCounter % 2) == 0
? imageLoad(imgLpv1, lpvPos)
: imageLoad(imgLpv2, lpvPos);
lpvSample.b = pow(lpvSample.b, 4) * LpvBlockSkyRange.x;
lpvSample.b = pow(lpvSample.b, LpvBlockPower) * LpvBlockSkyRange.x;
lpvSample.rgb = HsvToRgb(lpvSample.rgb);
return lpvSample;
@ -37,7 +44,7 @@ vec4 SampleLpvLinear(const in vec3 lpvPos) {
}
vec3 GetLpvBlockLight(const in vec4 lpvSample) {
return 3.0 * lpvSample.rgb;
return LpvBlockBrightness * lpvSample.rgb;
}
float GetLpvSkyLight(const in vec4 lpvSample) {

View File

@ -4,10 +4,3 @@ const uint VoxelSize = uint(exp2(LPV_SIZE));
const uvec3 VoxelSize3 = uvec3(VoxelSize);
const float voxelDistance = 64.0;
#define BLOCK_EMPTY 0
ivec3 GetVoxelIndex(const in vec3 playerPos) {
vec3 cameraOffset = fract(cameraPosition);
return ivec3(floor(playerPos + cameraOffset) + VoxelSize3/2u);
}

View File

@ -1,6 +0,0 @@
uint GetVoxelBlock(const in ivec3 voxelPos) {
if (clamp(voxelPos, ivec3(0), ivec3(VoxelSize3-1u)) != voxelPos)
return BLOCK_EMPTY;
return imageLoad(imgVoxelMask, voxelPos).r;
}

View File

@ -1,3 +1,8 @@
ivec3 GetVoxelIndex(const in vec3 playerPos) {
vec3 cameraOffset = fract(cameraPosition);
return ivec3(floor(playerPos + cameraOffset) + VoxelSize3/2u);
}
void SetVoxelBlock(const in vec3 playerPos, const in uint blockId) {
ivec3 voxelPos = GetVoxelIndex(playerPos);
if (clamp(voxelPos, ivec3(0), ivec3(VoxelSize-1u)) != voxelPos) return;