mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Fix math of simple stereo
This commit is contained in:
parent
2a3aaed711
commit
a9b5a4739e
1 changed files with 9 additions and 6 deletions
|
@ -24,6 +24,7 @@
|
|||
#include "Common/GPU/ShaderWriter.h"
|
||||
#include "Common/GPU/thin3d.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/System.h"
|
||||
#include "GPU/ge_constants.h"
|
||||
#include "GPU/GPUState.h"
|
||||
#include "GPU/Common/ShaderId.h"
|
||||
|
@ -916,6 +917,14 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
|
|||
}
|
||||
|
||||
WRITE(p, " vec4 viewPos = vec4(mul(vec4(worldpos, 1.0), u_view).xyz, 1.0);\n");
|
||||
if (useSimpleStereo) {
|
||||
float ipd = 0.065f;
|
||||
float scale = 1.0f;
|
||||
if (PSP_CoreParameter().compat.vrCompat().UnitsPerMeter > 0) {
|
||||
scale = PSP_CoreParameter().compat.vrCompat().UnitsPerMeter;
|
||||
}
|
||||
WRITE(p, " viewPos.x += %f * float(gl_ViewIndex * 2 - 1);\n", scale * ipd * 0.5);
|
||||
}
|
||||
|
||||
// Final view and projection transforms.
|
||||
if (gstate_c.Use(GPU_ROUND_DEPTH_TO_16BIT)) {
|
||||
|
@ -1351,12 +1360,6 @@ bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguag
|
|||
WRITE(p, " %sgl_Position.y *= u_scaleY;\n", compat.vsOutPrefix);
|
||||
}
|
||||
|
||||
if (useSimpleStereo && useHWTransform) {
|
||||
p.C(" float zFactor = 0.2 * float(gl_ViewIndex * 2 - 1);\n");
|
||||
p.C(" float zFocus = 0.0;\n");
|
||||
p.C(" gl_Position.x += (-gl_Position.z - zFocus) * zFactor;\n");
|
||||
}
|
||||
|
||||
if (needsZWHack) {
|
||||
// See comment in thin3d_vulkan.cpp.
|
||||
WRITE(p, " if (%sgl_Position.z == %sgl_Position.w) %sgl_Position.z *= 0.999999;\n",
|
||||
|
|
Loading…
Add table
Reference in a new issue