Skip to content

Commit

Permalink
removed blending options
Browse files Browse the repository at this point in the history
+ added opacity to affect splash plane but is broken
  • Loading branch information
Goby56 committed Apr 3, 2024
1 parent 21bf9a7 commit ecd54aa
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 100 deletions.
5 changes: 0 additions & 5 deletions src/main/java/com/goby56/wakes/config/WakesConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import com.goby56.wakes.WakesClient;
import com.goby56.wakes.config.enums.EffectSpawningRule;
import com.goby56.wakes.config.enums.Resolution;
import com.goby56.wakes.render.enums.BlendingFunction;
import com.goby56.wakes.render.enums.RenderType;
import com.goby56.wakes.render.enums.WakeColor;
import com.google.gson.Gson;
Expand Down Expand Up @@ -49,10 +48,6 @@ public class WakesConfig {
// Appearance
public Resolution wakeResolution = Resolution.SIXTEEN;
public float wakeOpacity = 1f;
public boolean useWaterBlending = true;
public BlendingFunction blendFunc = BlendingFunction.DEFAULT;
public GlStateManager.SrcFactor srcFactor = GlStateManager.SrcFactor.SRC_ALPHA;
public GlStateManager.DstFactor dstFactor = GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA;
public List<ColorInterval> colorIntervals = List.of(
new ColorInterval(WakeColor.TRANSPARENT, -50, -45),
new ColorInterval(WakeColor.DARK_GRAY, -45, -35),
Expand Down
38 changes: 3 additions & 35 deletions src/main/java/com/goby56/wakes/config/YACLIntegration.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.goby56.wakes.WakesClient;
import com.goby56.wakes.config.enums.EffectSpawningRule;
import com.goby56.wakes.config.enums.Resolution;
import com.goby56.wakes.render.enums.BlendingFunction;
import com.goby56.wakes.render.enums.RenderType;
import com.goby56.wakes.render.enums.WakeColor;
import com.goby56.wakes.simulation.WakeHandler;
Expand All @@ -12,29 +11,12 @@
import com.mojang.blaze3d.platform.GlStateManager;
import dev.isxander.yacl3.api.*;
import dev.isxander.yacl3.api.controller.*;
import net.minecraft.client.MinecraftClient;
import net.minecraft.client.gui.screen.Screen;
import net.minecraft.text.Text;

public class YACLIntegration {
public static Screen createScreen(Screen parent) {
WakesConfig config = WakesClient.CONFIG_INSTANCE;
boolean isUsingCustonBlendFunc = config.blendFunc == BlendingFunction.CUSTOM;
Option<Integer> wakeOpacityOption = optionOf(Integer.class, "wake_opacity", false)
.binding(100, () -> (int) (config.wakeOpacity * 100), val -> config.wakeOpacity = val / 100f)
.controller(opt -> integerSlider(opt, 0, 100))
.available(config.blendFunc.canVaryOpacity)
.build();
Option<GlStateManager.SrcFactor> srcFactorOption = optionOf(GlStateManager.SrcFactor.class, "src_factor", false)
.binding(GlStateManager.SrcFactor.SRC_ALPHA, () -> config.srcFactor, val -> config.srcFactor = val)
.controller(opt -> EnumControllerBuilder.create(opt)
.enumClass(GlStateManager.SrcFactor.class))
.build();
Option<GlStateManager.DstFactor> dstFactorOption = optionOf(GlStateManager.DstFactor.class, "dst_factor", false)
.binding(GlStateManager.DstFactor.ONE_MINUS_SRC_ALPHA, () -> config.dstFactor, val -> config.dstFactor = val)
.controller(opt -> EnumControllerBuilder.create(opt)
.enumClass(GlStateManager.DstFactor.class))
.build();
return YetAnotherConfigLib.createBuilder()
.title(WakesUtils.translatable("config", "title"))
.category(configCategory("basic")
Expand All @@ -45,21 +27,9 @@ public static Screen createScreen(Screen parent) {
.enumClass(Resolution.class)
.formatValue(val -> Text.of(val.toString())))
.build())
.option(wakeOpacityOption)
.option(optionOf(BlendingFunction.class, "blending_function", false)
.description(description("blending_function", new String[]{"default", "screen", "custom"})
.build())
.binding(BlendingFunction.DEFAULT, () -> config.blendFunc, val -> {
config.blendFunc = val;
// wakeOpacityOption.setAvailable(val.canVaryOpacity);
})
.controller(opt -> EnumControllerBuilder.create(opt)
.enumClass(BlendingFunction.class)
.formatValue(val -> WakesUtils.translatable("blending_function", val.name().toLowerCase())))
//.available(!MinecraftClient.isFabulousGraphicsOrBetter())
.build())
.option(booleanOption("use_water_blending", true)
.binding(true, () -> config.useWaterBlending, val -> config.useWaterBlending = val)
.option(optionOf(Integer.class, "wake_opacity", false)
.binding(100, () -> (int) (config.wakeOpacity * 100), val -> config.wakeOpacity = val / 100f)
.controller(opt -> integerSlider(opt, 0, 100))
.build())
.build())
.group(group("effect_spawning")
Expand Down Expand Up @@ -156,8 +126,6 @@ public static Screen createScreen(Screen parent) {
.option(booleanOption("disable_mod", false)
.binding(false, () -> config.disableMod, val -> config.disableMod = val)
.build())
.optionIf(isUsingCustonBlendFunc, srcFactorOption)
.optionIf(isUsingCustonBlendFunc, dstFactorOption)
.group(intervalGroup(0, WakeColor.TRANSPARENT, -50, -45))
.group(intervalGroup(1, WakeColor.DARK_GRAY, -45, -35))
.group(intervalGroup(2, WakeColor.GRAY, -35, -30))
Expand Down
16 changes: 5 additions & 11 deletions src/main/java/com/goby56/wakes/render/SplashPlaneRenderer.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.goby56.wakes.WakesClient;
import com.goby56.wakes.duck.ProducesWake;
import com.goby56.wakes.render.enums.BlendingFunction;
import com.goby56.wakes.render.enums.RenderType;
import com.goby56.wakes.utils.WakesUtils;
import com.mojang.blaze3d.systems.RenderSystem;
Expand Down Expand Up @@ -76,7 +75,6 @@ public static <T extends Entity> void render(T entity, float yaw, float tickDelt
RenderSystem.setShader(RenderType.getProgram());
RenderSystem.setShaderColor(1f, 1f, 1f, 1f);
RenderSystem.enableBlend();
BlendingFunction.applyBlendFunc();

matrices.push();
float velocity = (float) Math.floor(((ProducesWake) entity).getHorizontalVelocity() * 20) / 20f;
Expand All @@ -86,14 +84,10 @@ public static <T extends Entity> void render(T entity, float yaw, float tickDelt
Matrix4f matrix = matrices.peek().getPositionMatrix();

Vector3f color = new Vector3f();
if (WakesClient.CONFIG_INSTANCE.useWaterBlending) {
int waterCol = BiomeColors.getWaterColor(entity.getWorld(), entity.getBlockPos());
color.x = (float) (waterCol >> 16 & 0xFF) / 255f;
color.y = (float) (waterCol >> 8 & 0xFF) / 255f;
color.z = (float) (waterCol & 0xFF) / 255f;
} else {
color.set(1f, 1f, 1f);
}
int waterCol = BiomeColors.getWaterColor(entity.getWorld(), entity.getBlockPos());
color.x = (float) (waterCol >> 16 & 0xFF) / 255f;
color.y = (float) (waterCol >> 8 & 0xFF) / 255f;
color.z = (float) (waterCol & 0xFF) / 255f;

RenderSystem.setShaderTexture(0, tex.id);
tex.offsetPixels(animationFrame * tex.res, (int) (progress * (tex.outlineOffset - 1)) * tex.res);
Expand All @@ -120,7 +114,7 @@ private static void renderSurface(Matrix4f matrix, Vector3f color, int light) {
(float) (s * vertex.x * WakesClient.CONFIG_INSTANCE.splashPlaneWidth),
(float) (vertex.z * WakesClient.CONFIG_INSTANCE.splashPlaneHeight),
(float) (vertex.y * WakesClient.CONFIG_INSTANCE.splashPlaneDepth))
.color(color.x, color.y, color.z, 1f)
.color(color.x, color.y, color.z, WakesClient.CONFIG_INSTANCE.wakeOpacity)
.texture((float) (vertex.x / tex.width + tex.uvOffset.x), (float) (vertex.y / tex.height + tex.uvOffset.y))
.overlay(OverlayTexture.DEFAULT_UV)
.light(light)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.goby56.wakes.render;

import com.goby56.wakes.WakesClient;
import com.goby56.wakes.render.enums.BlendingFunction;
import com.goby56.wakes.simulation.WakeHandler;
import com.goby56.wakes.simulation.WakeNode;
import com.mojang.blaze3d.systems.RenderSystem;
Expand Down Expand Up @@ -29,8 +28,6 @@ public void afterTranslucent(WorldRenderContext context) {
RenderSystem.disableCull();
context.lightmapTextureManager().enable();

BlendingFunction.applyBlendFunc();

DynamicWakeTexture wakeTexture = DynamicWakeTexture.getInstance();

float x, y, z;
Expand All @@ -56,7 +53,7 @@ public void afterTranslucent(WorldRenderContext context) {

int waterCol = BiomeColors.getWaterColor(context.world(), node.blockPos());
int light = WorldRenderer.getLightmapCoordinates(context.world(), node.blockPos());
float a = (float) ((-Math.pow(node.t, 2) + 1) * Math.pow(WakesClient.CONFIG_INSTANCE.wakeOpacity, WakesClient.CONFIG_INSTANCE.blendFunc.canVaryOpacity ? 1 : 0));
float a = (float) ((-Math.pow(node.t, 2) + 1) * WakesClient.CONFIG_INSTANCE.wakeOpacity);

wakeTexture.populatePixels(node, distance, waterCol, a);

Expand All @@ -70,7 +67,6 @@ public void afterTranslucent(WorldRenderContext context) {
renderingTime += System.nanoTime() - t3;
}

RenderSystem.defaultBlendFunc();
RenderSystem.enableCull();

fullTime = System.nanoTime() - t1;
Expand Down
44 changes: 0 additions & 44 deletions src/main/java/com/goby56/wakes/render/enums/BlendingFunction.java

This file was deleted.

0 comments on commit ecd54aa

Please sign in to comment.