Posted September 28, 20222 yr How to get DeltaTime variable? I tried to take one from the Minecraft instance and multiply by 3 (because the default is not 60 but 20 fps). This works, except that with shaders the variable becomes several times larger and the animations become too fast. Edited September 28, 20222 yr by FoxBox
September 28, 20222 yr Minecraft uses what's known as a partialTick which is some value between 0-1 that represents the frames between the previous tick and the current tick. Typically, you would have the original position and the new position, and then linearly interpolate using the partialTick (usually via `Mth#lerp`). The partialTick is provided in nearly all rendering methods as a float.
September 28, 20222 yr Author Is it possible to add custom calculation of the usual Delta Time, which will work fine both with and without shaders?
September 28, 20222 yr Author I tried to do it like this, but with shaders the animations are 2x faster.. private static long LAST_TIME = 0; public static float DELTA_TIME = 0; @SubscribeEvent public static void onRenderTick(TickEvent.RenderTickEvent event) { if (event.phase == TickEvent.Phase.START) { final long time = Util.getNanos(); DELTA_TIME = (time - LAST_TIME) / 16666666F; LAST_TIME = time; } } Edited September 30, 20222 yr by FoxBox
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.