fix floodfill frame offset

This commit is contained in:
NULL511 2024-05-02 14:18:49 -04:00
parent f33b071152
commit 852d995db0
11 changed files with 40 additions and 53 deletions

View File

@ -1269,10 +1269,10 @@ void main() {
#ifdef IS_LPV_ENABLED
vec3 lpvPos = GetLpvPosition(feetPlayerPos) + 0.5*viewToWorld(FlatNormals);
// vec3 lpvPos = GetLpvPosition(feetPlayerPos) - 0.5*FlatNormals + slopednormal;
#else
const vec3 lpvPos = vec3(0.0);
#endif
// vec3 lpvPos = GetLpvPosition(feetPlayerPos) - 0.5*FlatNormals + slopednormal;
Indirect_lighting = DoAmbientLightColor(lpvPos, Indirect_lighting, MinimumLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy);
@ -1284,6 +1284,7 @@ void main() {
#ifdef SSS_view
Indirect_lighting = vec3(3.0);
#endif
/////////////////////////////////////////////////////////////////////////////////////
///////////////////////////// EFFECTS FOR INDIRECT /////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////

View File

@ -1,8 +1,6 @@
struct LpvBlockData { // 12 x1280 =?
uint data; // 4
uint LightColor; // 4
uint LightRangeSize; // 4
// uint LightMetadata;
struct LpvBlockData { // 8 x1280 =?
uint MaskWeight; // 4
uint ColorRange; // 4
};
#ifdef RENDER_SETUP
@ -24,6 +22,5 @@ uint BuildBlockLpvData(uint mixMask, float mixWeight) {
void ParseBlockLpvData(const in uint data, out uint mixMask, out float mixWeight) {
mixWeight = (data & 0xFF) / 255.0;
mixMask = (data >> 8) & 0xFF;
}

View File

@ -1,21 +1,12 @@
layout(rgba8) uniform image3D imgLpv1;
layout(rgba8) uniform image3D imgLpv2;
// How far light propagates (block, sky)
const vec2 LpvBlockSkyRange = vec2(15.0, 24.0);
const uint LpvSize = uint(exp2(LPV_SIZE));
const uvec3 LpvSize3 = uvec3(LpvSize);
const vec2 LpvBlockSkyRange = vec2(1.0, 24.0);
// #if defined RENDER_SHADOWCOMP || defined RENDER_GBUFFER
// layout(r16ui) uniform uimage2D imgVoxelMask;
// #elif defined RENDER_BEGIN || defined RENDER_GEOMETRY || defined RENDER_VERTEX
// layout(r16ui) uniform writeonly uimage2D imgVoxelMask;
// #else
// layout(r16ui) uniform readonly uimage2D imgVoxelMask;
// #endif
// #define LIGHT_NONE 0
vec3 GetLpvPosition(const in vec3 playerPos) {
vec3 cameraOffset = fract(cameraPosition);
return playerPos + cameraOffset + LpvSize3/2u;

View File

@ -9,22 +9,18 @@
vec4 SampleLpvNearest(const in ivec3 lpvPos) {
vec4 lpvSample = (frameCounter % 2) == 0
// #ifndef RENDER_GBUFFER
? imageLoad(imgLpv1, lpvPos)
: imageLoad(imgLpv2, lpvPos);
// #else
// ? imageLoad(imgLpv2, lpvPos, 0)
// : imageLoad(imgLpv1, lpvPos, 0);
// #endif
lpvSample.ba = exp2(lpvSample.ba * LpvBlockSkyRange) - 1.0;
//lpvSample.ba = exp2(lpvSample.ba * LpvBlockSkyRange) - 1.0;
lpvSample.b = (lpvSample.b*lpvSample.b) * LpvBlockSkyRange.x;
lpvSample.rgb = HsvToRgb(lpvSample.rgb);
return lpvSample;
}
vec4 SampleLpvLinear(const in vec3 lpvPos) {
vec3 pos = lpvPos - 0.5;
vec3 pos = lpvPos;// - 0.5;
ivec3 lpvCoord = ivec3(floor(pos));
vec3 lpvF = fract(pos);
@ -102,7 +98,7 @@ vec4 SampleLpvLinear(const in vec3 lpvPos) {
vec3 GetLpvBlockLight(const in vec4 lpvSample) {
// return GetLpvBlockLight(lpvSample, 1.0);
return 8.0 * lpvSample.rgb;// * LPV_BLOCKLIGHT_SCALE);// * DynamicLightBrightness;
return lpvSample.rgb;// * LPV_BLOCKLIGHT_SCALE);// * DynamicLightBrightness;
}
float GetLpvSkyLight(const in vec4 lpvSample) {

View File

@ -3,9 +3,11 @@ layout(r16ui) uniform uimage3D imgVoxelMask;
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));
return ivec3(floor(playerPos + cameraOffset) + VoxelSize3/2u);
}

View File

@ -4,9 +4,9 @@ uint GetVoxelBlock(const in ivec3 voxelPos) {
return imageLoad(imgVoxelMask, voxelPos).r;
}
uint GetVoxelBlock(const in vec3 playerPos) {
ivec3 voxelPos = GetVoxelIndex(playerPos);
// uint GetVoxelBlock(const in vec3 playerPos) {
// ivec3 voxelPos = GetVoxelIndex(playerPos);
// TODO: exit early if outside bounds
return imageLoad(imgVoxelMask, voxelPos).r;
}
// // TODO: exit early if outside bounds
// return imageLoad(imgVoxelMask, voxelPos).r;
// }

View File

@ -1,6 +1,6 @@
void SetVoxelBlock(const in vec3 playerPos, const in uint blockId) {
ivec3 voxelPos = GetVoxelIndex(playerPos);
if (clamp(voxelPos, ivec3(0), ivec3(VoxelSize-1u)) != voxelPos) return;
// TODO: exit early if outside bounds
imageStore(imgVoxelMask, voxelPos, uvec4(blockId));
}

View File

@ -18,6 +18,10 @@ iris.features.optional=ENTITY_TRANSLUCENT REVERSED_CULLING COMPUTE_SHADERS CUSTO
moon=false
#endif
#ifdef LPV_ENABLED
shadow.culling = reversed
#endif
#ifndef RENDER_ENTITY_SHADOWS
shadowBlockEntities = false
shadowEntities = false

View File

@ -48,10 +48,8 @@ void main() {
}
LpvBlockData block;
block.data = BuildBlockLpvData(mixMask, mixWeight);
block.LightColor = packUnorm4x8(vec4(lightColor, 0.0));
block.LightRangeSize = packUnorm4x8(vec4(lightRange/255.0, 0.0, 0.0, 0.0));
block.MaskWeight = BuildBlockLpvData(mixMask, mixWeight);
block.ColorRange = packUnorm4x8(vec4(lightColor, lightRange/255.0));
LpvBlockMap[blockId] = block;
#endif
}

View File

@ -197,8 +197,9 @@ void main() {
uint voxelId = blockId;
if (voxelId == 0u) voxelId = 1u;
vec3 origin = playerpos + at_midBlock/64.0;
SetVoxelBlock(origin, voxelId);
vec3 originPos = playerpos + at_midBlock/64.0;
SetVoxelBlock(originPos, voxelId);
}
#endif

View File

@ -25,6 +25,7 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
uniform int frameCounter;
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
#include "/lib/hsv.glsl"
#include "/lib/blocks.glsl"
@ -76,7 +77,7 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
uint blockId = voxelSharedData[shared_index];
if (blockId > 0 && blockId != BLOCK_EMPTY)
ParseBlockLpvData(LpvBlockMap[blockId].data, mixMask, mixWeight);
ParseBlockLpvData(LpvBlockMap[blockId].MaskWeight, mixMask, mixWeight);
return lpvSharedData[shared_index] * ((mixMask >> mask_index) & 1u);// * mixWeight;
}
@ -96,17 +97,16 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
void PopulateSharedIndex(const in ivec3 imgCoordOffset, const in ivec3 workGroupOffset, const in uint i) {
ivec3 pos = workGroupOffset + ivec3(i / lpvFlatten) % 10;
ivec3 lpvPos = imgCoordOffset + pos;
lpvSharedData[i] = GetLpvValue(lpvPos);
voxelSharedData[i] = GetVoxelBlock(lpvPos);
//ivec3 lpvPos = imgCoordOffset + pos;
lpvSharedData[i] = GetLpvValue(imgCoordOffset + pos);
voxelSharedData[i] = GetVoxelBlock(pos);
}
void PopulateShared() {
uint i = uint(gl_LocalInvocationIndex) * 2u;
if (i >= 1000u) return;
// ivec3 voxelOffset = GetLPVVoxelOffset();
ivec3 imgCoordOffset = ivec3(0);//GetLPVFrameOffset();
ivec3 imgCoordOffset = ivec3(floor(cameraPosition) - floor(previousCameraPosition));
ivec3 workGroupOffset = ivec3(gl_WorkGroupID * gl_WorkGroupSize) - 1;
PopulateSharedIndex(imgCoordOffset, workGroupOffset, i);
@ -140,9 +140,8 @@ void main() {
uint blockId = voxelSharedData[getSharedCoord(ivec3(gl_LocalInvocationID) + 1)];
float mixWeight = blockId == BLOCK_EMPTY ? 1.0 : 0.0;
LpvBlockData blockData = LpvBlockMap[blockId];
if (blockId > 0 && blockId != BLOCK_EMPTY)
ParseBlockLpvData(blockData.data, mixMask, mixWeight);
ParseBlockLpvData(LpvBlockMap[blockId].MaskWeight, mixMask, mixWeight);
#ifdef LPV_GLASS_TINT
if (blockId >= BLOCK_HONEY && blockId <= BLOCK_TINTED_GLASS) {
@ -161,11 +160,9 @@ void main() {
lightValue.ba = log2(lightValue.ba + 1.0) / LpvBlockSkyRange;
if (blockId > 0 && blockId != BLOCK_EMPTY) {
vec3 lightColor = unpackUnorm4x8(blockData.LightColor).rgb;
vec2 lightRangeSize = unpackUnorm4x8(blockData.LightRangeSize).xy;
float lightRange = lightRangeSize.x * 255.0;
lightColor = RGBToLinear(lightColor);
vec4 lightColorRange = unpackUnorm4x8(LpvBlockMap[blockId].ColorRange);
vec3 lightColor = RGBToLinear(lightColorRange.rgb);
float lightRange = lightColorRange.a * 255.0;
// #ifdef LIGHTING_FLICKER
// vec2 lightNoise = GetDynLightNoise(cameraPosition + blockLocalPos);