mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 07:26:48 +01:00
Finally room to breathe
- Expand packed overlay_light attribute into components - Make light a short backed vec2 - Divide light input by 256 directly instead of discarding lower bits - Remove debug overlay enum, instead only use OVERRIDE - Add overlay debug mode
This commit is contained in:
parent
a504aa1862
commit
d6abe89828
13 changed files with 25 additions and 48 deletions
|
@ -19,7 +19,8 @@ public final class InternalVertex {
|
||||||
.vector("position", FloatRepr.FLOAT, 3)
|
.vector("position", FloatRepr.FLOAT, 3)
|
||||||
.vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4)
|
.vector("color", FloatRepr.NORMALIZED_UNSIGNED_BYTE, 4)
|
||||||
.vector("tex", FloatRepr.FLOAT, 2)
|
.vector("tex", FloatRepr.FLOAT, 2)
|
||||||
.vector("overlay_light", IntegerRepr.SHORT, 4)
|
.vector("overlay", IntegerRepr.SHORT, 2)
|
||||||
|
.vector("light", FloatRepr.UNSIGNED_SHORT, 2)
|
||||||
.vector("normal", FloatRepr.NORMALIZED_BYTE, 3)
|
.vector("normal", FloatRepr.NORMALIZED_BYTE, 3)
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
|
|
|
@ -54,8 +54,9 @@ public class PipelineCompiler {
|
||||||
program.bindAttribLocation("_flw_a_pos", 0);
|
program.bindAttribLocation("_flw_a_pos", 0);
|
||||||
program.bindAttribLocation("_flw_a_color", 1);
|
program.bindAttribLocation("_flw_a_color", 1);
|
||||||
program.bindAttribLocation("_flw_a_texCoord", 2);
|
program.bindAttribLocation("_flw_a_texCoord", 2);
|
||||||
program.bindAttribLocation("_flw_a_overlay_light", 3);
|
program.bindAttribLocation("_flw_a_overlay", 3);
|
||||||
program.bindAttribLocation("_flw_a_normal", 4);
|
program.bindAttribLocation("_flw_a_light", 4);
|
||||||
|
program.bindAttribLocation("_flw_a_normal", 5);
|
||||||
})
|
})
|
||||||
.postLink((key, program) -> {
|
.postLink((key, program) -> {
|
||||||
program.setUniformBlockBinding("_FlwFrameUniforms", 0);
|
program.setUniformBlockBinding("_FlwFrameUniforms", 0);
|
||||||
|
|
|
@ -16,7 +16,6 @@ import net.minecraft.world.phys.Vec3;
|
||||||
public class FrameUniforms implements UniformProvider {
|
public class FrameUniforms implements UniformProvider {
|
||||||
public static final int SIZE = 304;
|
public static final int SIZE = 304;
|
||||||
public int debugMode;
|
public int debugMode;
|
||||||
public int debugOverlay;
|
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private RenderContext context;
|
private RenderContext context;
|
||||||
|
@ -75,7 +74,6 @@ public class FrameUniforms implements UniformProvider {
|
||||||
ptr = writeTime(ptr);
|
ptr = writeTime(ptr);
|
||||||
|
|
||||||
MemoryUtil.memPutInt(ptr, debugMode);
|
MemoryUtil.memPutInt(ptr, debugMode);
|
||||||
MemoryUtil.memPutInt(ptr + 4, debugOverlay);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private long writeMatrices(long ptr) {
|
private long writeMatrices(long ptr) {
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.jozufozu.flywheel.api.event.ReloadLevelRendererEvent;
|
||||||
import com.jozufozu.flywheel.api.event.RenderContext;
|
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 com.jozufozu.flywheel.config.DebugOverlay;
|
|
||||||
|
|
||||||
public class Uniforms {
|
public class Uniforms {
|
||||||
public static boolean frustumPaused = false;
|
public static boolean frustumPaused = false;
|
||||||
|
@ -55,9 +54,8 @@ public class Uniforms {
|
||||||
ubo.update();
|
ubo.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDebugMode(DebugMode mode, DebugOverlay visual) {
|
public static void setDebugMode(DebugMode mode) {
|
||||||
frame().provider.debugMode = mode.ordinal();
|
frame().provider.debugMode = mode.ordinal();
|
||||||
frame().provider.debugOverlay = visual.ordinal();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void onReloadLevelRenderer(ReloadLevelRendererEvent event) {
|
public static void onReloadLevelRenderer(ReloadLevelRendererEvent event) {
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
package com.jozufozu.flywheel.config;
|
package com.jozufozu.flywheel.config;
|
||||||
|
|
||||||
public enum DebugMode {
|
public enum DebugMode {
|
||||||
NONE,
|
OFF,
|
||||||
NORMALS,
|
NORMALS,
|
||||||
INSTANCE_ID,
|
INSTANCE_ID,
|
||||||
LIGHT,
|
LIGHT,
|
||||||
|
OVERLAY,
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +0,0 @@
|
||||||
package com.jozufozu.flywheel.config;
|
|
||||||
|
|
||||||
public enum DebugOverlay {
|
|
||||||
NONE,
|
|
||||||
MUL,
|
|
||||||
OVERRIDE,
|
|
||||||
}
|
|
|
@ -110,22 +110,10 @@ public class FlwCommands {
|
||||||
|
|
||||||
DebugMode mode = context.getArgument("mode", DebugMode.class);
|
DebugMode mode = context.getArgument("mode", DebugMode.class);
|
||||||
|
|
||||||
Uniforms.setDebugMode(mode, DebugOverlay.OVERRIDE);
|
Uniforms.setDebugMode(mode);
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
return Command.SINGLE_SUCCESS;
|
||||||
})
|
})));
|
||||||
.then(Commands.argument("overlay", EnumArgument.enumArgument(DebugOverlay.class))
|
|
||||||
.executes(context -> {
|
|
||||||
LocalPlayer player = Minecraft.getInstance().player;
|
|
||||||
if (player == null) return 0;
|
|
||||||
|
|
||||||
DebugMode mode = context.getArgument("mode", DebugMode.class);
|
|
||||||
DebugOverlay visual = context.getArgument("overlay", DebugOverlay.class);
|
|
||||||
|
|
||||||
Uniforms.setDebugMode(mode, visual);
|
|
||||||
|
|
||||||
return Command.SINGLE_SUCCESS;
|
|
||||||
}))));
|
|
||||||
|
|
||||||
command.then(Commands.literal("crumbling")
|
command.then(Commands.literal("crumbling")
|
||||||
.then(Commands.argument("pos", BlockPosArgument.blockPos())
|
.then(Commands.argument("pos", BlockPosArgument.blockPos())
|
||||||
|
|
|
@ -21,6 +21,7 @@ import com.jozufozu.flywheel.lib.visual.InstanceRecycler;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
import net.minecraft.client.renderer.LightTexture;
|
import net.minecraft.client.renderer.LightTexture;
|
||||||
|
import net.minecraft.client.renderer.texture.OverlayTexture;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.BlockPos.MutableBlockPos;
|
import net.minecraft.core.BlockPos.MutableBlockPos;
|
||||||
import net.minecraft.core.Direction.Axis;
|
import net.minecraft.core.Direction.Axis;
|
||||||
|
@ -266,6 +267,7 @@ public class ShadowComponent implements EntityComponent {
|
||||||
vertexList.u(i, 0);
|
vertexList.u(i, 0);
|
||||||
vertexList.v(i, 0);
|
vertexList.v(i, 0);
|
||||||
vertexList.light(i, LightTexture.FULL_BRIGHT);
|
vertexList.light(i, LightTexture.FULL_BRIGHT);
|
||||||
|
vertexList.overlay(i, OverlayTexture.NO_OVERLAY);
|
||||||
vertexList.normalX(i, 0);
|
vertexList.normalX(i, 0);
|
||||||
vertexList.normalY(i, 1);
|
vertexList.normalY(i, 1);
|
||||||
vertexList.normalZ(i, 0);
|
vertexList.normalZ(i, 0);
|
||||||
|
|
|
@ -7,5 +7,6 @@ void flw_instanceVertex(in FlwInstance i) {
|
||||||
flw_vertexTexCoord = (flw_vertexPos.xz - i.entityPosXZ) * 0.5 / i.radius + 0.5;
|
flw_vertexTexCoord = (flw_vertexPos.xz - i.entityPosXZ) * 0.5 / i.radius + 0.5;
|
||||||
|
|
||||||
flw_vertexColor.a = i.alpha;
|
flw_vertexColor.a = i.alpha;
|
||||||
|
// no overlay
|
||||||
flw_vertexOverlay = ivec2(0, 10);
|
flw_vertexOverlay = ivec2(0, 10);
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,13 +38,9 @@ void _flw_main() {
|
||||||
|
|
||||||
if (flw_material.useOverlay) {
|
if (flw_material.useOverlay) {
|
||||||
// Need to clamp the overlay texture coords to sane coordinates because integer vertex attributes explode on
|
// Need to clamp the overlay texture coords to sane coordinates because integer vertex attributes explode on
|
||||||
// some drivers for some draw calls.
|
// some drivers for some draw calls. This should only effect instances that don't write to overlay, but
|
||||||
// This can be removed once instancing uses sampler buffers, though
|
// the internal vertex format is unfortunately subject to these issues.
|
||||||
// we may need a solution for the internal vertex format. Perhaps
|
vec4 overlayColor = texelFetch(_flw_overlayTex, clamp(flw_fragOverlay, 0, 10), 0);
|
||||||
// pass as floats and convert to integers in the shader?
|
|
||||||
ivec2 actualCoord = clamp(flw_fragOverlay, 0, 10);
|
|
||||||
|
|
||||||
vec4 overlayColor = texelFetch(_flw_overlayTex, actualCoord, 0);
|
|
||||||
color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a);
|
color.rgb = mix(overlayColor.rgb, color.rgb, overlayColor.a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,13 +53,8 @@ void _flw_main() {
|
||||||
discard;
|
discard;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (_flw_debugOverlay) {
|
if (_flw_debugMode != 0u) {
|
||||||
case 1u:
|
color = _flw_debugColor;
|
||||||
color *= _flw_debugColor;
|
|
||||||
break;
|
|
||||||
case 2u:
|
|
||||||
color = _flw_debugColor;
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
_flw_outputColor = flw_fogFilter(color);
|
_flw_outputColor = flw_fogFilter(color);
|
||||||
|
|
|
@ -49,5 +49,8 @@ void _flw_main(in FlwInstance instance, in uint stableInstanceID) {
|
||||||
case 3u:
|
case 3u:
|
||||||
_flw_debugColor = vec4(vec2((flw_vertexLight * 15.0 + 0.5) / 16.), 0., 1.);
|
_flw_debugColor = vec4(vec2((flw_vertexLight * 15.0 + 0.5) / 16.), 0., 1.);
|
||||||
break;
|
break;
|
||||||
|
case 4u:
|
||||||
|
_flw_debugColor = vec4(flw_vertexOverlay / 16., 0., 1.);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,7 +31,6 @@ layout(std140) uniform _FlwFrameUniforms {
|
||||||
float flw_renderSeconds;
|
float flw_renderSeconds;
|
||||||
|
|
||||||
uint _flw_debugMode;
|
uint _flw_debugMode;
|
||||||
uint _flw_debugOverlay;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define flw_cameraPos _flw_cameraPos.xyz
|
#define flw_cameraPos _flw_cameraPos.xyz
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
in vec3 _flw_a_pos;
|
in vec3 _flw_a_pos;
|
||||||
in vec4 _flw_a_color;
|
in vec4 _flw_a_color;
|
||||||
in vec2 _flw_a_texCoord;
|
in vec2 _flw_a_texCoord;
|
||||||
in ivec4 _flw_a_overlay_light;
|
in ivec2 _flw_a_overlay;
|
||||||
|
in vec2 _flw_a_light;
|
||||||
in vec3 _flw_a_normal;
|
in vec3 _flw_a_normal;
|
||||||
|
|
||||||
void _flw_layoutVertex() {
|
void _flw_layoutVertex() {
|
||||||
flw_vertexPos = vec4(_flw_a_pos, 1.0);
|
flw_vertexPos = vec4(_flw_a_pos, 1.0);
|
||||||
flw_vertexColor = _flw_a_color;
|
flw_vertexColor = _flw_a_color;
|
||||||
flw_vertexTexCoord = _flw_a_texCoord;
|
flw_vertexTexCoord = _flw_a_texCoord;
|
||||||
flw_vertexOverlay = _flw_a_overlay_light.xy;
|
flw_vertexOverlay = _flw_a_overlay;
|
||||||
flw_vertexLight = (_flw_a_overlay_light.zw >> 4) / 15.0;
|
flw_vertexLight = _flw_a_light / 256.0;
|
||||||
flw_vertexNormal = _flw_a_normal;
|
flw_vertexNormal = _flw_a_normal;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue