mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-04-18 06:11:18 +00:00
SpaceWarp render jittering fixed
This commit is contained in:
parent
6542b604be
commit
3646a8feab
9 changed files with 40 additions and 25 deletions
|
@ -30,5 +30,5 @@ void main()
|
|||
|
||||
//TODO:implement motion vector
|
||||
gl_FragColor.rgb = var_Color.rgb;
|
||||
gl_FragColor.a = alpha;
|
||||
gl_FragColor.a = alpha == 1.0 ? 1.0 : 0.0;
|
||||
}
|
||||
|
|
|
@ -32,5 +32,5 @@ void main()
|
|||
|
||||
var_DiffuseTex = attr_TexCoord0.st;
|
||||
var_Color = u_VertColor * attr_Color + u_BaseColor;
|
||||
var_Color.rgb = abs(normal.xyz);
|
||||
var_Color.rgb = var_Color.rgb * 0.1 + abs(normal.xyz) * 0.9;
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "tr_dsa.h"
|
||||
#include "../vr/vr_base.h"
|
||||
#include "../vr/vr_clientinfo.h"
|
||||
#include "../vr/vr_renderer.h"
|
||||
|
||||
|
||||
extern const char *fallbackShader_bokeh_vp;
|
||||
|
@ -188,7 +189,7 @@ GLSL_OverrideShader
|
|||
*/
|
||||
shaderProgram_t* GLSL_OverrideShader(shaderProgram_t * program)
|
||||
{
|
||||
if( Cvar_VariableValue( "vr_motionVector" ) == 1)
|
||||
if( VR_RenderMotionVector() )
|
||||
{
|
||||
return &tr.motionVectorShader;
|
||||
}
|
||||
|
@ -865,8 +866,9 @@ void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value)
|
|||
{
|
||||
program = GLSL_OverrideShader(program);
|
||||
GLint *uniforms = program->uniforms;
|
||||
#ifdef GLSL_CACHE
|
||||
GLint *compare = (GLint *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]);
|
||||
if (!compare)
|
||||
return;
|
||||
|
||||
if (uniforms[uniformNum] == -1)
|
||||
return;
|
||||
|
@ -883,7 +885,7 @@ void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value)
|
|||
}
|
||||
|
||||
*compare = value;
|
||||
#endif
|
||||
|
||||
qglProgramUniform1iEXT(program->program, uniforms[uniformNum], value);
|
||||
}
|
||||
|
||||
|
@ -891,8 +893,9 @@ void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat valu
|
|||
{
|
||||
program = GLSL_OverrideShader(program);
|
||||
GLint *uniforms = program->uniforms;
|
||||
#ifdef GLSL_CACHE
|
||||
GLfloat *compare = (GLfloat *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]);
|
||||
if (!compare)
|
||||
return;
|
||||
|
||||
if (uniforms[uniformNum] == -1)
|
||||
return;
|
||||
|
@ -909,7 +912,7 @@ void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat valu
|
|||
}
|
||||
|
||||
*compare = value;
|
||||
#endif
|
||||
|
||||
qglProgramUniform1fEXT(program->program, uniforms[uniformNum], value);
|
||||
}
|
||||
|
||||
|
@ -917,8 +920,9 @@ void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t
|
|||
{
|
||||
program = GLSL_OverrideShader(program);
|
||||
GLint *uniforms = program->uniforms;
|
||||
#ifdef GLSL_CACHE
|
||||
vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]);
|
||||
if (!compare)
|
||||
return;
|
||||
|
||||
if (uniforms[uniformNum] == -1)
|
||||
return;
|
||||
|
@ -936,7 +940,7 @@ void GLSL_SetUniformVec2(shaderProgram_t *program, int uniformNum, const vec2_t
|
|||
|
||||
compare[0] = v[0];
|
||||
compare[1] = v[1];
|
||||
#endif
|
||||
|
||||
qglProgramUniform2fEXT(program->program, uniforms[uniformNum], v[0], v[1]);
|
||||
}
|
||||
|
||||
|
@ -944,8 +948,9 @@ void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t
|
|||
{
|
||||
program = GLSL_OverrideShader(program);
|
||||
GLint *uniforms = program->uniforms;
|
||||
#ifdef GLSL_CACHE
|
||||
vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]);
|
||||
if (!compare)
|
||||
return;
|
||||
|
||||
if (uniforms[uniformNum] == -1)
|
||||
return;
|
||||
|
@ -962,7 +967,7 @@ void GLSL_SetUniformVec3(shaderProgram_t *program, int uniformNum, const vec3_t
|
|||
}
|
||||
|
||||
VectorCopy(v, compare);
|
||||
#endif
|
||||
|
||||
qglProgramUniform3fEXT(program->program, uniforms[uniformNum], v[0], v[1], v[2]);
|
||||
}
|
||||
|
||||
|
@ -970,8 +975,9 @@ void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t
|
|||
{
|
||||
program = GLSL_OverrideShader(program);
|
||||
GLint *uniforms = program->uniforms;
|
||||
#ifdef GLSL_CACHE
|
||||
vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]);
|
||||
if (!compare)
|
||||
return;
|
||||
|
||||
if (uniforms[uniformNum] == -1)
|
||||
return;
|
||||
|
@ -988,7 +994,7 @@ void GLSL_SetUniformVec4(shaderProgram_t *program, int uniformNum, const vec4_t
|
|||
}
|
||||
|
||||
VectorCopy4(v, compare);
|
||||
#endif
|
||||
|
||||
qglProgramUniform4fEXT(program->program, uniforms[uniformNum], v[0], v[1], v[2], v[3]);
|
||||
}
|
||||
|
||||
|
@ -996,8 +1002,9 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_
|
|||
{
|
||||
program = GLSL_OverrideShader(program);
|
||||
GLint *uniforms = program->uniforms;
|
||||
#ifdef GLSL_CACHE
|
||||
vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]);
|
||||
if (!compare)
|
||||
return;
|
||||
|
||||
if (uniforms[uniformNum] == -1)
|
||||
return;
|
||||
|
@ -1014,7 +1021,7 @@ void GLSL_SetUniformFloat5(shaderProgram_t *program, int uniformNum, const vec5_
|
|||
}
|
||||
|
||||
VectorCopy5(v, compare);
|
||||
#endif
|
||||
|
||||
qglProgramUniform1fvEXT(program->program, uniforms[uniformNum], 5, v);
|
||||
}
|
||||
|
||||
|
@ -1022,8 +1029,9 @@ void GLSL_SetUniformMat4(shaderProgram_t *program, int uniformNum, const mat4_t
|
|||
{
|
||||
program = GLSL_OverrideShader(program);
|
||||
GLint *uniforms = program->uniforms;
|
||||
#ifdef GLSL_CACHE
|
||||
vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]);
|
||||
if (!compare)
|
||||
return;
|
||||
|
||||
if (uniforms[uniformNum] == -1)
|
||||
return;
|
||||
|
@ -1040,7 +1048,7 @@ void GLSL_SetUniformMat4(shaderProgram_t *program, int uniformNum, const mat4_t
|
|||
}
|
||||
|
||||
Mat4Copy(matrix, compare);
|
||||
#endif
|
||||
|
||||
qglProgramUniformMatrix4fvEXT(program->program, uniforms[uniformNum], 1, GL_FALSE, matrix);
|
||||
}
|
||||
|
||||
|
@ -1049,6 +1057,8 @@ void GLSL_SetUniformMat4BoneMatrix(shaderProgram_t *program, int uniformNum, /*c
|
|||
program = GLSL_OverrideShader(program);
|
||||
GLint *uniforms = program->uniforms;
|
||||
vec_t *compare = (float *)(program->uniformBuffer + program->uniformBufferOffsets[uniformNum]);
|
||||
if (!compare)
|
||||
return;
|
||||
|
||||
if (uniforms[uniformNum] == -1) {
|
||||
return;
|
||||
|
|
|
@ -49,7 +49,6 @@ cvar_t *vr_goreLevel = NULL;
|
|||
cvar_t *vr_hudDrawStatus = NULL;
|
||||
cvar_t *vr_showConsoleMessages = NULL;
|
||||
cvar_t *vr_spacewarp = NULL;
|
||||
cvar_t *vr_motionvector = NULL;
|
||||
|
||||
engine_t* VR_Init( ovrJava java )
|
||||
{
|
||||
|
@ -170,7 +169,6 @@ void VR_InitCvars( void )
|
|||
vr_hudDrawStatus = Cvar_Get ("vr_hudDrawStatus", "1", CVAR_ARCHIVE); // 0 - no hud, 1 - in-world hud, 2 - performance (static HUD)
|
||||
vr_showConsoleMessages = Cvar_Get ("vr_showConsoleMessages", "1", CVAR_ARCHIVE);
|
||||
vr_spacewarp = Cvar_Get ("vr_spaceWarp", "0", CVAR_ARCHIVE);
|
||||
vr_motionvector = Cvar_Get ("vr_motionVector", "0", CVAR_ARCHIVE);
|
||||
|
||||
// Values are: scale,right,up,forward,pitch,yaw,roll
|
||||
// VALUES PROVIDED BY SkillFur - Thank-you!
|
||||
|
|
|
@ -27,6 +27,7 @@ XrView* projections;
|
|||
XrPosef prevInvViewTransform[2];
|
||||
qboolean fullscreenMode = qfalse;
|
||||
qboolean stageSupported = qfalse;
|
||||
qboolean renderMotionVector = qfalse;
|
||||
|
||||
void VR_UpdateStageBounds(ovrApp* pappState) {
|
||||
XrExtent2Df stageBounds = {};
|
||||
|
@ -504,9 +505,9 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
|
||||
VR_RenderScene( engine, fov, qfalse );
|
||||
if (vr_spacewarp->integer) {
|
||||
Cvar_SetValue( "vr_motionVector", 1 );
|
||||
renderMotionVector = qtrue;
|
||||
VR_RenderScene( engine, fov, qtrue );
|
||||
Cvar_SetValue( "vr_motionVector", 0 );
|
||||
renderMotionVector = qfalse;
|
||||
}
|
||||
|
||||
for (int eye = 0; eye < ovrMaxNumEyes; eye++) {
|
||||
|
@ -545,7 +546,7 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
proj_spacewarp_views[eye].depthSubImage.imageRect.extent.width = frameBuffer->MotionVectorDepthSwapChain.Width;
|
||||
proj_spacewarp_views[eye].depthSubImage.imageRect.extent.height = frameBuffer->MotionVectorDepthSwapChain.Height;
|
||||
proj_spacewarp_views[eye].depthSubImage.imageArrayIndex = eye;
|
||||
proj_spacewarp_views[eye].appSpaceDeltaPose = XrPosef_Multiply(prevInvViewTransform[eye], viewTransform[eye]);
|
||||
proj_spacewarp_views[eye].appSpaceDeltaPose = prevInvViewTransform[eye]; //TODO:XrPosef_Multiply(prevInvViewTransform[eye], viewTransform[eye]);
|
||||
|
||||
proj_spacewarp_views[eye].minDepth = 0.0f;
|
||||
proj_spacewarp_views[eye].maxDepth = 1.0f;
|
||||
|
@ -618,3 +619,8 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
prevInvViewTransform[0] = invViewTransform[0];
|
||||
prevInvViewTransform[1] = invViewTransform[1];
|
||||
}
|
||||
|
||||
|
||||
int VR_RenderMotionVector() {
|
||||
return renderMotionVector;
|
||||
}
|
|
@ -10,6 +10,7 @@ void VR_InitRenderer( engine_t* engine );
|
|||
void VR_DestroyRenderer( engine_t* engine );
|
||||
void VR_DrawFrame( engine_t* engine );
|
||||
void VR_ReInitRenderer();
|
||||
int VR_RenderMotionVector();
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -344,7 +344,7 @@ void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer, GLboolean isMotionVecto
|
|||
res = xrWaitSwapchainImage(frameBuffer->MotionVectorSwapChain.Handle, &waitInfo);
|
||||
i++;
|
||||
ALOGV(
|
||||
" Retry xrWaitSwapchainImage %d times due to XR_TIMEOUT_EXPIRED (duration %f seconds)",
|
||||
" Retry xrWaitSwapchainImage %d times due to XR_TIMEOUT_EXPIRED (duration %f microseconds)",
|
||||
i,
|
||||
waitInfo.timeout * (1E-9));
|
||||
}
|
||||
|
|
|
@ -30,5 +30,5 @@ void main()
|
|||
|
||||
//TODO:implement motion vector
|
||||
gl_FragColor.rgb = var_Color.rgb;
|
||||
gl_FragColor.a = alpha;
|
||||
gl_FragColor.a = alpha == 1.0 ? 1.0 : 0.0;
|
||||
}
|
||||
|
|
|
@ -32,5 +32,5 @@ void main()
|
|||
|
||||
var_DiffuseTex = attr_TexCoord0.st;
|
||||
var_Color = u_VertColor * attr_Color + u_BaseColor;
|
||||
var_Color.rgb = abs(normal.xyz);
|
||||
var_Color.rgb = var_Color.rgb * 0.1 + abs(normal.xyz) * 0.9;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue