add lpv shift

This commit is contained in:
NULL511
2026-05-31 18:49:56 -04:00
parent ce4b4be2c0
commit 589483f82e
24 changed files with 96 additions and 58 deletions
+2 -2
View File
@@ -94,7 +94,7 @@ uniform int heldBlockLightValue2;
uniform int frameCounter;
#include "/lib/hsv.glsl"
#include "/lib/lpv_common.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/lpv_render.glsl"
#endif
@@ -526,7 +526,7 @@ float luma(vec3 color) {
///////////////////////// BLOCKLIGHT LIGHTING OR LPV LIGHTING OR FLOODFILL COLORED LIGHTING
#ifdef IS_LPV_ENABLED
vec3 lpvPos = GetLpvPosition(feetPlayerPos);
vec3 lpvPos = GetVoxelPosition(feetPlayerPos);
#else
const vec3 lpvPos = vec3(0.0);
#endif
+2 -2
View File
@@ -141,7 +141,7 @@ uniform vec3 OVERDRAW_PREVENTION_SCALE;
#ifdef IS_LPV_ENABLED
#include "/lib/hsv.glsl"
#include "/lib/lpv_common.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/lpv_render.glsl"
#endif
@@ -705,7 +705,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
}
#endif
vec3 lpvPos = GetLpvPosition(feetPlayerPos) + normalOffset;
vec3 lpvPos = GetVoxelPosition(feetPlayerPos) + normalOffset;
#else
const vec3 lpvPos = vec3(0.0);
#endif
+2 -2
View File
@@ -173,7 +173,7 @@ float convertHandDepth_2(in float depth, bool hand) {
#ifdef IS_LPV_ENABLED
#include "/lib/hsv.glsl"
#include "/lib/lpv_common.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/lpv_render.glsl"
#endif
@@ -1190,7 +1190,7 @@ void main() {
normalOffset = mix(normalOffset, texNormalOffset, (LPV_NORMAL_STRENGTH*0.01));
#endif
vec3 lpvPos = GetLpvPosition(feetPlayerPos) + normalOffset;
vec3 lpvPos = GetVoxelPosition(feetPlayerPos) + normalOffset;
#else
const vec3 lpvPos = vec3(0.0);
#endif
+3 -3
View File
@@ -127,7 +127,7 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo
#ifdef IS_LPV_ENABLED
#include "/lib/hsv.glsl"
#include "/lib/lpv_common.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/lpv_render.glsl"
#endif
vec4 raymarchLPV(
@@ -163,10 +163,10 @@ float linearizeDepthFast(const in float depth, const in float near, const in flo
LPVrayProgress = gbufferModelViewInverse[3].xyz + d*LPVrayStartPos;
vec3 lpvPos = GetLpvPosition(LPVrayProgress);
vec3 lpvPos = GetVoxelPosition(LPVrayProgress);
float fadeLength = 10.0; // in blocks
vec3 cubicRadius = clamp( min(((LpvSize3-1.0) - lpvPos)/fadeLength, lpvPos/fadeLength) ,0.0,1.0);
vec3 cubicRadius = clamp( min(((VoxelSize3-1.0) - lpvPos)/fadeLength, lpvPos/fadeLength) ,0.0,1.0);
float LpvFadeF = cubicRadius.x*cubicRadius.y*cubicRadius.z;
if(LpvFadeF < 0.01) break;
+27 -18
View File
@@ -10,24 +10,26 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
const ivec3 workGroups = ivec3(8, 8, 8);
#endif
uniform int frameCounter;
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
uniform mat4 gbufferModelViewInverse;
uniform mat4 gbufferPreviousModelView;
#ifdef IS_LPV_ENABLED
shared vec4 lpvSharedData[10*10*10];
shared uint voxelSharedData[10*10*10];
const vec2 LpvBlockSkyFalloff = vec2(0.96, 0.96);
const float LpvBlockFalloff = 0.96;
const ivec3 lpvFlatten = ivec3(1, 10, 100);
uniform int frameCounter;
uniform vec3 cameraPosition;
uniform vec3 previousCameraPosition;
#include "/lib/hsv.glsl"
#include "/lib/util.glsl"
#include "/lib/blocks.glsl"
#include "/lib/lpv_common.glsl"
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/lpv_blocks.glsl"
#include "/lib/lpv_buffer.glsl"
#include "/lib/voxel_common.glsl"
int sumOf(ivec3 vec) {return vec.x + vec.y + vec.z;}
@@ -36,22 +38,21 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
}
vec4 GetLpvValue(in ivec3 texCoord) {
if (clamp(texCoord, ivec3(0), ivec3(LpvSize) - 1) != texCoord) return vec4(0.0);
if (!InVoxelBounds(texCoord)) return vec4(0.0);
vec4 lpvSample = (frameCounter % 2) == 0
? imageLoad(imgLpv2, texCoord)
: imageLoad(imgLpv1, texCoord);
vec4 hsv_sky = vec4(RgbToHsv(lpvSample.rgb), lpvSample.a);
hsv_sky.zw = exp2(hsv_sky.zw * LpvBlockSkyRange) - 1.0;
hsv_sky.z = exp2(hsv_sky.z * LpvBlockRange) - 1.0;
lpvSample = vec4(HsvToRgb(hsv_sky.xyz), hsv_sky.w);
return lpvSample;
}
uint GetVoxelBlock(const in ivec3 voxelPos) {
if (clamp(voxelPos, ivec3(0), ivec3(VoxelSize3-1u)) != voxelPos)
return BLOCK_EMPTY;
if (!InVoxelBounds(voxelPos)) return BLOCK_EMPTY;
return imageLoad(imgVoxelMask, voxelPos).r;
}
@@ -72,7 +73,7 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
if (blockId > 0 && blockId != BLOCK_EMPTY) {
uvec2 blockData = imageLoad(imgBlockData, int(blockId)).rg;
mask = (blockData.g >> 24) & 0xFFFF;
mask = (blockData.g >> 24u) & 0xFFFFu;
}
return lpvSharedData[shared_index] * ((mask >> mask_index) & 1u);
@@ -89,7 +90,7 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
vec4 sZ1 = sampleShared(fragCoord + ivec3( 0, 0, -1), 5) * m1.z;
vec4 sZ2 = sampleShared(fragCoord + ivec3( 0, 0, 1), 4) * m2.z;
const vec4 avgFalloff = (1.0/6.0) * LpvBlockSkyFalloff.xxxy;
const float avgFalloff = (1.0/6.0) * LpvBlockFalloff;
return (sX1 + sX2 + sY1 + sY2 + sZ1 + sZ2) * avgFalloff;
}
#endif
@@ -100,23 +101,31 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
void main() {
#ifdef IS_LPV_ENABLED
uvec3 chunkPos = gl_WorkGroupID * gl_WorkGroupSize;
if (any(greaterThanEqual(chunkPos, LpvSize3))) return;
if (any(greaterThanEqual(chunkPos, VoxelSize3))) return;
// Pre-populate shared-memory buffer for improved sampling performance
uint i = uint(gl_LocalInvocationIndex) * 2u;
if (i < 1000u) {
ivec3 imgCoordOffset = ivec3(floor(cameraPosition) - floor(previousCameraPosition));
vec3 cameraViewDir = gbufferModelViewInverse[2].xyz;
vec3 lpvPosNow = GetVoxelOffset(cameraPosition, cameraViewDir);
vec3 previousCameraViewDir = vec3(gbufferPreviousModelView[0].z, gbufferPreviousModelView[1].z, gbufferPreviousModelView[2].z);
vec3 lpvPosLast = GetVoxelOffset(previousCameraPosition, previousCameraViewDir);
ivec3 imgCoordOffset = ivec3(floor(lpvPosLast) - floor(lpvPosNow)) + ivec3(floor(cameraPosition) - floor(previousCameraPosition));
ivec3 workGroupOffset = ivec3(gl_WorkGroupID * gl_WorkGroupSize) - 1;
PopulateSharedIndex(imgCoordOffset, workGroupOffset, i);
PopulateSharedIndex(imgCoordOffset, workGroupOffset, i + 1u);
}
memoryBarrierShared();
barrier();
// Exit early if outside LPV buffer size
ivec3 imgCoord = ivec3(gl_GlobalInvocationID);
if (any(greaterThanEqual(imgCoord, LpvSize3))) return;
if (any(greaterThanEqual(imgCoord, VoxelSize3))) return;
vec4 lightValue = vec4(0.0);
vec3 lightColor = vec3(0.0);
@@ -134,7 +143,7 @@ void main() {
lightRange = lightColorRange.a * 255.0;
vec4 tintColorMask = unpackUnorm4x8(blockData.g);
tintColor = srgbToLinear(tintColorMask.rgb);
mixMask = (blockData.g >> 24) & 0xFFFF;
mixMask = (blockData.g >> 24u) & 0xFFFFu;
}
// Mix neighbor voxel light values
@@ -153,7 +162,7 @@ void main() {
// Convert back to linear RGB space
vec4 hsv_sky = vec4(RgbToHsv(lightValue.rgb), lightValue.a);
hsv_sky.zw = log2(hsv_sky.zw + 1.0) / LpvBlockSkyRange;
hsv_sky.z = log2(hsv_sky.z + 1.0) / LpvBlockRange;
lightValue = vec4(HsvToRgb(hsv_sky.xyz), hsv_sky.w);
// Store final value
+3
View File
@@ -161,6 +161,8 @@ screen.Ambient_light = Ambient Light
option.LPV_VL_FOG_ILLUMINATION_BRIGHTNESS = Fog Light Propagation Brightness
suffix.LPV_VL_FOG_ILLUMINATION_BRIGHTNESS=%
option.VANILLA_LIGHTMAP_MASK = Vanilla Torch lightmap Mask
option.LPV_FRUSTUM_OFFSET = Shifting
suffix.LPV_FRUSTUM_OFFSET=%
option.AO_in_sunlight = Apply AO to sunlight
option.AO_Strength = AO Multiplier
@@ -251,6 +253,7 @@ screen.Ambient_light = Ambient Light
option.LPV_NOSHADOW_HACK.comment = Fix for Iris 1.7.0 and lower! Allows floodfill to work in Nether & End, but disables entity & dropped item lights.
option.LPV_VL_FOG_ILLUMINATION.comment = Allow the colored lighting to light up the air around it.
option.LPV_VL_FOG_ILLUMINATION_BRIGHTNESS.comment = Configure the brightness of lit up fog.
option.LPV_FRUSTUM_OFFSET.comment = Increases visible lighting range by shifting the lighting volume in the direction the camera is looking.
###################################################### ↓↓↓ THIS SUBMENU'S LABELS
screen.Resource_Pack_Support = Materials / Resource Pack Support
+1 -1
View File
@@ -46,7 +46,7 @@ vec3 doBlockLightLighting(
// create a smooth falloff at the edges of the voxel volume.
float fadeLength = 10.0; // in meters
vec3 cubicRadius = clamp( min(((LpvSize3-1.0) - lpvPos)/fadeLength, lpvPos/fadeLength) ,0.0,1.0);
vec3 cubicRadius = clamp( min(((VoxelSize3-1.0) - lpvPos)/fadeLength, lpvPos/fadeLength) ,0.0,1.0);
float voxelRangeFalloff = cubicRadius.x*cubicRadius.y*cubicRadius.z;
voxelRangeFalloff = 1.0 - pow(1.0-pow(voxelRangeFalloff,1.5),3.0);
-10
View File
@@ -1,10 +0,0 @@
// 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);
vec3 GetLpvPosition(const in vec3 playerPos) {
vec3 cameraOffset = fract(cameraPosition);
return playerPos + cameraOffset + LpvSize3/2u;
}
+2 -2
View File
@@ -11,14 +11,14 @@ float lpvCurve(float values) {
}
vec4 SampleLpvLinear(const in vec3 lpvPos) {
vec3 texcoord = lpvPos / LpvSize3;
vec3 texcoord = lpvPos / VoxelSize3;
vec4 lpvSample = (frameCounter % 2) == 0
? textureLod(texLpv1, texcoord, 0)
: textureLod(texLpv2, texcoord, 0);
vec3 hsv = RgbToHsv(lpvSample.rgb);
hsv.z = lpvCurve(hsv.b) * LpvBlockSkyRange.x;
hsv.z = lpvCurve(hsv.b) * LpvBlockRange;
lpvSample.rgb = HsvToRgb(hsv);
lpvSample.rgb = clamp(lpvSample.rgb/15.0,0.0,1.0);
+1
View File
@@ -776,6 +776,7 @@
//#define LPV_COLORED_CANDLES
//#define LPV_VL_FOG_ILLUMINATION
#define LPV_VL_FOG_ILLUMINATION_BRIGHTNESS 5 // [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 105 110 115 120 125 130 135 140 145 150 155 160 165 170 175 180 185 190 195 200]
#define LPV_FRUSTUM_OFFSET 25 // [0 5 10 15 20 25 30 35 40 45 50]
// Fix for making nether/end work until next Iris release to fix shadow matrices
//#define LPV_NOSHADOW_HACK
+5
View File
@@ -0,0 +1,5 @@
#ifdef RENDER_SHADOW
layout(r16ui) uniform uimage3D imgVoxelMask;
#else
layout(r16ui) uniform readonly uimage3D imgVoxelMask;
#endif
+26 -7
View File
@@ -1,10 +1,29 @@
#ifdef RENDER_SHADOW
layout(r16ui) uniform uimage3D imgVoxelMask;
#else
layout(r16ui) uniform readonly uimage3D imgVoxelMask;
#endif
#define BLOCK_EMPTY 0
const uint VoxelSize = uint(exp2(LPV_SIZE));
const uvec3 VoxelSize3 = uvec3(VoxelSize);
const ivec3 VoxelSize3 = ivec3(VoxelSize);
const ivec3 VoxelCenter = ivec3(VoxelSize/2u);
const float VoxelShiftF = LPV_FRUSTUM_OFFSET * 0.01;
#define BLOCK_EMPTY 0
const float LpvBlockRange = 15.0;
ivec3 GetVoxelCenter(const in vec3 viewDir) {
vec3 offset = viewDir * (VoxelSize * VoxelShiftF);
return VoxelCenter + ivec3(floor(offset));
}
vec3 GetVoxelOffset(const in vec3 cameraPos, const in vec3 playerViewDir) {
return fract(cameraPos) + GetVoxelCenter(playerViewDir);
}
vec3 GetVoxelPosition(const in vec3 playerPos) {
vec3 viewDir = gbufferModelViewInverse[2].xyz;
return playerPos + GetVoxelOffset(cameraPosition, viewDir);
}
bool InVoxelBounds(const in ivec3 voxelPos) {
const ivec3 voxelMin = ivec3(0);
const ivec3 voxelMax = ivec3(VoxelSize-1u);
return clamp(voxelPos, voxelMin, voxelMax) == voxelPos;
}
+2 -7
View File
@@ -1,11 +1,6 @@
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;
ivec3 voxelPos = ivec3(floor(GetVoxelPosition(playerPos)));
if (!InVoxelBounds(voxelPos)) return;
imageStore(imgVoxelMask, voxelPos, uvec4(blockId));
}
File diff suppressed because one or more lines are too long
+2
View File
@@ -20,6 +20,7 @@ Read the terms of modification and sharing before changing something below pleas
#endif
attribute vec3 vaPosition;
uniform mat4 gbufferModelViewInverse;
uniform mat4 shadowModelViewInverse;
uniform int renderStage;
@@ -31,6 +32,7 @@ Read the terms of modification and sharing before changing something below pleas
#include "/lib/blocks.glsl"
#include "/lib/entities.glsl"
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif
+4 -2
View File
@@ -23,17 +23,19 @@ Read the terms of modification and sharing before changing something below pleas
#endif
attribute vec3 vaPosition;
uniform mat4 gbufferModelViewInverse;
uniform mat4 shadowModelViewInverse;
uniform int renderStage;
uniform vec3 chunkOffset;
uniform vec3 cameraPosition;
uniform int currentRenderedItemId;
uniform int currentRenderedItemId;
uniform int blockEntityId;
uniform int entityId;
#include "/lib/blocks.glsl"
#include "/lib/entities.glsl"
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif
+1
View File
@@ -68,6 +68,7 @@ uniform int entityId;
uniform int currentRenderedItemId;
uniform int renderStage;
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif
+1
View File
@@ -66,6 +66,7 @@ uniform int entityId;
uniform int currentRenderedItemId;
uniform int renderStage;
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif
@@ -67,6 +67,7 @@ uniform int entityId;
uniform int currentRenderedItemId;
uniform int renderStage;
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif
@@ -67,6 +67,7 @@ uniform int entityId;
uniform int currentRenderedItemId;
uniform int renderStage;
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif
@@ -66,6 +66,7 @@ uniform int entityId;
uniform int currentRenderedItemId;
uniform int renderStage;
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif
@@ -67,6 +67,7 @@ uniform int entityId;
uniform int currentRenderedItemId;
uniform int renderStage;
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif
+2
View File
@@ -26,6 +26,7 @@ Read the terms of modification and sharing before changing something below pleas
#endif
attribute vec3 vaPosition;
uniform mat4 gbufferModelViewInverse;
uniform mat4 shadowModelViewInverse;
uniform int renderStage;
@@ -37,6 +38,7 @@ Read the terms of modification and sharing before changing something below pleas
#include "/lib/blocks.glsl"
#include "/lib/entities.glsl"
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif
+2
View File
@@ -23,6 +23,7 @@ Read the terms of modification and sharing before changing something below pleas
#endif
attribute vec3 vaPosition;
uniform mat4 gbufferModelViewInverse;
uniform mat4 shadowModelViewInverse;
uniform int renderStage;
@@ -34,6 +35,7 @@ Read the terms of modification and sharing before changing something below pleas
#include "/lib/blocks.glsl"
#include "/lib/entities.glsl"
#include "/lib/voxel_buffer.glsl"
#include "/lib/voxel_common.glsl"
#include "/lib/voxel_write.glsl"
#endif