Orient camera for ODS in game instead of in vertex shader
This makes it work more like regular 360 mode and is generally more compatible because it doesn't require the frustum culling workarounds which the GPU solution needs. In particular, this fixes frustum culling with newer sodium versions (which no longer use the vanilla intersection checking method) and fixes the clouds on modern Iris (which seems to be using a different shader program for clouds).
This commit is contained in:
@@ -129,7 +129,7 @@ public class IrisODSFrameCapturer implements FrameCapturer<ODSOpenGlFrame> {
|
||||
@Override
|
||||
protected OpenGlFrame renderFrame(int frameId, float partialTicks, CubicOpenGlFrameCapturer.Data captureData) {
|
||||
direction = captureData.ordinal();
|
||||
return super.renderFrame(frameId, partialTicks, null);
|
||||
return super.renderFrame(frameId, partialTicks, captureData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public class ODSFrameCapturer implements FrameCapturer<ODSOpenGlFrame> {
|
||||
@Override
|
||||
protected OpenGlFrame renderFrame(int frameId, float partialTicks, CubicOpenGlFrameCapturer.Data captureData) {
|
||||
directionVariable.set(captureData.ordinal());
|
||||
return super.renderFrame(frameId, partialTicks, null);
|
||||
return super.renderFrame(frameId, partialTicks, captureData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
package com.replaymod.render.mixin;
|
||||
|
||||
import com.replaymod.core.versions.MCVer;
|
||||
import com.replaymod.render.hooks.EntityRendererHandler;
|
||||
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.CallbackInfoReturnable;
|
||||
|
||||
//#if MC>=10800
|
||||
import net.minecraft.client.render.Frustum;
|
||||
//#else
|
||||
//$$ import net.minecraft.client.renderer.culling.Frustrum;
|
||||
//#endif
|
||||
|
||||
//#if MC>=10800
|
||||
@Mixin(Frustum.class)
|
||||
//#else
|
||||
//$$ @Mixin(Frustrum.class)
|
||||
//#endif
|
||||
public abstract class Mixin_Omnidirectional_DisableFrustumCulling {
|
||||
//#if MC>=11500
|
||||
@Inject(method = "isAnyCornerVisible", at = @At("HEAD"), cancellable = true)
|
||||
//#else
|
||||
//$$ @Inject(method = "intersects", at = @At("HEAD"), cancellable = true)
|
||||
//#endif
|
||||
public void intersects(CallbackInfoReturnable<Boolean> ci) {
|
||||
EntityRendererHandler handler = ((EntityRendererHandler.IEntityRenderer) MCVer.getMinecraft().gameRenderer).replayModRender_getHandler();
|
||||
if (handler != null && handler.omnidirectional) {
|
||||
// Note the following used to be true but for simplicity non-ODS omnidirectional is the same now too.
|
||||
// Normally the camera is always facing the direction of the omnidirectional image face that is currently
|
||||
// getting rendered. With ODS however, the camera is always facing forwards and the turning happens in the
|
||||
// vertex shader (non-trivial due to stereo). As such, all chunks need to be rendered all the time for ODS.
|
||||
ci.setReturnValue(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,10 +9,49 @@ uniform int direction;
|
||||
|
||||
const float eyeDistance = 0.14;
|
||||
|
||||
void orient(vec4 position, int orientation) {
|
||||
float z;
|
||||
if (orientation == 0) { // LEFT
|
||||
z = position.z;
|
||||
position.z = position.x;
|
||||
position.x = -z;
|
||||
} else if (orientation == 1) { // RIGHT
|
||||
z = position.z;
|
||||
position.z = -position.x;
|
||||
position.x = z;
|
||||
} else if (orientation == 2) { // FRONT
|
||||
// No changes required
|
||||
} else if (orientation == 3) { // BACK
|
||||
position.x = -position.x;
|
||||
position.z = -position.z;
|
||||
} else if (orientation == 4) { // TOP
|
||||
z = position.z;
|
||||
position.z = -position.y;
|
||||
position.y = z;
|
||||
} else if (orientation == 5) { // BOTTOM
|
||||
z = position.z;
|
||||
position.z = position.y;
|
||||
position.y = -z;
|
||||
}
|
||||
}
|
||||
|
||||
void orientInverse(vec4 position, int orientation) {
|
||||
if (orientation < 2) {
|
||||
orient(position, 1 - orientation); // LEFT and RIGHT flip
|
||||
} else if (orientation < 4) {
|
||||
orient(position, orientation); // FRONT and BACK are their own inverses
|
||||
} else {
|
||||
orient(position, (1 - (orientation - 4)) + 4); // TOP and BOTTOM flip
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Transform to view space
|
||||
vec4 position = gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
// Undo the camera rotation, so we always apply our stereo effect looking in the same direction
|
||||
orientInverse(position, direction);
|
||||
|
||||
// Distort for ODS
|
||||
// O := The origin
|
||||
// P := The current vertex/point
|
||||
@@ -34,30 +73,8 @@ void main() {
|
||||
// Calculate the vector between O and T and finally move the vertex by that vector
|
||||
position -= vec4(distTO * sin(angOT), 0, distTO * cos(angOT), 0);
|
||||
|
||||
// Rotate for different cubic views
|
||||
float z;
|
||||
if (direction == 0) { // LEFT
|
||||
z = position.z;
|
||||
position.z = position.x;
|
||||
position.x = -z;
|
||||
} else if (direction == 1) { // RIGHT
|
||||
z = position.z;
|
||||
position.z = -position.x;
|
||||
position.x = z;
|
||||
} else if (direction == 2) { // FRONT
|
||||
// No changes required
|
||||
} else if (direction == 3) { // BACK
|
||||
position.x = -position.x;
|
||||
position.z = -position.z;
|
||||
} else if (direction == 4) { // TOP
|
||||
z = position.z;
|
||||
position.z = -position.y;
|
||||
position.y = z;
|
||||
} else if (direction == 5) { // BOTTOM
|
||||
z = position.z;
|
||||
position.z = position.y;
|
||||
position.y = -z;
|
||||
}
|
||||
// Rotate back into the correct cubic view
|
||||
orient(position, direction);
|
||||
|
||||
// Transform to screen space
|
||||
gl_Position = gl_ProjectionMatrix * position;
|
||||
|
||||
@@ -14,10 +14,49 @@ uniform int direction;
|
||||
|
||||
const float eyeDistance = 0.14;
|
||||
|
||||
void orient(vec4 position, int orientation) {
|
||||
float z;
|
||||
if (orientation == 0) { // LEFT
|
||||
z = position.z;
|
||||
position.z = position.x;
|
||||
position.x = -z;
|
||||
} else if (orientation == 1) { // RIGHT
|
||||
z = position.z;
|
||||
position.z = -position.x;
|
||||
position.x = z;
|
||||
} else if (orientation == 2) { // FRONT
|
||||
// No changes required
|
||||
} else if (orientation == 3) { // BACK
|
||||
position.x = -position.x;
|
||||
position.z = -position.z;
|
||||
} else if (orientation == 4) { // TOP
|
||||
z = position.z;
|
||||
position.z = -position.y;
|
||||
position.y = z;
|
||||
} else if (orientation == 5) { // BOTTOM
|
||||
z = position.z;
|
||||
position.z = position.y;
|
||||
position.y = -z;
|
||||
}
|
||||
}
|
||||
|
||||
void orientInverse(vec4 position, int orientation) {
|
||||
if (orientation < 2) {
|
||||
orient(position, 1 - orientation); // LEFT and RIGHT flip
|
||||
} else if (orientation < 4) {
|
||||
orient(position, orientation); // FRONT and BACK are their own inverses
|
||||
} else {
|
||||
orient(position, (1 - (orientation - 4)) + 4); // TOP and BOTTOM flip
|
||||
}
|
||||
}
|
||||
|
||||
void main() {
|
||||
// Transform to view space
|
||||
vec4 position = gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
// Undo the camera rotation, so we always apply our stereo effect looking in the same direction
|
||||
orientInverse(position, direction);
|
||||
|
||||
// Distort for ODS
|
||||
// O := The origin
|
||||
// P := The current vertex/point
|
||||
@@ -39,30 +78,8 @@ void main() {
|
||||
// Calculate the vector between O and T and finally move the vertex by that vector
|
||||
position -= vec4(distTO * sin(angOT), 0, distTO * cos(angOT), 0);
|
||||
|
||||
// Rotate for different cubic views
|
||||
float z;
|
||||
if (direction == 0) { // LEFT
|
||||
z = position.z;
|
||||
position.z = position.x;
|
||||
position.x = -z;
|
||||
} else if (direction == 1) { // RIGHT
|
||||
z = position.z;
|
||||
position.z = -position.x;
|
||||
position.x = z;
|
||||
} else if (direction == 2) { // FRONT
|
||||
// No changes required
|
||||
} else if (direction == 3) { // BACK
|
||||
position.x = -position.x;
|
||||
position.z = -position.z;
|
||||
} else if (direction == 4) { // TOP
|
||||
z = position.z;
|
||||
position.z = -position.y;
|
||||
position.y = z;
|
||||
} else if (direction == 5) { // BOTTOM
|
||||
z = position.z;
|
||||
position.z = position.y;
|
||||
position.y = -z;
|
||||
}
|
||||
// Rotate back into the correct cubic view
|
||||
orient(position, direction);
|
||||
|
||||
// Transform to screen space
|
||||
gl_Position = gl_ProjectionMatrix * position;
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
"Mixin_HideNameTags",
|
||||
"Mixin_HideNameTags_LivingEntity",
|
||||
"Mixin_Omnidirectional_Camera",
|
||||
"Mixin_Omnidirectional_DisableFrustumCulling",
|
||||
"Mixin_Omnidirectional_Rotation",
|
||||
"Mixin_PreserveDepthDuringGuiRendering",
|
||||
"Mixin_SkipBlockOutlinesDuringRender",
|
||||
|
||||
Reference in New Issue
Block a user