VideoCommon: Switch to Nvidia stereoscopy offset formula.

This commit is contained in:
Jules Blok 2014-11-08 14:31:26 +01:00
parent 8210b9c915
commit f3ddf37d07
6 changed files with 13 additions and 12 deletions

View File

@ -457,7 +457,7 @@ VideoConfigDiag::VideoConfigDiag(wxWindow* parent, const std::string &title, con
szr_stereo->Add(new wxStaticText(page_enh, -1, _("Stereoscopic 3D Mode:")), 1, wxALIGN_CENTER_VERTICAL, 0);
szr_stereo->Add(CreateChoice(page_enh, vconfig.iStereoMode, wxGetTranslation(stereo_3d_desc), 4, stereo_choices));
wxSlider* const sep_slider = new wxSlider(page_enh, wxID_ANY, vconfig.iStereoSeparation, 30, 90, wxDefaultPosition, wxDefaultSize, wxSL_VALUE_LABEL);
wxSlider* const sep_slider = new wxSlider(page_enh, wxID_ANY, vconfig.iStereoSeparation, 10, 100, wxDefaultPosition, wxDefaultSize, wxSL_VALUE_LABEL);
sep_slider->Bind(wxEVT_SLIDER, &VideoConfigDiag::Event_StereoSep, this);
RegisterControl(sep_slider, wxGetTranslation(stereo_separation_desc));

View File

@ -43,6 +43,6 @@ struct VertexShaderConstants
float4 normalmatrices[32];
float4 posttransformmatrices[64];
float4 depthparams;
float4 stereooffset;
float4 stereoparams;
};

View File

@ -83,8 +83,8 @@ static inline void GenerateGeometryShader(T& out, u32 components, API_TYPE ApiTy
if (g_ActiveConfig.iStereoMode > 0)
{
out.Write("\t\tf.clipPos.x += f.clipPos.w * " I_STEREOOFFSET"[layer] * " I_PROJECTION"[0][0];\n");
out.Write("\t\tf.pos.x += f.pos.w * " I_STEREOOFFSET"[layer] * " I_PROJECTION"[0][0];\n");
out.Write("\t\tf.clipPos.x += " I_STEREOPARAMS"[layer] * (f.clipPos.w - " I_STEREOPARAMS"[2]);\n");
out.Write("\t\tf.pos.x += " I_STEREOPARAMS"[layer] * (f.pos.w - " I_STEREOPARAMS"[2]);\n");
}
out.Write("\t\tgl_Position = f.pos;\n");

View File

@ -239,7 +239,7 @@ private:
#define I_NORMALMATRICES "cnmtx"
#define I_POSTTRANSFORMMATRICES "cpostmtx"
#define I_DEPTHPARAMS "cDepth" // farZ, zRange
#define I_STEREOOFFSET "csoffset"
#define I_STEREOPARAMS "cstereo"
static const char s_shader_uniforms[] =
"\tfloat4 " I_POSNORMALMATRIX"[6];\n"
@ -251,4 +251,4 @@ static const char s_shader_uniforms[] =
"\tfloat4 " I_NORMALMATRICES"[32];\n"
"\tfloat4 " I_POSTTRANSFORMMATRICES"[64];\n"
"\tfloat4 " I_DEPTHPARAMS";\n"
"\tfloat4 " I_STEREOOFFSET";\n";
"\tfloat4 " I_STEREOPARAMS";\n";

View File

@ -515,13 +515,14 @@ void VertexShaderManager::SetConstants()
if (g_ActiveConfig.iStereoMode > 0 && xfmem.projection.type == GX_PERSPECTIVE)
{
float offset = g_ActiveConfig.iStereoSeparation / (200.0f * g_ActiveConfig.iStereoFocalLength);
constants.stereooffset[0] = (g_ActiveConfig.bStereoSwapEyes) ? offset : -offset;
constants.stereooffset[1] = (g_ActiveConfig.bStereoSwapEyes) ? -offset : offset;
float offset = g_ActiveConfig.iStereoSeparation / 10000.0f;
constants.stereoparams[0] = (g_ActiveConfig.bStereoSwapEyes) ? offset : -offset;
constants.stereoparams[1] = (g_ActiveConfig.bStereoSwapEyes) ? -offset : offset;
constants.stereoparams[2] = (float)g_ActiveConfig.iStereoFocalLength;
}
else
{
constants.stereooffset[0] = constants.stereooffset[1] = 0;
constants.stereoparams[0] = constants.stereoparams[1] = 0;
}
dirty = true;

View File

@ -67,8 +67,8 @@ void VideoConfig::Load(const std::string& ini_file)
settings->Get("FreeLook", &bFreeLook, 0);
settings->Get("UseFFV1", &bUseFFV1, 0);
settings->Get("StereoMode", &iStereoMode, 0);
settings->Get("StereoSeparation", &iStereoSeparation, 65);
settings->Get("StereoFocalLength", &iStereoFocalLength, 50);
settings->Get("StereoSeparation", &iStereoSeparation, 50);
settings->Get("StereoFocalLength", &iStereoFocalLength, 30);
settings->Get("StereoSwapEyes", &bStereoSwapEyes, false);
settings->Get("EnablePixelLighting", &bEnablePixelLighting, 0);
settings->Get("FastDepthCalc", &bFastDepthCalc, true);