diff --git a/shaders/dimensions/all_particles.fsh b/shaders/dimensions/all_particles.fsh index a237464..92937a4 100644 --- a/shaders/dimensions/all_particles.fsh +++ b/shaders/dimensions/all_particles.fsh @@ -35,6 +35,11 @@ uniform sampler2D texture; uniform sampler2D noisetex; uniform sampler2D colortex4; +#ifdef IS_LPV_ENABLED + uniform sampler3D texLpv1; + uniform sampler3D texLpv2; +#endif + uniform mat4 gbufferProjectionInverse; uniform mat4 gbufferModelViewInverse; diff --git a/shaders/dimensions/all_translucent.fsh b/shaders/dimensions/all_translucent.fsh index d3b885f..e8760ab 100644 --- a/shaders/dimensions/all_translucent.fsh +++ b/shaders/dimensions/all_translucent.fsh @@ -50,6 +50,11 @@ uniform sampler2D texture; uniform sampler2D specular; uniform sampler2D normals; +#ifdef IS_LPV_ENABLED + uniform sampler3D texLpv1; + uniform sampler3D texLpv2; +#endif + varying vec4 tangent; varying vec4 normalMat; varying vec3 binormal; diff --git a/shaders/dimensions/composite1.fsh b/shaders/dimensions/composite1.fsh index af38633..b97902f 100644 --- a/shaders/dimensions/composite1.fsh +++ b/shaders/dimensions/composite1.fsh @@ -86,6 +86,10 @@ uniform sampler2D colortex13; uniform sampler2D colortex14; uniform sampler2D colortex15; // flat normals(rgb), vanillaAO(alpha) +#ifdef IS_LPV_ENABLED + uniform sampler3D texLpv1; + uniform sampler3D texLpv2; +#endif uniform mat4 shadowModelView; diff --git a/shaders/dimensions/shadowcomp.csh b/shaders/dimensions/shadowcomp.csh index 232e5aa..7648358 100644 --- a/shaders/dimensions/shadowcomp.csh +++ b/shaders/dimensions/shadowcomp.csh @@ -1,3 +1,5 @@ +#define RENDER_SHADOWCOMP + layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in; #if LPV_SIZE == 8 @@ -27,6 +29,7 @@ layout (local_size_x = 8, local_size_y = 8, local_size_z = 8) in; #include "/lib/blocks.glsl" #include "/lib/lpv_common.glsl" #include "/lib/lpv_blocks.glsl" + #include "/lib/lpv_buffer.glsl" #include "/lib/voxel_common.glsl" int sumOf(ivec3 vec) {return vec.x + vec.y + vec.z;} diff --git a/shaders/lib/lpv_buffer.glsl b/shaders/lib/lpv_buffer.glsl new file mode 100644 index 0000000..7f544f4 --- /dev/null +++ b/shaders/lib/lpv_buffer.glsl @@ -0,0 +1,7 @@ +#ifdef RENDER_SHADOWCOMP + layout(rgba8) uniform restrict image3D imgLpv1; + layout(rgba8) uniform restrict image3D imgLpv2; +#else + layout(rgba8) uniform readonly image3D imgLpv1; + layout(rgba8) uniform readonly image3D imgLpv2; +#endif diff --git a/shaders/lib/lpv_common.glsl b/shaders/lib/lpv_common.glsl index 8b196ad..949bff3 100644 --- a/shaders/lib/lpv_common.glsl +++ b/shaders/lib/lpv_common.glsl @@ -1,6 +1,3 @@ -layout(rgba8) uniform image3D imgLpv1; -layout(rgba8) uniform image3D imgLpv2; - // How far light propagates (block, sky) const vec2 LpvBlockSkyRange = vec2(15.0, 24.0); diff --git a/shaders/lib/lpv_render.glsl b/shaders/lib/lpv_render.glsl index 6151750..471ed17 100644 --- a/shaders/lib/lpv_render.glsl +++ b/shaders/lib/lpv_render.glsl @@ -7,8 +7,8 @@ const float LpvBlockBrightness = 2.0; vec4 SampleLpvNearest(const in ivec3 lpvPos) { vec4 lpvSample = (frameCounter % 2) == 0 - ? imageLoad(imgLpv1, lpvPos) - : imageLoad(imgLpv2, lpvPos); + ? texelFetch(texLpv1, lpvPos, 0) + : texelFetch(texLpv2, lpvPos, 0); lpvSample.b = pow(lpvSample.b, LpvBlockPower) * LpvBlockSkyRange.x; lpvSample.rgb = HsvToRgb(lpvSample.rgb); diff --git a/shaders/lib/voxel_common.glsl b/shaders/lib/voxel_common.glsl index 138092d..f548bc7 100644 --- a/shaders/lib/voxel_common.glsl +++ b/shaders/lib/voxel_common.glsl @@ -1,4 +1,8 @@ -layout(r16ui) uniform uimage3D imgVoxelMask; +#ifdef RENDER_SHADOW + layout(r16ui) uniform uimage3D imgVoxelMask; +#else + layout(r16ui) uniform readonly uimage3D imgVoxelMask; +#endif const uint VoxelSize = uint(exp2(LPV_SIZE)); const uvec3 VoxelSize3 = uvec3(VoxelSize); diff --git a/shaders/shaders.properties b/shaders/shaders.properties index fd9fd2b..b902dd6 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -627,16 +627,16 @@ uniform.float.shadowMaxProj = 150.0/abs(sunPosY) #if LPV_SIZE == 8 image.imgVoxelMask = none RED_INTEGER R16UI UNSIGNED_SHORT true false 256 256 256 - image.imgLpv1 = none RGB RGBA8 BYTE false false 256 256 256 - image.imgLpv2 = none RGB RGBA8 BYTE false false 256 256 256 + image.imgLpv1 = texLpv1 RGB RGBA8 BYTE false false 256 256 256 + image.imgLpv2 = texLpv2 RGB RGBA8 BYTE false false 256 256 256 #elif LPV_SIZE == 7 image.imgVoxelMask = none RED_INTEGER R16UI UNSIGNED_SHORT true false 128 128 128 - image.imgLpv1 = none RGB RGBA8 BYTE false false 128 128 128 - image.imgLpv2 = none RGB RGBA8 BYTE false false 128 128 128 + image.imgLpv1 = texLpv1 RGB RGBA8 BYTE false false 128 128 128 + image.imgLpv2 = texLpv2 RGB RGBA8 BYTE false false 128 128 128 #elif LPV_SIZE == 6 image.imgVoxelMask = none RED_INTEGER R16UI UNSIGNED_SHORT true false 64 64 64 - image.imgLpv1 = none RGB RGBA8 BYTE false false 64 64 64 - image.imgLpv2 = none RGB RGBA8 BYTE false false 64 64 64 + image.imgLpv1 = texLpv1 RGB RGBA8 BYTE false false 64 64 64 + image.imgLpv2 = texLpv2 RGB RGBA8 BYTE false false 64 64 64 #endif #else program.world1/setup.enabled = false diff --git a/shaders/world0/shadow.vsh b/shaders/world0/shadow.vsh index e0f9c94..298282e 100644 --- a/shaders/world0/shadow.vsh +++ b/shaders/world0/shadow.vsh @@ -4,6 +4,7 @@ #extension GL_EXT_shader_image_load_store: enable #endif +#define RENDER_SHADOW /* @@ -221,6 +222,7 @@ void main() { break; // TODO: blaze, magma_cube + } } if (voxelId > 0u) @@ -275,4 +277,4 @@ void main() { bias = 6.0 + (1-clamp(dot(WsunVec,FlatNormals),0,1))*0.3; } gl_Position.z /= bias; -} \ No newline at end of file +}