migrate block data to image; hand-light initial

This commit is contained in:
NULL511
2024-05-06 15:12:52 -04:00
parent bfcf3e1805
commit a1cb96dd03
9 changed files with 955 additions and 919 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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

View File

@ -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;
}