From 7abf6a675994a5b4f683c45da43cdc3ed00fd4a9 Mon Sep 17 00:00:00 2001 From: doctor4t Date: Wed, 1 Jan 2025 21:51:24 +0100 Subject: [PATCH] Holding out for a hero (ryanhcode) --- changelog.md | 5 ++ .../ladysnake/effective/core/Effective.java | 9 ++ .../core/particle/CascadeParticle.java | 3 +- .../particle/SoftParticleRenderType.java | 86 +++++++++++-------- .../effective/shaders/core/soft_particle.fsh | 31 +++---- 5 files changed, 80 insertions(+), 54 deletions(-) diff --git a/changelog.md b/changelog.md index 2b0510d..b05492e 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1,8 @@ +------------------------------------------------------ +Effective 2.4.3 (Alpha) - 1.21.1 +------------------------------------------------------ +- Added a Chilean Spanish translation thanks to Ganbare-Lucifer + ------------------------------------------------------ Effective 2.4.2 (Alpha) - 1.21.1 ------------------------------------------------------ diff --git a/src/client/java/org/ladysnake/effective/core/Effective.java b/src/client/java/org/ladysnake/effective/core/Effective.java index 8b8844f..53e098b 100644 --- a/src/client/java/org/ladysnake/effective/core/Effective.java +++ b/src/client/java/org/ladysnake/effective/core/Effective.java @@ -4,10 +4,13 @@ import net.fabricmc.fabric.api.client.event.lifecycle.v1.ClientTickEvents; import net.fabricmc.fabric.api.client.networking.v1.ClientPlayConnectionEvents; import net.fabricmc.fabric.api.client.particle.v1.ParticleFactoryRegistry; +import net.fabricmc.fabric.api.client.rendering.v1.CoreShaderRegistrationCallback; import net.fabricmc.fabric.api.client.rendering.v1.EntityModelLayerRegistry; import net.fabricmc.fabric.api.particle.v1.FabricParticleTypes; import net.minecraft.client.MinecraftClient; import net.minecraft.client.network.ClientPlayerEntity; +import net.minecraft.client.render.RenderLayers; +import net.minecraft.client.render.VertexFormats; import net.minecraft.entity.passive.GlowSquidEntity; import net.minecraft.particle.SimpleParticleType; import net.minecraft.registry.Registries; @@ -28,6 +31,7 @@ import org.ladysnake.effective.core.render.entity.model.SplashBottomRimModel; import org.ladysnake.effective.core.render.entity.model.SplashModel; import org.ladysnake.effective.core.render.entity.model.SplashRimModel; +import org.ladysnake.effective.core.render.particle.SoftParticleRenderType; import org.ladysnake.effective.core.world.RenderedHypnotizingEntities; import org.ladysnake.effective.core.world.WaterfallCloudGenerators; import org.ladysnake.satin.api.event.EntitiesPreRenderCallback; @@ -220,6 +224,11 @@ public void onInitializeClient() { } }); + // register soft particle shader + CoreShaderRegistrationCallback.EVENT.register(registrationContext -> { + registrationContext.register(Effective.id("soft_particle"), VertexFormats.POSITION_TEXTURE_COLOR_LIGHT, SoftParticleRenderType::loadShader); + }); + // jeb rainbow glow squids ClientTickEvents.END_CLIENT_TICK.register(client -> ticksJeb++); EntitiesPreRenderCallback.EVENT.register((camera, frustum, tickDelta) -> uniformSTimeJeb.set((ticksJeb + tickDelta) * 0.05f)); diff --git a/src/client/java/org/ladysnake/effective/core/particle/CascadeParticle.java b/src/client/java/org/ladysnake/effective/core/particle/CascadeParticle.java index 286f8e3..d5781a1 100644 --- a/src/client/java/org/ladysnake/effective/core/particle/CascadeParticle.java +++ b/src/client/java/org/ladysnake/effective/core/particle/CascadeParticle.java @@ -7,6 +7,7 @@ import net.minecraft.client.world.ClientWorld; import net.minecraft.particle.SimpleParticleType; import net.minecraft.util.math.BlockPos; +import org.ladysnake.effective.core.render.particle.SoftParticleRenderType; public class CascadeParticle extends SpriteBillboardParticle { private final SpriteProvider spriteProvider; @@ -26,7 +27,7 @@ public CascadeParticle(ClientWorld world, double x, double y, double z, double v } public ParticleTextureSheet getType() { - return ParticleTextureSheet.PARTICLE_SHEET_TRANSLUCENT; + return SoftParticleRenderType.SOFT_PARTICLE; } @Override diff --git a/src/client/java/org/ladysnake/effective/core/render/particle/SoftParticleRenderType.java b/src/client/java/org/ladysnake/effective/core/render/particle/SoftParticleRenderType.java index 6f336c8..88e465e 100644 --- a/src/client/java/org/ladysnake/effective/core/render/particle/SoftParticleRenderType.java +++ b/src/client/java/org/ladysnake/effective/core/render/particle/SoftParticleRenderType.java @@ -1,38 +1,48 @@ -//package org.ladysnake.effective.core.render.particle; -// -//import com.mojang.blaze3d.systems.RenderSystem; -//import net.minecraft.client.MinecraftClient; -//import net.minecraft.client.particle.ParticleTextureSheet; -//import net.minecraft.client.render.BufferBuilder; -//import net.minecraft.client.render.Tessellator; -//import net.minecraft.client.texture.SpriteAtlasTexture; -//import net.minecraft.client.texture.TextureManager; -//import org.jetbrains.annotations.NotNull; -//import org.jetbrains.annotations.Nullable; -// -//public class SoftParticleRenderType implements ParticleTextureSheet { -// @NotNull -// public static final SoftParticleRenderType SOFT_PARTICLE = new SoftParticleRenderType(); -// -// @Override -// public @Nullable BufferBuilder begin(Tessellator tessellator, TextureManager textureManager) { -// final MinecraftClient minecraft = MinecraftClient.getInstance(); -// -// RenderSystem.setShader(() -> softParticle); -// -// // Disallow soft particles from writing to the depth buffer -// RenderSystem.depthMask(false); -// -// // Set `Sampler0` to the particle atlas -// // noinspection deprecation -// RenderSystem.setShaderTexture(0, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE); -// -// RenderSystem.enableBlend(); -// RenderSystem.defaultBlendFunc(); -// -// // Set the sampler for the depth texture -// softParticle.setSampler("DiffuseDepthSampler", minecraft.getMainRenderTarget().getDepthTextureId()); -// -// return tesselator.begin(VertexFormat.Mode.QUADS, DefaultVertexFormat.PARTICLE); -// } -//} +package org.ladysnake.effective.core.render.particle; + +import com.mojang.blaze3d.systems.RenderSystem; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gl.ShaderProgram; +import net.minecraft.client.particle.ParticleTextureSheet; +import net.minecraft.client.render.BufferBuilder; +import net.minecraft.client.render.Tessellator; +import net.minecraft.client.render.VertexFormat; +import net.minecraft.client.render.VertexFormats; +import net.minecraft.client.texture.SpriteAtlasTexture; +import net.minecraft.client.texture.TextureManager; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.util.Objects; + +public class SoftParticleRenderType implements ParticleTextureSheet { + @NotNull + public static final SoftParticleRenderType SOFT_PARTICLE = new SoftParticleRenderType(); + private static ShaderProgram softParticle; + + @Override + public @Nullable BufferBuilder begin(Tessellator tessellator, TextureManager textureManager) { + final MinecraftClient minecraft = MinecraftClient.getInstance(); + + RenderSystem.setShader(() -> softParticle); + + // Disallow soft particles from writing to the depth buffer + RenderSystem.depthMask(false); + + // Set `Sampler0` to the particle atlas + // noinspection deprecation + RenderSystem.setShaderTexture(0, SpriteAtlasTexture.PARTICLE_ATLAS_TEXTURE); + + RenderSystem.enableBlend(); + RenderSystem.defaultBlendFunc(); + + // Set the sampler for the depth texture + softParticle.addSampler("DiffuseDepthSampler", minecraft.getFramebuffer().getDepthAttachment()); + + return tessellator.begin(VertexFormat.DrawMode.QUADS, VertexFormats.POSITION_TEXTURE_COLOR_LIGHT); + } + + public static void loadShader(@NotNull final ShaderProgram shader) { + softParticle = Objects.requireNonNull(shader); + } +} diff --git a/src/client/resources/assets/effective/shaders/core/soft_particle.fsh b/src/client/resources/assets/effective/shaders/core/soft_particle.fsh index b83f8d9..78b0836 100644 --- a/src/client/resources/assets/effective/shaders/core/soft_particle.fsh +++ b/src/client/resources/assets/effective/shaders/core/soft_particle.fsh @@ -27,19 +27,20 @@ float linearizeDepth(float depthSample) { } void main() { - vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; - if (color.a < 0.001) { - discard; - } - - // Depth only occupies the red channel, we don't care about the other two - float depthSample = texture(DiffuseDepthSampler, gl_FragCoord.xy / ScreenSize).r; - - float depth = linearizeDepth(depthSample); - float particleDepth = linearizeDepth(gl_FragCoord.z); - - // Linearly blends from 1x to 0x opacity at 1+ meter depth difference to 0 depth difference - float opacity = color.a * min(depth - particleDepth, 1.0); - - fragColor = linear_fog(vec4(color.rgb, opacity), vertexDistance, FogStart, FogEnd, FogColor); + fragColor = vec4(1.0); +// vec4 color = texture(Sampler0, texCoord0) * vertexColor * ColorModulator; +// if (color.a < 0.001) { +// discard; +// } +// +// // Depth only occupies the red channel, we don't care about the other two +// float depthSample = texture(DiffuseDepthSampler, gl_FragCoord.xy / ScreenSize).r; +// +// float depth = linearizeDepth(depthSample); +// float particleDepth = linearizeDepth(gl_FragCoord.z); +// +// // Linearly blends from 1x to 0x opacity at 1+ meter depth difference to 0 depth difference +// float opacity = color.a * min(depth - particleDepth, 1.0); +// +// fragColor = linear_fog(vec4(color.rgb, opacity), vertexDistance, FogStart, FogEnd, FogColor); }