Motion Blur, Color Saturation

This commit is contained in:
kirillsaint 2023-06-30 17:07:33 +06:00
parent c29bf80044
commit afc69f88b0
7 changed files with 155 additions and 1 deletions

View File

@ -0,0 +1,26 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.block.Block;
import net.minecraft.block.BlockGlass;
import net.minecraft.block.BlockStainedGlass;
import net.minecraft.block.material.MapColor;
import net.minecraft.block.material.Material;
import net.minecraft.util.BlockPos;
import net.minecraft.util.EnumFacing;
import net.minecraft.world.IBlockAccess;
import net.silentclient.client.Client;
import net.silentclient.client.mods.render.ClearGlassMod;
import org.spongepowered.asm.mixin.Mixin;
@Mixin({BlockGlass.class, BlockStainedGlass.class})
public class BlockGlassMixin extends Block {
public BlockGlassMixin(Material blockMaterialIn, MapColor blockMapColorIn) {
super(blockMaterialIn, blockMapColorIn);
}
@Override
public boolean shouldSideBeRendered(IBlockAccess worldIn, BlockPos pos, EnumFacing side) {
return !Client.getInstance().getModInstances().getModByClass(ClearGlassMod.class).isEnabled() && super.shouldSideBeRendered(worldIn, pos, side);
}
}

View File

@ -4,6 +4,7 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.entity.EntityPlayerSP;
import net.minecraft.client.renderer.EntityRenderer;
import net.minecraft.client.renderer.GlStateManager;
import net.minecraft.client.shader.ShaderGroup;
import net.minecraft.entity.Entity;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.util.MovingObjectPosition;
@ -16,8 +17,10 @@ import net.silentclient.client.event.impl.EventRender3D;
import net.silentclient.client.event.impl.EventZoomFov;
import net.silentclient.client.mixin.ducks.EntityRendererExt;
import net.silentclient.client.mods.render.AnimationsMod;
import net.silentclient.client.mods.render.NewMotionBlurMod;
import net.silentclient.client.utils.animations.OldSneaking;
import net.silentclient.client.utils.culling.EntityCulling;
import net.silentclient.client.utils.shader.MotionBlurUtils;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
@ -27,6 +30,9 @@ import org.spongepowered.asm.mixin.injection.Redirect;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.ArrayList;
import java.util.List;
@Mixin(EntityRenderer.class)
public abstract class EntityRendererMixin implements EntityRendererExt {
private float rotationYaw;
@ -130,6 +136,10 @@ public abstract class EntityRendererMixin implements EntityRendererExt {
@Shadow protected abstract void hurtCameraEffect(float partialTicks);
@Shadow private ShaderGroup theShaderGroup;
@Shadow private boolean useShader;
@Override
public void silent$loadShader(StaticResourceLocation location) {
this.loadShader(location.getLocation());
@ -161,6 +171,39 @@ public abstract class EntityRendererMixin implements EntityRendererExt {
}
}
@Inject(method = "updateCameraAndRender", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/shader" + "/Framebuffer;bindFramebuffer(Z)V", shift = At.Shift.BEFORE))
public void updateCameraAndRender(float partialTicks, long nanoTime, CallbackInfo ci) {
ShaderGroup colorSaturation = Client.getInstance().getModInstances().getColorSaturation().getShader();
if (colorSaturation != null) {
GlStateManager.matrixMode(5890);
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
colorSaturation.loadShaderGroup(partialTicks);
GlStateManager.popMatrix();
}
List<ShaderGroup> shaders = new ArrayList<ShaderGroup>();
if (this.theShaderGroup != null && this.useShader) {
shaders.add(this.theShaderGroup);
}
ShaderGroup motionBlur = MotionBlurUtils.instance.getShader();
if(Client.getInstance().getModInstances().getModByClass(NewMotionBlurMod.class).isEnabled() && !Client.getInstance().getModInstances().getModByClass(NewMotionBlurMod.class).isForceDisabled()) {
if (motionBlur != null){
shaders.add(motionBlur);
}
for (ShaderGroup shader : shaders){
GlStateManager.pushMatrix();
GlStateManager.loadIdentity();
shader.loadShaderGroup(partialTicks);
GlStateManager.popMatrix();
}
}
}
@Inject(method = "renderHand", at = @At("HEAD"))
public void swingProgress(float partialTicks, int xOffset, CallbackInfo ci) {
if(mc.thePlayer != null && Client.getInstance().getModInstances().getOldAnimationsMod().isEnabled() && Client.getInstance().getSettingsManager().getSettingByClass(AnimationsMod.class, "1.7 Punching Animation").getValBoolean()

View File

@ -0,0 +1,16 @@
package net.silentclient.client.mixin.mixins;
import net.minecraft.client.shader.Shader;
import net.minecraft.client.shader.ShaderGroup;
import net.silentclient.client.mods.util.IMixinShaderGroup;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Accessor;
import java.util.List;
@Mixin(ShaderGroup.class)
public abstract class ShaderGroupMixin implements IMixinShaderGroup {
@Override
@Accessor
public abstract List<Shader> getListShaders();
}

View File

@ -0,0 +1,26 @@
{
"targets": ["swap", "previous"],
"passes": [
{
"name": "sc_motionblur2",
"intarget": "minecraft:main",
"outtarget": "swap",
"auxtargets": [
{
"name": "PrevSampler",
"id": "previous"
}
]
},
{
"name": "blit",
"intarget": "swap",
"outtarget": "previous"
},
{
"name": "blit",
"intarget": "swap",
"outtarget": "minecraft:main"
}
]
}

View File

@ -0,0 +1,16 @@
#version 120
uniform sampler2D DiffuseSampler;
uniform sampler2D PrevSampler;
varying vec2 texCoord;
varying vec2 oneTexel;
uniform vec2 InSize;
uniform float BlurFactor;
void main() {
gl_FragColor = mix(texture2D(DiffuseSampler, texCoord), texture2D(PrevSampler, texCoord), BlurFactor);
gl_FragColor.w = 1.0;
}

View File

@ -0,0 +1,25 @@
{
"blend": {
"func": "add",
"srcrgb": "one",
"dstrgb": "zero"
},
"vertex": "sobel",
"fragment": "sc_motionblur2",
"attributes": ["Position"],
"samplers": [{ "name": "DiffuseSampler" }, { "name": "PrevSampler" }],
"uniforms": [
{
"name": "ProjMat",
"type": "matrix4x4",
"count": 16,
"values": [
1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0,
0.0, 1.0
]
},
{ "name": "InSize", "type": "float", "count": 2, "values": [1.0, 1.0] },
{ "name": "OutSize", "type": "float", "count": 2, "values": [1.0, 1.0] },
{ "name": "BlurFactor", "type": "float", "count": 1, "values": [0.3] }
]
}

View File

@ -37,6 +37,8 @@
"mixins.ModelBipedMixin",
"mixins.LoadingScreenRendererMixin",
"accessors.MinecraftAccessor",
"accessors.ItemFoodAccessor"
"accessors.ItemFoodAccessor",
"mixins.BlockGlassMixin",
"mixins.ShaderGroupMixin"
]
}