feat: initial commit
This commit is contained in:
+5
@@ -0,0 +1,5 @@
|
||||
#extension GL_ARB_shader_storage_buffer_object : enable
|
||||
|
||||
layout(std430, binding = 0) SSBO_QUALIFIER buffer blockDataBuffer {
|
||||
uvec4 data[];
|
||||
} blockDataSSBO;
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
#define SSBO_QUALIFIER
|
||||
|
||||
#if WORLD_SPACE_PLAYER_REF == 1
|
||||
#include "/lib/voxelization/SSBOs/playerVerticesBuffer.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/voxelization/SSBOs/wsrBuffer.glsl"
|
||||
#include "/lib/voxelization/SSBOs/wsrLodBuffer.glsl"
|
||||
|
||||
#if COLORED_LIGHTING < 512
|
||||
const ivec3 sceneVoxelVolumeSize = ivec3(COLORED_LIGHTING_INTERNAL, 64, COLORED_LIGHTING_INTERNAL);
|
||||
#else
|
||||
const ivec3 sceneVoxelVolumeSize = ivec3(512, 64, 512);
|
||||
#endif
|
||||
|
||||
void clearSSBOs() {
|
||||
int pixelIndex = int(gl_FragCoord.x) + int(viewWidth) * int(gl_FragCoord.y);
|
||||
|
||||
int k = sceneVoxelVolumeSize.x * sceneVoxelVolumeSize.y * sceneVoxelVolumeSize.z / 32;
|
||||
if (pixelIndex < k) {
|
||||
if (pixelIndex < k / 64)
|
||||
wsrLodSSBO.bitmasks[pixelIndex] = 0u;
|
||||
|
||||
wsrSSBO.bitmasks[pixelIndex] = 0u;
|
||||
}
|
||||
|
||||
#if WORLD_SPACE_PLAYER_REF == 1
|
||||
if (pixelIndex == 0) {
|
||||
playerVerticesSSBO.bounds = playerBounds(ivec3(1e6), ivec3(-1e6), ivec3(1e6), ivec3(-1e6),
|
||||
ivec3(1e6), ivec3(-1e6), ivec3(1e6), ivec3(-1e6),
|
||||
ivec3(1e6), ivec3(-1e6), ivec3(1e6), ivec3(-1e6));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#extension GL_ARB_shader_storage_buffer_object : enable
|
||||
|
||||
struct playerBounds {
|
||||
ivec3 headMin, headMax;
|
||||
ivec3 torsoMin, torsoMax;
|
||||
ivec3 leftLegMin, leftLegMax;
|
||||
ivec3 rightLegMin, rightLegMax;
|
||||
ivec3 leftHandMin, leftHandMax;
|
||||
ivec3 rightHandMin, rightHandMax;
|
||||
};
|
||||
|
||||
layout(std430, binding = 3) SSBO_QUALIFIER buffer playerVerticesBuffer {
|
||||
vec3 vertexPositions[216];
|
||||
vec2 vertexData[216];
|
||||
playerBounds bounds;
|
||||
} playerVerticesSSBO;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
#extension GL_ARB_shader_storage_buffer_object : enable
|
||||
|
||||
layout(std430, binding = 1) SSBO_QUALIFIER buffer wsrBuffer {
|
||||
uint bitmasks[];
|
||||
} wsrSSBO;
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
#extension GL_ARB_shader_storage_buffer_object : enable
|
||||
|
||||
layout(std430, binding = 2) SSBO_QUALIFIER buffer wsrLodBuffer {
|
||||
uint bitmasks[];
|
||||
} wsrLodSSBO;
|
||||
+49
@@ -0,0 +1,49 @@
|
||||
layout(r32i) uniform iimage2D endcrystal_img;
|
||||
|
||||
void UpdateEndCrystalMap(vec3 pos) {
|
||||
int packedPos = int(pos.x + 512.5) + (int(pos.y + 512.5) << 10) + (int(pos.z + 512.5) << 20);
|
||||
for (int k = 0; k < 20; k++) {
|
||||
int registeredPos = imageAtomicCompSwap(endcrystal_img, ivec2(k, 0), 0, packedPos);
|
||||
vec3 otherPos = vec3(ivec3(registeredPos) >> ivec3(0, 10, 20) & 1023) - 512.0;
|
||||
if (registeredPos == 0 || length((otherPos - pos) * vec3(1, 0.3, 1)) < 2.3) {
|
||||
ivec4 addData = ivec4(10 * pos.x + 5120.5, 10 * pos.y + 5120.5, 10 * pos.z + 5120.5, 5130) - 5120;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
imageAtomicAdd(endcrystal_img, ivec2(k, i+1), addData[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateBeamMap(vec3 pos) {
|
||||
int packedPos = int(pos.x + 512.5) + (int(pos.y + 512.5) << 10) + (int(pos.z + 512.5) << 20);
|
||||
for (int k = 20; k < 35; k++) {
|
||||
int registeredPos = imageAtomicCompSwap(endcrystal_img, ivec2(k, 0), 0, packedPos);
|
||||
vec3 otherPos = vec3(ivec3(registeredPos) >> ivec3(0, 10, 20) & 1023) - 512.0;
|
||||
if (registeredPos == 0 || length((otherPos - pos)) < 10.0) {
|
||||
ivec4 addData = ivec4(10 * pos.x + 5120.5, 10 * pos.y + 5120.5, 10 * pos.z + 5120.5, 5130) - 5120;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
imageAtomicAdd(endcrystal_img, ivec2(k, i+1), addData[i]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void UpdateDragonPos(vec3 pos) {
|
||||
ivec4 addData = ivec4(10 * pos.x + 5120.5, 10 * pos.y + 5120.5, 10 * pos.z + 5120.5, 5130) - 5120;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
imageAtomicAdd(endcrystal_img, ivec2(35, i+1), addData[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void SetEndDragonDeath() {
|
||||
imageAtomicExchange(endcrystal_img, ivec2(35, 0), 10000 + int(3000 * frameTime));
|
||||
}
|
||||
|
||||
void SetEndPortalLoc(vec3 pos) {
|
||||
ivec4 coords = ivec4(pos + at_midBlock.xyz / 64.0 + cameraPositionFract + 1000, 1001) - 1000;
|
||||
for (int k = 0; k < 4; k++) {
|
||||
imageAtomicAdd(endcrystal_img, ivec2(35, k), coords[k]);
|
||||
}
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
const ivec3 leaves_voxelVolumeSize = ivec3(128);
|
||||
|
||||
vec3 SceneToLeavesVoxel(vec3 scenePos) {
|
||||
return scenePos + fract(cameraPosition) + 0.5 * vec3(leaves_voxelVolumeSize);
|
||||
}
|
||||
|
||||
bool CheckInsideLeavesVoxelVolume(vec3 voxelPos) {
|
||||
#ifndef SHADOW
|
||||
voxelPos -= leaves_voxelVolumeSize / 2;
|
||||
voxelPos += sign(voxelPos) * 0.95;
|
||||
voxelPos += leaves_voxelVolumeSize / 2;
|
||||
#endif
|
||||
voxelPos /= vec3(leaves_voxelVolumeSize);
|
||||
return clamp01(voxelPos) == voxelPos;
|
||||
}
|
||||
|
||||
#if defined SHADOW && defined VERTEX_SHADER
|
||||
void UpdateLeavesVoxelMap(int mat) {
|
||||
if (renderStage == MC_RENDER_STAGE_ENTITIES)
|
||||
return;
|
||||
|
||||
vec3 model_pos = gl_Vertex.xyz + at_midBlock.xyz / 64.0;
|
||||
vec3 view_pos = mat3(gl_ModelViewMatrix) * model_pos + gl_ModelViewMatrix[3].xyz;
|
||||
vec3 scenePos = mat3(shadowModelViewInverse) * view_pos + shadowModelViewInverse[3].xyz;
|
||||
vec3 voxelPos = SceneToLeavesVoxel(scenePos);
|
||||
|
||||
if (CheckInsideLeavesVoxelVolume(voxelPos))
|
||||
imageStore(leaves_img, ivec3(voxelPos), uvec4(mat == 10009 ? 2u : 1u, 0u, 0u, 0u));
|
||||
}
|
||||
#endif
|
||||
+462
@@ -0,0 +1,462 @@
|
||||
#include "/lib/shaderSettings/materials.glsl"
|
||||
|
||||
#ifdef IS_IRIS
|
||||
#ifndef INCLUDE_VOXELIZATION
|
||||
#define INCLUDE_VOXELIZATION
|
||||
|
||||
#if COLORED_LIGHTING_INTERNAL <= 512
|
||||
const ivec3 voxelVolumeSize = ivec3(COLORED_LIGHTING_INTERNAL, COLORED_LIGHTING_INTERNAL * 0.5, COLORED_LIGHTING_INTERNAL);
|
||||
#else
|
||||
const ivec3 voxelVolumeSize = ivec3(COLORED_LIGHTING_INTERNAL, 512 * 0.5, COLORED_LIGHTING_INTERNAL);
|
||||
#endif
|
||||
|
||||
float effectiveACTdistance = min(float(COLORED_LIGHTING_INTERNAL), shadowDistance * 2.0);
|
||||
|
||||
vec3 transform(mat4 m, vec3 pos) {
|
||||
return mat3(m) * pos + m[3].xyz;
|
||||
}
|
||||
|
||||
vec3 SceneToVoxel(vec3 scenePos) {
|
||||
return scenePos + cameraPositionBestFract + (0.5 * vec3(voxelVolumeSize));
|
||||
}
|
||||
|
||||
bool CheckInsideVoxelVolume(vec3 voxelPos) {
|
||||
#ifndef SHADOW
|
||||
voxelPos -= voxelVolumeSize / 2;
|
||||
voxelPos += sign(voxelPos) * 0.95;
|
||||
voxelPos += voxelVolumeSize / 2;
|
||||
#endif
|
||||
voxelPos /= vec3(voxelVolumeSize);
|
||||
return clamp01(voxelPos) == voxelPos;
|
||||
}
|
||||
|
||||
uint GetVoxelVolume(ivec3 pos) {
|
||||
return texelFetch(voxel_sampler, pos, 0).x & 32767u;
|
||||
}
|
||||
|
||||
uint GetVoxelVolumeRaw(ivec3 pos) {
|
||||
return texelFetch(voxel_sampler, pos, 0).x;
|
||||
}
|
||||
|
||||
vec4 GetComplexLightVolume(vec3 pos, sampler3D ff_sampler) {
|
||||
vec4 lightVolume;
|
||||
|
||||
#if defined COMPOSITE1 || defined DEFERRED1
|
||||
#undef ACT_CORNER_LEAK_FIX
|
||||
#endif
|
||||
|
||||
#ifndef ACT_CORNER_LEAK_FIX
|
||||
lightVolume = texture(ff_sampler, pos);
|
||||
#else
|
||||
// Manual light filtering
|
||||
ivec3 posTX = ivec3(pos * voxelVolumeSize);
|
||||
vec3 texPos = pos * vec3(voxelVolumeSize) - 0.5;
|
||||
ivec3 base = ivec3(floor(texPos));
|
||||
vec3 frac = fract(texPos);
|
||||
float lightDivide = 0.0;
|
||||
|
||||
for (int x = 0; x <= 1; x++)
|
||||
for (int y = 0; y <= 1; y++)
|
||||
for (int z = 0; z <= 1; z++) {
|
||||
ivec3 offset = ivec3(x, y, z);
|
||||
ivec3 newPos = clamp(base + offset, ivec3(0), voxelVolumeSize - 1);
|
||||
|
||||
// Light Leak Fix
|
||||
ivec3 realOffset = newPos - posTX;
|
||||
ivec3 absRealOffset = abs(realOffset);
|
||||
int totalRealOffset = absRealOffset.x + absRealOffset.y + absRealOffset.z;
|
||||
if (totalRealOffset == 2) {
|
||||
bool isReachable = false;
|
||||
ivec3 checkPos;
|
||||
|
||||
if (realOffset.x != 0) {
|
||||
checkPos = posTX + ivec3(realOffset.x, 0, 0);
|
||||
if (int(GetVoxelVolume(checkPos)) == 0) isReachable = true;
|
||||
}
|
||||
if (realOffset.y != 0) {
|
||||
checkPos = posTX + ivec3(0, realOffset.y, 0);
|
||||
if (int(GetVoxelVolume(checkPos)) == 0) isReachable = true;
|
||||
}
|
||||
if (realOffset.z != 0) {
|
||||
checkPos = posTX + ivec3(0, 0, realOffset.z);
|
||||
if (int(GetVoxelVolume(checkPos)) == 0) isReachable = true;
|
||||
}
|
||||
|
||||
if (!isReachable) continue;
|
||||
} else if (totalRealOffset == 3) continue;
|
||||
|
||||
// Skip solids
|
||||
if (int(GetVoxelVolume(newPos)) == 1)
|
||||
continue;
|
||||
|
||||
// Interpolation weight
|
||||
vec3 w3 = mix(vec3(1.0) - frac, frac, vec3(offset));
|
||||
float weight = w3.x * w3.y * w3.z;
|
||||
|
||||
lightVolume += weight * texelFetch(ff_sampler, newPos, 0);
|
||||
lightDivide += weight;
|
||||
}
|
||||
|
||||
if (lightDivide > 0.0) lightVolume /= lightDivide;
|
||||
#endif
|
||||
|
||||
return lightVolume;
|
||||
}
|
||||
|
||||
vec4 GetLightVolume(vec3 pos) {
|
||||
vec4 lightVolume;
|
||||
|
||||
if (int(framemod2) == 0) {
|
||||
lightVolume = GetComplexLightVolume(pos, floodfill_sampler_copy);
|
||||
} else {
|
||||
lightVolume = GetComplexLightVolume(pos, floodfill_sampler);
|
||||
}
|
||||
|
||||
return lightVolume;
|
||||
}
|
||||
|
||||
int GetVoxelIDs(int mat) {
|
||||
/* These return IDs must be consistent across the following files:
|
||||
"lightVoxelization.glsl", "blocklightColors.glsl", "item.properties"
|
||||
The order of if-checks or block IDs don't matter. The returning IDs matter. */
|
||||
|
||||
if (mat < 10604) {
|
||||
if (mat < 10396) {
|
||||
if (mat < 10300) {
|
||||
if (mat < 10228) {
|
||||
if (mat < 10076) {
|
||||
if (mat == 10056) return 14; // Lava Cauldron
|
||||
if (mat == 10068 || mat == 10070) return 13; // Lava
|
||||
if (mat == 10072) return 5; // Fire
|
||||
} else {
|
||||
if (mat == 10076) return 27; // Soul Fire
|
||||
#if defined GLOWING_NETHER_TREES && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10216) return 62; // Crimson Stem, Crimson Hyphae
|
||||
if (mat == 10224) return 63; // Warped Stem, Warped Hyphae
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (mat < 10276) {
|
||||
if (mat == 10228) return 255; // Bedrock
|
||||
#if defined GLOWING_ORE_ANCIENTDEBRIS && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10252) return 52; // Ancient Debris
|
||||
#endif
|
||||
#if defined GLOWING_RAW_BLOCKS && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10268) return 43; // Raw Iron Block
|
||||
#endif
|
||||
#if defined GLOWING_ORE_IRON && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10272) return 43; // Iron Ore
|
||||
#endif
|
||||
} else {
|
||||
#if defined GLOWING_ORE_IRON && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10276) return 43; // Deepslate Iron Ore
|
||||
#endif
|
||||
#if defined GLOWING_RAW_BLOCKS && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10280) return 45; // Raw Coper Block
|
||||
#endif
|
||||
#if defined GLOWING_ORE_COPPER && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10284) return 45; // Copper Ore
|
||||
if (mat == 10288) return 45; // Deepslate Copper Ore
|
||||
#endif
|
||||
#if defined GLOWING_RAW_BLOCKS && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10296) return 44; // Raw Gold Block
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 10340) {
|
||||
if (mat < 10320) {
|
||||
#if defined GLOWING_ORE_GOLD && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10300) return 44; // Gold Ore
|
||||
if (mat == 10302) return 44; // Deepslate Gold Ore
|
||||
#endif
|
||||
#if defined GLOWING_ORE_MODDED && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10304) return 39; // Modded Pink Ore
|
||||
if (mat == 10306) return 36; // Modded Purple Ore
|
||||
#endif
|
||||
#if defined GLOWING_ORE_NETHERGOLD && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10308) return 50; // Nether Gold Ore
|
||||
#endif
|
||||
} else {
|
||||
#if defined GLOWING_ORE_DIAMOND && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10320) return 48; // Diamond Ore
|
||||
if (mat == 10324) return 48; // Deepslate Diamond Ore
|
||||
#endif
|
||||
if (mat == 10332) return 36; // Amethyst Cluster, Amethyst Buds
|
||||
#if defined GLOWING_EMERALD_BLOCK && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10336) return 47; // Emerald Block
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (mat < 10356) {
|
||||
#if defined GLOWING_ORE_EMERALD && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10340) return 47; // Emerald Ore
|
||||
if (mat == 10344) return 47; // Deepslate Emerald Ore
|
||||
#endif
|
||||
#if defined EMISSIVE_LAPIS_BLOCK && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10352) return 42; // Lapis Block
|
||||
#endif
|
||||
} else {
|
||||
#if defined GLOWING_ORE_LAPIS && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10356) return 46; // Lapis Ore
|
||||
if (mat == 10360) return 46; // Deepslate Lapis Ore
|
||||
#endif
|
||||
#if defined GLOWING_ORE_NETHERQUARTZ && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10368) return 49; // Nether Quartz Ore
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 10516) {
|
||||
if (mat < 10476) {
|
||||
if (mat < 10448) {
|
||||
if (mat == 10396) return 11; // Jack o'Lantern
|
||||
if (mat == 10404) return 6; // Sea Pickle:Waterlogged
|
||||
if (mat == 10412) return 10; // Glowstone
|
||||
} else {
|
||||
if (mat == 10448) return 18; // Sea Lantern
|
||||
if (mat == 10452) return 37; // Magma Block
|
||||
#ifdef DO_IPBR_LIGHTS
|
||||
if (mat == 10456) return 60; // Command Block
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
if (mat < 10500) {
|
||||
if (mat == 10476) return 26; // Crying Obsidian
|
||||
#if defined GLOWING_ORE_GILDEDBLACKSTONE && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10484) return 51; // Gilded Blackstone
|
||||
#endif
|
||||
if (mat == 10496) return 2; // Torch
|
||||
} else {
|
||||
if (mat == 10500) return 3; // End Rod
|
||||
#ifdef DO_IPBR_LIGHTS
|
||||
if (mat == 10508) return 39; // Chorus Flower:Alive
|
||||
if (mat == 10512) return 39; // Chorus Flower:Dead
|
||||
#endif
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 10564) {
|
||||
if (mat < 10548) {
|
||||
if (mat == 10516) return 21; // Furnace:Lit
|
||||
if (mat == 10528) return 28; // Soul Torch
|
||||
if (mat == 10544) return 34; // Glow Lichen
|
||||
} else {
|
||||
if (mat == 10548) return 33; // Enchanting Table
|
||||
if (mat == 10556) return 58; // End Portal Frame:Active
|
||||
if (mat == 10560 || mat == 10562) return 12; // Lantern
|
||||
}
|
||||
} else {
|
||||
if (mat < 10580) {
|
||||
if (mat == 10564) return 29; // Soul Lantern
|
||||
#if defined EMISSIVE_DRAGON_EGG && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10572) return 38; // Dragon Egg
|
||||
#endif
|
||||
if (mat == 10576) return 22; // Smoker:Lit
|
||||
} else {
|
||||
if (mat == 10580) return 23; // Blast Furnace:Lit
|
||||
if (mat == 10592) return 17; // Respawn Anchor:Lit
|
||||
#ifdef DO_IPBR_LIGHTS
|
||||
if (mat == 10596) return 66; // Redstone Wire:Lit
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 10788) {
|
||||
if (mat < 10656) {
|
||||
if (mat < 10632) {
|
||||
if (mat < 10616) {
|
||||
if (mat == 10604) return 35; // Redstone Torch
|
||||
#if defined EMISSIVE_REDSTONE_BLOCK && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10608) return 41; // Redstone Block
|
||||
#endif
|
||||
#if defined GLOWING_ORE_REDSTONE && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10612) return 32; // Redstone Ore:Unlit
|
||||
#endif
|
||||
} else {
|
||||
if (mat == 10616) return 31; // Redstone Ore:Lit
|
||||
#if defined GLOWING_ORE_REDSTONE && defined DO_IPBR_LIGHTS
|
||||
if (mat == 10620) return 32; // Deepslate Redstone Ore:Unlit
|
||||
#endif
|
||||
if (mat == 10624) return 31; // Deepslate Redstone Ore:Lit
|
||||
}
|
||||
} else {
|
||||
if (mat < 10646) {
|
||||
if (mat == 10632) return 20; // Cave Vines:With Glow Berries
|
||||
if (mat == 10640) return 16; // Redstone Lamp:Lit
|
||||
#ifdef DO_IPBR_LIGHTS
|
||||
if (mat == 10644) return 67; // Repeater:Lit, Comparator:Lit
|
||||
#endif
|
||||
} else {
|
||||
#ifdef DO_IPBR_LIGHTS
|
||||
if (mat == 10646) return 66; // Comparator:Unlit:Subtract
|
||||
#endif
|
||||
if (mat == 10648) return 19; // Shroomlight
|
||||
if (mat == 10652) return 15; // Campfire:Lit
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 10704) {
|
||||
if (mat < 10688) {
|
||||
if (mat == 10656) return 30; // Soul Campfire:Lit
|
||||
if (mat == 10680) return 7; // Ochre Froglight
|
||||
if (mat == 10684) return 8; // Verdant Froglight
|
||||
} else {
|
||||
if (mat == 10688) return 9; // Pearlescent Froglight
|
||||
if (mat == 10696) return 57; // Sculk, Sculk Catalyst
|
||||
if (mat == 10698) return 57; // Sculk Vein, Sculk Sensor:Unlit
|
||||
if (mat == 10700) return 57; // Sculk Shrieker
|
||||
}
|
||||
} else {
|
||||
if (mat < 10776) {
|
||||
if (mat == 10704) return 57; // Sculk Sensor:Lit
|
||||
#ifdef DO_IPBR_LIGHTS
|
||||
if (mat == 10708) return 53; // Spawner
|
||||
if (mat == 10736) return 64; // Structure Block, Jigsaw Block, Test Block, Test Instance Block
|
||||
#endif
|
||||
} else {
|
||||
#ifdef DO_IPBR_LIGHTS
|
||||
if (mat == 10776) return 61; // Warped Fungus, Crimson Fungus
|
||||
if (mat == 10780) return 61; // Potted Warped Fungus, Potted Crimson Fungus
|
||||
#endif
|
||||
if (mat == 10784) return 36; // Calibrated Sculk Sensor:Unlit
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 10980) {
|
||||
if (mat < 10876) {
|
||||
if (mat < 10856) {
|
||||
if (mat == 10788) return 36; // Calibrated Sculk Sensor:Lit
|
||||
#ifdef DO_IPBR_LIGHTS
|
||||
if (mat == 10836) return 40; // Brewing Stand
|
||||
#endif
|
||||
if (mat == 10852) return 55; // Copper Bulb:BrighterOnes:Lit
|
||||
} else {
|
||||
if (mat == 10856) return 56; // Copper Bulb:DimmerOnes:Lit
|
||||
if (mat == 10868) return 54; // Trial Spawner:NotOminous:Active, Vault:NotOminous:Active
|
||||
if (mat == 10872) return 68; // Vault:Inactive
|
||||
}
|
||||
} else {
|
||||
if (mat < 10948) {
|
||||
if (mat == 10876) return 69; // Trial Spawner:Ominous:Active, Vault:Ominous:Active
|
||||
#ifdef DO_IPBR_LIGHTS
|
||||
if (mat == 10884) return 65; // Weeping Vines Plant
|
||||
#endif
|
||||
#ifndef COLORED_CANDLE_LIGHT
|
||||
if (mat >= 10900 && mat <= 10922) return 24; // Standard Candles:Lit
|
||||
#else
|
||||
if (mat == 10900) return 24; // Standard Candles:Lit
|
||||
if (mat == 10902) return 70; // Red Candles:Lit
|
||||
if (mat == 10904) return 71; // Orange Candles:Lit
|
||||
if (mat == 10906) return 72; // Yellow Candles:Lit
|
||||
if (mat == 10908) return 73; // Lime Candles:Lit
|
||||
if (mat == 10910) return 74; // Green Candles:Lit
|
||||
if (mat == 10912) return 75; // Cyan Candles:Lit
|
||||
if (mat == 10914) return 76; // Light Blue Candles:Lit
|
||||
if (mat == 10916) return 77; // Blue Candles:Lit
|
||||
if (mat == 10918) return 78; // Purple Candles:Lit
|
||||
if (mat == 10920) return 79; // Magenta Candles:Lit
|
||||
if (mat == 10922) return 80; // Pink Candles:Lit
|
||||
#endif
|
||||
} else {
|
||||
if (mat == 10948) return 82; // Creaking Heart: Active
|
||||
if (mat == 10972) return 83; // Firefly Bush
|
||||
if (mat == 10976) return 81; // Open Eyeblossom
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (mat < 31000) {
|
||||
if (mat < 30012) {
|
||||
if (mat < 21014) {
|
||||
if (mat == 10980) return 81; // Potted Open Eyeblossom
|
||||
if (abs(mat - 10986) <= 2) return 84; // Copper Torch, Copper Lantern
|
||||
if (mat == 21000) return 97; // White Modded Blocks - Also used For Black / Gray
|
||||
if (mat == 21002) return 43; // Brown Modded Blocks
|
||||
if (mat == 21004) return 70; // Red Modded Blocks
|
||||
if (mat == 21006) return 71; // Orange Modded Blocks
|
||||
if (mat == 21008) return 72; // Yellow Modded Blocks
|
||||
if (mat == 21010) return 73; // Lime Modded Blocks
|
||||
if (mat == 21012) return 74; // Green Modded Blocks
|
||||
} else {
|
||||
if (mat == 21014) return 75; // Cyan Modded Blocks
|
||||
if (mat == 21016) return 76; // Light Blue Modded Blocks
|
||||
if (mat == 21018) return 77; // Blue Modded Blocks
|
||||
if (mat == 21020) return 78; // Purple Modded Blocks
|
||||
if (mat == 21022) return 79; // Magenta Modded Blocks
|
||||
if (mat == 21024) return 80; // Pink Modded Blocks
|
||||
if (mat == 30008) return 254; // Tinted Glass
|
||||
}
|
||||
} else {
|
||||
if (mat == 30012) return 213; // Slime Block
|
||||
if (mat == 30016) return 201; // Honey Block
|
||||
if (mat == 30020) return 25; // Nether Portal
|
||||
}
|
||||
} else {
|
||||
if (mat < 32008) {
|
||||
if (mat >= 31000 && mat < 32000) return 200 + (mat - 31000) / 2; // Stained Glass+
|
||||
if (mat == 32004) return 216; // Ice
|
||||
} else {
|
||||
if (mat == 32008) return 217; // Glass
|
||||
if (mat == 32012) return 218; // Glass Pane
|
||||
if (mat == 32016) return 4; // Beacon
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 1; // Standard Block
|
||||
}
|
||||
|
||||
#if defined SHADOW && defined VERTEX_SHADER
|
||||
void UpdateVoxelMap(int mat) {
|
||||
if (mat == 32000 // Water
|
||||
|| mat < 30000 && mat % 2 == 1 // Non-solid terrain
|
||||
|| mat < 10000 // Block entities or unknown blocks that we treat as non-solid
|
||||
) return;
|
||||
|
||||
vec3 modelPos = gl_Vertex.xyz + at_midBlock.xyz / 64.0;
|
||||
vec3 viewPos = transform(gl_ModelViewMatrix, modelPos);
|
||||
vec3 scenePos = transform(shadowModelViewInverse, viewPos);
|
||||
#ifdef WORLD_CURVATURE
|
||||
scenePos.y += doWorldCurvature(scenePos.xz);
|
||||
#endif
|
||||
vec3 voxelPos = SceneToVoxel(scenePos);
|
||||
|
||||
//#define OPTIMIZATION_ACT_HALF_RATE_VOXELS
|
||||
#ifdef OPTIMIZATION_ACT_HALF_RATE_VOXELS
|
||||
if (int(framemod2) == 0) {
|
||||
if (scenePos.z > 0.0) return;
|
||||
} else {
|
||||
if (scenePos.z < 0.0) return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined GBUFFERS_COLORWHEEL || defined SHADOW_COLORWHEEL
|
||||
bool isEligible = true;
|
||||
#else
|
||||
bool isEligible = any(equal(ivec4(renderStage), ivec4(
|
||||
MC_RENDER_STAGE_TERRAIN_SOLID,
|
||||
MC_RENDER_STAGE_TERRAIN_TRANSLUCENT,
|
||||
MC_RENDER_STAGE_TERRAIN_CUTOUT,
|
||||
MC_RENDER_STAGE_TERRAIN_CUTOUT_MIPPED)));
|
||||
#endif
|
||||
|
||||
if (isEligible && CheckInsideVoxelVolume(voxelPos)) {
|
||||
int voxelData = GetVoxelIDs(mat);
|
||||
|
||||
#if defined GBUFFERS_COLORWHEEL || defined SHADOW_COLORWHEEL
|
||||
voxelData = voxelData | 32768;
|
||||
#endif
|
||||
|
||||
imageStore(voxel_img, ivec3(voxelPos), uvec4(voxelData, 0u, 0u, 0u));
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif //INCLUDE_VOXELIZATION
|
||||
#endif
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
const ivec3 puddle_voxelVolumeSize = ivec3(128);
|
||||
|
||||
vec3 TransformMat(mat4 m, vec3 pos) {
|
||||
return mat3(m) * pos + m[3].xyz;
|
||||
}
|
||||
|
||||
vec3 SceneToPuddleVoxel(vec3 scenePos) {
|
||||
return scenePos + fract(cameraPosition) + (0.5 * vec3(puddle_voxelVolumeSize));
|
||||
}
|
||||
|
||||
bool CheckInsidePuddleVoxelVolume(vec3 voxelPos) {
|
||||
#ifndef SHADOW
|
||||
voxelPos -= puddle_voxelVolumeSize / 2;
|
||||
voxelPos += sign(voxelPos) * 0.95;
|
||||
voxelPos += puddle_voxelVolumeSize / 2;
|
||||
#endif
|
||||
voxelPos /= vec3(puddle_voxelVolumeSize);
|
||||
return clamp01(voxelPos) == voxelPos;
|
||||
}
|
||||
|
||||
#if defined SHADOW && defined VERTEX_SHADER
|
||||
void UpdatePuddleVoxelMap(int mat) {
|
||||
if (renderStage != MC_RENDER_STAGE_TERRAIN_TRANSLUCENT) return;
|
||||
if (mat == 32000) return; // Water
|
||||
|
||||
vec3 model_pos = gl_Vertex.xyz + at_midBlock.xyz / 64.0;
|
||||
vec3 view_pos = TransformMat(gl_ModelViewMatrix, model_pos);
|
||||
vec3 scenePos = TransformMat(shadowModelViewInverse, view_pos);
|
||||
vec3 voxelPos = SceneToPuddleVoxel(scenePos);
|
||||
|
||||
if (CheckInsidePuddleVoxelVolume(voxelPos))
|
||||
if (scenePos.y >= -3.5)
|
||||
imageStore(puddle_img, ivec2(voxelPos.xz), uvec4(10u, 0u, 0u, 0u));
|
||||
}
|
||||
#endif
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
#extension GL_ARB_gpu_shader5 : enable
|
||||
#extension GL_ARB_shading_language_packing : enable
|
||||
|
||||
struct faceData {
|
||||
vec3 glColor;
|
||||
vec2 lightmap;
|
||||
vec3 textureBounds;
|
||||
|
||||
};
|
||||
|
||||
#if defined SHADOW && defined VERTEX_SHADER
|
||||
#define SSBO_QUALIFIER
|
||||
#else
|
||||
#define SSBO_QUALIFIER readonly
|
||||
#endif
|
||||
|
||||
#if WORLD_SPACE_PLAYER_REF == 1
|
||||
#include "/lib/voxelization/SSBOs/playerVerticesBuffer.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/voxelization/SSBOs/blockDataBuffer.glsl"
|
||||
#include "/lib/voxelization/SSBOs/wsrLodBuffer.glsl"
|
||||
#include "/lib/voxelization/SSBOs/wsrBuffer.glsl"
|
||||
|
||||
// Face index with no duplicates!
|
||||
// Number of unique indecies 3abc + ab + bc + ca compared to 6abc,
|
||||
// (where a, b, and c refer to sceneVoxelVolumeSize.x, y, and z)
|
||||
int getFaceIndex(ivec3 voxelPos, vec3 normal) {
|
||||
const int offsetY = (sceneVoxelVolumeSize.x + 1) * sceneVoxelVolumeSize.y * sceneVoxelVolumeSize.z;
|
||||
const int offsetZ = (sceneVoxelVolumeSize.y + 1) * sceneVoxelVolumeSize.x * sceneVoxelVolumeSize.z + offsetY;
|
||||
|
||||
if (abs(normal.x) > 0.99)
|
||||
return max(int(normal.x), 0) + voxelPos.x + voxelPos.y * (sceneVoxelVolumeSize.x + 1) +
|
||||
voxelPos.z * (sceneVoxelVolumeSize.x + 1) * sceneVoxelVolumeSize.y;
|
||||
else if (abs(normal.y) > 0.99)
|
||||
return max(int(normal.y), 0) + voxelPos.y + voxelPos.x * (sceneVoxelVolumeSize.y + 1) +
|
||||
voxelPos.z * (sceneVoxelVolumeSize.y + 1) * sceneVoxelVolumeSize.x + offsetY;
|
||||
else
|
||||
return max(int(normal.z), 0) + voxelPos.z + voxelPos.x * (sceneVoxelVolumeSize.z + 1) +
|
||||
voxelPos.y * (sceneVoxelVolumeSize.z + 1) * sceneVoxelVolumeSize.x + offsetZ;
|
||||
}
|
||||
|
||||
uvec4 packFaceData(faceData data) {
|
||||
uvec3 uv = uvec3(clamp(data.textureBounds * 65536.0, 0.0, 65535.0));
|
||||
uvec2 lightmap = uvec2(clamp(data.lightmap * 65536.0, 0.0, 65535.0));
|
||||
return uvec4((uv.x << 16u) | uv.y, uv.z, packUnorm4x8(vec4(data.glColor, 0.0)), (lightmap.x << 16u) | lightmap.y);
|
||||
}
|
||||
|
||||
faceData getFaceData(ivec3 voxelPos, vec3 normal) {
|
||||
uvec4 data = blockDataSSBO.data[getFaceIndex(voxelPos, normal)];
|
||||
return faceData(unpackUnorm4x8(data.z).xyz,
|
||||
vec2(data.w >> 16u, data.w & 65535u) / 65536.0,
|
||||
vec3(data.x >> 16u, data.x & 65535u, data.y) / 65536.0);
|
||||
}
|
||||
|
||||
bool checkLodVoxelAt(ivec3 lodVoxelPos) {
|
||||
uint voxelIndex = uint(lodVoxelPos.x + lodVoxelPos.y * sceneVoxelLodVolumeSize.x +
|
||||
lodVoxelPos.z * sceneVoxelLodVolumeSize.x * sceneVoxelLodVolumeSize.y);
|
||||
|
||||
uint mask = 1u << (voxelIndex & 31u);
|
||||
return (wsrLodSSBO.bitmasks[voxelIndex >> 5] & mask) != 0;
|
||||
}
|
||||
|
||||
bool checkVoxelAt(ivec3 voxelPos) {
|
||||
uint voxelIndex = uint(voxelPos.x + voxelPos.y * sceneVoxelVolumeSize.x +
|
||||
voxelPos.z * sceneVoxelVolumeSize.x * sceneVoxelVolumeSize.y);
|
||||
|
||||
uint mask = 1u << (voxelIndex & 31u);
|
||||
return (wsrSSBO.bitmasks[voxelIndex >> 5] & mask) != 0;
|
||||
}
|
||||
|
||||
#if defined SHADOW && defined VERTEX_SHADER
|
||||
void storeFaceData(ivec3 voxelPos, vec3 normal, vec2 origin, float textureRad, bool storeToAllFaces, bool storeToAllFacesExceptTop, vec3 playerPos) {
|
||||
vec2 lmCoordM = lmCoord;
|
||||
|
||||
if (storeToAllFaces || storeToAllFacesExceptTop) {
|
||||
vec3 playerPosPrevious = playerPos - previousCameraPosition + cameraPosition;
|
||||
vec3 voxelPosPrevious = playerToPreviousSceneVoxel(playerPosPrevious);
|
||||
faceData oldFaceData = getFaceData(ivec3(voxelPosPrevious), normal);
|
||||
lmCoordM = mix(max(lmCoord, oldFaceData.lightmap), lmCoord, 0.01);
|
||||
}
|
||||
|
||||
uvec4 newData = packFaceData(faceData(glColor.rgb, vec2(lmCoordM.x * 0.99 + 0.001, lmCoordM.y), vec3(origin, textureRad)));
|
||||
|
||||
if (storeToAllFaces || storeToAllFacesExceptTop) {
|
||||
vec3 faceOffsets[6] = vec3[6](
|
||||
vec3( 0.0, 1.0, 0.0),
|
||||
vec3( 0.0, 0.0, 1.0),
|
||||
vec3( 1.0, 0.0, 0.0),
|
||||
vec3( 0.0, 0.0, -1.0),
|
||||
vec3( 0.0, -1.0, 0.0),
|
||||
vec3(-1.0, 0.0, 0.0)
|
||||
);
|
||||
|
||||
int start = 0 + int(storeToAllFacesExceptTop);
|
||||
for(int i = start; i < 6; i++) {
|
||||
if (!checkVoxelAt(ivec3(voxelPos + faceOffsets[i])))
|
||||
blockDataSSBO.data[getFaceIndex(voxelPos, faceOffsets[i])] = newData;
|
||||
}
|
||||
} else {
|
||||
blockDataSSBO.data[getFaceIndex(voxelPos, normal)] = newData;
|
||||
}
|
||||
}
|
||||
|
||||
void updateWsrLodBitmask(ivec3 lodVoxelPos) {
|
||||
uint voxelIndex = uint(lodVoxelPos.x + lodVoxelPos.y * sceneVoxelLodVolumeSize.x +
|
||||
lodVoxelPos.z * sceneVoxelLodVolumeSize.x * sceneVoxelLodVolumeSize.y);
|
||||
|
||||
atomicOr(wsrLodSSBO.bitmasks[voxelIndex >> 5], 1u << (voxelIndex & 31u));
|
||||
}
|
||||
|
||||
void updateWsrBitmask(ivec3 voxelPos) {
|
||||
uint voxelIndex = uint(voxelPos.x + voxelPos.y * sceneVoxelVolumeSize.x +
|
||||
voxelPos.z * sceneVoxelVolumeSize.x * sceneVoxelVolumeSize.y);
|
||||
|
||||
atomicOr(wsrSSBO.bitmasks[voxelIndex >> 5], 1u << (voxelIndex & 31u));
|
||||
}
|
||||
#endif
|
||||
+231
@@ -0,0 +1,231 @@
|
||||
#if COLORED_LIGHTING < 512
|
||||
const ivec3 sceneVoxelVolumeSize = ivec3(COLORED_LIGHTING_INTERNAL, 64, COLORED_LIGHTING_INTERNAL);
|
||||
#else
|
||||
const ivec3 sceneVoxelVolumeSize = ivec3(512, 64, 512);
|
||||
#endif
|
||||
|
||||
const ivec3 sceneVoxelLodVolumeSize = sceneVoxelVolumeSize / 4;
|
||||
|
||||
vec3 playerToSceneVoxel(vec3 playerPos) {
|
||||
return playerPos + cameraPositionBestFract + 0.5 * vec3(sceneVoxelVolumeSize);
|
||||
}
|
||||
|
||||
vec3 playerToPreviousSceneVoxel(vec3 previousPlayerPos) {
|
||||
return previousPlayerPos + previousCameraPositionBestFract + 0.5 * vec3(sceneVoxelVolumeSize);
|
||||
}
|
||||
|
||||
bool CheckInsideSceneVoxelVolume(vec3 voxelPos) {
|
||||
#ifndef SHADOW
|
||||
voxelPos -= 0.5 * sceneVoxelVolumeSize;
|
||||
voxelPos += sign(voxelPos) * 0.95;
|
||||
voxelPos += 0.5 * sceneVoxelVolumeSize;
|
||||
#endif
|
||||
voxelPos /= vec3(sceneVoxelVolumeSize);
|
||||
return clamp01(voxelPos) == voxelPos;
|
||||
}
|
||||
|
||||
#include "/lib/voxelization/reflectionVoxelData.glsl"
|
||||
|
||||
#if defined SHADOW && defined VERTEX_SHADER
|
||||
void UpdateSceneVoxelMap(int mat, vec3 normal, vec3 position) {
|
||||
ivec3 eligibleStages = ivec3(
|
||||
MC_RENDER_STAGE_TERRAIN_SOLID,
|
||||
MC_RENDER_STAGE_TERRAIN_CUTOUT,
|
||||
MC_RENDER_STAGE_TERRAIN_CUTOUT_MIPPED
|
||||
);
|
||||
|
||||
if (!any(equal(ivec3(renderStage), eligibleStages))) return;
|
||||
|
||||
vec3 viewPos = mat3(gl_ModelViewMatrix) * (gl_Vertex.xyz + at_midBlock.xyz / 64.0) + gl_ModelViewMatrix[3].xyz;
|
||||
vec3 scenePos = mat3(shadowModelViewInverse) * viewPos + shadowModelViewInverse[3].xyz;
|
||||
vec3 voxelPos = playerToSceneVoxel(scenePos);
|
||||
|
||||
if (CheckInsideSceneVoxelVolume(voxelPos)) {
|
||||
bool doSolidBlockCheck = true;
|
||||
bool storeToAllFaces = false;
|
||||
bool storeToAllFacesExceptTop = false;
|
||||
uint matM = mat > 10 ? uint(mat) : 1u;
|
||||
vec2 textureRad = abs(texCoord - mc_midTexCoord.xy);
|
||||
vec2 origin = mc_midTexCoord.xy - textureRad;
|
||||
|
||||
if (mat == 10132) { // Grass Block Regular
|
||||
if (texture2D(tex, mc_midTexCoord.xy).a < 0.5) return; // Grass Block Side Overlay
|
||||
}
|
||||
|
||||
if (abs(mat - 10009) <= 2) { // Leaves (10007, 10009, 10011)
|
||||
doSolidBlockCheck = false;
|
||||
}
|
||||
|
||||
if (mat == 10129 // Farmland:Dry
|
||||
|| mat == 10137 // Farmland:Wet
|
||||
|| mat == 10493 // Dirt Path
|
||||
) {
|
||||
doSolidBlockCheck = false;
|
||||
textureRad *= 0.5;
|
||||
origin.y += 2.0 / atlasSize.y;
|
||||
}
|
||||
|
||||
if (abs(mat - 10069) <= 1 // Lava (10068, 10070)
|
||||
) {
|
||||
if (abs(dot(textureRad, vec2(atlasSize.x, -atlasSize.y))) < 6.5)
|
||||
storeToAllFaces = true;
|
||||
else return;
|
||||
}
|
||||
|
||||
// Half blocks that we want to display as full blocks in reflections
|
||||
if (mat == 10035 // Stone Bricks, Mossy Stone Bricks
|
||||
|| abs(mat - 10095) <= 12 && mat % 4 == 3 // Stone, Smooth Stone, Granite, Diorite, Andesite, Bricks, Mud Bricks
|
||||
|| mat == 10155 // Cobblestone, Mossy Cobblestone
|
||||
|| abs(mat - 10191) <= 32 && mat % 8 == 7 // Oak, Spruce, Birch, Jungle, Acacia, DarkOak, Mangrove, Crimson, Warped
|
||||
|| mat == 10111 // Cobbled Deepslate
|
||||
|| mat == 10115 // Polished Deepslate, Deepslate Bricks, Deepslate Tiles
|
||||
|| mat == 10243 // Sandstone
|
||||
|| mat == 10247 // Red Sandstone
|
||||
|| mat == 10295 // Copper
|
||||
|| mat == 10367 // Quartz
|
||||
|| mat == 10379 // Purpur
|
||||
|| mat == 10381 // Powder Snow
|
||||
|| mat == 10419 // Nether Bricks
|
||||
|| mat == 10423 // Red Nether Bricks
|
||||
|| mat == 10431 // End Stone Bricks
|
||||
|| mat == 10443 // Prismarine, Prismarine Bricks
|
||||
|| mat == 10447 // Dark Prismarine
|
||||
|| mat == 10483 // Blackstone
|
||||
|| mat == 10715 // Tuff
|
||||
|| mat == 10759 // Bamboo, Bamboo Mosaic
|
||||
|| mat == 10763 // Cherry
|
||||
|| mat == 10931 // Pale Oak
|
||||
) {
|
||||
if (textureRad.y < 5.0 / atlasSize.y) {
|
||||
// Discarding if textureRad is too small to fix (somewhat rare) flickering on stairs
|
||||
if (textureRad.x < 5.0 / atlasSize.x) return;
|
||||
|
||||
// Half textureRad for stairs and slabs to not overshoot their textures
|
||||
textureRad *= 0.5;
|
||||
|
||||
// P.S: Don't ask me how any of these checks make sense because I have absolutely no idea either
|
||||
}
|
||||
|
||||
doSolidBlockCheck = false;
|
||||
if (normal.y < 0.5) storeToAllFacesExceptTop = true; // Not overriding top face or else carpets look broken on top of slabs
|
||||
}
|
||||
|
||||
if (mat == 10669 || mat == 10843|| mat == 10845 || mat == 10925 || mat == 10953) { // Wool Carpets, Moss Carpet, Snow Layers < 8
|
||||
if (normal.y > 0.5) {
|
||||
voxelPos.y -= 1.0;
|
||||
doSolidBlockCheck = false;
|
||||
} else return;
|
||||
}
|
||||
|
||||
if (mat == 10072 // Fire
|
||||
|| mat == 10076 // Soul Fire
|
||||
|| mat == 10332 // Amethyst Clusters
|
||||
|| mat == 10544 // Glow Lichen
|
||||
) {
|
||||
doSolidBlockCheck = false;
|
||||
storeToAllFaces = true;
|
||||
}
|
||||
|
||||
if (mat == 10652 || mat == 10656) { // Campfire:Lit, Soul Campfire:Lit
|
||||
if (abs(abs(normal.x) - 0.5) < 0.25) {
|
||||
doSolidBlockCheck = false;
|
||||
storeToAllFaces = true;
|
||||
} else return;
|
||||
}
|
||||
|
||||
// Blocks to remove from reflections
|
||||
if (mat == 10056 // Lava Cauldron
|
||||
|| mat == 10404 // Sea Pickle
|
||||
|| mat == 10496 // Torch
|
||||
|| mat == 10500 // End Rod
|
||||
|| mat == 10508 // Chorus Flower:Alive
|
||||
|| mat == 10512 // Chorus Flower:Dead
|
||||
|| mat == 10528 // Soul Torch
|
||||
|| mat == 10556 // End Portal Frame:Active
|
||||
|| mat == 10572 // Dragon Egg
|
||||
|| mat == 10604 || mat == 10605 // Redstone Torch
|
||||
|| mat == 10632 // Cave Vines
|
||||
|| mat == 10644 // Powered Repeater, Powered Comparator
|
||||
|| mat == 10776 // Crimson Fungus, Warped Fungus
|
||||
|| mat == 10780 // Potted Crimson Fungus, Potted Warped Fungus
|
||||
|| mat == 10836 // Brewing Stand
|
||||
|| mat == 10884 // Weeping Vines
|
||||
|| mat == 10972 // Firefly Bush
|
||||
|| mat == 10976 // Open Eyeblossom
|
||||
|| mat == 10980 // Potted Open Eyeblossom
|
||||
|| abs(mat - 10562) <= 2 // Lantern & Soul Lantern
|
||||
|| abs(mat - 10599) <= 3 // Redstone Wire
|
||||
|| abs(mat - 10701) <= 3 // Non-Solid Sculk Stuff
|
||||
|| abs(mat - 10786) <= 2 // Calibrated Sculk Sensor
|
||||
|| abs(mat - 10911) <= 11 // Lit Candles & Candle Cakes
|
||||
|| mat == 10984 // Copper Torch
|
||||
|| mat == 10988 // Copper Lantern
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (doSolidBlockCheck) {
|
||||
if (
|
||||
mat % 2 == 1 // Non-solids
|
||||
|| abs(mat - 5000) <= 4999 // Block entities that we treat as non-solid
|
||||
)
|
||||
return;
|
||||
}
|
||||
|
||||
imageStore(wsr_img, ivec3(voxelPos), uvec4(matM, 0u, 0u, 0u));
|
||||
storeFaceData(ivec3(voxelPos), round(normal), origin, textureRad.x, storeToAllFaces, storeToAllFacesExceptTop, scenePos);
|
||||
|
||||
updateWsrBitmask(ivec3(voxelPos));
|
||||
updateWsrLodBitmask(ivec3(voxelPos / 4.0));
|
||||
}
|
||||
}
|
||||
|
||||
#if WORLD_SPACE_PLAYER_REF == 1
|
||||
uniform writeonly image2D playerAtlas_img;
|
||||
|
||||
#define updateAABB(aabb_min, aabb_max, pos) \
|
||||
atomicMin(aabb_min.x, pos.x); \
|
||||
atomicMin(aabb_min.y, pos.y); \
|
||||
atomicMin(aabb_min.z, pos.z); \
|
||||
atomicMax(aabb_max.x, pos.x); \
|
||||
atomicMax(aabb_max.y, pos.y); \
|
||||
atomicMax(aabb_max.z, pos.z);
|
||||
|
||||
|
||||
void UpdatePlayerVertexList(vec3 position) {
|
||||
if (entityId == 50017 && textureSize(tex, 0) == ivec2(64) && gl_VertexID < 288) { // Current Player
|
||||
|
||||
// The atlas takes 4 frames to fully generate, reload every 600 frames
|
||||
if (framemod600 > 5 && framemod600 <= 9 && gl_VertexID < 256) {
|
||||
int i = gl_VertexID * 4 + int(framemod4) * 1024;
|
||||
for (int j = 0; j < 4; j++) {
|
||||
ivec2 coord = ivec2((i + j) % 64, (i + j) / 64);
|
||||
imageStore(playerAtlas_img, coord, texelFetch(tex, coord, 0));
|
||||
}
|
||||
}
|
||||
|
||||
ivec3 aabbPos = ivec3(position * 1000.0);
|
||||
|
||||
if (gl_VertexID < 48) { // Head
|
||||
updateAABB(playerVerticesSSBO.bounds.headMin, playerVerticesSSBO.bounds.headMax, aabbPos);
|
||||
} else if (gl_VertexID < 96) { // Right Hand
|
||||
updateAABB(playerVerticesSSBO.bounds.rightHandMin, playerVerticesSSBO.bounds.rightHandMax, aabbPos);
|
||||
} else if (gl_VertexID < 144) { // Left Leg
|
||||
updateAABB(playerVerticesSSBO.bounds.leftLegMin, playerVerticesSSBO.bounds.leftLegMax, aabbPos);
|
||||
} else if (gl_VertexID < 192) { // Left Hand
|
||||
updateAABB(playerVerticesSSBO.bounds.leftHandMin, playerVerticesSSBO.bounds.leftHandMax, aabbPos);
|
||||
} else if (gl_VertexID < 240) { // Right leg
|
||||
updateAABB(playerVerticesSSBO.bounds.rightLegMin, playerVerticesSSBO.bounds.rightLegMax, aabbPos);
|
||||
} else { // Torso
|
||||
updateAABB(playerVerticesSSBO.bounds.torsoMin, playerVerticesSSBO.bounds.torsoMax, aabbPos);
|
||||
}
|
||||
|
||||
if (gl_VertexID % 4 != 3) {
|
||||
int ssboIndex = gl_VertexID - gl_VertexID / 4;
|
||||
playerVerticesSSBO.vertexPositions[ssboIndex] = position;
|
||||
playerVerticesSSBO.vertexData[ssboIndex] = texCoord;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
Reference in New Issue
Block a user