mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2024-12-22 17:47:34 +08:00
migrate block data to image; hand-light initial
This commit is contained in:
parent
bfcf3e1805
commit
a1cb96dd03
@ -2,6 +2,7 @@
|
||||
|
||||
#ifdef IS_LPV_ENABLED
|
||||
#extension GL_EXT_shader_image_load_store: enable
|
||||
#extension GL_ARB_shading_language_packing: enable
|
||||
#endif
|
||||
|
||||
#include "/lib/res_params.glsl"
|
||||
@ -35,7 +36,9 @@ uniform int isEyeInWater;
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D noisetex;
|
||||
uniform sampler2D colortex4;
|
||||
|
||||
#ifdef IS_LPV_ENABLED
|
||||
uniform usampler1D texBlockData;
|
||||
uniform sampler3D texLpv1;
|
||||
uniform sampler3D texLpv2;
|
||||
#endif
|
||||
@ -61,6 +64,8 @@ flat varying float HELD_ITEM_BRIGHTNESS;
|
||||
uniform float nightVision;
|
||||
#endif
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
#define CLOUDSHADOWSONLY
|
||||
#include "/lib/volumetricClouds.glsl"
|
||||
@ -417,7 +422,7 @@ void main() {
|
||||
const vec3 lpvPos = vec3(0.0);
|
||||
#endif
|
||||
|
||||
Indirect_lighting = DoAmbientLightColor(lpvPos, AmbientLightColor, MinimumLightColor, Torch_Color, clamp(lightmap.xy,0,1), exposure);
|
||||
Indirect_lighting = DoAmbientLightColor(feetPlayerPos, lpvPos, AmbientLightColor, MinimumLightColor, Torch_Color, clamp(lightmap.xy,0,1), exposure);
|
||||
|
||||
#ifdef LINES
|
||||
gl_FragData[0].rgb = (Indirect_lighting + Direct_lighting) * toLinear(color.rgb);
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
#ifdef IS_LPV_ENABLED
|
||||
#extension GL_EXT_shader_image_load_store: enable
|
||||
#extension GL_ARB_shading_language_packing: enable
|
||||
#endif
|
||||
|
||||
#include "/lib/res_params.glsl"
|
||||
@ -49,6 +50,7 @@ uniform sampler2D specular;
|
||||
uniform sampler2D normals;
|
||||
|
||||
#ifdef IS_LPV_ENABLED
|
||||
uniform usampler1D texBlockData;
|
||||
uniform sampler3D texLpv1;
|
||||
uniform sampler3D texLpv2;
|
||||
#endif
|
||||
@ -92,6 +94,7 @@ uniform vec3 nsunColor;
|
||||
#include "/lib/projections.glsl"
|
||||
#include "/lib/sky_gradient.glsl"
|
||||
#include "/lib/waterBump.glsl"
|
||||
#include "/lib/util.glsl"
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
flat varying float Flashing;
|
||||
@ -634,7 +637,7 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
||||
const vec3 lpvPos = vec3(0.0);
|
||||
#endif
|
||||
|
||||
Indirect_lighting = DoAmbientLightColor(lpvPos, AmbientLightColor, MinimumLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, exposure);
|
||||
Indirect_lighting = DoAmbientLightColor(feetPlayerPos, lpvPos, AmbientLightColor, MinimumLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy, exposure);
|
||||
|
||||
vec3 FinalColor = (Indirect_lighting + Direct_lighting) * Albedo;
|
||||
|
||||
|
@ -1,7 +1,8 @@
|
||||
#include "/lib/settings.glsl"
|
||||
|
||||
#ifdef IS_LPV_ENABLED
|
||||
#extension GL_EXT_shader_image_load_store: enable
|
||||
#extension GL_ARB_shader_image_load_store: enable
|
||||
#extension GL_ARB_shading_language_packing: enable
|
||||
#endif
|
||||
|
||||
#include "/lib/res_params.glsl"
|
||||
@ -76,6 +77,7 @@ uniform sampler2D colortex14;
|
||||
uniform sampler2D colortex15; // flat normals(rgb), vanillaAO(alpha)
|
||||
|
||||
#ifdef IS_LPV_ENABLED
|
||||
uniform usampler1D texBlockData;
|
||||
uniform sampler3D texLpv1;
|
||||
uniform sampler3D texLpv2;
|
||||
#endif
|
||||
@ -166,9 +168,12 @@ vec3 toScreenSpace(vec3 p) {
|
||||
#include "/lib/volumetricClouds.glsl"
|
||||
#endif
|
||||
|
||||
#include "/lib/util.glsl"
|
||||
|
||||
#ifdef IS_LPV_ENABLED
|
||||
#include "/lib/hsv.glsl"
|
||||
#include "/lib/lpv_common.glsl"
|
||||
// #include "/lib/lpv_blocks.glsl"
|
||||
#include "/lib/lpv_render.glsl"
|
||||
#endif
|
||||
|
||||
@ -238,10 +243,10 @@ vec3 fp10Dither(vec3 color,float dither){
|
||||
|
||||
|
||||
|
||||
float facos(float sx){
|
||||
float x = clamp(abs( sx ),0.,1.);
|
||||
return sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 );
|
||||
}
|
||||
// float facos(float sx){
|
||||
// float x = clamp(abs( sx ),0.,1.);
|
||||
// return sqrt( 1. - x ) * ( -0.16882 * x + 1.56734 );
|
||||
// }
|
||||
|
||||
vec2 tapLocation(int sampleNumber,int nb, float nbRot,float jitter,float distort)
|
||||
{
|
||||
@ -1192,7 +1197,7 @@ void main() {
|
||||
const vec3 lpvPos = vec3(0.0);
|
||||
#endif
|
||||
|
||||
Indirect_lighting = DoAmbientLightColor(lpvPos, Indirect_lighting, MinimumLightColor, vec3(TORCH_R,TORCH_G,TORCH_B) , lightmap.xy, exposure);
|
||||
Indirect_lighting = DoAmbientLightColor(feetPlayerPos, lpvPos, Indirect_lighting, MinimumLightColor, vec3(TORCH_R,TORCH_G,TORCH_B) , lightmap.xy, exposure);
|
||||
|
||||
#ifdef OVERWORLD_SHADER
|
||||
Indirect_lighting += LightningFlashLighting;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -17,9 +17,6 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
|
||||
const vec2 LpvBlockSkyFalloff = vec2(0.96, 0.96);
|
||||
const ivec3 lpvFlatten = ivec3(1, 10, 100);
|
||||
|
||||
#define EPSILON 1e-6
|
||||
|
||||
|
||||
uniform int frameCounter;
|
||||
uniform vec3 cameraPosition;
|
||||
uniform vec3 previousCameraPosition;
|
||||
@ -61,13 +58,15 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
|
||||
int shared_index = getSharedIndex(pos + 1);
|
||||
|
||||
float mixWeight = 1.0;
|
||||
uint mixMask = 0xFFFF;
|
||||
uint mask = 0xFFFF;
|
||||
uint blockId = voxelSharedData[shared_index];
|
||||
|
||||
if (blockId > 0 && blockId != BLOCK_EMPTY)
|
||||
ParseBlockLpvData(LpvBlockMap[blockId].MaskWeight, mixMask, mixWeight);
|
||||
if (blockId > 0 && blockId != BLOCK_EMPTY) {
|
||||
uvec2 blockData = imageLoad(imgBlockData, int(blockId)).rg;
|
||||
mask = (blockData.g >> 24) & 0xFFFF;
|
||||
}
|
||||
|
||||
return lpvSharedData[shared_index] * ((mixMask >> mask_index) & 1u);// * mixWeight;
|
||||
return lpvSharedData[shared_index] * ((mask >> mask_index) & 1u);
|
||||
}
|
||||
|
||||
vec4 mixNeighbours(const in ivec3 fragCoord, const in uint mask) {
|
||||
@ -122,29 +121,30 @@ void main() {
|
||||
uint blockId = voxelSharedData[getSharedIndex(ivec3(gl_LocalInvocationID) + 1)];
|
||||
vec4 lightValue = vec4(0.0);
|
||||
vec3 tintColor = vec3(1.0);
|
||||
float mixWeight = 1.0;
|
||||
uint mixMask = 0xFFFF;
|
||||
|
||||
if (blockId > 0u) {
|
||||
mixWeight = 0.0;
|
||||
ParseBlockLpvData(LpvBlockMap[blockId].MaskWeight, mixMask, mixWeight);
|
||||
tintColor = vec3(0.0);
|
||||
|
||||
uint tintData = LpvBlockMap[blockId].Tint;
|
||||
tintColor = unpackUnorm4x8(tintData).rgb;
|
||||
vec4 lightColorRange = unpackUnorm4x8(LpvBlockMap[blockId].ColorRange);
|
||||
uvec2 blockData = imageLoad(imgBlockData, int(blockId)).rg;
|
||||
vec4 lightColorRange = unpackUnorm4x8(blockData.r);
|
||||
vec4 tintColorMask = unpackUnorm4x8(blockData.g);
|
||||
tintColor = srgbToLinear(tintColorMask.rgb);
|
||||
mixMask = (blockData.g >> 24) & 0xFFFF;
|
||||
|
||||
vec3 lightColor = srgbToLinear(lightColorRange.rgb);
|
||||
float lightRange = lightColorRange.a * 255.0;
|
||||
|
||||
if (lightRange > EPSILON) {
|
||||
vec3 lightColor = srgbToLinear(lightColorRange.rgb);
|
||||
if (lightRange > 0.0) {
|
||||
lightValue.rgb = Lpv_RgbToHsv(lightColor, lightRange);
|
||||
lightValue.ba = exp2(lightValue.ba * LpvBlockSkyRange) - 1.0;
|
||||
lightValue.rgb = HsvToRgb(lightValue.rgb);
|
||||
}
|
||||
}
|
||||
|
||||
if (mixWeight > EPSILON) {
|
||||
if (any(greaterThan(tintColor, vec3(0.0)))) {
|
||||
vec4 lightMixed = mixNeighbours(ivec3(gl_LocalInvocationID), mixMask);
|
||||
lightMixed.rgb *= srgbToLinear(tintColor) * mixWeight;
|
||||
lightMixed.rgb *= tintColor;
|
||||
lightValue += lightMixed;
|
||||
}
|
||||
|
||||
|
@ -1 +1,4 @@
|
||||
item.1000 = glow_berries soul_lantern soul_torch conduit beacon sea_pickle sea_lantern glowstone torch 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 = 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.1001 = torch
|
||||
item.1002 = soul_torch
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ separateAo = true
|
||||
rain.depth = false
|
||||
beacon.beam.depth = true
|
||||
|
||||
iris.features.optional = ENTITY_TRANSLUCENT REVERSED_CULLING COMPUTE_SHADERS CUSTOM_IMAGES SSBO
|
||||
iris.features.optional = ENTITY_TRANSLUCENT REVERSED_CULLING COMPUTE_SHADERS CUSTOM_IMAGES
|
||||
|
||||
#if RESOURCEPACK_SKY == 2
|
||||
sun=true
|
||||
@ -554,9 +554,8 @@ uniform.float.shadowMaxProj = 150.0/abs(sunPosY)
|
||||
####### FLOODFILL STUFF #######
|
||||
###############################
|
||||
|
||||
# if defined LPV_ENABLED && defined IRIS_FEATURE_CUSTOM_IMAGES
|
||||
#ifdef LPV_ENABLED
|
||||
bufferObject.0=32000
|
||||
image.imgBlockData = texBlockData RG_INTEGER RG32UI UNSIGNED_INT false false 2048
|
||||
|
||||
#if LPV_SIZE == 8
|
||||
image.imgVoxelMask = none RED_INTEGER R16UI UNSIGNED_SHORT true false 256 256 256
|
||||
|
Loading…
Reference in New Issue
Block a user