mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2024-12-23 01:59:39 +08:00
fix geo-normal space; cleanup
This commit is contained in:
parent
3ab6b68165
commit
da5654476c
@ -1267,7 +1267,9 @@ void main() {
|
||||
|
||||
#endif
|
||||
|
||||
vec3 lpvPos = GetLpvPosition(feetPlayerPos) - 0.5*FlatNormals + slopednormal;
|
||||
vec3 lpvPos = GetLpvPosition(feetPlayerPos) + 0.5*viewToWorld(FlatNormals);
|
||||
// vec3 lpvPos = GetLpvPosition(feetPlayerPos) - 0.5*FlatNormals + slopednormal;
|
||||
|
||||
Indirect_lighting = DoAmbientLightColor(lpvPos, Indirect_lighting, MinimumLightColor, vec3(TORCH_R,TORCH_G,TORCH_B), lightmap.xy);
|
||||
|
||||
Indirect_lighting *= Absorbtion;
|
||||
|
@ -14,7 +14,7 @@ vec3 DoAmbientLightColor(
|
||||
|
||||
// do torch lighting.
|
||||
#if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store
|
||||
vec4 lpvSample = SampleLpv(lpvPos);
|
||||
vec4 lpvSample = SampleLpvLinear(lpvPos);
|
||||
vec3 TorchLight = GetLpvBlockLight(lpvSample);
|
||||
#else
|
||||
// float TorchLM = 10.0 - ( 1.0 / (pow(exp(-0.5*inversesqrt(Lightmap.x)),5.0)+0.1));
|
||||
|
@ -4,6 +4,8 @@ layout(rgba8) uniform image3D imgLpv2;
|
||||
const uint LpvSize = uint(exp2(LPV_SIZE));
|
||||
const uvec3 LpvSize3 = uvec3(LpvSize);
|
||||
|
||||
const vec2 LpvBlockSkyRange = vec2(1.0, 24.0);
|
||||
|
||||
// #if defined RENDER_SHADOWCOMP || defined RENDER_GBUFFER
|
||||
// layout(r16ui) uniform uimage2D imgVoxelMask;
|
||||
// #elif defined RENDER_BEGIN || defined RENDER_GEOMETRY || defined RENDER_VERTEX
|
||||
@ -16,5 +18,5 @@ const uvec3 LpvSize3 = uvec3(LpvSize);
|
||||
|
||||
vec3 GetLpvPosition(const in vec3 playerPos) {
|
||||
vec3 cameraOffset = fract(cameraPosition);
|
||||
return playerPos + cameraOffset + LpvSize3/2u + 0.5;
|
||||
return playerPos + cameraOffset + LpvSize3/2u;
|
||||
}
|
||||
|
@ -1,13 +1,3 @@
|
||||
// vec4 cubic(const in float v) {
|
||||
// vec4 n = vec4(1.0, 2.0, 3.0, 4.0) - v;
|
||||
// vec4 s = n * n * n;
|
||||
// float x = s.x;
|
||||
// float y = s.y - 4.0 * s.x;
|
||||
// float z = s.z - 4.0 * s.y + 6.0 * s.x;
|
||||
// float w = 6.0 - x - y - z;
|
||||
// return vec4(x, y, z, w) * (1.0/6.0);
|
||||
// }
|
||||
|
||||
// float LpvVoxelTest(const in ivec3 voxelCoord) {
|
||||
// ivec3 gridCell = ivec3(floor(voxelCoord / LIGHT_BIN_SIZE));
|
||||
// uint gridIndex = GetVoxelGridCellIndex(gridCell);
|
||||
@ -27,13 +17,13 @@ vec4 SampleLpvNearest(const in ivec3 lpvPos) {
|
||||
// : imageLoad(imgLpv1, lpvPos, 0);
|
||||
// #endif
|
||||
|
||||
lpvSample.ba = exp2(lpvSample.ba * LpvBlockSkyRange) - 1.0;
|
||||
lpvSample.rgb = HsvToRgb(lpvSample.rgb);
|
||||
|
||||
return lpvSample;// / DynamicLightRangeF;
|
||||
return lpvSample;
|
||||
}
|
||||
|
||||
vec4 SampleLpvLinear(const in vec3 lpvPos) {
|
||||
// vec3 pos = lpvPos - 0.49999;
|
||||
vec3 pos = lpvPos - 0.5;
|
||||
ivec3 lpvCoord = ivec3(floor(pos));
|
||||
vec3 lpvF = fract(pos);
|
||||
@ -110,106 +100,9 @@ vec4 SampleLpvLinear(const in vec3 lpvPos) {
|
||||
return mix(sample_z1, sample_z2, lpvF.z);// * voxel_corner;
|
||||
}
|
||||
|
||||
// vec4 SampleLpvCubic(in vec3 lpvPos) {
|
||||
// vec3 pos = lpvPos - 0.5;
|
||||
// vec3 texF = fract(pos);
|
||||
// pos = floor(pos);
|
||||
|
||||
// vec4 cubic_x = cubic(texF.x);
|
||||
// vec4 cubic_y = cubic(texF.y);
|
||||
// vec4 cubic_z = cubic(texF.z);
|
||||
|
||||
// vec3 pos_min = pos - 0.5;
|
||||
// vec3 pos_max = pos + 1.5;
|
||||
|
||||
// vec3 s_min = vec3(cubic_x.x, cubic_y.x, cubic_z.x) + vec3(cubic_x.y, cubic_y.y, cubic_z.y);
|
||||
// vec3 s_max = vec3(cubic_x.z, cubic_y.z, cubic_z.z) + vec3(cubic_x.w, cubic_y.w, cubic_z.w);
|
||||
|
||||
// vec3 offset_min = pos_min + vec3(cubic_x.y, cubic_y.y, cubic_z.y) / s_min;
|
||||
// vec3 offset_max = pos_max + vec3(cubic_x.w, cubic_y.w, cubic_z.w) / s_max;
|
||||
|
||||
// vec4 sample_x1y1z1 = SampleLpvLinear(vec3(offset_max.x, offset_max.y, offset_max.z));
|
||||
// vec4 sample_x2y1z1 = SampleLpvLinear(vec3(offset_min.x, offset_max.y, offset_max.z));
|
||||
// vec4 sample_x1y2z1 = SampleLpvLinear(vec3(offset_max.x, offset_min.y, offset_max.z));
|
||||
// vec4 sample_x2y2z1 = SampleLpvLinear(vec3(offset_min.x, offset_min.y, offset_max.z));
|
||||
|
||||
// vec4 sample_x1y1z2 = SampleLpvLinear(vec3(offset_max.x, offset_max.y, offset_min.z));
|
||||
// vec4 sample_x2y1z2 = SampleLpvLinear(vec3(offset_min.x, offset_max.y, offset_min.z));
|
||||
// vec4 sample_x1y2z2 = SampleLpvLinear(vec3(offset_max.x, offset_min.y, offset_min.z));
|
||||
// vec4 sample_x2y2z2 = SampleLpvLinear(vec3(offset_min.x, offset_min.y, offset_min.z));
|
||||
|
||||
// // #ifdef LPV_VOXEL_TEST
|
||||
// // vec3 lpvCameraOffset = fract(cameraPosition);
|
||||
// // vec3 voxelCameraOffset = fract(cameraPosition / LIGHT_BIN_SIZE) * LIGHT_BIN_SIZE;
|
||||
// // ivec3 voxelPos = ivec3(lpvPos - SceneLPVCenter + VoxelBlockCenter + voxelCameraOffset - lpvCameraOffset + 0.5);
|
||||
|
||||
// // float voxel_x1y1z1 = LpvVoxelTest(voxelPos + ivec3(1, 1, 1));
|
||||
// // float voxel_x2y1z1 = LpvVoxelTest(voxelPos + ivec3(0, 1, 1));
|
||||
// // float voxel_x1y2z1 = LpvVoxelTest(voxelPos + ivec3(1, 0, 1));
|
||||
// // float voxel_x2y2z1 = LpvVoxelTest(voxelPos + ivec3(0, 0, 1));
|
||||
|
||||
// // float voxel_x1y1z2 = LpvVoxelTest(voxelPos + ivec3(1, 1, 0));
|
||||
// // float voxel_x2y1z2 = LpvVoxelTest(voxelPos + ivec3(0, 1, 0));
|
||||
// // float voxel_x1y2z2 = LpvVoxelTest(voxelPos + ivec3(1, 0, 0));
|
||||
// // float voxel_x2y2z2 = LpvVoxelTest(voxelPos + ivec3(0, 0, 0));
|
||||
|
||||
// // sample_x1y1z1 *= voxel_x1y1z1;
|
||||
// // sample_x2y1z1 *= voxel_x2y1z1;
|
||||
// // sample_x1y2z1 *= voxel_x1y2z1;
|
||||
// // sample_x2y2z1 *= voxel_x2y2z1;
|
||||
|
||||
// // sample_x1y1z2 *= voxel_x1y1z2;
|
||||
// // sample_x2y1z2 *= voxel_x2y1z2;
|
||||
// // sample_x1y2z2 *= voxel_x1y2z2;
|
||||
// // sample_x2y2z2 *= voxel_x2y2z2;
|
||||
// // #endif
|
||||
|
||||
// vec3 mixF = s_min / (s_min + s_max);
|
||||
|
||||
// vec4 sample_y1z1 = mix(sample_x1y1z1, sample_x2y1z1, mixF.x);
|
||||
// vec4 sample_y2z1 = mix(sample_x1y2z1, sample_x2y2z1, mixF.x);
|
||||
|
||||
// vec4 sample_y1z2 = mix(sample_x1y1z2, sample_x2y1z2, mixF.x);
|
||||
// vec4 sample_y2z2 = mix(sample_x1y2z2, sample_x2y2z2, mixF.x);
|
||||
|
||||
// vec4 sample_z1 = mix(sample_y1z1, sample_y2z1, mixF.y);
|
||||
// vec4 sample_z2 = mix(sample_y1z2, sample_y2z2, mixF.y);
|
||||
|
||||
// return mix(sample_z1, sample_z2, mixF.z);
|
||||
// }
|
||||
|
||||
vec4 SampleLpv(const in vec3 samplePos) {
|
||||
// #if LPV_SAMPLE_MODE == LPV_SAMPLE_CUBIC
|
||||
// vec4 lpvSample = SampleLpvCubic(samplePos);
|
||||
// #elif LPV_SAMPLE_MODE == LPV_SAMPLE_LINEAR
|
||||
vec4 lpvSample = SampleLpvLinear(samplePos);
|
||||
// #else
|
||||
// ivec3 coord = ivec3(samplePos);
|
||||
// vec4 lpvSample = SampleLpvNearest(coord);
|
||||
// #endif
|
||||
|
||||
return lpvSample;
|
||||
}
|
||||
|
||||
// vec4 SampleLpv(const in vec3 playerPos, const in vec3 geoNormal, const in vec3 texNormal) {
|
||||
// ivec3 lpvPos = GetLpvPosition(playerPos);
|
||||
|
||||
// // #if MATERIAL_NORMALS != 0
|
||||
// vec3 samplePos = lpvPos - 0.5 * geoNormal + texNormal;
|
||||
// // #else
|
||||
// // vec3 samplePos = lpvPos + 0.5 * geoNormal;
|
||||
// // #endif
|
||||
|
||||
// return SampleLpvLinear(samplePos);
|
||||
// }
|
||||
|
||||
// vec3 GetLpvBlockLight(in vec4 lpvSample, const in float power) {
|
||||
// return (lpvSample.rgb * LPV_BLOCKLIGHT_SCALE) / 8.0 * DynamicLightBrightness;
|
||||
// }
|
||||
|
||||
vec3 GetLpvBlockLight(const in vec4 lpvSample) {
|
||||
// return GetLpvBlockLight(lpvSample, 1.0);
|
||||
return 4.0 * lpvSample.rgb;// * LPV_BLOCKLIGHT_SCALE);// * DynamicLightBrightness;
|
||||
return 8.0 * lpvSample.rgb;// * LPV_BLOCKLIGHT_SCALE);// * DynamicLightBrightness;
|
||||
}
|
||||
|
||||
float GetLpvSkyLight(const in vec4 lpvSample) {
|
||||
|
@ -17,7 +17,6 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in;
|
||||
shared uint voxelSharedData[10*10*10];
|
||||
|
||||
const vec2 LpvBlockSkyFalloff = vec2(0.96, 0.96);
|
||||
const vec2 LpvBlockSkyRange = vec2(1.0, 24.0);
|
||||
const ivec3 lpvFlatten = ivec3(1, 10, 100);
|
||||
|
||||
#define GAMMA 2.2
|
||||
|
Loading…
Reference in New Issue
Block a user