From 138b7bc6438df27533dae04cffb7b2b1161db77e Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Sun, 26 Dec 2021 11:57:39 +0500 Subject: Removed previous liquids implementation --- cwd/assets/altcraft/scripts/blocks.lua | 8 -------- cwd/assets/minecraft/blockstates/lava.json | 5 ----- cwd/assets/minecraft/blockstates/water.json | 5 ----- cwd/assets/minecraft/models/block/lava.json | 6 ------ cwd/assets/minecraft/models/block/water.json | 6 ------ 5 files changed, 30 deletions(-) delete mode 100644 cwd/assets/minecraft/blockstates/lava.json delete mode 100644 cwd/assets/minecraft/blockstates/water.json delete mode 100644 cwd/assets/minecraft/models/block/lava.json delete mode 100644 cwd/assets/minecraft/models/block/water.json (limited to 'cwd') diff --git a/cwd/assets/altcraft/scripts/blocks.lua b/cwd/assets/altcraft/scripts/blocks.lua index 5678677..72a1599 100644 --- a/cwd/assets/altcraft/scripts/blocks.lua +++ b/cwd/assets/altcraft/scripts/blocks.lua @@ -33,14 +33,6 @@ local function RegisterBlocks() AC.RegisterBlock(BlockId.new(7,0), true, "bedrock", "normal") - AC.RegisterBlock(BlockId.new(8,0), true, "water", "normal") - - AC.RegisterBlock(BlockId.new(9,0), true, "water", "normal") - - AC.RegisterBlock(BlockId.new(10,0), true, "lava", "normal") - - AC.RegisterBlock(BlockId.new(11,0), true, "lava", "normal") - AC.RegisterBlock(BlockId.new(12,0), true, "sand", "normal") AC.RegisterBlock(BlockId.new(12,1), true, "red_sand", "normal") diff --git a/cwd/assets/minecraft/blockstates/lava.json b/cwd/assets/minecraft/blockstates/lava.json deleted file mode 100644 index 97b01d3..0000000 --- a/cwd/assets/minecraft/blockstates/lava.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "variants": { - "normal": { "model": "lava" } - } -} diff --git a/cwd/assets/minecraft/blockstates/water.json b/cwd/assets/minecraft/blockstates/water.json deleted file mode 100644 index 683334a..0000000 --- a/cwd/assets/minecraft/blockstates/water.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "variants": { - "normal": { "model": "water" } - } -} diff --git a/cwd/assets/minecraft/models/block/lava.json b/cwd/assets/minecraft/models/block/lava.json deleted file mode 100644 index 714d0b2..0000000 --- a/cwd/assets/minecraft/models/block/lava.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "blocks/lava_flow" - } -} diff --git a/cwd/assets/minecraft/models/block/water.json b/cwd/assets/minecraft/models/block/water.json deleted file mode 100644 index 860815a..0000000 --- a/cwd/assets/minecraft/models/block/water.json +++ /dev/null @@ -1,6 +0,0 @@ -{ - "parent": "block/cube_all", - "textures": { - "all": "blocks/water_flow" - } -} -- cgit v1.2.3 From bb25dc91d9a83a9f9031ad364f1cbbc1b39a4c7c Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Mon, 27 Dec 2021 22:49:09 +0500 Subject: Added RegisterLiquid to lua api --- cwd/assets/altcraft/scripts/blocks.lua | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cwd') diff --git a/cwd/assets/altcraft/scripts/blocks.lua b/cwd/assets/altcraft/scripts/blocks.lua index 72a1599..dde4b57 100644 --- a/cwd/assets/altcraft/scripts/blocks.lua +++ b/cwd/assets/altcraft/scripts/blocks.lua @@ -33,6 +33,12 @@ local function RegisterBlocks() AC.RegisterBlock(BlockId.new(7,0), true, "bedrock", "normal") + AC.RegisterLiquid(BlockId.new(8,0), "blocks/water_flow", "blocks/water_still") + AC.RegisterLiquid(BlockId.new(9,0), "blocks/water_flow", "blocks/water_still") + + AC.RegisterLiquid(BlockId.new(10,0), "blocks/lava_flow", "blocks/lava_still") + AC.RegisterLiquid(BlockId.new(11,0), "blocks/lava_flow", "blocks/lava_still") + AC.RegisterBlock(BlockId.new(12,0), true, "sand", "normal") AC.RegisterBlock(BlockId.new(12,1), true, "red_sand", "normal") -- cgit v1.2.3 From 12923669214ba73a809f4e221a634244888b0146 Mon Sep 17 00:00:00 2001 From: LaG1924 Date: Thu, 15 Dec 2022 15:53:56 +0500 Subject: Added liquid rendering pass --- .../altcraft/shaders/frag/fwd_liquid_face.fs | 38 ++++++++++++++++++++++ cwd/assets/altcraft/shaders/frag/liquid_face.fs | 22 +++++++++++++ cwd/assets/altcraft/shaders/vert/liquid_face.vs | 38 ++++++++++++++++++++++ 3 files changed, 98 insertions(+) create mode 100644 cwd/assets/altcraft/shaders/frag/fwd_liquid_face.fs create mode 100644 cwd/assets/altcraft/shaders/frag/liquid_face.fs create mode 100644 cwd/assets/altcraft/shaders/vert/liquid_face.vs (limited to 'cwd') diff --git a/cwd/assets/altcraft/shaders/frag/fwd_liquid_face.fs b/cwd/assets/altcraft/shaders/frag/fwd_liquid_face.fs new file mode 100644 index 0000000..f8d9376 --- /dev/null +++ b/cwd/assets/altcraft/shaders/frag/fwd_liquid_face.fs @@ -0,0 +1,38 @@ +#version 330 core + +in vec4 faceWorldPos; +in vec3 faceTextureUv; +in vec3 faceAddColor; +in vec3 faceNormal; +in vec2 faceLight; + +out vec4 fragColor; + +uniform sampler2DArray textureAtlas; + +layout (std140) uniform Globals { + mat4 projView; + mat4 proj; + mat4 invProj; + mat4 view; + uvec2 viewportSize; + vec4 ssaoKernels[64]; + float globalTime; + float dayTime; + float gamma; +}; + +void main() { + vec4 col = texture(textureAtlas, faceTextureUv); + + float localLight = faceLight.r / 15.0f; + float skyLight = faceLight.g / 15.0f; + float lightLevel = clamp(localLight + skyLight * dayTime, 0.01f, 1.0f); + lightLevel = pow(lightLevel, 3); + lightLevel = clamp(lightLevel, 0.005f, 1.0f); + + fragColor = vec4(col.rgb * faceAddColor.rgb * lightLevel, 1.0f); + + fragColor.rgb = pow(fragColor.rgb, vec3(1.0f / gamma)); + fragColor.a = col.a; +} diff --git a/cwd/assets/altcraft/shaders/frag/liquid_face.fs b/cwd/assets/altcraft/shaders/frag/liquid_face.fs new file mode 100644 index 0000000..3e5c0d4 --- /dev/null +++ b/cwd/assets/altcraft/shaders/frag/liquid_face.fs @@ -0,0 +1,22 @@ +#version 330 core + +in vec3 faceTextureUv; +in vec3 faceAddColor; +in vec3 faceNormal; +in vec2 faceLight; +in float faceAmbientOcclusion; + +layout (location = 0) out vec4 color; +layout (location = 1) out vec4 normal; +layout (location = 2) out vec4 light; + +uniform sampler2DArray textureAtlas; + +void main() { + vec4 col = texture(textureAtlas, faceTextureUv); + + color = vec4(col.rgb * faceAddColor.rgb, 1.0f); + normal = vec4(faceNormal, 1.0f); + light = vec4(faceLight / 15.0f, faceAmbientOcclusion, 1.0f); + color.a = col.a; +} diff --git a/cwd/assets/altcraft/shaders/vert/liquid_face.vs b/cwd/assets/altcraft/shaders/vert/liquid_face.vs new file mode 100644 index 0000000..101e4d0 --- /dev/null +++ b/cwd/assets/altcraft/shaders/vert/liquid_face.vs @@ -0,0 +1,38 @@ +#version 330 core + +in vec3 pos[4]; +in vec2 uv[4]; +in vec2 light[4]; +in vec3 normal; +in vec3 color; +in vec3 layerAnimationAo; + +out vec3 faceTextureUv; +out vec3 faceNormal; +out vec3 faceAddColor; +out vec2 faceLight; +out float faceAmbientOcclusion; + +layout (std140) uniform Globals { + mat4 projView; + mat4 proj; + mat4 invProj; + mat4 view; + uvec2 viewportSize; + vec4 ssaoKernels[64]; + float globalTime; + float dayTime; + float gamma; +}; + +void main() { + gl_Position = projView * vec4(pos[gl_VertexID], 1.0f); + + faceTextureUv = vec3(uv[gl_VertexID], layerAnimationAo.r); + faceTextureUv.y -= (uv[2].y - uv[0].y) * trunc(mod(globalTime * 4.0f, layerAnimationAo.g)); + + faceNormal = (view * vec4(normal, 0.0f)).xyz; + faceAddColor = color; + faceLight = light[gl_VertexID]; + faceAmbientOcclusion = layerAnimationAo.b; +} -- cgit v1.2.3