item lights

This commit is contained in:
NULL511 2024-05-07 10:27:37 -04:00
parent a1cb96dd03
commit 0c88744e8d
5 changed files with 1098 additions and 915 deletions

View File

@ -4,6 +4,8 @@ const ivec3 workGroups = ivec3(6, 6, 1);
#ifdef IS_LPV_ENABLED
#include "/lib/blocks.glsl"
#include "/lib/items.glsl"
// #include "/lib/entities.glsl"
#include "/lib/lpv_blocks.glsl"
const vec3 LightColor_Amethyst = vec3(0.464, 0.227, 0.788);
@ -49,9 +51,6 @@ void main() {
uint mixMask = 0xFFFF;
vec3 tintColor = vec3(1.0);
if (blockId < 1000) {
// BLOCKS
switch (blockId) {
case BLOCK_WATER:
mixWeight = 0.8;
@ -76,34 +75,40 @@ void main() {
case BLOCK_SAPLING:
mixWeight = 0.9;
break;
}
// lightsources
case BLOCK_AMETHYST_BUD_LARGE:
if (blockId == BLOCK_AMETHYST_BUD_LARGE || blockId == ITEM_AMETHYST_BUD_LARGE) {
lightColor = LightColor_Amethyst;
lightRange = 4.0;
mixWeight = 0.6;
break;
case BLOCK_AMETHYST_BUD_MEDIUM:
}
if (blockId == BLOCK_AMETHYST_BUD_MEDIUM || blockId == ITEM_AMETHYST_BUD_MEDIUM) {
lightColor = LightColor_Amethyst;
lightRange = 2.0;
mixWeight = 0.8;
break;
case BLOCK_AMETHYST_CLUSTER:
}
if (blockId == BLOCK_AMETHYST_CLUSTER || blockId == ITEM_AMETHYST_CLUSTER) {
lightColor = LightColor_Amethyst;
lightRange = 5.0;
mixWeight = 0.4;
break;
case BLOCK_BEACON:
}
if (blockId == BLOCK_BEACON || blockId == ITEM_BEACON) {
lightColor = vec3(1.0);
lightRange = 15.0;
break;
case BLOCK_BREWING_STAND:
}
if (blockId == BLOCK_BREWING_STAND) {
lightColor = vec3(0.636, 0.509, 0.179);
lightRange = 1.0;
mixWeight = 0.8;
break;
}
switch (blockId) {
#ifdef LPV_COLORED_CANDLES
case BLOCK_CANDLES_PLAIN_LIT_1:
lightColor = LightColor_Candles;
@ -483,20 +488,26 @@ void main() {
mixWeight = 1.0;
break;
#endif
}
case BLOCK_CAVE_VINE_BERRIES:
if (blockId == ITEM_BLAZE_ROD) {
// TODO
}
if (blockId == BLOCK_CAVE_VINE_BERRIES || blockId == ITEM_GLOW_BERRIES) {
lightColor = vec3(0.651, 0.369, 0.157);
lightRange = 14.0;
mixWeight = 1.0;
break;
}
#ifdef LPV_REDSTONE_LIGHTS
case BLOCK_COMPARATOR_LIT:
if (blockId == BLOCK_COMPARATOR_LIT) {
lightColor = LightColor_RedstoneTorch;
lightRange = 4.0;
break;
}
#endif
switch (blockId) {
case BLOCK_COPPER_BULB_LIT:
lightColor = LightColor_CopperBulb;
lightRange = 15.0;
@ -517,61 +528,85 @@ void main() {
lightColor = vec3(1.0);
lightRange = 15.0;
break;
case BLOCK_CRYING_OBSIDIAN:
}
if (blockId == BLOCK_CRYING_OBSIDIAN) {
lightColor = vec3(0.390, 0.065, 0.646);
lightRange = 10.0;
break;
case BLOCK_END_GATEWAY:
}
if (blockId == BLOCK_END_GATEWAY) {
lightColor = vec3(1.0);
lightRange = 15.0;
break;
case BLOCK_END_ROD:
}
if (blockId == BLOCK_END_ROD || blockId == ITEM_END_ROD) {
lightColor = vec3(0.957, 0.929, 0.875);
lightRange = 14.0;
break;
case BLOCK_FIRE:
}
if (blockId == BLOCK_FIRE) {
lightColor = vec3(0.864, 0.598, 0.348);
lightRange = 15.0;
mixWeight = 1.0;
break;
case BLOCK_FROGLIGHT_OCHRE:
}
if (blockId == BLOCK_FROGLIGHT_OCHRE || blockId == ITEM_FROGLIGHT_OCHRE) {
lightColor = vec3(0.768, 0.648, 0.108);
lightRange = 15.0;
break;
case BLOCK_FROGLIGHT_PEARLESCENT:
}
if (blockId == BLOCK_FROGLIGHT_PEARLESCENT || blockId == ITEM_FROGLIGHT_PEARLESCENT) {
lightColor = vec3(0.737, 0.435, 0.658);
lightRange = 15.0;
break;
case BLOCK_FROGLIGHT_VERDANT:
}
if (blockId == BLOCK_FROGLIGHT_VERDANT || blockId == ITEM_FROGLIGHT_VERDANT) {
lightColor = vec3(0.463, 0.763, 0.409);
lightRange = 15.0;
break;
case BLOCK_FURNACE_LIT:
}
if (blockId == BLOCK_FURNACE_LIT) {
lightColor = vec3(0.8, 0.7, 0.1);
lightRange = 13.0;
break;
case BLOCK_GLOW_LICHEN:
}
if (blockId == BLOCK_GLOW_LICHEN || blockId == ITEM_GLOW_LICHEN) {
lightColor = vec3(0.092, 0.217, 0.126);
lightRange = 7.0;
break;
case BLOCK_GLOWSTONE:
}
if (blockId == BLOCK_GLOWSTONE || blockId == ITEM_GLOWSTONE) {
lightColor = vec3(0.747, 0.594, 0.326);
lightRange = 15.0;
break;
case BLOCK_JACK_O_LANTERN:
}
if (blockId == ITEM_GLOWSTONE_DUST) {
lightColor = vec3(0.747, 0.594, 0.326);
lightRange = 8.0;
}
if (blockId == BLOCK_JACK_O_LANTERN || blockId == ITEM_JACK_O_LANTERN) {
lightColor = vec3(0.864, 0.598, 0.348);
lightRange = 15.0;
break;
case BLOCK_LANTERN:
}
if (blockId == BLOCK_LANTERN || blockId == ITEM_LANTERN) {
lightColor = vec3(0.839, 0.541, 0.2);
lightRange = 15.0;
mixWeight = 0.8;
break;
case BLOCK_LAVA:
}
if (blockId == BLOCK_LAVA) {
lightColor = vec3(0.659, 0.302, 0.106);
lightRange = 15.0;
break;
}
else if (blockId == ITEM_LAVA_BUCKET) {
lightColor = vec3(0.659, 0.302, 0.106);
lightRange = 8.0;
}
switch (blockId) {
case BLOCK_LIGHT_1:
lightColor = LightColor_LightBlock;
lightRange = 1;
@ -647,20 +682,24 @@ void main() {
lightRange = 15;
mixWeight = 1.0;
break;
}
case BLOCK_MAGMA:
if (blockId == BLOCK_MAGMA || blockId == ITEM_MAGMA) {
lightColor = vec3(0.747, 0.323, 0.110);
lightRange = 3.0;
break;
case BLOCK_REDSTONE_LAMP_LIT:
}
if (blockId == BLOCK_REDSTONE_LAMP_LIT) {
lightColor = vec3(0.953, 0.796, 0.496);
lightRange = 15.0;
break;
case BLOCK_REDSTONE_TORCH_LIT:
}
if (blockId == BLOCK_REDSTONE_TORCH_LIT || blockId == ITEM_REDSTONE_TORCH) {
lightColor = LightColor_RedstoneTorch;
lightRange = 7.0;
break;
}
switch (blockId) {
#ifdef LPV_REDSTONE_LIGHTS
case BLOCK_REDSTONE_WIRE_1:
lightColor = LightColor_RedstoneTorch;
@ -757,33 +796,42 @@ void main() {
lightRange = 15.0;
mixWeight = 1.0;
break;
case BLOCK_SEA_LANTERN:
}
if (blockId == BLOCK_SEA_LANTERN || blockId == ITEM_SEA_LANTERN) {
lightColor = vec3(0.553, 0.748, 0.859);
lightRange = 15.0;
break;
case BLOCK_SHROOMLIGHT:
}
if (blockId == BLOCK_SHROOMLIGHT || blockId == ITEM_SHROOMLIGHT) {
lightColor = vec3(0.848, 0.469, 0.205);
lightRange = 15.0;
break;
case BLOCK_SOUL_FIRE:
}
if (blockId == BLOCK_SOUL_FIRE) {
lightColor = vec3(0.1, 0.6, 1.0);
lightRange = 10.0;
mixWeight = 1.0;
break;
case BLOCK_SOUL_LANTERN:
case BLOCK_SOUL_TORCH:
}
if (
blockId == BLOCK_SOUL_TORCH || blockId == ITEM_SOUL_TORCH ||
blockId == BLOCK_SOUL_LANTERN || blockId == ITEM_SOUL_LANTERN
) {
lightColor = vec3(0.1, 0.6, 1.0);
lightRange = 10.0;
mixWeight = 0.8;
break;
case BLOCK_TORCH:
}
if (blockId == BLOCK_TORCH || blockId == ITEM_TORCH) {
lightColor = vec3(1.0, 0.6, 0.1);
lightRange = 14.0;
mixWeight = 0.8;
break;
}
// reflective translucents / glass
switch (blockId) {
case BLOCK_HONEY:
tintColor = vec3(0.984, 0.733, 0.251);
mixWeight = 1.0;
@ -939,32 +987,14 @@ void main() {
mixMask = BuildLpvMask(1u, 1u, 1u, 0u, 1u, 1u);
mixWeight = 0.8;
break;
}
// Misc
case BLOCK_SIGN:
if (blockId == BLOCK_SIGN) {
mixWeight = 0.9;
break;
}
}
if (blockId >= 1000) {
// ITEMS
switch (blockId) {
// TODO
case 1001: // torch
lightColor = vec3(1.0, 0.6, 0.1);
lightRange = 14.0;
mixWeight = 0.8;
break;
case 1002: // soul torch
lightColor = vec3(0.1, 0.6, 1.0);
lightRange = 10.0;
mixWeight = 0.8;
break;
}
}
// hack to increase light (if set)
if (lightRange > 0.0) lightRange += 1.0;

View File

@ -1,4 +1,52 @@
item.1000 = glow_berries soul_lantern conduit beacon sea_pickle sea_lantern glowstone redstone_torch jack_o_lantern magma_block lantern shroomlight end_rod lava_bucket conquest:white_paper_lantern conquest:yellow_paper_lantern conquest:small_red_paper_lantern conquest:chinese_palace_lantern conquest:campfire conquest:brazier conquest:hanging_brazier conquest:chandelier conquest:candelabra conquest:cross_chandelier conquest:conquest:iron_candelabrum_1 conquest:conquest:golden_candelabrum_1 conquest:candle conquest:hanging_candle_holder conquest:candle_in_a_lantern conquest:candles conquest:hand_candle conquest:torch_with_grille conquest:elven_hand_light conquest:ship_lantern conquest:victorian_lantern conquest:small_lantern conquest:big_lantern conquest:hanging_oil_lamp conquest:oil_lamp conquest:terracotta_oil_lamp conquest:invisible_light_low conquest:invisible_light_medium conquest:invisible_light
item.1000=soul_lantern conduit beacon sea_pickle sea_lantern glowstone redstone_torch jack_o_lantern magma_block lantern shroomlight end_rod lava_bucket conquest:white_paper_lantern conquest:yellow_paper_lantern conquest:small_red_paper_lantern conquest:chinese_palace_lantern conquest:campfire conquest:brazier conquest:hanging_brazier conquest:chandelier conquest:candelabra conquest:cross_chandelier conquest:conquest:iron_candelabrum_1 conquest:conquest:golden_candelabrum_1 conquest:candle conquest:hanging_candle_holder conquest:candle_in_a_lantern conquest:candles conquest:hand_candle conquest:torch_with_grille conquest:elven_hand_light conquest:ship_lantern conquest:victorian_lantern conquest:small_lantern conquest:big_lantern conquest:hanging_oil_lamp conquest:oil_lamp conquest:terracotta_oil_lamp conquest:invisible_light_low conquest:invisible_light_medium conquest:invisible_light
item.1001 = torch
item.1002 = soul_torch
item.1001=large_amethyst_bud
item.1002=medium_amethyst_bud
item.1003=amethyst_cluster
item.1004=beacon
item.1005=blaze_rod
item.1006=end_rod
item.1007=ochre_froglight
item.1008=pearlescent_froglight
item.1009=verdant_froglight
item.1010=glow_berries
item.1011=glow_lichen
item.1012=glowstone
item.1013=glowstone_dust
item.1014=jack_o_lantern
item.1015=lantern
item.1016=lava_bucket
## ITEM_LIGHT
# item.* = light
item.1017=magma_block
item.1018=redstone_torch
item.1019=sculk_catalyst
item.1020=sea_lantern
item.1021=shroomlight
item.1022=soul_lantern
item.1023=soul_torch
item.1024=torch

View File

@ -1,5 +1,5 @@
#ifdef IS_LPV_ENABLED
vec3 GetHandLight(const in int itemId, const in vec3 playerPos) {
vec3 GetHandLight(const in int itemId, const in vec3 playerPos, const in vec3 normal) {
vec3 lightFinal = vec3(0.0);
vec3 lightColor = vec3(0.0);
float lightRange = 0.0;
@ -11,8 +11,10 @@
if (lightRange > 0.0) {
float lightDist = length(playerPos);
vec3 lightDir = playerPos / lightDist;
float NoL = 1.0;//max(dot(normal, lightDir), 0.0);
float falloff = pow(1.0 - lightDist / lightRange, 3.0);
lightFinal = lightColor * max(falloff, 0.0);
lightFinal = lightColor * NoL * max(falloff, 0.0);
}
return lightFinal;
@ -55,11 +57,13 @@ vec3 DoAmbientLightColor(
TorchLight = mix(TorchLight,LpvTorchLight/5.0, LpvFadeF);
const vec3 normal = vec3(0.0); // TODO
if (heldItemId > 0)
TorchLight += GetHandLight(heldItemId, playerPos);
TorchLight += GetHandLight(heldItemId, playerPos, normal);
if (heldItemId2 > 0)
TorchLight += GetHandLight(heldItemId2, playerPos);
TorchLight += GetHandLight(heldItemId2, playerPos, normal);
#endif
return IndirectLight + TorchLight * TorchBrightness_autoAdjust;

View File

@ -1 +1,25 @@
#define ITEM_LIGHT_SOURCES 1000
#define ITEM_AMETHYST_BUD_LARGE 1001
#define ITEM_AMETHYST_BUD_MEDIUM 1002
#define ITEM_AMETHYST_CLUSTER 1003
#define ITEM_BEACON 1004
#define ITEM_BLAZE_ROD 1005
#define ITEM_END_ROD 1006
#define ITEM_FROGLIGHT_OCHRE 1007
#define ITEM_FROGLIGHT_PEARLESCENT 1008
#define ITEM_FROGLIGHT_VERDANT 1009
#define ITEM_GLOW_BERRIES 1010
#define ITEM_GLOW_LICHEN 1011
#define ITEM_GLOWSTONE 1012
#define ITEM_GLOWSTONE_DUST 1013
#define ITEM_JACK_O_LANTERN 1014
#define ITEM_LANTERN 1015
#define ITEM_LAVA_BUCKET 1016
#define ITEM_MAGMA 1017
#define ITEM_REDSTONE_TORCH 1018
#define ITEM_SCULK_CATALYST 1019
#define ITEM_SEA_LANTERN 1020
#define ITEM_SHROOMLIGHT 1021
#define ITEM_SOUL_LANTERN 1022
#define ITEM_SOUL_TORCH 1023
#define ITEM_TORCH 1024

View File

@ -0,0 +1,77 @@
#= ITEM_LIGHT_SOURCES
item.1000 = soul_lantern conduit beacon sea_pickle sea_lantern glowstone redstone_torch jack_o_lantern magma_block lantern shroomlight end_rod lava_bucket conquest:white_paper_lantern conquest:yellow_paper_lantern conquest:small_red_paper_lantern conquest:chinese_palace_lantern conquest:campfire conquest:brazier conquest:hanging_brazier conquest:chandelier conquest:candelabra conquest:cross_chandelier conquest:conquest:iron_candelabrum_1 conquest:conquest:golden_candelabrum_1 conquest:candle conquest:hanging_candle_holder conquest:candle_in_a_lantern conquest:candles conquest:hand_candle conquest:torch_with_grille conquest:elven_hand_light conquest:ship_lantern conquest:victorian_lantern conquest:small_lantern conquest:big_lantern conquest:hanging_oil_lamp conquest:oil_lamp conquest:terracotta_oil_lamp conquest:invisible_light_low conquest:invisible_light_medium conquest:invisible_light
#= ITEM_AMETHYST_BUD_LARGE
item.* = large_amethyst_bud
#= ITEM_AMETHYST_BUD_MEDIUM
item.* = medium_amethyst_bud
#= ITEM_AMETHYST_CLUSTER
item.* = amethyst_cluster
#= ITEM_BEACON
item.* = beacon
#= ITEM_BLAZE_ROD
item.* = blaze_rod
#= ITEM_END_ROD
item.* = end_rod
#= ITEM_FROGLIGHT_OCHRE
item.* = ochre_froglight
#= ITEM_FROGLIGHT_PEARLESCENT
item.* = pearlescent_froglight
#= ITEM_FROGLIGHT_VERDANT
item.* = verdant_froglight
#= ITEM_GLOW_BERRIES
item.* = glow_berries
#= ITEM_GLOW_LICHEN
item.* = glow_lichen
#= ITEM_GLOWSTONE
item.* = glowstone
#= ITEM_GLOWSTONE_DUST
item.* = glowstone_dust
#= ITEM_JACK_O_LANTERN
item.* = jack_o_lantern
#= ITEM_LANTERN
item.* = lantern
#= ITEM_LAVA_BUCKET
item.* = lava_bucket
## ITEM_LIGHT
# item.* = light
#= ITEM_MAGMA
item.* = magma_block
#= ITEM_REDSTONE_TORCH
item.* = redstone_torch
#= ITEM_SCULK_CATALYST
item.* = sculk_catalyst
#= ITEM_SEA_LANTERN
item.* = sea_lantern
#= ITEM_SHROOMLIGHT
item.* = shroomlight
#= ITEM_SOUL_LANTERN
item.* = soul_lantern
#= ITEM_SOUL_TORCH
item.* = soul_torch
#= ITEM_TORCH
item.* = torch