Implement ODS rendering via Iris Shader for MC 1.17
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
#version 120
|
||||
|
||||
uniform sampler2D texture;
|
||||
uniform sampler2D lightmap;
|
||||
|
||||
varying vec4 color;
|
||||
varying vec2 texcoord;
|
||||
varying vec2 lmcoord;
|
||||
|
||||
void main() {
|
||||
vec4 lightmap = texture2D(lightmap, lmcoord);
|
||||
vec4 color = texture2D(texture, texcoord) * color;
|
||||
color *= lightmap;
|
||||
gl_FragColor = color;
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
#version 120
|
||||
|
||||
varying vec4 color;
|
||||
varying vec2 texcoord;
|
||||
varying vec2 lmcoord;
|
||||
|
||||
uniform int leftEye;
|
||||
uniform int direction;
|
||||
|
||||
const float eyeDistance = 0.14;
|
||||
|
||||
void main() {
|
||||
// Transform to view space
|
||||
vec4 position = gl_ModelViewMatrix * gl_Vertex;
|
||||
|
||||
// Distort for ODS
|
||||
// O := The origin
|
||||
// P := The current vertex/point
|
||||
// T := Point of tangency with the tangent going through P
|
||||
// Distance between P and O
|
||||
float distPO = sqrt(position.x * position.x + position.z * position.z);
|
||||
float distTO = eyeDistance * 0.5;
|
||||
// Angle between PO and PT
|
||||
float angP = acos(distTO / distPO);
|
||||
// Angle between PO and TO (angle at the origin)
|
||||
float angO = 90.0 - angP;
|
||||
if (leftEye == 0) {
|
||||
angO = -angO;
|
||||
}
|
||||
// The angel of OP within the circle, that is between OP and O(0,1)
|
||||
float angOP = atan(position.x, position.z);
|
||||
// The angle of OT within the circle, that is between OT and O(0,1)
|
||||
float angOT = angO + angOP;
|
||||
// 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;
|
||||
}
|
||||
|
||||
// Transform to screen space
|
||||
gl_Position = gl_ProjectionMatrix * position;
|
||||
|
||||
// Misc.
|
||||
color = gl_Color;
|
||||
texcoord = (gl_TextureMatrix[0] * gl_MultiTexCoord0).xy;
|
||||
lmcoord = (gl_TextureMatrix[1] * gl_MultiTexCoord1).xy;
|
||||
}
|
||||
@@ -20,6 +20,10 @@
|
||||
"Mixin_StabilizeCamera",
|
||||
"Mixin_Stereoscopic_Camera",
|
||||
"Mixin_Stereoscopic_HandRenderPass",
|
||||
//#if MC>=11600
|
||||
"Mixin_AddIrisOdsShaderUniforms",
|
||||
"Mixin_LoadIrisOdsShaderPack",
|
||||
//#endif
|
||||
//#if MC>=10800
|
||||
//#if MC>=11500
|
||||
"Mixin_BlockOnChunkRebuilds",
|
||||
|
||||
Reference in New Issue
Block a user