Skip to content

Commit

Permalink
Holding out for a hero (ryanhcode)
Browse files Browse the repository at this point in the history
  • Loading branch information
doctor4t committed Jan 1, 2025
1 parent 6399760 commit 7abf6a6
Show file tree
Hide file tree
Showing 5 changed files with 80 additions and 54 deletions.
5 changes: 5 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -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
------------------------------------------------------
Expand Down
9 changes: 9 additions & 0 deletions src/client/java/org/ladysnake/effective/core/Effective.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

0 comments on commit 7abf6a6

Please sign in to comment.