working DOF
This commit is contained in:
@@ -4,6 +4,12 @@ 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 org.apache.commons.lang3.tuple.Triple;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -50,14 +56,14 @@ public class RealLensOpenGlFrameCapturer
|
||||
|
||||
|
||||
|
||||
private static Data[] calculateCameras() {
|
||||
Data[] cameras = golden_disk(SAMPLES, APERTURE_RADIUS);
|
||||
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;
|
||||
float dirZ = focal_distance - cam.dz;
|
||||
|
||||
// Вычисляем yaw и pitch из направления
|
||||
cam.yaw = (float) -Math.toDegrees(Math.atan2(dirX, dirZ));
|
||||
@@ -67,11 +73,14 @@ public class RealLensOpenGlFrameCapturer
|
||||
return cameras;
|
||||
}
|
||||
|
||||
private final Path positionPath;
|
||||
|
||||
public RealLensOpenGlFrameCapturer(
|
||||
WorldRenderer worldRenderer,
|
||||
RenderInfo renderInfo
|
||||
) {
|
||||
super(worldRenderer, renderInfo);
|
||||
this.positionPath = ReplayModSimplePathing.instance.getCurrentTimeline().getPositionPath();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,13 +88,24 @@ public class RealLensOpenGlFrameCapturer
|
||||
float partialTicks = renderInfo.updateForNextFrame();
|
||||
int frameId = framesDone++;
|
||||
|
||||
Data[] cameras = calculateCameras();
|
||||
int fps = renderInfo.getRenderSettings().getFramesPerSecond();
|
||||
long keyframeTime = (long) frameId * 1000 / fps;
|
||||
|
||||
float focalDistance = positionPath.getValue(LensProperties.FOCAL_DISTANCE, keyframeTime).map(Triple::getLeft).orElse(5.0f);
|
||||
float apertureRadius = positionPath.getValue(LensProperties.APERTURE_RADIUS, keyframeTime).map(Triple::getLeft).orElse(0.05f);
|
||||
int samples = renderInfo.getRenderSettings().getLensBlurSamples();
|
||||
|
||||
if (positionPath == null) {
|
||||
System.err.println("positionPath is null!");
|
||||
focalDistance = Float.MAX_VALUE;
|
||||
apertureRadius = 0.01f;
|
||||
}
|
||||
|
||||
Data[] cameras = calculateCameras(focalDistance, apertureRadius, samples);
|
||||
|
||||
OpenGlFrame[] frames = new OpenGlFrame[cameras.length];
|
||||
|
||||
for (int i = 0; i < cameras.length; i++) {
|
||||
// CAMERAS[i] передаётся в renderFrame → worldRenderer.renderWorld(partialTicks, CAMERAS[i])
|
||||
// → EntityRendererHandler.data = CAMERAS[i] (автоматически)
|
||||
frames[i] = renderFrame(frameId, partialTicks, cameras[i]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user