kinda working

This commit is contained in:
NULL511
2024-05-02 12:43:30 -04:00
parent 2c4eea5b26
commit 3ab6b68165
16 changed files with 306 additions and 201 deletions

View File

@ -1,2 +1,19 @@
#define BLOCK_WATER 8
#define BLOCK_LIGHT_SOURCES 10005
#define BLOCK_CAVE_VINE_BERRIES 1000
#define BLOCK_SOUL_FIRE 1001
#define BLOCK_SOUL_LANTERN 1002
#define BLOCK_SOUL_TORCH 1003
#define BLOCK_SEA_LANTERN 1009
#define BLOCK_GLOWSTONE 1010
#define BLOCK_TORCH 1011
#define BLOCK_LAVA 1012
#define BLOCK_FIRE 1013
#define BLOCK_REDSTONE_TORCH 1014
#define BLOCK_MAGMA 1016
#define BLOCK_LANTERN 1018
#define BLOCK_SHROOMLIGHT 1020

View File

@ -1,4 +1,5 @@
vec3 DoAmbientLightColor(
vec3 lpvPos,
vec3 SkyColor,
vec3 MinimumColor,
vec3 TorchColor,
@ -12,11 +13,16 @@ vec3 DoAmbientLightColor(
vec3 IndirectLight = max(SkyColor * ambient_brightness * skyLM, MinimumLight);
// do torch lighting.
// float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1));
// TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5;
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
vec4 lpvSample = SampleLpv(lpvPos);
vec3 TorchLight = GetLpvBlockLight(lpvSample);
#else
// float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1));
// TorchLM = pow(TorchLM/4,10) + pow(Lightmap.x,1.5)*0.5;
float TorchLM = pow(Lightmap.x,10.0)*5.0 + pow(Lightmap.x,1.5);
vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM * (1.0 + LightLevelZero*dot(SkyColor * ambient_brightness,vec3(0.3333)));
float TorchLM = pow(Lightmap.x,10.0)*5.0 + pow(Lightmap.x,1.5);
vec3 TorchLight = TorchColor * TORCH_AMOUNT * TorchLM * (1.0 + LightLevelZero*dot(SkyColor * ambient_brightness,vec3(0.3333)));
#endif
return IndirectLight + TorchLight;
}

View File

@ -12,4 +12,9 @@ const uvec3 LpvSize3 = uvec3(LpvSize);
// layout(r16ui) uniform readonly uimage2D imgVoxelMask;
// #endif
#define LIGHT_NONE 0
// #define LIGHT_NONE 0
vec3 GetLpvPosition(const in vec3 playerPos) {
vec3 cameraOffset = fract(cameraPosition);
return playerPos + cameraOffset + LpvSize3/2u + 0.5;
}

View File

@ -1,35 +1,35 @@
vec4 cubic(const in float v) {
vec4 n = vec4(1.0, 2.0, 3.0, 4.0) - v;
vec4 s = n * n * n;
float x = s.x;
float y = s.y - 4.0 * s.x;
float z = s.z - 4.0 * s.y + 6.0 * s.x;
float w = 6.0 - x - y - z;
return vec4(x, y, z, w) * (1.0/6.0);
}
// vec4 cubic(const in float v) {
// vec4 n = vec4(1.0, 2.0, 3.0, 4.0) - v;
// vec4 s = n * n * n;
// float x = s.x;
// float y = s.y - 4.0 * s.x;
// float z = s.z - 4.0 * s.y + 6.0 * s.x;
// float w = 6.0 - x - y - z;
// return vec4(x, y, z, w) * (1.0/6.0);
// }
float LpvVoxelTest(const in ivec3 voxelCoord) {
ivec3 gridCell = ivec3(floor(voxelCoord / LIGHT_BIN_SIZE));
uint gridIndex = GetVoxelGridCellIndex(gridCell);
ivec3 blockCell = voxelCoord - gridCell * LIGHT_BIN_SIZE;
// float LpvVoxelTest(const in ivec3 voxelCoord) {
// ivec3 gridCell = ivec3(floor(voxelCoord / LIGHT_BIN_SIZE));
// uint gridIndex = GetVoxelGridCellIndex(gridCell);
// ivec3 blockCell = voxelCoord - gridCell * LIGHT_BIN_SIZE;
uint blockId = GetVoxelBlockMask(blockCell, gridIndex);
return IsTraceOpenBlock(blockId) ? 1.0 : 0.0;
}
// uint blockId = GetVoxelBlockMask(blockCell, gridIndex);
// return IsTraceOpenBlock(blockId) ? 1.0 : 0.0;
// }
vec4 SampleLpvNearest(const in ivec3 lpvPos) {
vec4 lpvSample = (frameCounter % 2) == 0
#ifndef RENDER_GBUFFER
? texelFetch(texLPV_1, lpvPos, 0)
: texelFetch(texLPV_2, lpvPos, 0);
#else
? texelFetch(texLPV_2, lpvPos, 0)
: texelFetch(texLPV_1, lpvPos, 0);
#endif
// #ifndef RENDER_GBUFFER
? imageLoad(imgLpv1, lpvPos)
: imageLoad(imgLpv2, lpvPos);
// #else
// ? imageLoad(imgLpv2, lpvPos, 0)
// : imageLoad(imgLpv1, lpvPos, 0);
// #endif
lpvSample.rgb = HsvToRgb(lpvSample.rgb);
return lpvSample / DynamicLightRangeF;
return lpvSample;// / DynamicLightRangeF;
}
vec4 SampleLpvLinear(const in vec3 lpvPos) {
@ -48,55 +48,55 @@ vec4 SampleLpvLinear(const in vec3 lpvPos) {
vec4 sample_x1y2z2 = SampleLpvNearest(lpvCoord + ivec3(0, 1, 1));
vec4 sample_x2y2z2 = SampleLpvNearest(lpvCoord + ivec3(1, 1, 1));
#ifdef LPV_VOXEL_TEST
vec3 lpvCameraOffset = fract(cameraPosition);
vec3 voxelCameraOffset = fract(cameraPosition / LIGHT_BIN_SIZE) * LIGHT_BIN_SIZE;
ivec3 voxelPos = ivec3(lpvPos - SceneLPVCenter + VoxelBlockCenter + voxelCameraOffset - lpvCameraOffset + 0.5);
// #ifdef LPV_VOXEL_TEST
// vec3 lpvCameraOffset = fract(cameraPosition);
// vec3 voxelCameraOffset = fract(cameraPosition / LIGHT_BIN_SIZE) * LIGHT_BIN_SIZE;
// ivec3 voxelPos = ivec3(lpvPos - SceneLPVCenter + VoxelBlockCenter + voxelCameraOffset - lpvCameraOffset + 0.5);
float voxel_x1y1z1 = LpvVoxelTest(voxelPos + ivec3(0, 0, 0));
float voxel_x2y1z1 = LpvVoxelTest(voxelPos + ivec3(1, 0, 0));
float voxel_x1y2z1 = LpvVoxelTest(voxelPos + ivec3(0, 1, 0));
float voxel_x2y2z1 = LpvVoxelTest(voxelPos + ivec3(1, 1, 0));
// float voxel_x1y1z1 = LpvVoxelTest(voxelPos + ivec3(0, 0, 0));
// float voxel_x2y1z1 = LpvVoxelTest(voxelPos + ivec3(1, 0, 0));
// float voxel_x1y2z1 = LpvVoxelTest(voxelPos + ivec3(0, 1, 0));
// float voxel_x2y2z1 = LpvVoxelTest(voxelPos + ivec3(1, 1, 0));
float voxel_x1y1z2 = LpvVoxelTest(voxelPos + ivec3(0, 0, 1));
float voxel_x2y1z2 = LpvVoxelTest(voxelPos + ivec3(1, 0, 1));
float voxel_x1y2z2 = LpvVoxelTest(voxelPos + ivec3(0, 1, 1));
float voxel_x2y2z2 = LpvVoxelTest(voxelPos + ivec3(1, 1, 1));
// float voxel_x1y1z2 = LpvVoxelTest(voxelPos + ivec3(0, 0, 1));
// float voxel_x2y1z2 = LpvVoxelTest(voxelPos + ivec3(1, 0, 1));
// float voxel_x1y2z2 = LpvVoxelTest(voxelPos + ivec3(0, 1, 1));
// float voxel_x2y2z2 = LpvVoxelTest(voxelPos + ivec3(1, 1, 1));
sample_x1y1z1 *= voxel_x1y1z1;
sample_x2y1z1 *= voxel_x2y1z1;
sample_x1y2z1 *= voxel_x1y2z1;
sample_x2y2z1 *= voxel_x2y2z1;
// sample_x1y1z1 *= voxel_x1y1z1;
// sample_x2y1z1 *= voxel_x2y1z1;
// sample_x1y2z1 *= voxel_x1y2z1;
// sample_x2y2z1 *= voxel_x2y2z1;
sample_x1y1z2 *= voxel_x1y1z2;
sample_x2y1z2 *= voxel_x2y1z2;
sample_x1y2z2 *= voxel_x1y2z2;
sample_x2y2z2 *= voxel_x2y2z2;
// sample_x1y1z2 *= voxel_x1y1z2;
// sample_x2y1z2 *= voxel_x2y1z2;
// sample_x1y2z2 *= voxel_x1y2z2;
// sample_x2y2z2 *= voxel_x2y2z2;
// TODO: Add special checks for avoiding diagonal blending between occluded edges/corners
// // TODO: Add special checks for avoiding diagonal blending between occluded edges/corners
// TODO: preload voxel grid into array
// then prevent blending if all but current and opposing quadrants are empty
// // TODO: preload voxel grid into array
// // then prevent blending if all but current and opposing quadrants are empty
// ivec3 iq = 1 - ivec3(step(vec3(0.5), lpvF));
// float voxel_iqx = 1.0 - LpvVoxelTest(ivec3(voxelPos) + ivec3(iq.x, 0, 0));
// float voxel_iqy = 1.0 - LpvVoxelTest(ivec3(voxelPos) + ivec3(0, iq.y, 0));
// float voxel_iqz = 1.0 - LpvVoxelTest(ivec3(voxelPos) + ivec3(0, 0, iq.z));
// float voxel_corner = 1.0 - voxel_iqx * voxel_iqy * voxel_iqz;
// // ivec3 iq = 1 - ivec3(step(vec3(0.5), lpvF));
// // float voxel_iqx = 1.0 - LpvVoxelTest(ivec3(voxelPos) + ivec3(iq.x, 0, 0));
// // float voxel_iqy = 1.0 - LpvVoxelTest(ivec3(voxelPos) + ivec3(0, iq.y, 0));
// // float voxel_iqz = 1.0 - LpvVoxelTest(ivec3(voxelPos) + ivec3(0, 0, iq.z));
// // float voxel_corner = 1.0 - voxel_iqx * voxel_iqy * voxel_iqz;
// float voxel_y1 = LpvVoxelTest(ivec3(voxelPos + vec3(0, 0, 0)));
// sample_x1y1z1 *= voxel_y1;
// sample_x2y1z1 *= voxel_y1;
// sample_x1y1z2 *= voxel_y1;
// sample_x2y1z2 *= voxel_y1;
// // float voxel_y1 = LpvVoxelTest(ivec3(voxelPos + vec3(0, 0, 0)));
// // sample_x1y1z1 *= voxel_y1;
// // sample_x2y1z1 *= voxel_y1;
// // sample_x1y1z2 *= voxel_y1;
// // sample_x2y1z2 *= voxel_y1;
// float voxel_y2 = LpvVoxelTest(voxelPos + ivec3(0, 1, 0));
// sample_x1y2z1 *= voxel_y2;
// sample_x2y2z1 *= voxel_y2;
// sample_x1y2z2 *= voxel_y2;
// sample_x2y2z2 *= voxel_y2;
#endif
// // float voxel_y2 = LpvVoxelTest(voxelPos + ivec3(0, 1, 0));
// // sample_x1y2z1 *= voxel_y2;
// // sample_x2y2z1 *= voxel_y2;
// // sample_x1y2z2 *= voxel_y2;
// // sample_x2y2z2 *= voxel_y2;
// #endif
vec4 sample_y1z1 = mix(sample_x1y1z1, sample_x2y1z1, lpvF.x);
vec4 sample_y2z1 = mix(sample_x1y2z1, sample_x2y2z1, lpvF.x);
@ -110,96 +110,98 @@ vec4 SampleLpvLinear(const in vec3 lpvPos) {
return mix(sample_z1, sample_z2, lpvF.z);// * voxel_corner;
}
vec4 SampleLpvCubic(in vec3 lpvPos) {
vec3 pos = lpvPos - 0.5;
vec3 texF = fract(pos);
pos = floor(pos);
// vec4 SampleLpvCubic(in vec3 lpvPos) {
// vec3 pos = lpvPos - 0.5;
// vec3 texF = fract(pos);
// pos = floor(pos);
vec4 cubic_x = cubic(texF.x);
vec4 cubic_y = cubic(texF.y);
vec4 cubic_z = cubic(texF.z);
// vec4 cubic_x = cubic(texF.x);
// vec4 cubic_y = cubic(texF.y);
// vec4 cubic_z = cubic(texF.z);
vec3 pos_min = pos - 0.5;
vec3 pos_max = pos + 1.5;
// vec3 pos_min = pos - 0.5;
// vec3 pos_max = pos + 1.5;
vec3 s_min = vec3(cubic_x.x, cubic_y.x, cubic_z.x) + vec3(cubic_x.y, cubic_y.y, cubic_z.y);
vec3 s_max = vec3(cubic_x.z, cubic_y.z, cubic_z.z) + vec3(cubic_x.w, cubic_y.w, cubic_z.w);
// vec3 s_min = vec3(cubic_x.x, cubic_y.x, cubic_z.x) + vec3(cubic_x.y, cubic_y.y, cubic_z.y);
// vec3 s_max = vec3(cubic_x.z, cubic_y.z, cubic_z.z) + vec3(cubic_x.w, cubic_y.w, cubic_z.w);
vec3 offset_min = pos_min + vec3(cubic_x.y, cubic_y.y, cubic_z.y) / s_min;
vec3 offset_max = pos_max + vec3(cubic_x.w, cubic_y.w, cubic_z.w) / s_max;
// vec3 offset_min = pos_min + vec3(cubic_x.y, cubic_y.y, cubic_z.y) / s_min;
// vec3 offset_max = pos_max + vec3(cubic_x.w, cubic_y.w, cubic_z.w) / s_max;
vec4 sample_x1y1z1 = SampleLpvLinear(vec3(offset_max.x, offset_max.y, offset_max.z));
vec4 sample_x2y1z1 = SampleLpvLinear(vec3(offset_min.x, offset_max.y, offset_max.z));
vec4 sample_x1y2z1 = SampleLpvLinear(vec3(offset_max.x, offset_min.y, offset_max.z));
vec4 sample_x2y2z1 = SampleLpvLinear(vec3(offset_min.x, offset_min.y, offset_max.z));
// vec4 sample_x1y1z1 = SampleLpvLinear(vec3(offset_max.x, offset_max.y, offset_max.z));
// vec4 sample_x2y1z1 = SampleLpvLinear(vec3(offset_min.x, offset_max.y, offset_max.z));
// vec4 sample_x1y2z1 = SampleLpvLinear(vec3(offset_max.x, offset_min.y, offset_max.z));
// vec4 sample_x2y2z1 = SampleLpvLinear(vec3(offset_min.x, offset_min.y, offset_max.z));
vec4 sample_x1y1z2 = SampleLpvLinear(vec3(offset_max.x, offset_max.y, offset_min.z));
vec4 sample_x2y1z2 = SampleLpvLinear(vec3(offset_min.x, offset_max.y, offset_min.z));
vec4 sample_x1y2z2 = SampleLpvLinear(vec3(offset_max.x, offset_min.y, offset_min.z));
vec4 sample_x2y2z2 = SampleLpvLinear(vec3(offset_min.x, offset_min.y, offset_min.z));
// vec4 sample_x1y1z2 = SampleLpvLinear(vec3(offset_max.x, offset_max.y, offset_min.z));
// vec4 sample_x2y1z2 = SampleLpvLinear(vec3(offset_min.x, offset_max.y, offset_min.z));
// vec4 sample_x1y2z2 = SampleLpvLinear(vec3(offset_max.x, offset_min.y, offset_min.z));
// vec4 sample_x2y2z2 = SampleLpvLinear(vec3(offset_min.x, offset_min.y, offset_min.z));
#ifdef LPV_VOXEL_TEST
vec3 lpvCameraOffset = fract(cameraPosition);
vec3 voxelCameraOffset = fract(cameraPosition / LIGHT_BIN_SIZE) * LIGHT_BIN_SIZE;
ivec3 voxelPos = ivec3(lpvPos - SceneLPVCenter + VoxelBlockCenter + voxelCameraOffset - lpvCameraOffset + 0.5);
// // #ifdef LPV_VOXEL_TEST
// // vec3 lpvCameraOffset = fract(cameraPosition);
// // vec3 voxelCameraOffset = fract(cameraPosition / LIGHT_BIN_SIZE) * LIGHT_BIN_SIZE;
// // ivec3 voxelPos = ivec3(lpvPos - SceneLPVCenter + VoxelBlockCenter + voxelCameraOffset - lpvCameraOffset + 0.5);
float voxel_x1y1z1 = LpvVoxelTest(voxelPos + ivec3(1, 1, 1));
float voxel_x2y1z1 = LpvVoxelTest(voxelPos + ivec3(0, 1, 1));
float voxel_x1y2z1 = LpvVoxelTest(voxelPos + ivec3(1, 0, 1));
float voxel_x2y2z1 = LpvVoxelTest(voxelPos + ivec3(0, 0, 1));
// // float voxel_x1y1z1 = LpvVoxelTest(voxelPos + ivec3(1, 1, 1));
// // float voxel_x2y1z1 = LpvVoxelTest(voxelPos + ivec3(0, 1, 1));
// // float voxel_x1y2z1 = LpvVoxelTest(voxelPos + ivec3(1, 0, 1));
// // float voxel_x2y2z1 = LpvVoxelTest(voxelPos + ivec3(0, 0, 1));
float voxel_x1y1z2 = LpvVoxelTest(voxelPos + ivec3(1, 1, 0));
float voxel_x2y1z2 = LpvVoxelTest(voxelPos + ivec3(0, 1, 0));
float voxel_x1y2z2 = LpvVoxelTest(voxelPos + ivec3(1, 0, 0));
float voxel_x2y2z2 = LpvVoxelTest(voxelPos + ivec3(0, 0, 0));
// // float voxel_x1y1z2 = LpvVoxelTest(voxelPos + ivec3(1, 1, 0));
// // float voxel_x2y1z2 = LpvVoxelTest(voxelPos + ivec3(0, 1, 0));
// // float voxel_x1y2z2 = LpvVoxelTest(voxelPos + ivec3(1, 0, 0));
// // float voxel_x2y2z2 = LpvVoxelTest(voxelPos + ivec3(0, 0, 0));
sample_x1y1z1 *= voxel_x1y1z1;
sample_x2y1z1 *= voxel_x2y1z1;
sample_x1y2z1 *= voxel_x1y2z1;
sample_x2y2z1 *= voxel_x2y2z1;
// // sample_x1y1z1 *= voxel_x1y1z1;
// // sample_x2y1z1 *= voxel_x2y1z1;
// // sample_x1y2z1 *= voxel_x1y2z1;
// // sample_x2y2z1 *= voxel_x2y2z1;
sample_x1y1z2 *= voxel_x1y1z2;
sample_x2y1z2 *= voxel_x2y1z2;
sample_x1y2z2 *= voxel_x1y2z2;
sample_x2y2z2 *= voxel_x2y2z2;
#endif
// // sample_x1y1z2 *= voxel_x1y1z2;
// // sample_x2y1z2 *= voxel_x2y1z2;
// // sample_x1y2z2 *= voxel_x1y2z2;
// // sample_x2y2z2 *= voxel_x2y2z2;
// // #endif
vec3 mixF = s_min / (s_min + s_max);
// vec3 mixF = s_min / (s_min + s_max);
vec4 sample_y1z1 = mix(sample_x1y1z1, sample_x2y1z1, mixF.x);
vec4 sample_y2z1 = mix(sample_x1y2z1, sample_x2y2z1, mixF.x);
// vec4 sample_y1z1 = mix(sample_x1y1z1, sample_x2y1z1, mixF.x);
// vec4 sample_y2z1 = mix(sample_x1y2z1, sample_x2y2z1, mixF.x);
vec4 sample_y1z2 = mix(sample_x1y1z2, sample_x2y1z2, mixF.x);
vec4 sample_y2z2 = mix(sample_x1y2z2, sample_x2y2z2, mixF.x);
// vec4 sample_y1z2 = mix(sample_x1y1z2, sample_x2y1z2, mixF.x);
// vec4 sample_y2z2 = mix(sample_x1y2z2, sample_x2y2z2, mixF.x);
vec4 sample_z1 = mix(sample_y1z1, sample_y2z1, mixF.y);
vec4 sample_z2 = mix(sample_y1z2, sample_y2z2, mixF.y);
// vec4 sample_z1 = mix(sample_y1z1, sample_y2z1, mixF.y);
// vec4 sample_z2 = mix(sample_y1z2, sample_y2z2, mixF.y);
return mix(sample_z1, sample_z2, mixF.z);
}
// return mix(sample_z1, sample_z2, mixF.z);
// }
vec4 SampleLpv(const in vec3 samplePos) {
#if LPV_SAMPLE_MODE == LPV_SAMPLE_CUBIC
vec4 lpvSample = SampleLpvCubic(samplePos);
#elif LPV_SAMPLE_MODE == LPV_SAMPLE_LINEAR
// #if LPV_SAMPLE_MODE == LPV_SAMPLE_CUBIC
// vec4 lpvSample = SampleLpvCubic(samplePos);
// #elif LPV_SAMPLE_MODE == LPV_SAMPLE_LINEAR
vec4 lpvSample = SampleLpvLinear(samplePos);
#else
ivec3 coord = ivec3(samplePos);
vec4 lpvSample = SampleLpvNearest(coord);
#endif
// #else
// ivec3 coord = ivec3(samplePos);
// vec4 lpvSample = SampleLpvNearest(coord);
// #endif
return lpvSample;
}
vec4 SampleLpv(const in vec3 lpvPos, const in vec3 geoNormal, const in vec3 texNormal) {
#if MATERIAL_NORMALS != 0
vec3 samplePos = lpvPos - 0.5 * geoNormal + texNormal;
#else
vec3 samplePos = lpvPos + 0.5 * geoNormal;
#endif
// vec4 SampleLpv(const in vec3 playerPos, const in vec3 geoNormal, const in vec3 texNormal) {
// ivec3 lpvPos = GetLpvPosition(playerPos);
return SampleLpv(samplePos);
}
// // #if MATERIAL_NORMALS != 0
// vec3 samplePos = lpvPos - 0.5 * geoNormal + texNormal;
// // #else
// // vec3 samplePos = lpvPos + 0.5 * geoNormal;
// // #endif
// return SampleLpvLinear(samplePos);
// }
// vec3 GetLpvBlockLight(in vec4 lpvSample, const in float power) {
// return (lpvSample.rgb * LPV_BLOCKLIGHT_SCALE) / 8.0 * DynamicLightBrightness;
@ -207,10 +209,11 @@ vec4 SampleLpv(const in vec3 lpvPos, const in vec3 geoNormal, const in vec3 texN
vec3 GetLpvBlockLight(const in vec4 lpvSample) {
// return GetLpvBlockLight(lpvSample, 1.0);
return (1.0/8.0) * (lpvSample.rgb * LPV_BLOCKLIGHT_SCALE) * DynamicLightBrightness;
return 4.0 * lpvSample.rgb;// * LPV_BLOCKLIGHT_SCALE);// * DynamicLightBrightness;
}
float GetLpvSkyLight(const in vec4 lpvSample) {
float skyLight = saturate(lpvSample.a);
return _pow2(skyLight);
// return _pow2(skyLight);
return skyLight*skyLight;
}

View File

@ -673,11 +673,13 @@ const vec3 aerochrome_color = mix(vec3(1.0, 0.0, 0.0), vec3(0.715, 0.303, 0.631)
// ----- DISTANT HORIZONS SETTINGS ----- //
///////////////////////////////////////////
#define LPV_ENABLED
//#define LPV_ENABLED
#define LPV_SIZE 7 // [6 7 8]
#if defined LPV_ENABLED && defined IRIS_FEATURE_CUSTOM_IMAGES
#define IS_LPV_ENABLED
#ifdef LPV_ENABLED
#ifdef IRIS_FEATURE_CUSTOM_IMAGES
#define IS_LPV_ENABLED
#endif
#endif

View File

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

View File

@ -1,11 +1,11 @@
uint GetVoxelBlock(const in ivec3 voxelPos) {
// TODO: exit early if outside bounds
return imageLoad(imgVoxelMask, voxelPos).r;
}
uint GetVoxelBlock(const in vec3 playerPos) {
vec3 cameraOffset = fract(cameraPosition);
ivec3 voxelPos = ivec3(floor(playerPos + cameraOffset + VoxelSize/2u));
ivec3 voxelPos = GetVoxelIndex(playerPos);
// TODO: exit early if outside bounds
return imageLoad(imgVoxelMask, voxelPos).r;

View File

@ -1,6 +1,5 @@
void SetVoxelBlock(const in vec3 playerPos, const in uint blockId) {
vec3 cameraOffset = fract(cameraPosition);
ivec3 voxelPos = ivec3(floor(playerPos + cameraOffset + VoxelSize/2u));
ivec3 voxelPos = GetVoxelIndex(playerPos);
// TODO: exit early if outside bounds
imageStore(imgVoxelMask, voxelPos, uvec4(blockId));