From 7cd1cde2c3c231923a3e1e33f5f66abf63d3db86 Mon Sep 17 00:00:00 2001 From: NULL511 Date: Sun, 5 May 2024 16:07:28 -0400 Subject: [PATCH] nether/end shadow pass for voxel data, broken iris uniforms though --- shaders/block.properties | 2 +- shaders/shaders.properties | 5 +- shaders/template/block.properties | 1 + shaders/world-1/shadow.fsh | 10 +++ shaders/world-1/shadow.vsh | 121 ++++++++++++++++++++++++++++++ shaders/world1/shadow.fsh | 10 +++ shaders/world1/shadow.vsh | 121 ++++++++++++++++++++++++++++++ 7 files changed, 268 insertions(+), 2 deletions(-) create mode 100644 shaders/world-1/shadow.fsh create mode 100644 shaders/world-1/shadow.vsh create mode 100644 shaders/world1/shadow.fsh create mode 100644 shaders/world1/shadow.vsh diff --git a/shaders/block.properties b/shaders/block.properties index b31be1e..2641257 100644 --- a/shaders/block.properties +++ b/shaders/block.properties @@ -393,7 +393,7 @@ block.321=yellow_stained_glass yellow_stained_glass_pane ####### ----- LPV shapes ----- ####### -block.401=chain ladder lever tripwire_hook candle:lit=false black_candle:lit=false blue_candle:lit=false brown_candle:lit=false cyan_candle:lit=false gray_candle:lit=false green_candle:lit=false light_blue_candle:lit=false light_gray_candle:lit=false lime_candle:lit=false magenta_candle:lit=false orange_candle:lit=false pink_candle:lit=false purple_candle:lit=false red_candle:lit=false white_candle:lit=false yellow_candle:lit=false acacia_button bamboo_button birch_button cherry_button crimson_button dark_oak_button jungle_button mangrove_button oak_button polished_blackstone_button spruce_button stone_button warped_button +block.401=chain ladder lever tripwire_hook snow:layers=1 candle:lit=false black_candle:lit=false blue_candle:lit=false brown_candle:lit=false cyan_candle:lit=false gray_candle:lit=false green_candle:lit=false light_blue_candle:lit=false light_gray_candle:lit=false lime_candle:lit=false magenta_candle:lit=false orange_candle:lit=false pink_candle:lit=false purple_candle:lit=false red_candle:lit=false white_candle:lit=false yellow_candle:lit=false acacia_button bamboo_button birch_button cherry_button crimson_button dark_oak_button jungle_button mangrove_button oak_button polished_blackstone_button spruce_button stone_button warped_button block.402=black_carpet blue_carpet brown_carpet cyan_carpet gray_carpet green_carpet light_blue_carpet light_gray_carpet lime_carpet magenta_carpet moss_carpet orange_carpet pink_carpet purple_carpet red_carpet white_carpet yellow_carpet diff --git a/shaders/shaders.properties b/shaders/shaders.properties index 946cf5c..f43de0f 100644 --- a/shaders/shaders.properties +++ b/shaders/shaders.properties @@ -19,7 +19,7 @@ iris.features.optional = ENTITY_TRANSLUCENT REVERSED_CULLING COMPUTE_SHADERS CUS #endif #ifdef LPV_ENABLED - # shadow.enabled = true + shadow.enabled = true shadow.culling = reversed voxelizeLightBlocks = true #endif @@ -576,6 +576,9 @@ uniform.float.shadowMaxProj = 150.0/abs(sunPosY) program.world0/setup.enabled = false program.world-1/setup.enabled = false + program.world1/shadow.enabled = false + program.world-1/shadow.enabled = false + program.world1/shadowcomp.enabled = false program.world0/shadowcomp.enabled = false program.world-1/shadowcomp.enabled = false diff --git a/shaders/template/block.properties b/shaders/template/block.properties index 8aad4e8..b50a3fa 100644 --- a/shaders/template/block.properties +++ b/shaders/template/block.properties @@ -578,6 +578,7 @@ block.*= vine #= BLOCK_LPV_IGNORE block.401= chain ladder lever tripwire_hook \ + snow:layers=1 \ [candle]:lit=false \ acacia_button bamboo_button birch_button cherry_button crimson_button dark_oak_button jungle_button mangrove_button oak_button polished_blackstone_button spruce_button stone_button warped_button diff --git a/shaders/world-1/shadow.fsh b/shaders/world-1/shadow.fsh new file mode 100644 index 0000000..f0a8503 --- /dev/null +++ b/shaders/world-1/shadow.fsh @@ -0,0 +1,10 @@ +#version 120 + +#include "/lib/settings.glsl" + + +//////////////////////////////VOID MAIN////////////////////////////// + +void main() { + gl_FragData[0] = vec4(0.0); +} diff --git a/shaders/world-1/shadow.vsh b/shaders/world-1/shadow.vsh new file mode 100644 index 0000000..61de9bc --- /dev/null +++ b/shaders/world-1/shadow.vsh @@ -0,0 +1,121 @@ +#version 120 +#extension GL_ARB_explicit_attrib_location: enable +#extension GL_ARB_shader_image_load_store: enable + +#include "/lib/settings.glsl" + +#define RENDER_SHADOW + + +/* +!! DO NOT REMOVE !! +This code is from Chocapic13' shaders +Read the terms of modification and sharing before changing something below please ! +!! DO NOT REMOVE !! +*/ + +// #define SHADOW_MAP_BIAS 0.5 +// const float PI = 3.1415927; +// varying vec2 texcoord; +// uniform mat4 shadowProjectionInverse; +// uniform mat4 shadowProjection; +uniform mat4 shadowModelViewInverse; +// uniform mat4 shadowModelView; +// uniform mat4 gbufferModelView; +// uniform mat4 gbufferModelViewInverse; +// uniform mat4 gbufferProjection; +// uniform mat4 gbufferProjectionInverse; +// uniform int hideGUI; +uniform vec3 cameraPosition; +// uniform float frameTimeCounter; +// uniform int frameCounter; +// uniform float screenBrightness; +// uniform vec3 sunVec; +// uniform float aspectRatio; +// uniform float sunElevation; +// uniform vec3 sunPosition; +// uniform float lightSign; +// uniform float cosFov; +// uniform vec3 shadowViewDir; +// uniform vec3 shadowCamera; +// uniform vec3 shadowLightVec; +// uniform float shadowMaxProj; +// attribute vec4 mc_midTexCoord; +// varying vec4 color; + +#ifdef IS_LPV_ENABLED + attribute vec4 mc_Entity; + attribute vec3 at_midBlock; + + uniform int renderStage; + uniform int currentRenderedItemId; + uniform int blockEntityId; + uniform int entityId; + + // #include "/lib/Shadow_Params.glsl" + // #include "/lib/bokeh.glsl" + + + #include "/lib/blocks.glsl" + #include "/lib/entities.glsl" + #include "/lib/voxel_common.glsl" + #include "/lib/voxel_write.glsl" +#endif + + +void main() { + #if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store + vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; + + int blockId = int(mc_Entity.x + 0.5); + + #if defined IS_LPV_ENABLED || defined WAVY_PLANTS + vec3 playerpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz; + #endif + + if ( + renderStage == MC_RENDER_STAGE_TERRAIN_SOLID || renderStage == MC_RENDER_STAGE_TERRAIN_TRANSLUCENT || + renderStage == MC_RENDER_STAGE_TERRAIN_CUTOUT || renderStage == MC_RENDER_STAGE_TERRAIN_CUTOUT_MIPPED + ) { + uint voxelId = uint(blockId); + if (voxelId == 0u) voxelId = 1u; + + vec3 originPos = playerpos + at_midBlock/64.0; + + SetVoxelBlock(originPos, voxelId); + } + + #ifdef LPV_ENTITY_LIGHTS + if ( + (currentRenderedItemId > 0 || entityId > 0) && + (renderStage == MC_RENDER_STAGE_BLOCK_ENTITIES || renderStage == MC_RENDER_STAGE_ENTITIES) + ) { + uint voxelId = 0u; + + if (currentRenderedItemId > 0) { + if (entityId == ENTITY_PLAYER) { + // TODO: remove once hand-light is added + if (currentRenderedItemId < 1000) + voxelId = uint(currentRenderedItemId); + } + else if (entityId != ENTITY_ITEM_FRAME) + voxelId = uint(currentRenderedItemId); + } + else { + switch (entityId) { + case ENTITY_SPECTRAL_ARROW: + voxelId = uint(BLOCK_TORCH); + break; + + // TODO: blaze, magma_cube + } + } + + if (voxelId > 0u) + SetVoxelBlock(playerpos, voxelId); + } + #endif + #endif + + gl_Position = vec4(-1.0); +} \ No newline at end of file diff --git a/shaders/world1/shadow.fsh b/shaders/world1/shadow.fsh new file mode 100644 index 0000000..f0a8503 --- /dev/null +++ b/shaders/world1/shadow.fsh @@ -0,0 +1,10 @@ +#version 120 + +#include "/lib/settings.glsl" + + +//////////////////////////////VOID MAIN////////////////////////////// + +void main() { + gl_FragData[0] = vec4(0.0); +} diff --git a/shaders/world1/shadow.vsh b/shaders/world1/shadow.vsh new file mode 100644 index 0000000..61de9bc --- /dev/null +++ b/shaders/world1/shadow.vsh @@ -0,0 +1,121 @@ +#version 120 +#extension GL_ARB_explicit_attrib_location: enable +#extension GL_ARB_shader_image_load_store: enable + +#include "/lib/settings.glsl" + +#define RENDER_SHADOW + + +/* +!! DO NOT REMOVE !! +This code is from Chocapic13' shaders +Read the terms of modification and sharing before changing something below please ! +!! DO NOT REMOVE !! +*/ + +// #define SHADOW_MAP_BIAS 0.5 +// const float PI = 3.1415927; +// varying vec2 texcoord; +// uniform mat4 shadowProjectionInverse; +// uniform mat4 shadowProjection; +uniform mat4 shadowModelViewInverse; +// uniform mat4 shadowModelView; +// uniform mat4 gbufferModelView; +// uniform mat4 gbufferModelViewInverse; +// uniform mat4 gbufferProjection; +// uniform mat4 gbufferProjectionInverse; +// uniform int hideGUI; +uniform vec3 cameraPosition; +// uniform float frameTimeCounter; +// uniform int frameCounter; +// uniform float screenBrightness; +// uniform vec3 sunVec; +// uniform float aspectRatio; +// uniform float sunElevation; +// uniform vec3 sunPosition; +// uniform float lightSign; +// uniform float cosFov; +// uniform vec3 shadowViewDir; +// uniform vec3 shadowCamera; +// uniform vec3 shadowLightVec; +// uniform float shadowMaxProj; +// attribute vec4 mc_midTexCoord; +// varying vec4 color; + +#ifdef IS_LPV_ENABLED + attribute vec4 mc_Entity; + attribute vec3 at_midBlock; + + uniform int renderStage; + uniform int currentRenderedItemId; + uniform int blockEntityId; + uniform int entityId; + + // #include "/lib/Shadow_Params.glsl" + // #include "/lib/bokeh.glsl" + + + #include "/lib/blocks.glsl" + #include "/lib/entities.glsl" + #include "/lib/voxel_common.glsl" + #include "/lib/voxel_write.glsl" +#endif + + +void main() { + #if defined IS_LPV_ENABLED && defined MC_GL_EXT_shader_image_load_store + vec3 position = mat3(gl_ModelViewMatrix) * vec3(gl_Vertex) + gl_ModelViewMatrix[3].xyz; + + int blockId = int(mc_Entity.x + 0.5); + + #if defined IS_LPV_ENABLED || defined WAVY_PLANTS + vec3 playerpos = mat3(shadowModelViewInverse) * position + shadowModelViewInverse[3].xyz; + #endif + + if ( + renderStage == MC_RENDER_STAGE_TERRAIN_SOLID || renderStage == MC_RENDER_STAGE_TERRAIN_TRANSLUCENT || + renderStage == MC_RENDER_STAGE_TERRAIN_CUTOUT || renderStage == MC_RENDER_STAGE_TERRAIN_CUTOUT_MIPPED + ) { + uint voxelId = uint(blockId); + if (voxelId == 0u) voxelId = 1u; + + vec3 originPos = playerpos + at_midBlock/64.0; + + SetVoxelBlock(originPos, voxelId); + } + + #ifdef LPV_ENTITY_LIGHTS + if ( + (currentRenderedItemId > 0 || entityId > 0) && + (renderStage == MC_RENDER_STAGE_BLOCK_ENTITIES || renderStage == MC_RENDER_STAGE_ENTITIES) + ) { + uint voxelId = 0u; + + if (currentRenderedItemId > 0) { + if (entityId == ENTITY_PLAYER) { + // TODO: remove once hand-light is added + if (currentRenderedItemId < 1000) + voxelId = uint(currentRenderedItemId); + } + else if (entityId != ENTITY_ITEM_FRAME) + voxelId = uint(currentRenderedItemId); + } + else { + switch (entityId) { + case ENTITY_SPECTRAL_ARROW: + voxelId = uint(BLOCK_TORCH); + break; + + // TODO: blaze, magma_cube + } + } + + if (voxelId > 0u) + SetVoxelBlock(playerpos, voxelId); + } + #endif + #endif + + gl_Position = vec4(-1.0); +} \ No newline at end of file