mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-02-22 09:55:33 +01:00
Add options uniform
This commit is contained in:
parent
ef2f2268cc
commit
56d03601cd
6 changed files with 113 additions and 6 deletions
|
@ -0,0 +1,61 @@
|
||||||
|
package com.jozufozu.flywheel.backend.engine.uniform;
|
||||||
|
|
||||||
|
import org.lwjgl.system.MemoryUtil;
|
||||||
|
|
||||||
|
import net.minecraft.client.Minecraft;
|
||||||
|
import net.minecraft.client.Options;
|
||||||
|
|
||||||
|
public class OptionsUniforms implements UniformProvider {
|
||||||
|
public static final int SIZE = 4 * 14;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int byteSize() {
|
||||||
|
return SIZE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(long ptr) {
|
||||||
|
Options options = Minecraft.getInstance().options;
|
||||||
|
|
||||||
|
MemoryUtil.memPutFloat(ptr, options.gamma().get().floatValue());
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutInt(ptr, options.fov().get());
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutFloat(ptr, options.screenEffectScale().get().floatValue());
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutFloat(ptr, options.glintSpeed().get().floatValue());
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutFloat(ptr, options.glintStrength().get().floatValue());
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutInt(ptr, options.biomeBlendRadius().get());
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutInt(ptr, options.ambientOcclusion().get() ? 1 : 0);
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutInt(ptr, options.bobView().get() ? 1 : 0);
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutInt(ptr, options.highContrast().get() ? 1 : 0);
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutFloat(ptr, options.textBackgroundOpacity().get().floatValue());
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutInt(ptr, options.backgroundForChatOnly().get() ? 1 : 0);
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutFloat(ptr, options.darknessEffectScale().get().floatValue());
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutFloat(ptr, options.damageTiltStrength().get().floatValue());
|
||||||
|
ptr += 4;
|
||||||
|
|
||||||
|
MemoryUtil.memPutInt(ptr, options.hideLightningFlash().get() ? 1 : 0);
|
||||||
|
}
|
||||||
|
}
|
|
@ -5,11 +5,14 @@ import com.jozufozu.flywheel.api.event.RenderContext;
|
||||||
import com.jozufozu.flywheel.backend.gl.GlStateTracker;
|
import com.jozufozu.flywheel.backend.gl.GlStateTracker;
|
||||||
import com.jozufozu.flywheel.config.DebugMode;
|
import com.jozufozu.flywheel.config.DebugMode;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class Uniforms {
|
public class Uniforms {
|
||||||
public static boolean frustumPaused = false;
|
public static boolean frustumPaused = false;
|
||||||
public static boolean frustumCapture = false;
|
public static boolean frustumCapture = false;
|
||||||
private static UniformBuffer<FrameUniforms> frame;
|
private static @Nullable UniformBuffer<FrameUniforms> frame;
|
||||||
private static UniformBuffer<FogUniforms> fog;
|
private static @Nullable UniformBuffer<FogUniforms> fog;
|
||||||
|
private static @Nullable UniformBuffer<OptionsUniforms> options;
|
||||||
|
|
||||||
public static UniformBuffer<FrameUniforms> frame() {
|
public static UniformBuffer<FrameUniforms> frame() {
|
||||||
if (frame == null) {
|
if (frame == null) {
|
||||||
|
@ -25,9 +28,17 @@ public class Uniforms {
|
||||||
return fog;
|
return fog;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static UniformBuffer<OptionsUniforms> options() {
|
||||||
|
if (options == null) {
|
||||||
|
options = new UniformBuffer<>(2, new OptionsUniforms());
|
||||||
|
}
|
||||||
|
return options;
|
||||||
|
}
|
||||||
|
|
||||||
public static void bindForDraw() {
|
public static void bindForDraw() {
|
||||||
bindFrame();
|
bindFrame();
|
||||||
bindFog();
|
bindFog();
|
||||||
|
bindOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bindFrame() {
|
public static void bindFrame() {
|
||||||
|
@ -42,6 +53,12 @@ public class Uniforms {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void bindOptions() {
|
||||||
|
if (options != null) {
|
||||||
|
options.bind();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static void onFogUpdate() {
|
public static void onFogUpdate() {
|
||||||
try (var restoreState = GlStateTracker.getRestoreState()) {
|
try (var restoreState = GlStateTracker.getRestoreState()) {
|
||||||
fog().update();
|
fog().update();
|
||||||
|
@ -52,6 +69,8 @@ public class Uniforms {
|
||||||
var ubo = frame();
|
var ubo = frame();
|
||||||
ubo.provider.setContext(ctx);
|
ubo.provider.setContext(ctx);
|
||||||
ubo.update();
|
ubo.update();
|
||||||
|
|
||||||
|
options();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDebugMode(DebugMode mode) {
|
public static void setDebugMode(DebugMode mode) {
|
||||||
|
@ -68,5 +87,10 @@ public class Uniforms {
|
||||||
fog.delete();
|
fog.delete();
|
||||||
fog = null;
|
fog = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (options != null) {
|
||||||
|
options.delete();
|
||||||
|
options = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "flywheel:internal/material.glsl"
|
#include "flywheel:internal/material.glsl"
|
||||||
#include "flywheel:internal/uniforms/frame.glsl"
|
#include "flywheel:internal/uniforms/uniforms.glsl"
|
||||||
#include "flywheel:internal/uniforms/fog.glsl"
|
|
||||||
|
|
||||||
in vec4 flw_vertexPos;
|
in vec4 flw_vertexPos;
|
||||||
in vec4 flw_vertexColor;
|
in vec4 flw_vertexColor;
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
#include "flywheel:internal/material.glsl"
|
#include "flywheel:internal/material.glsl"
|
||||||
#include "flywheel:internal/uniforms/frame.glsl"
|
#include "flywheel:internal/uniforms/uniforms.glsl"
|
||||||
#include "flywheel:internal/uniforms/fog.glsl"
|
|
||||||
|
|
||||||
// TODO: can we combine some of these internally to use fewer in/out slots?
|
// TODO: can we combine some of these internally to use fewer in/out slots?
|
||||||
out vec4 flw_vertexPos;
|
out vec4 flw_vertexPos;
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// options.glsl - Houses uniforms for many of the game's settings, focusing on video and accessibility settings.
|
||||||
|
|
||||||
|
layout(std140) uniform _FlwOptionsUniforms {
|
||||||
|
float flw_brightnessOption;
|
||||||
|
uint flw_fovOption;
|
||||||
|
float flw_distortionOption;
|
||||||
|
float flw_glintSpeedOption;
|
||||||
|
float flw_glintStrengthOption;
|
||||||
|
uint flw_biomeBlendOption;
|
||||||
|
uint flw_smoothLightingOption;
|
||||||
|
uint flw_viewBobbingOption;
|
||||||
|
|
||||||
|
uint flw_highContrastOption;
|
||||||
|
float flw_textBackgroundOpacityOption;
|
||||||
|
uint flw_textBackgroundForChatOnlyOption;
|
||||||
|
float flw_darknessPulsingOption;
|
||||||
|
float flw_damageTiltOption;
|
||||||
|
uint hideLightningFlashesOption;
|
||||||
|
};
|
|
@ -0,0 +1,5 @@
|
||||||
|
// uniforms.glsl - Includes common uniforms.
|
||||||
|
|
||||||
|
#include "flywheel:internal/uniforms/frame.glsl"
|
||||||
|
#include "flywheel:internal/uniforms/fog.glsl"
|
||||||
|
#include "flywheel:internal/uniforms/options.glsl"
|
Loading…
Add table
Reference in a new issue