mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-11-15 06:54:21 +01:00
Finish adding most view.h things to frame.glsl
This commit is contained in:
parent
9f1c722474
commit
87c914100e
@ -16,11 +16,17 @@ import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Camera;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
import net.minecraft.core.BlockPos;
|
||||
import net.minecraft.core.Vec3i;
|
||||
import net.minecraft.tags.FluidTags;
|
||||
import net.minecraft.world.level.Level;
|
||||
import net.minecraft.world.level.block.Blocks;
|
||||
import net.minecraft.world.level.block.state.BlockState;
|
||||
import net.minecraft.world.level.material.FluidState;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
public class FrameUniforms implements UniformProvider {
|
||||
public static final int SIZE = 304;
|
||||
public static final int SIZE = 1188;
|
||||
public int debugMode;
|
||||
|
||||
@Nullable
|
||||
@ -123,11 +129,19 @@ public class FrameUniforms implements UniformProvider {
|
||||
MemoryUtil.memPutFloat(ptr, Math.max(2.5F, (float) window.getWidth() / 1920.0F * 2.5F));
|
||||
ptr += 4;
|
||||
|
||||
MemoryUtil.memPutFloat(ptr, (float) window.getWidth() / (float) window.getHeight());
|
||||
ptr += 4;
|
||||
|
||||
MemoryUtil.memPutFloat(ptr, Minecraft.getInstance().gameRenderer.getDepthFar());
|
||||
ptr += 4;
|
||||
|
||||
MemoryUtil.memPutInt(ptr, getConstantAmbientLightFlag(context));
|
||||
ptr += 4;
|
||||
|
||||
ptr = writeTime(ptr);
|
||||
|
||||
ptr = writeCameraIn(ptr);
|
||||
|
||||
MemoryUtil.memPutInt(ptr, debugMode);
|
||||
|
||||
lastInit = true;
|
||||
@ -195,6 +209,45 @@ public class FrameUniforms implements UniformProvider {
|
||||
return ptr + 16;
|
||||
}
|
||||
|
||||
private long writeCameraIn(long ptr) {
|
||||
Camera camera = context.camera();
|
||||
if (!camera.isInitialized()) {
|
||||
MemoryUtil.memPutInt(ptr, 0);
|
||||
MemoryUtil.memPutInt(ptr + 4, 0);
|
||||
return ptr + 8;
|
||||
}
|
||||
Level level = camera.getEntity().level();
|
||||
BlockPos blockPos = camera.getBlockPosition();
|
||||
Vec3 cameraPos = camera.getPosition();
|
||||
FluidState fState = level.getFluidState(blockPos);
|
||||
BlockState bState = level.getBlockState(blockPos);
|
||||
float height = fState.getHeight(level, blockPos);
|
||||
|
||||
if (fState.isEmpty()) {
|
||||
MemoryUtil.memPutInt(ptr, 0);
|
||||
} else if (cameraPos.y < blockPos.getY() + height) {
|
||||
if (fState.is(FluidTags.WATER)) {
|
||||
MemoryUtil.memPutInt(ptr, 1);
|
||||
} else if (fState.is(FluidTags.LAVA)) {
|
||||
MemoryUtil.memPutInt(ptr, 2);
|
||||
} else {
|
||||
MemoryUtil.memPutInt(ptr, -1);
|
||||
}
|
||||
}
|
||||
|
||||
if (bState.isAir()) {
|
||||
MemoryUtil.memPutInt(ptr + 4, 0);
|
||||
} else {
|
||||
if (bState.is(Blocks.POWDER_SNOW)) {
|
||||
MemoryUtil.memPutInt(ptr + 4, 0);
|
||||
} else {
|
||||
MemoryUtil.memPutInt(ptr + 4, -1);
|
||||
}
|
||||
}
|
||||
|
||||
return ptr + 8;
|
||||
}
|
||||
|
||||
private static long writeVec3(long ptr, float camX, float camY, float camZ) {
|
||||
MemoryUtil.memPutFloat(ptr, camX);
|
||||
MemoryUtil.memPutFloat(ptr + 4, camY);
|
||||
|
@ -38,6 +38,8 @@ layout(std140) uniform _FlwFrameUniforms {
|
||||
|
||||
vec2 flw_viewportSize;
|
||||
float flw_defaultLineWidth;
|
||||
float flw_aspectRatio;
|
||||
float flw_viewDistance;
|
||||
|
||||
uint flw_constantAmbientLight;
|
||||
|
||||
@ -47,6 +49,9 @@ layout(std140) uniform _FlwFrameUniforms {
|
||||
float flw_renderTicks;
|
||||
float flw_renderSeconds;
|
||||
|
||||
uint flw_cameraInFluid;
|
||||
uint flw_cameraInBlock;
|
||||
|
||||
uint _flw_debugMode;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user