mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2025-06-22 00:37:35 +08:00
migrate block data to image; hand-light initial
This commit is contained in:
@ -1,15 +1,26 @@
|
||||
#ifdef IS_LPV_ENABLED
|
||||
vec3 GetHandLight(const in int itemId) {
|
||||
if (itemId < 1000) {
|
||||
// TODO: block lights
|
||||
}
|
||||
else {
|
||||
// TODO: item lights
|
||||
vec3 GetHandLight(const in int itemId, const in vec3 playerPos) {
|
||||
vec3 lightFinal = vec3(0.0);
|
||||
vec3 lightColor = vec3(0.0);
|
||||
float lightRange = 0.0;
|
||||
|
||||
uvec2 blockData = texelFetch(texBlockData, itemId, 0).rg;
|
||||
vec4 lightColorRange = unpackUnorm4x8(blockData.r);
|
||||
lightColor = srgbToLinear(lightColorRange.rgb);
|
||||
lightRange = lightColorRange.a * 255.0;
|
||||
|
||||
if (lightRange > 0.0) {
|
||||
float lightDist = length(playerPos);
|
||||
float falloff = pow(1.0 - lightDist / lightRange, 3.0);
|
||||
lightFinal = lightColor * max(falloff, 0.0);
|
||||
}
|
||||
|
||||
return lightFinal;
|
||||
}
|
||||
#endif
|
||||
|
||||
vec3 DoAmbientLightColor(
|
||||
vec3 playerPos,
|
||||
vec3 lpvPos,
|
||||
vec3 SkyColor,
|
||||
vec3 MinimumColor,
|
||||
@ -45,10 +56,10 @@ vec3 DoAmbientLightColor(
|
||||
TorchLight = mix(TorchLight,LpvTorchLight/5.0, LpvFadeF);
|
||||
|
||||
if (heldItemId > 0)
|
||||
TorchLight += GetHandLight(heldItemId);
|
||||
TorchLight += GetHandLight(heldItemId, playerPos);
|
||||
|
||||
if (heldItemId2 > 0)
|
||||
TorchLight += GetHandLight(heldItemId2);
|
||||
TorchLight += GetHandLight(heldItemId2, playerPos);
|
||||
#endif
|
||||
|
||||
return IndirectLight + TorchLight * TorchBrightness_autoAdjust;
|
||||
|
@ -1,28 +1,12 @@
|
||||
struct LpvBlockData { // 12 x2000 =?
|
||||
uint MaskWeight; // 4
|
||||
uint ColorRange; // 4
|
||||
uint Tint; // 4
|
||||
};
|
||||
/*
|
||||
lightColor 3*8=24
|
||||
lightRange 8=8
|
||||
tintColor 3*8=24
|
||||
lightMask 6=8
|
||||
*/
|
||||
|
||||
#ifdef RENDER_SETUP
|
||||
layout(binding = 0) writeonly buffer lpvBlockData
|
||||
layout(rg32ui) uniform writeonly uimage1D imgBlockData;
|
||||
#else
|
||||
layout(binding = 0) readonly buffer lpvBlockData
|
||||
layout(rg32ui) uniform readonly uimage1D imgBlockData;
|
||||
#endif
|
||||
{
|
||||
LpvBlockData LpvBlockMap[];
|
||||
};
|
||||
|
||||
|
||||
uint BuildBlockLpvData(uint mixMask, float mixWeight) {
|
||||
uint data = uint(saturate(mixWeight) * 255.0);
|
||||
|
||||
data = data | (mixMask << 8);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
void ParseBlockLpvData(const in uint data, out uint mixMask, out float mixWeight) {
|
||||
mixWeight = (data & 0xFF) / 255.0;
|
||||
mixMask = (data >> 8) & 0xFF;
|
||||
}
|
||||
|
Reference in New Issue
Block a user