Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 96bce7f38d | |||
| 4e7c027ec0 | |||
| 9be1fd8f6b | |||
| 0fae99c535 | |||
| 9f51c59508 | |||
| 6024227716 | |||
| 69013c2124 | |||
| 3b070a7efc | |||
| 646577e97f |
@@ -12,6 +12,7 @@ import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||
import com.replaymod.replaystudio.pathing.path.Path;
|
||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||
import com.replaymod.pathing.properties.FovProperty;
|
||||
import de.johni0702.minecraft.gui.utils.EventRegistrations;
|
||||
import net.minecraft.client.MinecraftClient;
|
||||
import net.minecraft.client.render.RenderTickCounter;
|
||||
@@ -114,6 +115,7 @@ public abstract class AbstractTimelinePlayer extends EventRegistrations {
|
||||
if (wasAsyncMode) {
|
||||
replayHandler.getReplaySender().setAsyncMode(true);
|
||||
}
|
||||
FovProperty.currentOverride = null;
|
||||
unregister();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.replaymod.pathing.properties;
|
||||
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.replaymod.replaystudio.pathing.property.AbstractProperty;
|
||||
import com.replaymod.replaystudio.pathing.property.PropertyPart;
|
||||
import com.replaymod.replaystudio.pathing.property.PropertyParts;
|
||||
import de.johni0702.minecraft.gui.utils.NonNull;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class FovProperty extends AbstractProperty<Triple<Float, Float, Float>> {
|
||||
public static final float DEFAULT_FOV = 70.0f;
|
||||
|
||||
public static volatile Float currentOverride = null;
|
||||
|
||||
public static final FovProperty FOV = new FovProperty("fov", DEFAULT_FOV);
|
||||
|
||||
public final PropertyPart<Triple<Float, Float, Float>> VALUE =
|
||||
new PropertyParts.ForFloatTriple(this, true, PropertyParts.TripleElement.LEFT);
|
||||
|
||||
private FovProperty(String id, float defaultValue) {
|
||||
super(id, "replaymod.gui.editkeyframe." + id, null, Triple.of(defaultValue, 0f, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PropertyPart<Triple<Float, Float, Float>>> getParts() {
|
||||
return Collections.singletonList(VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToGame(Triple<Float, Float, Float> value, @NonNull Object replayHandler) {
|
||||
currentOverride = value.getLeft();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toJson(JsonWriter writer, Triple<Float, Float, Float> value) throws IOException {
|
||||
writer.value(value.getLeft());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Triple<Float, Float, Float> fromJson(JsonReader reader) throws IOException {
|
||||
return Triple.of((float) reader.nextDouble(), 0f, 0f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.replaymod.pathing.properties;
|
||||
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import com.replaymod.replaystudio.pathing.property.AbstractProperty;
|
||||
import com.replaymod.replaystudio.pathing.property.PropertyPart;
|
||||
import com.replaymod.replaystudio.pathing.property.PropertyParts;
|
||||
import de.johni0702.minecraft.gui.utils.NonNull;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
|
||||
public class LensProperties extends AbstractProperty<Triple<Float, Float, Float>> {
|
||||
public static final float DEFAULT_FOCAL_DISTANCE = 5.0f;
|
||||
public static final float DEFAULT_APERTURE_RADIUS = 0.05f;
|
||||
|
||||
public static final LensProperties FOCAL_DISTANCE = new LensProperties("focalDistance", DEFAULT_FOCAL_DISTANCE);
|
||||
public static final LensProperties APERTURE_RADIUS = new LensProperties("apertureRadius", DEFAULT_APERTURE_RADIUS);
|
||||
|
||||
public final PropertyPart<Triple<Float, Float, Float>> VALUE =
|
||||
new PropertyParts.ForFloatTriple(this, true, PropertyParts.TripleElement.LEFT);
|
||||
|
||||
private LensProperties(String id, float defaultValue) {
|
||||
super(id, "replaymod.gui.editkeyframe." + id, null, Triple.of(defaultValue, 0f, 0f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PropertyPart<Triple<Float, Float, Float>>> getParts() {
|
||||
return Collections.singletonList(VALUE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void applyToGame(Triple<Float, Float, Float> value, @NonNull Object replayHandler) {}
|
||||
|
||||
@Override
|
||||
public void toJson(JsonWriter writer, Triple<Float, Float, Float> value) throws IOException {
|
||||
writer.value(value.getLeft());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Triple<Float, Float, Float> fromJson(JsonReader reader) throws IOException {
|
||||
return Triple.of((float) reader.nextDouble(), 0f, 0f);
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ import static com.replaymod.render.ReplayModRender.LOGGER;
|
||||
|
||||
public class RenderSettings {
|
||||
public enum RenderMethod {
|
||||
DEFAULT, STEREOSCOPIC, CUBIC, EQUIRECTANGULAR, ODS, BLEND;
|
||||
DEFAULT, REALLENS, STEREOSCOPIC, CUBIC, EQUIRECTANGULAR, ODS, BLEND;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
@@ -155,6 +155,9 @@ public class RenderSettings {
|
||||
private final boolean depthMap;
|
||||
private final boolean cameraPathExport;
|
||||
private final AntiAliasing antiAliasing;
|
||||
private final int lensBlurSamples;
|
||||
private final int motionBlurSubframes;
|
||||
private final float shutterAngle;
|
||||
|
||||
private final String exportCommand;
|
||||
// We switched from rgb24 to bgra for performance at one point, so for backwards compatibility we need to
|
||||
@@ -189,6 +192,9 @@ public class RenderSettings {
|
||||
false,
|
||||
false,
|
||||
RenderSettings.AntiAliasing.NONE,
|
||||
16,
|
||||
1,
|
||||
180f,
|
||||
"",
|
||||
RenderSettings.EncodingPreset.MP4_CUSTOM.getValue(),
|
||||
false
|
||||
@@ -215,6 +221,9 @@ public class RenderSettings {
|
||||
boolean depthMap,
|
||||
boolean cameraPathExport,
|
||||
AntiAliasing antiAliasing,
|
||||
int lensBlurSamples,
|
||||
int motionBlurSubframes,
|
||||
float shutterAngle,
|
||||
String exportCommand,
|
||||
String exportArguments,
|
||||
boolean highPerformance
|
||||
@@ -238,6 +247,9 @@ public class RenderSettings {
|
||||
this.depthMap = depthMap;
|
||||
this.cameraPathExport = cameraPathExport;
|
||||
this.antiAliasing = antiAliasing;
|
||||
this.lensBlurSamples = lensBlurSamples;
|
||||
this.motionBlurSubframes = motionBlurSubframes;
|
||||
this.shutterAngle = shutterAngle;
|
||||
this.exportCommand = exportCommand;
|
||||
this.exportArguments = exportArguments;
|
||||
this.highPerformance = highPerformance;
|
||||
@@ -264,6 +276,9 @@ public class RenderSettings {
|
||||
depthMap,
|
||||
cameraPathExport,
|
||||
antiAliasing,
|
||||
lensBlurSamples,
|
||||
motionBlurSubframes,
|
||||
shutterAngle,
|
||||
exportCommand,
|
||||
exportArguments,
|
||||
highPerformance
|
||||
@@ -457,6 +472,12 @@ public class RenderSettings {
|
||||
return antiAliasing;
|
||||
}
|
||||
|
||||
public int getLensBlurSamples() { return lensBlurSamples; }
|
||||
|
||||
public int getMotionBlurSubframes() { return motionBlurSubframes; }
|
||||
|
||||
public float getShutterAngle() { return shutterAngle; }
|
||||
|
||||
public String getExportCommand() {
|
||||
return exportCommand;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,194 @@
|
||||
package com.replaymod.render.capturer;
|
||||
|
||||
import com.replaymod.render.frame.OpenGlFrame;
|
||||
import com.replaymod.render.frame.RealLensOpenGlFrame;
|
||||
import com.replaymod.render.rendering.Channel;
|
||||
|
||||
import com.replaymod.replaystudio.pathing.path.Path;
|
||||
import com.replaymod.simplepathing.ReplayModSimplePathing;
|
||||
import com.replaymod.pathing.properties.LensProperties;
|
||||
|
||||
import com.replaymod.render.RenderSettings;
|
||||
import com.replaymod.render.utils.ByteBufferPool;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replay.ReplayModReplay;
|
||||
import com.replaymod.replaystudio.pathing.path.Timeline;
|
||||
import com.replaymod.simplepathing.SPTimeline;
|
||||
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import java.util.concurrent.ThreadLocalRandom;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||
|
||||
public class RealLensOpenGlFrameCapturer
|
||||
extends OpenGlFrameCapturer<RealLensOpenGlFrame, RealLensOpenGlFrameCapturer.Data> {
|
||||
|
||||
public static class Data implements CaptureData {
|
||||
|
||||
public float dx, dy, dz;
|
||||
public float yaw, pitch;
|
||||
|
||||
public Data(float dx, float dy, float dz,
|
||||
float yaw, float pitch) {
|
||||
this.dx = dx;
|
||||
this.dy = dy;
|
||||
this.dz = dz;
|
||||
this.yaw = yaw;
|
||||
this.pitch = pitch;
|
||||
}
|
||||
}
|
||||
|
||||
private static Data[] golden_disk(int n, float r) {
|
||||
|
||||
Data[] points = new Data[n];
|
||||
|
||||
final float GOLDEN_ANGLE = (float) (Math.PI * (3.0 - Math.sqrt(5.0)));
|
||||
|
||||
float random_offset = (float) Math.sqrt(r*r/n) * 0.0f;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
float rr = r * (float) Math.sqrt((float) i / n);
|
||||
float t = i * GOLDEN_ANGLE;
|
||||
points[i] = new Data(
|
||||
rr * (float) Math.cos(t) + (ThreadLocalRandom.current().nextFloat() * 2f - 1f) * random_offset,
|
||||
rr * (float) Math.sin(t) + (ThreadLocalRandom.current().nextFloat() * 2f - 1f) * random_offset,
|
||||
0f, 0f, 0f
|
||||
);
|
||||
}
|
||||
|
||||
return points;
|
||||
}
|
||||
|
||||
private static final float FOCAL_DISTANCE = 5.0f;
|
||||
private static final float APERTURE_RADIUS = 0.05f;
|
||||
private static final int SAMPLES = 64;
|
||||
|
||||
|
||||
|
||||
private static Data[] calculateCameras(float focal_distance, float aperture_radius, int samples) {
|
||||
Data[] cameras = golden_disk(samples, aperture_radius);
|
||||
|
||||
for (Data cam : cameras) {
|
||||
// Направление от смещённой камеры к фокальной точке (0, 0, FOCAL_DISTANCE)
|
||||
float dirX = 0 - cam.dx;
|
||||
float dirY = 0 - cam.dy;
|
||||
float dirZ = focal_distance - cam.dz;
|
||||
|
||||
// Вычисляем yaw и pitch из направления
|
||||
cam.yaw = (float) -Math.toDegrees(Math.atan2(dirX, dirZ));
|
||||
cam.pitch = (float) Math.toDegrees(Math.atan2(dirY, Math.sqrt(dirX*dirX + dirZ*dirZ)));
|
||||
}
|
||||
|
||||
return cameras;
|
||||
}
|
||||
|
||||
private static Data singleDiskSample(int i, int n, float focalDistance, float apertureRadius) {
|
||||
final float GOLDEN_ANGLE = (float) (Math.PI * (3.0 - Math.sqrt(5.0)));
|
||||
|
||||
float rr = apertureRadius * (float) Math.sqrt((float) i / n);
|
||||
float t = i * GOLDEN_ANGLE;
|
||||
|
||||
float dx = rr * (float) Math.cos(t);
|
||||
float dy = rr * (float) Math.sin(t);
|
||||
float dz = 0f;
|
||||
|
||||
Data cam = new Data(dx, dy, dz, 0f, 0f);
|
||||
|
||||
float dirX = -dx, dirY = -dy, dirZ = focalDistance - dz;
|
||||
cam.yaw = (float) -Math.toDegrees(Math.atan2(dirX, dirZ));
|
||||
cam.pitch = (float) Math.toDegrees(Math.atan2(dirY, Math.sqrt(dirX * dirX + dirZ * dirZ)));
|
||||
return cam;
|
||||
}
|
||||
|
||||
private final Path positionPath;
|
||||
private final Timeline timeline;
|
||||
private final ReplayHandler replayHandler;
|
||||
|
||||
public RealLensOpenGlFrameCapturer(
|
||||
WorldRenderer worldRenderer,
|
||||
RenderInfo renderInfo
|
||||
) {
|
||||
super(worldRenderer, renderInfo);
|
||||
SPTimeline spTimeline = ReplayModSimplePathing.instance.getCurrentTimeline();
|
||||
this.positionPath = spTimeline.getPositionPath();
|
||||
this.timeline = spTimeline.getTimeline();
|
||||
this.replayHandler = ReplayModReplay.instance.getReplayHandler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Channel, RealLensOpenGlFrame> process() {
|
||||
// Продвигает состояние игры к времени ТЕКУЩЕГО выходного кадра
|
||||
// (через onTick -> timeline.applyToGame(videoTime)).
|
||||
renderInfo.updateForNextFrame();
|
||||
int frameId = framesDone++;
|
||||
|
||||
RenderSettings settings = renderInfo.getRenderSettings();
|
||||
int fps = settings.getFramesPerSecond();
|
||||
int N = Math.max(1, settings.getLensBlurSamples()); // единый бюджет сэмплов
|
||||
float shutter = settings.getShutterAngle(); // градусы
|
||||
|
||||
boolean motionBlur = shutter > 0f;
|
||||
double dt = 1000.0 / fps; // длительность выходного кадра, мс
|
||||
double shutterFrac = motionBlur ? (shutter / 360.0) : 0.0;
|
||||
|
||||
int width = getFrameWidth();
|
||||
int height = getFrameHeight();
|
||||
int bpp = 4;
|
||||
int totalBytes = width * height * bpp;
|
||||
|
||||
long[] accumulator = new long[totalBytes];
|
||||
|
||||
// перемешанные слои времени, чтобы время не коррелировало с индексом апертурной спирали
|
||||
int[] order = new int[N];
|
||||
for (int i = 0; i < N; i++) order[i] = i;
|
||||
for (int i = N - 1; i > 0; i--) { // Fisher-Yates
|
||||
int j = ThreadLocalRandom.current().nextInt(i + 1);
|
||||
int tmp = order[i];
|
||||
order[i] = order[j];
|
||||
order[j] = tmp;
|
||||
}
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
// --- время: 1 стратифицированный джиттернутый сэмпл на слой ---
|
||||
long tSub;
|
||||
if (motionBlur) {
|
||||
double u = (i + ThreadLocalRandom.current().nextDouble()) / N;
|
||||
tSub = (long) (frameId * dt + u * shutterFrac * dt);
|
||||
timeline.applyToGame(tSub, replayHandler);
|
||||
} else {
|
||||
tSub = (long) (frameId * dt);
|
||||
}
|
||||
// partialTicks от РЕАЛЬНОГО времени реплея (frac(replayTime/50)),
|
||||
// как в AbstractTimelinePlayer.onTick. (tSub % 50) даёт рассинхрон -> раздвоение.
|
||||
long replayTime = replayHandler.getReplaySender().currentTimeStamp();
|
||||
float subPartialTicks = (float) ((replayTime % 50L) / 50.0);
|
||||
|
||||
float focal = positionPath.getValue(LensProperties.FOCAL_DISTANCE, tSub).map(Triple::getLeft).orElse(5.0f);
|
||||
float apert = positionPath.getValue(LensProperties.APERTURE_RADIUS, tSub).map(Triple::getLeft).orElse(0.05f);
|
||||
Data cam = singleDiskSample(order[i], N, focal, apert);
|
||||
|
||||
OpenGlFrame sub = renderFrame(frameId, subPartialTicks, cam);
|
||||
ByteBuffer buf = sub.getByteBuffer();
|
||||
buf.rewind();
|
||||
for (int k = 0; k < totalBytes; k++) {
|
||||
accumulator[k] += (buf.get(k) & 0xFF);
|
||||
}
|
||||
ByteBufferPool.release(buf);
|
||||
}
|
||||
|
||||
ByteBuffer out = ByteBufferPool.allocate(totalBytes);
|
||||
for (int k = 0; k < totalBytes; k++) {
|
||||
out.put((byte) (accumulator[k] / N));
|
||||
}
|
||||
out.rewind();
|
||||
|
||||
OpenGlFrame averaged = new OpenGlFrame(frameId, new Dimension(width, height), bpp, out);
|
||||
return Collections.singletonMap(Channel.BRGA, new RealLensOpenGlFrame(new OpenGlFrame[]{averaged}));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.replaymod.render.frame;
|
||||
|
||||
import com.replaymod.render.rendering.Frame;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
public class RealLensOpenGlFrame implements Frame {
|
||||
|
||||
private final OpenGlFrame[] frames;
|
||||
|
||||
public RealLensOpenGlFrame(OpenGlFrame[] frames) {
|
||||
Validate.notNull(frames, "frames");
|
||||
Validate.isTrue(frames.length > 0, "frames must not be empty");
|
||||
|
||||
int frameId = frames[0].getFrameId();
|
||||
int remaining = frames[0].getByteBuffer().remaining();
|
||||
|
||||
for (OpenGlFrame frame : frames) {
|
||||
Validate.isTrue(
|
||||
frame.getFrameId() == frameId,
|
||||
"Frame ids do not match."
|
||||
);
|
||||
Validate.isTrue(
|
||||
frame.getByteBuffer().remaining() == remaining,
|
||||
"Buffer sizes do not match."
|
||||
);
|
||||
}
|
||||
|
||||
this.frames = frames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFrameId() {
|
||||
return frames[0].getFrameId();
|
||||
}
|
||||
|
||||
public OpenGlFrame[] getFrames() {
|
||||
return frames;
|
||||
}
|
||||
}
|
||||
@@ -101,6 +101,9 @@ public class GuiExportFailed extends GuiScreen {
|
||||
oldSettings.isDepthMap(),
|
||||
oldSettings.isCameraPathExport(),
|
||||
oldSettings.getAntiAliasing(),
|
||||
oldSettings.getLensBlurSamples(),
|
||||
oldSettings.getMotionBlurSubframes(),
|
||||
oldSettings.getShutterAngle(),
|
||||
oldSettings.getExportCommand(),
|
||||
oldSettings.getEncodingPreset().getValue(),
|
||||
oldSettings.isHighPerformance()
|
||||
|
||||
@@ -103,6 +103,9 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
|
||||
public final GuiNumberField videoWidth = new GuiNumberField().setSize(50, 20).setMinValue(1).setValidateOnFocusChange(true);
|
||||
public final GuiNumberField videoHeight = new GuiNumberField().setSize(50, 20).setMinValue(1).setValidateOnFocusChange(true);
|
||||
public final GuiNumberField lensBlurSamples = new GuiNumberField().setSize(50, 20).setMinValue(1).setMaxValue(512).setValidateOnFocusChange(true);
|
||||
public final GuiNumberField motionBlurSubframes = new GuiNumberField().setSize(50, 20).setMinValue(1).setMaxValue(512).setValidateOnFocusChange(true);
|
||||
public final GuiNumberField shutterAngle = new GuiNumberField().setSize(50, 20).setMinValue(0).setMaxValue(360).setValidateOnFocusChange(true);
|
||||
public final GuiSlider frameRateSlider = new GuiSlider().onValueChanged(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -199,7 +202,9 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
injectSphericalMetadata, sphericalFovSlider,
|
||||
depthMap, new GuiLabel(),
|
||||
cameraPathExport, new GuiLabel(),
|
||||
new GuiLabel().setI18nText("replaymod.gui.rendersettings.antialiasing"), antiAliasingDropdown));
|
||||
new GuiLabel().setI18nText("replaymod.gui.rendersettings.antialiasing"), antiAliasingDropdown,
|
||||
new GuiLabel().setI18nText("replaymod.gui.rendersettings.lensblursamples"), lensBlurSamples,
|
||||
new GuiLabel().setI18nText("replaymod.gui.rendersettings.shutterangle"), shutterAngle));
|
||||
|
||||
public final GuiTextField exportCommand = new GuiTextField().setI18nHint("replaymod.gui.rendersettings.command")
|
||||
.setSize(55, 20).setMaxLength(100).onTextChanged((old) -> updateInputs());
|
||||
@@ -416,6 +421,10 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
boolean commandChanged = !exportCommand.getText().isEmpty();
|
||||
boolean argsChanged = !encodingPresetDropdown.getSelectedValue().getValue().equals(exportArguments.getText());
|
||||
exportReset.setEnabled(commandChanged || argsChanged);
|
||||
boolean isRealLens = renderMethod == RenderSettings.RenderMethod.REALLENS;
|
||||
lensBlurSamples.setEnabled(isRealLens);
|
||||
motionBlurSubframes.setEnabled(isRealLens);
|
||||
shutterAngle.setEnabled(isRealLens);
|
||||
}
|
||||
|
||||
protected String updateResolution() {
|
||||
@@ -542,6 +551,9 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
depthMap.setChecked(settings.isDepthMap());
|
||||
cameraPathExport.setChecked(settings.isCameraPathExport());
|
||||
antiAliasingDropdown.setSelected(settings.getAntiAliasing());
|
||||
lensBlurSamples.setValue(settings.getLensBlurSamples());
|
||||
motionBlurSubframes.setValue(settings.getMotionBlurSubframes());
|
||||
shutterAngle.setValue((int) settings.getShutterAngle());
|
||||
exportCommand.setText(settings.getExportCommand());
|
||||
String exportArguments = settings.getExportArguments();
|
||||
if (exportArguments == null || settings.getEncodingPreset() == null || invalidEncodingPreset) {
|
||||
@@ -575,6 +587,9 @@ public class GuiRenderSettings extends AbstractGuiPopup<GuiRenderSettings> {
|
||||
depthMap.isChecked() && (serialize || depthMap.isEnabled()),
|
||||
cameraPathExport.isChecked(),
|
||||
serialize || antiAliasingDropdown.isEnabled() ? antiAliasingDropdown.getSelectedValue() : RenderSettings.AntiAliasing.NONE,
|
||||
lensBlurSamples.getInteger(),
|
||||
motionBlurSubframes.getInteger(),
|
||||
(float) shutterAngle.getInteger(),
|
||||
exportCommand.getText(),
|
||||
exportArguments.getText(),
|
||||
highPerformance
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.replaymod.render.mixin;
|
||||
|
||||
import com.replaymod.pathing.properties.FovProperty;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.ModifyArg;
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public abstract class Mixin_DynamicFov {
|
||||
private static final String METHOD = "getBasicProjectionMatrix";
|
||||
//#if MC>=11903
|
||||
//#if MC>=12005
|
||||
//$$ private static final String TARGET = "Lorg/joml/Matrix4f;perspective(FFFF)Lorg/joml/Matrix4f;";
|
||||
//#else
|
||||
//$$ private static final String TARGET = "Lorg/joml/Matrix4f;setPerspective(FFFF)Lorg/joml/Matrix4f;";
|
||||
//#endif
|
||||
//$$ private static final boolean TARGET_REMAP = false;
|
||||
//#else
|
||||
private static final String TARGET = "Lnet/minecraft/util/math/Matrix4f;viewboxMatrix(DFFF)Lnet/minecraft/util/math/Matrix4f;";
|
||||
private static final boolean TARGET_REMAP = true;
|
||||
//#endif
|
||||
|
||||
@ModifyArg(method = METHOD, at = @At(value = "INVOKE", target = TARGET, remap = TARGET_REMAP), index = 0)
|
||||
//#if MC>=11903
|
||||
//$$ private float replayModRender_dynamicFov(float fovY) {
|
||||
//$$ Float override = FovProperty.currentOverride;
|
||||
//$$ if (override == null) return fovY;
|
||||
//$$ return (float) Math.toRadians(Math.max(1f, Math.min(179f, override)));
|
||||
//$$ }
|
||||
//#else
|
||||
private double replayModRender_dynamicFov(double fovY) {
|
||||
Float override = FovProperty.currentOverride;
|
||||
if (override == null) return fovY;
|
||||
return Math.max(1.0, Math.min(179.0, override));
|
||||
}
|
||||
//#endif
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.replaymod.render.mixin;
|
||||
|
||||
import com.replaymod.render.capturer.RealLensOpenGlFrameCapturer;
|
||||
import com.replaymod.render.hooks.EntityRendererHandler;
|
||||
import net.minecraft.client.render.GameRenderer;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
import net.minecraft.client.util.math.Vector3f;
|
||||
import net.minecraft.util.math.Matrix4f;
|
||||
import org.spongepowered.asm.mixin.Mixin;
|
||||
import org.spongepowered.asm.mixin.injection.At;
|
||||
import org.spongepowered.asm.mixin.injection.Inject;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;
|
||||
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
|
||||
|
||||
//#if MC>=12005
|
||||
//$$ import com.llamalad7.mixinextras.injector.ModifyExpressionValue;
|
||||
//$$ import org.joml.Matrix4f;
|
||||
//#endif
|
||||
|
||||
@Mixin(GameRenderer.class)
|
||||
public abstract class Mixin_RealLens_Camera implements EntityRendererHandler.IEntityRenderer {
|
||||
|
||||
//#if MC>=12005
|
||||
//#if MC>=12100
|
||||
//$$ @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;rotation(Lorg/joml/Quaternionfc;)Lorg/joml/Matrix4f;"))
|
||||
//#else
|
||||
//$$ @ModifyExpressionValue(method = "renderWorld", at = @At(value = "INVOKE", target = "Lorg/joml/Matrix4f;rotationXYZ(FFF)Lorg/joml/Matrix4f;"))
|
||||
//#endif
|
||||
//$$ private Matrix4f realLens_applyCameraTransform(Matrix4f matrix) {
|
||||
//#else
|
||||
@Inject(method = "renderWorld", at = @At("HEAD"))
|
||||
private void realLens_applyCameraTransform(float partialTicks, long frameStartNano, MatrixStack matrixStack, CallbackInfo ci) {
|
||||
//#endif
|
||||
EntityRendererHandler handler = replayModRender_getHandler();
|
||||
if (!(handler != null && handler.data instanceof RealLensOpenGlFrameCapturer.Data)) {
|
||||
//#if MC>=12005
|
||||
//$$ return matrix;
|
||||
//#else
|
||||
return;
|
||||
//#endif
|
||||
}
|
||||
|
||||
RealLensOpenGlFrameCapturer.Data cam = (RealLensOpenGlFrameCapturer.Data) handler.data;
|
||||
|
||||
//#if MC>=12005
|
||||
//$$ matrix.translateLocal(cam.dx, cam.dy, cam.dz);
|
||||
//$$ return matrix;
|
||||
//#else
|
||||
matrixStack.translate(cam.dx, cam.dy, cam.dz);
|
||||
//#endif
|
||||
|
||||
// In Mixin_RealLens_Camera, add rotation after translation
|
||||
//#if MC>=12005
|
||||
//$$ matrix.rotateLocal((float) Math.toRadians(cam.pitch), 1, 0, 0);
|
||||
//$$ matrix.rotateLocal((float) Math.toRadians(cam.yaw), 0, 1, 0);
|
||||
//#else
|
||||
matrixStack.multiply(Vector3f.POSITIVE_X.getDegreesQuaternion(cam.pitch));
|
||||
matrixStack.multiply(Vector3f.POSITIVE_Y.getDegreesQuaternion(cam.yaw));
|
||||
//#endif
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,101 @@
|
||||
package com.replaymod.render.processor;
|
||||
|
||||
import com.replaymod.render.frame.BitmapFrame;
|
||||
import com.replaymod.render.frame.OpenGlFrame;
|
||||
import com.replaymod.render.frame.RealLensOpenGlFrame;
|
||||
import com.replaymod.render.utils.ByteBufferPool;
|
||||
import de.johni0702.minecraft.gui.utils.lwjgl.Dimension;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static com.replaymod.render.utils.Utils.openGlBytesToBitmap;
|
||||
|
||||
public class RealLensToBitmapProcessor
|
||||
extends AbstractFrameProcessor<RealLensOpenGlFrame, BitmapFrame> {
|
||||
|
||||
@Override
|
||||
public BitmapFrame process(RealLensOpenGlFrame rawFrame) {
|
||||
|
||||
OpenGlFrame[] frames = rawFrame.getFrames();
|
||||
OpenGlFrame first = frames[0];
|
||||
|
||||
int width = first.getSize().getWidth();
|
||||
int height = first.getSize().getHeight();
|
||||
int bpp = first.getBytesPerPixel();
|
||||
|
||||
int totalBytes = width * height * bpp;
|
||||
|
||||
int[] accumulator = new int[totalBytes];
|
||||
|
||||
ByteBuffer converted = ByteBufferPool.allocate(totalBytes);
|
||||
|
||||
try {
|
||||
|
||||
for (OpenGlFrame frame : frames) {
|
||||
|
||||
converted.clear();
|
||||
|
||||
// BGRA -> bitmap layout (still BGRA at this point)
|
||||
openGlBytesToBitmap(
|
||||
frame,
|
||||
0,
|
||||
0,
|
||||
converted,
|
||||
width
|
||||
);
|
||||
|
||||
converted.rewind();
|
||||
|
||||
// accumulate per channel with B <-> R swap
|
||||
for (int i = 0; i < totalBytes; i += bpp) {
|
||||
|
||||
int b = converted.get(i) & 0xFF;
|
||||
int g = converted.get(i + 1) & 0xFF;
|
||||
int r = converted.get(i + 2) & 0xFF;
|
||||
int a = (bpp == 4) ? (converted.get(i + 3) & 0xFF) : 255;
|
||||
|
||||
// swap R and B here
|
||||
accumulator[i] += b;
|
||||
accumulator[i + 1] += g;
|
||||
accumulator[i + 2] += r;
|
||||
|
||||
if (bpp == 4) {
|
||||
accumulator[i + 3] += a;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ByteBuffer output = ByteBufferPool.allocate(totalBytes);
|
||||
|
||||
int samples = frames.length;
|
||||
|
||||
for (int i = 0; i < totalBytes; i += bpp) {
|
||||
|
||||
output.put((byte) (accumulator[i] / samples)); // R
|
||||
output.put((byte) (accumulator[i + 1] / samples)); // G
|
||||
output.put((byte) (accumulator[i + 2] / samples)); // B
|
||||
|
||||
if (bpp == 4) {
|
||||
output.put((byte) (accumulator[i + 3] / samples)); // A
|
||||
}
|
||||
}
|
||||
|
||||
output.rewind();
|
||||
|
||||
return new BitmapFrame(
|
||||
rawFrame.getFrameId(),
|
||||
new Dimension(width, height),
|
||||
bpp,
|
||||
output
|
||||
);
|
||||
|
||||
} finally {
|
||||
|
||||
ByteBufferPool.release(converted);
|
||||
|
||||
for (OpenGlFrame frame : frames) {
|
||||
ByteBufferPool.release(frame.getByteBuffer());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,9 @@ import com.replaymod.render.processor.ODSToBitmapProcessor;
|
||||
import com.replaymod.render.processor.OpenGlToBitmapProcessor;
|
||||
import com.replaymod.render.processor.StereoscopicToBitmapProcessor;
|
||||
import com.replaymod.render.utils.PixelBufferObject;
|
||||
import com.replaymod.render.capturer.RealLensOpenGlFrameCapturer;
|
||||
import com.replaymod.render.frame.RealLensOpenGlFrame;
|
||||
import com.replaymod.render.processor.RealLensToBitmapProcessor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@@ -32,6 +35,8 @@ public class Pipelines {
|
||||
switch (method) {
|
||||
case DEFAULT:
|
||||
return newDefaultPipeline(renderInfo, consumer);
|
||||
case REALLENS:
|
||||
return newRealLensPipeline(renderInfo, consumer);
|
||||
case STEREOSCOPIC:
|
||||
return newStereoscopicPipeline(renderInfo, consumer);
|
||||
case CUBIC:
|
||||
@@ -58,6 +63,15 @@ public class Pipelines {
|
||||
return new Pipeline<>(worldRenderer, capturer, new OpenGlToBitmapProcessor(), consumer);
|
||||
}
|
||||
|
||||
public static Pipeline<RealLensOpenGlFrame, BitmapFrame> newRealLensPipeline(
|
||||
RenderInfo renderInfo, FrameConsumer<BitmapFrame> consumer) {
|
||||
RenderSettings settings = renderInfo.getRenderSettings();
|
||||
WorldRenderer worldRenderer = new EntityRendererHandler(settings, renderInfo);
|
||||
FrameCapturer<RealLensOpenGlFrame> capturer =
|
||||
new RealLensOpenGlFrameCapturer(worldRenderer, renderInfo);
|
||||
return new Pipeline<>(worldRenderer, capturer, new RealLensToBitmapProcessor(), consumer);
|
||||
}
|
||||
|
||||
public static Pipeline<StereoscopicOpenGlFrame, BitmapFrame> newStereoscopicPipeline(RenderInfo renderInfo, FrameConsumer<BitmapFrame> consumer) {
|
||||
RenderSettings settings = renderInfo.getRenderSettings();
|
||||
WorldRenderer worldRenderer = new EntityRendererHandler(settings, renderInfo);
|
||||
|
||||
@@ -9,6 +9,8 @@ import com.google.gson.stream.JsonWriter;
|
||||
import com.replaymod.pathing.properties.CameraProperties;
|
||||
import com.replaymod.pathing.properties.SpectatorProperty;
|
||||
import com.replaymod.pathing.properties.TimestampProperty;
|
||||
import com.replaymod.pathing.properties.LensProperties;
|
||||
import com.replaymod.pathing.properties.FovProperty;
|
||||
import com.replaymod.replaystudio.pathing.PathingRegistry;
|
||||
import com.replaymod.replaystudio.pathing.change.AddKeyframe;
|
||||
import com.replaymod.replaystudio.pathing.change.Change;
|
||||
@@ -172,6 +174,9 @@ public class SPTimeline implements PathingRegistry {
|
||||
UpdateKeyframeProperties.Builder builder = UpdateKeyframeProperties.create(path, keyframe);
|
||||
builder.setValue(CameraProperties.POSITION, Triple.of(posX, posY, posZ));
|
||||
builder.setValue(CameraProperties.ROTATION, Triple.of(yaw, pitch, roll));
|
||||
builder.setValue(LensProperties.FOCAL_DISTANCE, Triple.of(LensProperties.DEFAULT_FOCAL_DISTANCE, 0f, 0f));
|
||||
builder.setValue(LensProperties.APERTURE_RADIUS, Triple.of(LensProperties.DEFAULT_APERTURE_RADIUS, 0f, 0f));
|
||||
builder.setValue(FovProperty.FOV, Triple.of(FovProperty.DEFAULT_FOV, 0f, 0f));
|
||||
if (spectated != -1) {
|
||||
builder.setValue(SpectatorProperty.PROPERTY, spectated);
|
||||
}
|
||||
@@ -307,6 +312,28 @@ public class SPTimeline implements PathingRegistry {
|
||||
timeline.pushChange(change);
|
||||
}
|
||||
|
||||
public Change updateLensProperties(long time, float focalDistance, float apertureRadius) {
|
||||
Keyframe keyframe = positionPath.getKeyframe(time);
|
||||
Preconditions.checkState(keyframe != null, "Keyframe does not exist");
|
||||
|
||||
Change change = UpdateKeyframeProperties.create(positionPath, keyframe)
|
||||
.setValue(LensProperties.FOCAL_DISTANCE, Triple.of(focalDistance, 0f, 0f))
|
||||
.setValue(LensProperties.APERTURE_RADIUS, Triple.of(apertureRadius, 0f, 0f))
|
||||
.done();
|
||||
change.apply(timeline);
|
||||
return change;
|
||||
}
|
||||
|
||||
public Change updateFov(long time, float fov) {
|
||||
Keyframe keyframe = positionPath.getKeyframe(time);
|
||||
Preconditions.checkState(keyframe != null, "Keyframe does not exist");
|
||||
Change change = UpdateKeyframeProperties.create(positionPath, keyframe)
|
||||
.setValue(FovProperty.FOV, Triple.of(fov, 0f, 0f))
|
||||
.done();
|
||||
change.apply(timeline);
|
||||
return change;
|
||||
}
|
||||
|
||||
public Change setInterpolatorToDefault(long time) {
|
||||
LOGGER.debug("Setting interpolator of position keyframe at {} to the default", time);
|
||||
|
||||
@@ -451,6 +478,9 @@ public class SPTimeline implements PathingRegistry {
|
||||
// otherwise create a new interpolator
|
||||
interpolator = new LinearInterpolator();
|
||||
interpolator.registerProperty(SpectatorProperty.PROPERTY);
|
||||
interpolator.registerProperty(LensProperties.FOCAL_DISTANCE);
|
||||
interpolator.registerProperty(LensProperties.APERTURE_RADIUS);
|
||||
interpolator.registerProperty(FovProperty.FOV);
|
||||
}
|
||||
// Now that we have an interpolator, set it for the current segment
|
||||
updates.put(segment, interpolator);
|
||||
@@ -569,6 +599,9 @@ public class SPTimeline implements PathingRegistry {
|
||||
private Interpolator registerPositionInterpolatorProperties(Interpolator interpolator) {
|
||||
interpolator.registerProperty(CameraProperties.POSITION);
|
||||
interpolator.registerProperty(CameraProperties.ROTATION);
|
||||
interpolator.registerProperty(LensProperties.FOCAL_DISTANCE);
|
||||
interpolator.registerProperty(LensProperties.APERTURE_RADIUS);
|
||||
interpolator.registerProperty(FovProperty.FOV);
|
||||
return interpolator;
|
||||
}
|
||||
|
||||
@@ -591,6 +624,9 @@ public class SPTimeline implements PathingRegistry {
|
||||
timeline.registerProperty(CameraProperties.POSITION);
|
||||
timeline.registerProperty(CameraProperties.ROTATION);
|
||||
timeline.registerProperty(SpectatorProperty.PROPERTY);
|
||||
timeline.registerProperty(LensProperties.FOCAL_DISTANCE);
|
||||
timeline.registerProperty(LensProperties.APERTURE_RADIUS);
|
||||
timeline.registerProperty(FovProperty.FOV);
|
||||
timeline.registerProperty(ExplicitInterpolationProperty.PROPERTY);
|
||||
|
||||
return timeline;
|
||||
|
||||
@@ -145,17 +145,24 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
||||
protected abstract Change save();
|
||||
|
||||
public static class Spectator extends GuiEditKeyframe<Spectator> {
|
||||
public final GuiLensKeyframePanel lensPanel = new GuiLensKeyframePanel();
|
||||
|
||||
public Spectator(GuiPathing gui, SPPath path, long keyframe) {
|
||||
super(gui, path, keyframe, "spec");
|
||||
|
||||
link(timeMinField, timeSecField, timeMSecField);
|
||||
inputs.setLayout(new VerticalLayout().setSpacing(10)).addElements(new VerticalLayout.Data(0.5, false), lensPanel.load(this.keyframe));
|
||||
|
||||
link(lensPanel.focalDistanceField, lensPanel.apertureRadiusField, lensPanel.fovField, timeMinField, timeSecField, timeMSecField);
|
||||
|
||||
popup.invokeAll(IGuiLabel.class, e -> e.setColor(Colors.BLACK));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Change save() {
|
||||
return CombinedChange.createFromApplied();
|
||||
SPTimeline timeline = guiPathing.getMod().getCurrentTimeline();
|
||||
Change lensChange = timeline.updateLensProperties(time, lensPanel.getFocalDistance(), lensPanel.getApertureRadius());
|
||||
Change fovChange = timeline.updateFov(time, lensPanel.getFov());
|
||||
return CombinedChange.createFromApplied(lensChange, fovChange);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,6 +223,8 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
||||
|
||||
public final InterpolationPanel interpolationPanel = new InterpolationPanel();
|
||||
|
||||
public final GuiLensKeyframePanel lensPanel = new GuiLensKeyframePanel();
|
||||
|
||||
{
|
||||
GuiPanel positionInputs = new GuiPanel()
|
||||
.setLayout(new GridLayout().setCellsEqualSize(false).setColumns(4).setSpacingX(3).setSpacingY(5))
|
||||
@@ -225,10 +234,11 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.ypos"), yField,
|
||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.campitch"), pitchField,
|
||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.zpos"), zField,
|
||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.camroll"), rollField);
|
||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.camroll"), rollField
|
||||
);
|
||||
|
||||
inputs.setLayout(new VerticalLayout().setSpacing(10)).addElements(new VerticalLayout.Data(0.5, false),
|
||||
positionInputs, interpolationPanel);
|
||||
positionInputs, lensPanel, interpolationPanel);
|
||||
}
|
||||
|
||||
public Position(GuiPathing gui, SPPath path, long keyframe) {
|
||||
@@ -245,7 +255,9 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
||||
rollField.setValue(rot.getRight());
|
||||
});
|
||||
|
||||
link(xField, yField, zField, yawField, pitchField, rollField, timeMinField, timeSecField, timeMSecField);
|
||||
lensPanel.load(this.keyframe);
|
||||
|
||||
link(xField, yField, zField, yawField, pitchField, rollField, lensPanel.focalDistanceField, lensPanel.apertureRadiusField, lensPanel.fovField, timeMinField, timeSecField, timeMSecField);
|
||||
|
||||
popup.invokeAll(IGuiLabel.class, e -> e.setColor(Colors.BLACK));
|
||||
}
|
||||
@@ -257,16 +269,20 @@ public abstract class GuiEditKeyframe<T extends GuiEditKeyframe<T>> extends Abst
|
||||
xField.getDouble(), yField.getDouble(), zField.getDouble(),
|
||||
yawField.getFloat(), pitchField.getFloat(), rollField.getFloat()
|
||||
);
|
||||
Change lensChange = timeline.updateLensProperties(time,
|
||||
lensPanel.getFocalDistance(), lensPanel.getApertureRadius());
|
||||
Change fovChange = timeline.updateFov(time, lensPanel.getFov());
|
||||
if (interpolationPanel.getSettingsPanel() == null) {
|
||||
// The last keyframe doesn't have interpolator settings because there is no segment following it
|
||||
return positionChange;
|
||||
return CombinedChange.createFromApplied(positionChange, lensChange, fovChange);
|
||||
}
|
||||
Interpolator interpolator = interpolationPanel.getSettingsPanel().createInterpolator();
|
||||
if (interpolationPanel.getInterpolatorType() == InterpolatorType.DEFAULT) {
|
||||
return CombinedChange.createFromApplied(positionChange, timeline.setInterpolatorToDefault(time),
|
||||
timeline.setDefaultInterpolator(interpolator));
|
||||
return CombinedChange.createFromApplied(positionChange, lensChange, fovChange,
|
||||
timeline.setInterpolatorToDefault(time), timeline.setDefaultInterpolator(interpolator));
|
||||
} else {
|
||||
return CombinedChange.createFromApplied(positionChange, timeline.setInterpolator(time, interpolator));
|
||||
return CombinedChange.createFromApplied(positionChange, lensChange, fovChange,
|
||||
timeline.setInterpolator(time, interpolator));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.replaymod.simplepathing.gui;
|
||||
|
||||
import com.replaymod.pathing.properties.LensProperties;
|
||||
import com.replaymod.pathing.properties.FovProperty;
|
||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||
import de.johni0702.minecraft.gui.container.AbstractGuiContainer;
|
||||
import de.johni0702.minecraft.gui.element.GuiLabel;
|
||||
import de.johni0702.minecraft.gui.element.GuiNumberField;
|
||||
import de.johni0702.minecraft.gui.layout.GridLayout;
|
||||
import org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
public class GuiLensKeyframePanel extends AbstractGuiContainer<GuiLensKeyframePanel> {
|
||||
public final GuiNumberField focalDistanceField =
|
||||
new GuiNumberField().setValidateOnFocusChange(true).setSize(60, 20).setPrecision(3).setMinValue(0);
|
||||
public final GuiNumberField apertureRadiusField =
|
||||
new GuiNumberField().setValidateOnFocusChange(true).setSize(60, 20).setPrecision(4).setMinValue(0);
|
||||
public final GuiNumberField fovField =
|
||||
new GuiNumberField().setValidateOnFocusChange(true).setSize(60, 20).setPrecision(1).setMinValue(1).setMaxValue(179);
|
||||
|
||||
public GuiLensKeyframePanel() {
|
||||
setLayout(new GridLayout().setCellsEqualSize(false).setColumns(2).setSpacingX(3).setSpacingY(5));
|
||||
addElements(new GridLayout.Data(1, 0.5),
|
||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.focalDistance"), focalDistanceField,
|
||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.apertureRadius"), apertureRadiusField,
|
||||
new GuiLabel().setI18nText("replaymod.gui.editkeyframe.fov"), fovField);
|
||||
}
|
||||
|
||||
public GuiLensKeyframePanel load(Keyframe keyframe) {
|
||||
focalDistanceField.setValue(keyframe.getValue(LensProperties.FOCAL_DISTANCE)
|
||||
.map(Triple::getLeft).orElse(LensProperties.DEFAULT_FOCAL_DISTANCE));
|
||||
apertureRadiusField.setValue(keyframe.getValue(LensProperties.APERTURE_RADIUS)
|
||||
.map(Triple::getLeft).orElse(LensProperties.DEFAULT_APERTURE_RADIUS));
|
||||
fovField.setValue(keyframe.getValue(FovProperty.FOV)
|
||||
.map(Triple::getLeft).orElse(FovProperty.DEFAULT_FOV));
|
||||
return this;
|
||||
}
|
||||
|
||||
public float getFocalDistance() { return focalDistanceField.getFloat(); }
|
||||
public float getApertureRadius() { return apertureRadiusField.getFloat(); }
|
||||
public float getFov() { return fovField.getFloat(); }
|
||||
|
||||
@Override
|
||||
protected GuiLensKeyframePanel getThis() { return this; }
|
||||
}
|
||||
@@ -7,6 +7,8 @@ import com.replaymod.core.versions.MCVer;
|
||||
import com.replaymod.pathing.properties.CameraProperties;
|
||||
import com.replaymod.pathing.properties.SpectatorProperty;
|
||||
import com.replaymod.pathing.properties.TimestampProperty;
|
||||
import com.replaymod.pathing.properties.LensProperties;
|
||||
import com.replaymod.pathing.properties.FovProperty;
|
||||
import com.replaymod.replay.ReplayHandler;
|
||||
import com.replaymod.replaystudio.pathing.interpolation.Interpolator;
|
||||
import com.replaymod.replaystudio.pathing.path.Keyframe;
|
||||
@@ -72,6 +74,8 @@ public class PathPreviewRenderer extends EventRegistrations {
|
||||
private static final int SLOW_PATH_COLOR = 0xffcccc;
|
||||
private static final int FAST_PATH_COLOR = 0x660000;
|
||||
private static final double FASTEST_PATH_SPEED = 0.01;
|
||||
private static final float DOF_GIZMO_SCALE = 10f;
|
||||
private static final float DOF_GIZMO_FAR_LEN = 64f;
|
||||
|
||||
private final ReplayModSimplePathing mod;
|
||||
private final ReplayHandler replayHandler;
|
||||
@@ -209,6 +213,9 @@ public class PathPreviewRenderer extends EventRegistrations {
|
||||
//#endif
|
||||
|
||||
int time = guiPathing.timeline.getCursorPosition();
|
||||
float focal = path.getValue(LensProperties.FOCAL_DISTANCE, time).map(Triple::getLeft).orElse(LensProperties.DEFAULT_FOCAL_DISTANCE);
|
||||
float aperture = path.getValue(LensProperties.APERTURE_RADIUS, time).map(Triple::getLeft).orElse(LensProperties.DEFAULT_APERTURE_RADIUS);
|
||||
float fov = path.getValue(FovProperty.FOV, time).map(Triple::getLeft).orElse(FovProperty.DEFAULT_FOV);
|
||||
Optional<Integer> entityId = path.getValue(SpectatorProperty.PROPERTY, time);
|
||||
if (entityId.isPresent()) {
|
||||
// Spectating an entity
|
||||
@@ -218,6 +225,7 @@ public class PathPreviewRenderer extends EventRegistrations {
|
||||
Location loc = entityTracker.getEntityPositionAtTimestamp(entityId.get(), replayTime.get());
|
||||
if (loc != null) {
|
||||
drawCamera(viewPos, loc2Vec(loc), new Vector3f(loc.getYaw(), loc.getPitch(), 0f));
|
||||
drawFocusGizmo(viewPos, loc2Vec(loc), new Vector3f(loc.getYaw(), loc.getPitch(), 0f), focal, aperture, fov);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -227,6 +235,7 @@ public class PathPreviewRenderer extends EventRegistrations {
|
||||
Optional<Vector3f> cameraRot = path.getValue(CameraProperties.ROTATION, time).map(this::tripleF2Vec);
|
||||
if (cameraPos.isPresent() && cameraRot.isPresent()) {
|
||||
drawCamera(viewPos, cameraPos.get(), cameraRot.get());
|
||||
drawFocusGizmo(viewPos, cameraPos.get(), cameraRot.get(), focal, aperture, fov);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
@@ -526,6 +535,100 @@ public class PathPreviewRenderer extends EventRegistrations {
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
private void drawFocusGizmo(Vector3f view, Vector3f pos, Vector3f rot, float focalDistance, float apertureRadius, float fov) {
|
||||
float a = Math.max(0.15f, apertureRadius * DOF_GIZMO_SCALE);
|
||||
int rayColor = 0x66ccffaa; // RGBA: голубой (лучи апертуры)
|
||||
int markerColor = 0xffaa00ff; // RGBA: оранжевый (маркер плоскости фокуса)
|
||||
float mr = focalDistance * (float) Math.tan(Math.toRadians(fov) / 2.0); // радиус кольца-маркера
|
||||
int markerSeg = 12;
|
||||
|
||||
pushMatrix();
|
||||
|
||||
Vector3f t = Vector3f.sub(pos, view, null);
|
||||
GL11.glTranslatef(t.x, t.y, t.z);
|
||||
GL11.glRotatef(-rot.x, 0, 1, 0); // Yaw
|
||||
GL11.glRotatef(rot.y, 1, 0, 0); // Pitch
|
||||
GL11.glRotatef(rot.z, 0, 0, 1); // Roll
|
||||
|
||||
//#if MC>=12105
|
||||
//$$ VertexConsumerProvider.Immediate immediate = mc.getBufferBuilders().getEntityVertexConsumers();
|
||||
//$$ immediate.draw();
|
||||
//#if MC>=12111
|
||||
//$$ VertexConsumer buffer = immediate.getBuffer(RenderLayers.LINES);
|
||||
//#else
|
||||
//$$ VertexConsumer buffer = immediate.getBuffer(RenderLayer.LINES);
|
||||
//#endif
|
||||
//#else
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
//#if MC>=12100
|
||||
//$$ BufferBuilder buffer = tessellator.begin(net.minecraft.client.render.VertexFormat.DrawMode.LINES, VertexFormats.LINES);
|
||||
//#else
|
||||
BufferBuilder buffer = tessellator.getBuffer();
|
||||
buffer.begin(GL11.GL_LINES, VertexFormats.POSITION_COLOR);
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
MatrixStack ms = new MatrixStack();
|
||||
Vector3f apex = new Vector3f(0f, 0f, focalDistance); // точка схождения
|
||||
|
||||
for (Vector3f edge : new Vector3f[]{
|
||||
new Vector3f( a, 0f, 0f), new Vector3f(-a, 0f, 0f),
|
||||
new Vector3f(0f, a, 0f), new Vector3f(0f, -a, 0f)}) {
|
||||
Vector3f dir = Vector3f.sub(apex, edge, null); // apex - edge
|
||||
dir.normalise();
|
||||
dir.scale(DOF_GIZMO_FAR_LEN);
|
||||
Vector3f far = Vector3f.add(apex, dir, null);
|
||||
emitLine(ms, buffer, edge, far, rayColor, 2f);
|
||||
}
|
||||
|
||||
// маркер фокальной плоскости: крестик
|
||||
emitLine(ms, buffer, new Vector3f(-mr, 0f, focalDistance), new Vector3f(mr, 0f, focalDistance), markerColor, 2f);
|
||||
emitLine(ms, buffer, new Vector3f(0f, -mr, focalDistance), new Vector3f(0f, mr, focalDistance), markerColor, 2f);
|
||||
// маркер фокальной плоскости: кольцо
|
||||
Vector3f prev = null;
|
||||
for (int i = 0; i <= markerSeg; i++) {
|
||||
double ang = 2 * Math.PI * i / markerSeg;
|
||||
Vector3f p = new Vector3f((float) (mr * Math.cos(ang)), (float) (mr * Math.sin(ang)), focalDistance);
|
||||
if (prev != null) emitLine(ms, buffer, prev, p, markerColor, 2f);
|
||||
prev = p;
|
||||
}
|
||||
|
||||
//#if MC>=12105
|
||||
//$$ immediate.draw();
|
||||
//#else
|
||||
//#if MC>=12102
|
||||
//$$ RenderSystem.setShader(ShaderProgramKeys.RENDERTYPE_LINES);
|
||||
//#elseif MC>=11700
|
||||
//$$ RenderSystem.applyModelViewMatrix();
|
||||
//$$ RenderSystem.setShader(GameRenderer::getRenderTypeLinesShader);
|
||||
//#else
|
||||
GL11.glDisable(GL11.GL_TEXTURE_2D);
|
||||
//#endif
|
||||
|
||||
//#if MC>=11700
|
||||
//$$ RenderSystem.disableCull();
|
||||
//#endif
|
||||
|
||||
//#if MC>=12100
|
||||
//$$ try (var builtBuffer = buffer.end()) {
|
||||
//$$ net.minecraft.client.render.BufferRenderer.drawWithGlobalProgram(builtBuffer);
|
||||
//$$ }
|
||||
//#else
|
||||
tessellator.draw();
|
||||
//#endif
|
||||
|
||||
//#if MC>=11700
|
||||
//$$ RenderSystem.enableCull();
|
||||
//#endif
|
||||
|
||||
//#if MC<11700
|
||||
GL11.glEnable(GL11.GL_TEXTURE_2D);
|
||||
//#endif
|
||||
//#endif
|
||||
|
||||
popMatrix();
|
||||
}
|
||||
|
||||
//#if MC>=12105
|
||||
//$$ private void vertex(VertexConsumer buffer, float x, float y, float z, float u, float v, int alpha) {
|
||||
//#else
|
||||
|
||||
Submodule src/main/resources/assets/replaymod/lang updated: ed16d95cd3...9d5205f920
@@ -31,10 +31,12 @@
|
||||
"Mixin_SkipBlockOutlinesDuringRender",
|
||||
"Mixin_SkipHudDuringRender",
|
||||
"Mixin_StabilizeCamera",
|
||||
"Mixin_RealLens_Camera",
|
||||
"Mixin_Stereoscopic_Camera",
|
||||
"Mixin_Stereoscopic_HandRenderPass",
|
||||
"Mixin_SuppressFramebufferResizeDuringRender",
|
||||
"Mixin_UseGuiFramebufferDuringGuiRendering",
|
||||
"Mixin_DynamicFov",
|
||||
//#if MC>=11600
|
||||
"Mixin_AddIrisOdsShaderUniforms",
|
||||
"Mixin_LoadIrisOdsShaderPack",
|
||||
|
||||
0
versions/1.20.1/logs/latest.log
Normal file
0
versions/1.20.1/logs/latest.log
Normal file
0
versions/1.20.4/logs/latest.log
Normal file
0
versions/1.20.4/logs/latest.log
Normal file
0
versions/1.21.11/logs/latest.log
Normal file
0
versions/1.21.11/logs/latest.log
Normal file
0
versions/26.1/logs/latest.log
Normal file
0
versions/26.1/logs/latest.log
Normal file
Reference in New Issue
Block a user