mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-10 14:52:00 +00:00
Not working yet
This commit is contained in:
parent
0c52a61cf6
commit
e1a04d2200
45 changed files with 619 additions and 227 deletions
Binary file not shown.
|
@ -2809,7 +2809,7 @@ void CG_DrawActive( void ) {
|
|||
|
||||
|
||||
float ipd = trap_Cvar_VariableValue("r_stereoSeparation") / 1000.0f;
|
||||
float separation = worldscale * (ipd / 2) * (cg.stereoView == STEREO_LEFT ? -1.0f : 1.0f);
|
||||
float separation = 0.0F;//worldscale * (ipd / 2) * (cg.stereoView == STEREO_LEFT ? -1.0f : 1.0f);
|
||||
|
||||
if (cg.snap->ps.pm_flags & PMF_FOLLOW && vr->follow_mode == VRFM_FIRSTPERSON)
|
||||
{
|
||||
|
|
|
@ -297,7 +297,7 @@ static void CG_TouchItem( centity_t *cent ) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (cg.stereoView == STEREO_LEFT)
|
||||
//if (cg.stereoView == STEREO_LEFT)
|
||||
{
|
||||
// grab it
|
||||
BG_AddPredictableEventToPlayerstate(EV_ITEM_PICKUP, cent->currentState.modelindex,
|
||||
|
|
|
@ -745,7 +745,7 @@ static int CG_CalcViewValues( ) {
|
|||
VectorCopy(cg.refdef.vieworg, cg.vr_vieworigin);
|
||||
}
|
||||
|
||||
if (!cgs.localServer && cg.stereoView == STEREO_LEFT)
|
||||
if (!cgs.localServer)// && cg.stereoView == STEREO_LEFT)
|
||||
{
|
||||
vec3_t weaponorigin, weaponangles;
|
||||
CG_CalculateVRWeaponPosition(weaponorigin, weaponangles);
|
||||
|
@ -998,7 +998,7 @@ void CG_DrawActiveFrame( int serverTime, stereoFrame_t stereoView, qboolean demo
|
|||
// this counter will be bumped for every valid scene we generate
|
||||
cg.clientFrame++;
|
||||
|
||||
if (cg.stereoView == STEREO_LEFT)
|
||||
//if (cg.stereoView == STEREO_LEFT)
|
||||
{
|
||||
// update cg.predictedPlayerState - only do this on the first eye render
|
||||
CG_PredictPlayerState();
|
||||
|
|
|
@ -599,7 +599,8 @@ void SCR_UpdateScreen( void ) {
|
|||
// XXX
|
||||
int in_anaglyphMode = Cvar_VariableIntegerValue("r_anaglyphMode");
|
||||
// if running in stereo, we need to draw the frame twice
|
||||
if ( cls.glconfig.stereoEnabled || in_anaglyphMode) {
|
||||
if ( qfalse )//cls.glconfig.stereoEnabled || in_anaglyphMode)
|
||||
{
|
||||
SCR_DrawScreenField( STEREO_LEFT );
|
||||
SCR_DrawScreenField( STEREO_RIGHT );
|
||||
} else {
|
||||
|
|
|
@ -256,6 +256,11 @@ extern void (APIENTRYP qglUnlockArraysEXT) (void);
|
|||
GLE(void, FramebufferTexture2D, GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level) \
|
||||
GLE(void, FramebufferRenderbuffer, GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) \
|
||||
GLE(void, GenerateMipmap, GLenum target) \
|
||||
GLE(void*, MapBufferRange, GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access) \
|
||||
GLE(void, UnmapBuffer, GLenum target) \
|
||||
GLE(GLuint, GetUniformBlockIndex, GLuint program, const GLchar *uniformBlockName) \
|
||||
GLE(void, UniformBlockBinding, GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding) \
|
||||
GLE(void, BindBufferBase, GLenum target, GLuint index, GLuint buffer) \
|
||||
GLE(void, BlitFramebuffer, GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) \
|
||||
GLE(void, RenderbufferStorageMultisample, GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height) \
|
||||
|
||||
|
|
|
@ -91,7 +91,7 @@ typedef struct {
|
|||
|
||||
#if __ANDROID__
|
||||
void (*SetVRHeadsetParms)( const ovrMatrix4f *projectionMatrix,
|
||||
int renderBufferL, int renderBufferR );
|
||||
int renderBuffer );
|
||||
#endif
|
||||
|
||||
int (*MarkFragments)( int numPoints, const vec3_t *points, const vec3_t projection,
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,17 @@ uniform float u_Time;
|
|||
#endif
|
||||
|
||||
uniform vec4 u_Color;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
varying vec4 var_Color;
|
||||
|
@ -80,7 +90,7 @@ void main()
|
|||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
vec3 dist = u_DlightInfo.xyz - position;
|
||||
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,17 @@ uniform float u_DeformParams[5];
|
|||
#endif
|
||||
|
||||
uniform float u_Time;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
|
@ -125,7 +135,7 @@ void main()
|
|||
position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
var_Scale = CalcFog(position) * u_Color.a * u_Color.a;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,18 @@ uniform float u_DeformParams[5];
|
|||
uniform float u_Time;
|
||||
#endif
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
uniform vec4 u_BaseColor;
|
||||
uniform vec4 u_VertColor;
|
||||
|
||||
|
@ -227,7 +238,7 @@ void main()
|
|||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
#if defined(USE_TCGEN)
|
||||
vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1);
|
||||
|
|
|
@ -41,14 +41,21 @@ uniform vec4 u_DiffuseTexMatrix;
|
|||
uniform vec4 u_DiffuseTexOffTurb;
|
||||
#endif
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
uniform vec4 u_BaseColor;
|
||||
uniform vec4 u_VertColor;
|
||||
|
||||
#if defined(USE_MODELMATRIX)
|
||||
uniform mat4 u_ModelMatrix;
|
||||
#endif
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
#elif defined(USE_BONE_ANIMATION)
|
||||
|
@ -188,7 +195,7 @@ void main()
|
|||
var_TexCoords.xy = texCoords;
|
||||
#endif
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
#if defined(USE_MODELMATRIX)
|
||||
position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec3 attr_Normal;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec3 var_Position;
|
||||
varying vec3 var_Normal;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
|
||||
var_Position = attr_Position;
|
||||
var_Normal = attr_Normal;
|
||||
|
|
|
@ -16,9 +16,17 @@ uniform float u_DeformParams[5];
|
|||
//#endif
|
||||
|
||||
uniform float u_Time;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
|
@ -102,7 +110,7 @@ void main()
|
|||
|
||||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
|
||||
var_Tex1 = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
uniform vec3 u_ToneMinAvgMaxLinear;
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
@ -21,7 +32,7 @@ float FilmicTonemap(float x)
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
var_InvWhite = 1.0 / FilmicTonemap(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x);
|
||||
}
|
||||
|
|
|
@ -546,7 +546,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
R_TransformDlights( backEnd.refdef.num_dlights, backEnd.refdef.dlights, &backEnd.or );
|
||||
}
|
||||
|
||||
GL_SetModelviewMatrix( backEnd.or.modelMatrix, qtrue );
|
||||
GL_SetModelviewMatrix( backEnd.or.eyeViewMatrix[2], qtrue );
|
||||
|
||||
//
|
||||
// change depthrange. Also change projection matrix so first person weapon does not look like coming
|
||||
|
@ -556,24 +556,21 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
{
|
||||
if (depthRange)
|
||||
{
|
||||
if(backEnd.viewParms.stereoFrame != STEREO_CENTER)
|
||||
if(isCrosshair)
|
||||
{
|
||||
if(isCrosshair)
|
||||
if(oldDepthRange)
|
||||
{
|
||||
if(oldDepthRange)
|
||||
{
|
||||
// was not a crosshair but now is, change back proj matrix
|
||||
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
|
||||
}
|
||||
// was not a crosshair but now is, change back proj matrix
|
||||
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
|
||||
}
|
||||
else
|
||||
{
|
||||
viewParms_t temp = backEnd.viewParms;
|
||||
}
|
||||
else
|
||||
{
|
||||
viewParms_t temp = backEnd.viewParms;
|
||||
|
||||
R_SetupProjection(&temp, r_znear->value, 0, qfalse);
|
||||
R_SetupProjection(&temp, r_znear->value, 0, qfalse);
|
||||
|
||||
GL_SetProjectionMatrix( temp.projectionMatrix );
|
||||
}
|
||||
GL_SetProjectionMatrix( temp.projectionMatrix );
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
|
@ -586,7 +583,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
}
|
||||
else
|
||||
{
|
||||
if(!wasCrosshair && backEnd.viewParms.stereoFrame != STEREO_CENTER)
|
||||
if(!wasCrosshair)
|
||||
{
|
||||
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
|
||||
}
|
||||
|
@ -621,7 +618,7 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
|
||||
// go back to the world modelview matrix
|
||||
|
||||
GL_SetModelviewMatrix( backEnd.viewParms.world.modelMatrix, qtrue );
|
||||
GL_SetModelviewMatrix( backEnd.viewParms.world.eyeViewMatrix[2], qtrue );
|
||||
|
||||
#ifdef __ANDROID__
|
||||
glDepthRangef(0, 1);
|
||||
|
@ -756,7 +753,8 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
|
|||
|
||||
GLSL_BindProgram(&tr.textureColorShader);
|
||||
|
||||
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
//GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);
|
||||
|
||||
RB_InstantQuad2(quadVerts, texCoords);
|
||||
|
|
|
@ -415,7 +415,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
|
|||
tr.vrParms.renderBufferOriginal = tr.renderFbo->frameBuffer;
|
||||
}
|
||||
|
||||
if ( stereoFrame == STEREO_LEFT ) {
|
||||
/* if ( stereoFrame == STEREO_LEFT ) {
|
||||
if (tr.vrParms.valid == qtrue) {
|
||||
if (tr.renderFbo) {
|
||||
switchEyeCommand_t* sec;
|
||||
|
@ -440,6 +440,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
|
|||
} else {
|
||||
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame );
|
||||
}
|
||||
*/
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -537,6 +538,8 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
|
|||
}
|
||||
|
||||
tr.refdef.stereoFrame = stereoFrame;
|
||||
|
||||
GLSL_PrepareShaders();
|
||||
}
|
||||
|
||||
|
||||
|
@ -591,10 +594,9 @@ void R_Mat4Transpose( const float in[4][4], float* out ) {
|
|||
|
||||
|
||||
void RE_SetVRHeadsetParms( const ovrMatrix4f *projectionMatrix,
|
||||
int renderBufferL, int renderBufferR ) {
|
||||
int renderBuffer ) {
|
||||
R_Mat4Transpose(projectionMatrix->M, tr.vrParms.projection);
|
||||
tr.vrParms.renderBufferL = renderBufferL;
|
||||
tr.vrParms.renderBufferR = renderBufferR;
|
||||
tr.vrParms.renderBuffer = renderBuffer;
|
||||
tr.vrParms.valid = qtrue;
|
||||
}
|
||||
//#endif
|
||||
|
|
|
@ -440,14 +440,14 @@ void FBO_Shutdown(void)
|
|||
for(j = 0; j < glRefConfig.maxColorAttachments; j++)
|
||||
{
|
||||
if(fbo->colorBuffers[j])
|
||||
qglDeleteRenderbuffers(1, &fbo->colorBuffers[j]);
|
||||
qglDeleteTextures(1, &fbo->colorBuffers[j]);
|
||||
}
|
||||
|
||||
if(fbo->depthBuffer)
|
||||
qglDeleteRenderbuffers(1, &fbo->depthBuffer);
|
||||
qglDeleteTextures(1, &fbo->depthBuffer);
|
||||
|
||||
if(fbo->stencilBuffer)
|
||||
qglDeleteRenderbuffers(1, &fbo->stencilBuffer);
|
||||
qglDeleteTextures(1, &fbo->stencilBuffer);
|
||||
|
||||
if(fbo->frameBuffer)
|
||||
qglDeleteFramebuffers(1, &fbo->frameBuffer);
|
||||
|
@ -576,8 +576,9 @@ void FBO_BlitFromTexture(struct image_s *src, vec4_t inSrcTexCorners, vec2_t inS
|
|||
GL_State( blend );
|
||||
|
||||
GLSL_BindProgram(shaderProgram);
|
||||
|
||||
GLSL_SetUniformMat4(shaderProgram, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection);
|
||||
|
||||
GLSL_SetUniformMat4(shaderProgram, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
// GLSL_SetUniformMat4(shaderProgram, UNIFORM_MODELVIEWPROJECTIONMATRIX, projection);
|
||||
GLSL_SetUniformVec4(shaderProgram, UNIFORM_COLOR, color);
|
||||
GLSL_SetUniformVec2(shaderProgram, UNIFORM_INVTEXRES, invTexRes);
|
||||
GLSL_SetUniformVec2(shaderProgram, UNIFORM_AUTOEXPOSUREMINMAX, tr.refdef.autoExposureMinMax);
|
||||
|
|
|
@ -149,7 +149,7 @@ void RB_AddFlare( void *surface, int fogNum, vec3_t point, vec3_t color, vec3_t
|
|||
|
||||
// if the point is off the screen, don't bother adding it
|
||||
// calculate screen coordinates and depth
|
||||
R_TransformModelToClip( point, backEnd.or.modelMatrix,
|
||||
R_TransformModelToClip( point, backEnd.or.eyeViewMatrix[2],
|
||||
backEnd.viewParms.projectionMatrix, eye, clip );
|
||||
|
||||
// check to see if the point is completely off screen
|
||||
|
|
|
@ -24,6 +24,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "tr_dsa.h"
|
||||
|
||||
|
||||
extern const char *fallbackShader_bokeh_vp;
|
||||
extern const char *fallbackShader_bokeh_fp;
|
||||
extern const char *fallbackShader_calclevels4x_vp;
|
||||
|
@ -60,6 +61,13 @@ typedef struct uniformInfo_s
|
|||
}
|
||||
uniformInfo_t;
|
||||
|
||||
#define ORTHO_PROJECTION 0
|
||||
#define NORMAL_PROJECTION 1
|
||||
|
||||
GLuint viewMatricesBuffer;
|
||||
GLuint projectionMatricesBuffer[2];
|
||||
|
||||
|
||||
// These must be in the same order as in uniform_t in tr_local.h.
|
||||
static uniformInfo_t uniformsInfo[] =
|
||||
{
|
||||
|
@ -122,7 +130,6 @@ static uniformInfo_t uniformsInfo[] =
|
|||
{ "u_FogColorMask", GLSL_VEC4 },
|
||||
|
||||
{ "u_ModelMatrix", GLSL_MAT16 },
|
||||
{ "u_ModelViewProjectionMatrix", GLSL_MAT16 },
|
||||
|
||||
{ "u_Time", GLSL_FLOAT },
|
||||
{ "u_VertexLerp" , GLSL_FLOAT },
|
||||
|
@ -160,6 +167,61 @@ typedef enum
|
|||
}
|
||||
glslPrintLog_t;
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
GLSL_ViewMatricesUniformBuffer
|
||||
====================
|
||||
*/
|
||||
static void GLSL_ViewMatricesUniformBuffer(const float value[32]) {
|
||||
|
||||
// Update the scene matrices.
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, viewMatricesBuffer);
|
||||
float* viewMatrices = (float*)qglMapBufferRange(
|
||||
GL_UNIFORM_BUFFER,
|
||||
0,
|
||||
2 * 16 * sizeof(float),
|
||||
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
|
||||
|
||||
if (viewMatrices == NULL)
|
||||
{
|
||||
ri.Error(ERR_DROP, "View Matrices Uniform Buffer is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy((char*)viewMatrices, value, 32 * sizeof(float));
|
||||
|
||||
qglUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
GLSL_ProjectionMatricesUniformBuffer
|
||||
====================
|
||||
*/
|
||||
static void GLSL_ProjectionMatricesUniformBuffer(GLint projectionMatricesBuffer, const float value[16]) {
|
||||
|
||||
// Update the scene matrices.
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, projectionMatricesBuffer);
|
||||
float* projectionMatrix = (float*)qglMapBufferRange(
|
||||
GL_UNIFORM_BUFFER,
|
||||
0,
|
||||
16 * sizeof(float),
|
||||
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
|
||||
|
||||
if (projectionMatrix == NULL)
|
||||
{
|
||||
ri.Error(ERR_DROP, "Projection Matrices Uniform Buffer is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy((char*)projectionMatrix, value, 16 * sizeof(float));
|
||||
|
||||
qglUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
}
|
||||
|
||||
static void GLSL_PrintLog(GLuint programOrShader, glslPrintLog_t type, qboolean developerOnly)
|
||||
{
|
||||
char *msg;
|
||||
|
@ -244,6 +306,11 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLchar *extra, char *
|
|||
#ifdef __ANDROID__
|
||||
Q_strcat(dest, size, "#version 300 es\n");
|
||||
|
||||
//Enable multiview
|
||||
Q_strcat(dest, size, "#define NUM_VIEWS 2\n");
|
||||
Q_strcat(dest, size, "#extension GL_OVR_multiview2 : enable\n");
|
||||
Q_strcat(dest, size, "layout(num_views=NUM_VIEWS) in;\n");
|
||||
|
||||
// HACK: use in main menu medium float precision (to prevent issue with missing models textures)
|
||||
if (Cvar_Get("r_uiFullScreen", "1", 0)->integer)
|
||||
Q_strcat(dest, size, "precision mediump float;\n");
|
||||
|
@ -661,6 +728,23 @@ void GLSL_InitUniforms(shaderProgram_t *program)
|
|||
|
||||
GLint *uniforms = program->uniforms;
|
||||
|
||||
//Shader Matrices for the View Matrices
|
||||
GLuint viewMatricesUniformLocation = qglGetUniformBlockIndex(program->program, "ViewMatrices");
|
||||
int numBufferBindings = 0;
|
||||
program->viewMatricesBinding = numBufferBindings++;
|
||||
qglUniformBlockBinding(
|
||||
program->program,
|
||||
viewMatricesUniformLocation,
|
||||
program->viewMatricesBinding);
|
||||
|
||||
//Shader Matrices for the Projection Matrix
|
||||
GLuint projectionMatrixUniformLocation = qglGetUniformBlockIndex(program->program, "ProjectionMatrix");
|
||||
program->projectionMatrixBinding = numBufferBindings++;
|
||||
qglUniformBlockBinding(
|
||||
program->program,
|
||||
projectionMatrixUniformLocation,
|
||||
program->projectionMatrixBinding);
|
||||
|
||||
size = 0;
|
||||
for (i = 0; i < UNIFORM_COUNT; i++)
|
||||
{
|
||||
|
@ -949,6 +1033,28 @@ void GLSL_InitGPUShaders(void)
|
|||
|
||||
ri.Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n");
|
||||
|
||||
//Generate buffer for 2 * view matrices
|
||||
qglGenBuffers(1, &viewMatricesBuffer);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, viewMatricesBuffer);
|
||||
qglBufferData(
|
||||
GL_UNIFORM_BUFFER,
|
||||
2 * 16 * sizeof(float),
|
||||
NULL,
|
||||
GL_STATIC_DRAW);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
|
||||
for (int i = 0; i < 2; ++i)
|
||||
{
|
||||
qglGenBuffers(1, &projectionMatricesBuffer[i]);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, projectionMatricesBuffer[i]);
|
||||
qglBufferData(
|
||||
GL_UNIFORM_BUFFER,
|
||||
16 * sizeof(float),
|
||||
NULL,
|
||||
GL_STATIC_DRAW);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
}
|
||||
|
||||
R_IssuePendingRenderCommands();
|
||||
|
||||
startTime = ri.Milliseconds();
|
||||
|
@ -1517,6 +1623,51 @@ void GLSL_ShutdownGPUShaders(void)
|
|||
GLSL_DeleteGPUShader(&tr.depthBlurShader[i]);
|
||||
}
|
||||
|
||||
void GLSL_PrepareShaders(void)
|
||||
{
|
||||
static qboolean first = qtrue;
|
||||
static float defaultProjection[16];
|
||||
if (first)
|
||||
{
|
||||
memset(defaultProjection, 0, 16 * sizeof(float));
|
||||
|
||||
float orthoProjectionMatrix[16];
|
||||
|
||||
int width, height;
|
||||
if (glState.currentFBO)
|
||||
{
|
||||
width = glState.currentFBO->width;
|
||||
height = glState.currentFBO->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = glConfig.vidWidth;
|
||||
height = glConfig.vidHeight;
|
||||
}
|
||||
|
||||
Mat4Ortho(0, width, height, 0, 0, 1, orthoProjectionMatrix);
|
||||
|
||||
//ortho projection matrix
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[ORTHO_PROJECTION],
|
||||
orthoProjectionMatrix);
|
||||
|
||||
first = qfalse;
|
||||
}
|
||||
|
||||
//We only need to do the following if the default projection changes
|
||||
if (memcmp(defaultProjection, tr.vrParms.projection, 16 * sizeof(float)) != 0)
|
||||
{
|
||||
//Take a copy of the default projection
|
||||
memcpy(defaultProjection, tr.vrParms.projection, 16 * sizeof(float));
|
||||
|
||||
//unadjusted projection matrix
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[NORMAL_PROJECTION],
|
||||
tr.vrParms.projection);
|
||||
}
|
||||
|
||||
//Set up the buffers that won't change this frame
|
||||
GLSL_ViewMatricesUniformBuffer(tr.viewParms.world.viewMatrix);
|
||||
}
|
||||
|
||||
void GLSL_BindProgram(shaderProgram_t * program)
|
||||
{
|
||||
|
@ -1531,6 +1682,18 @@ void GLSL_BindProgram(shaderProgram_t * program)
|
|||
|
||||
if (GL_UseProgram(programObject))
|
||||
backEnd.pc.c_glslShaderBinds++;
|
||||
|
||||
|
||||
qglBindBufferBase(
|
||||
GL_UNIFORM_BUFFER,
|
||||
program->viewMatricesBinding,
|
||||
viewMatricesBuffer);
|
||||
|
||||
qglBindBufferBase(
|
||||
GL_UNIFORM_BUFFER,
|
||||
program->projectionMatrixBinding,
|
||||
projectionMatricesBuffer[backEnd.projection2D ? ORTHO_PROJECTION : NORMAL_PROJECTION]);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -107,7 +107,12 @@ typedef struct {
|
|||
vec3_t origin; // in world coordinates
|
||||
vec3_t axis[3]; // orientation in world
|
||||
vec3_t viewOrigin; // viewParms->or.origin in local coordinates
|
||||
float modelMatrix[16];
|
||||
// float eyeViewMatrix[2][16];
|
||||
union {
|
||||
float eyeViewMatrix[3][16];
|
||||
float viewMatrix[48];
|
||||
};
|
||||
|
||||
float transformMatrix[16];
|
||||
} orientationr_t;
|
||||
|
||||
|
@ -671,7 +676,6 @@ typedef enum
|
|||
UNIFORM_FOGCOLORMASK,
|
||||
|
||||
UNIFORM_MODELMATRIX,
|
||||
UNIFORM_MODELVIEWPROJECTIONMATRIX,
|
||||
|
||||
UNIFORM_TIME,
|
||||
UNIFORM_VERTEXLERP,
|
||||
|
@ -714,6 +718,10 @@ typedef struct shaderProgram_s
|
|||
GLuint fragmentShader;
|
||||
uint32_t attribs; // vertex array attributes
|
||||
|
||||
//New for multiview - The view and projection matrix uniforms
|
||||
GLuint projectionMatrixBinding;
|
||||
GLuint viewMatricesBinding;
|
||||
|
||||
// uniform parameters
|
||||
GLint uniforms[UNIFORM_COUNT];
|
||||
short uniformBufferOffsets[UNIFORM_COUNT]; // max 32767/64=511 uniforms
|
||||
|
@ -836,14 +844,12 @@ typedef struct {
|
|||
vec3_t visBounds[2];
|
||||
float zFar;
|
||||
float zNear;
|
||||
stereoFrame_t stereoFrame;
|
||||
} viewParms_t;
|
||||
|
||||
typedef struct {
|
||||
qboolean valid;
|
||||
float projection[16];
|
||||
int renderBufferL;
|
||||
int renderBufferR;
|
||||
int renderBuffer;
|
||||
int renderBufferOriginal;
|
||||
} vrParms_t;
|
||||
|
||||
|
@ -2234,6 +2240,7 @@ GLSL
|
|||
*/
|
||||
|
||||
void GLSL_InitGPUShaders(void);
|
||||
void GLSL_PrepareShaders(void);
|
||||
void GLSL_ShutdownGPUShaders(void);
|
||||
void GLSL_VertexAttribPointers(uint32_t attribBits);
|
||||
void GLSL_BindProgram(shaderProgram_t * program);
|
||||
|
@ -2309,7 +2316,7 @@ int R_IQMLerpTag( orientation_t *tag, iqmData_t *data,
|
|||
=============================================================
|
||||
=============================================================
|
||||
*/
|
||||
void R_TransformModelToClip( const vec3_t src, const float *modelMatrix, const float *projectionMatrix,
|
||||
void R_TransformModelToClip( const vec3_t src, const float *viewMatrix, const float *projectionMatrix,
|
||||
vec4_t eye, vec4_t dst );
|
||||
void R_TransformClipToWindow( const vec4_t clip, const viewParms_t *view, vec4_t normalized, vec4_t window );
|
||||
|
||||
|
@ -2508,7 +2515,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame );
|
|||
void RE_EndFrame( int *frontEndMsec, int *backEndMsec );
|
||||
#if __ANDROID__
|
||||
void RE_SetVRHeadsetParms( const ovrMatrix4f *projectionMatrix,
|
||||
int renderBufferL, int renderBufferR );
|
||||
int renderBuffer );
|
||||
#endif
|
||||
void RE_SaveJPG(char * filename, int quality, int image_width, int image_height,
|
||||
unsigned char *image_buffer, int padding);
|
||||
|
|
|
@ -533,7 +533,7 @@ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms,
|
|||
glMatrix[15] = 1;
|
||||
|
||||
Mat4Copy(glMatrix, or->transformMatrix);
|
||||
myGlMultMatrix( glMatrix, viewParms->world.modelMatrix, or->modelMatrix );
|
||||
myGlMultMatrix( glMatrix, viewParms->world.eyeViewMatrix[2], or->eyeViewMatrix[2] );
|
||||
|
||||
// calculate the viewer origin in the model's space
|
||||
// needed for fog, specular, and environment mapping
|
||||
|
@ -566,7 +566,6 @@ Sets up the modelview matrix for a given viewParm
|
|||
void R_RotateForViewer (void)
|
||||
{
|
||||
float viewerMatrix[16];
|
||||
vec3_t origin;
|
||||
|
||||
Com_Memset (&tr.or, 0, sizeof(tr.or));
|
||||
tr.or.axis[0][0] = 1;
|
||||
|
@ -574,35 +573,47 @@ void R_RotateForViewer (void)
|
|||
tr.or.axis[2][2] = 1;
|
||||
VectorCopy (tr.viewParms.or.origin, tr.or.viewOrigin);
|
||||
|
||||
// transform by the camera placement
|
||||
VectorCopy( tr.viewParms.or.origin, origin );
|
||||
for (int eye = 0; eye <= 2; ++eye)
|
||||
{
|
||||
// transform by the camera placement
|
||||
vec3_t origin;
|
||||
VectorCopy(tr.viewParms.or.origin, origin);
|
||||
|
||||
viewerMatrix[0] = tr.viewParms.or.axis[0][0];
|
||||
viewerMatrix[4] = tr.viewParms.or.axis[0][1];
|
||||
viewerMatrix[8] = tr.viewParms.or.axis[0][2];
|
||||
viewerMatrix[12] = -origin[0] * viewerMatrix[0] + -origin[1] * viewerMatrix[4] + -origin[2] * viewerMatrix[8];
|
||||
if (eye < 2)
|
||||
{
|
||||
float scale = ((r_stereoSeparation->value / 1000.0f) / 2.0f) * (32.0f);
|
||||
VectorMA(origin, (eye == 0 ? 1.0f : -1.0f) * 100.0f, tr.viewParms.or.axis[1], origin);
|
||||
}
|
||||
|
||||
viewerMatrix[1] = tr.viewParms.or.axis[1][0];
|
||||
viewerMatrix[5] = tr.viewParms.or.axis[1][1];
|
||||
viewerMatrix[9] = tr.viewParms.or.axis[1][2];
|
||||
viewerMatrix[13] = -origin[0] * viewerMatrix[1] + -origin[1] * viewerMatrix[5] + -origin[2] * viewerMatrix[9];
|
||||
viewerMatrix[0] = tr.viewParms.or.axis[0][0];
|
||||
viewerMatrix[4] = tr.viewParms.or.axis[0][1];
|
||||
viewerMatrix[8] = tr.viewParms.or.axis[0][2];
|
||||
viewerMatrix[12] = -origin[0] * viewerMatrix[0] + -origin[1] * viewerMatrix[4] +
|
||||
-origin[2] * viewerMatrix[8];
|
||||
|
||||
viewerMatrix[2] = tr.viewParms.or.axis[2][0];
|
||||
viewerMatrix[6] = tr.viewParms.or.axis[2][1];
|
||||
viewerMatrix[10] = tr.viewParms.or.axis[2][2];
|
||||
viewerMatrix[14] = -origin[0] * viewerMatrix[2] + -origin[1] * viewerMatrix[6] + -origin[2] * viewerMatrix[10];
|
||||
viewerMatrix[1] = tr.viewParms.or.axis[1][0];
|
||||
viewerMatrix[5] = tr.viewParms.or.axis[1][1];
|
||||
viewerMatrix[9] = tr.viewParms.or.axis[1][2];
|
||||
viewerMatrix[13] = -origin[0] * viewerMatrix[1] + -origin[1] * viewerMatrix[5] +
|
||||
-origin[2] * viewerMatrix[9];
|
||||
|
||||
viewerMatrix[3] = 0;
|
||||
viewerMatrix[7] = 0;
|
||||
viewerMatrix[11] = 0;
|
||||
viewerMatrix[15] = 1;
|
||||
viewerMatrix[2] = tr.viewParms.or.axis[2][0];
|
||||
viewerMatrix[6] = tr.viewParms.or.axis[2][1];
|
||||
viewerMatrix[10] = tr.viewParms.or.axis[2][2];
|
||||
viewerMatrix[14] = -origin[0] * viewerMatrix[2] + -origin[1] * viewerMatrix[6] +
|
||||
-origin[2] * viewerMatrix[10];
|
||||
|
||||
// convert from our coordinate system (looking down X)
|
||||
// to OpenGL's coordinate system (looking down -Z)
|
||||
myGlMultMatrix( viewerMatrix, s_flipMatrix, tr.or.modelMatrix );
|
||||
viewerMatrix[3] = 0;
|
||||
viewerMatrix[7] = 0;
|
||||
viewerMatrix[11] = 0;
|
||||
viewerMatrix[15] = 1;
|
||||
|
||||
// convert from our coordinate system (looking down X)
|
||||
// to OpenGL's coordinate system (looking down -Z)
|
||||
myGlMultMatrix(viewerMatrix, s_flipMatrix, tr.or.eyeViewMatrix[eye]);
|
||||
}
|
||||
|
||||
tr.viewParms.world = tr.or;
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -727,45 +738,8 @@ void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean comp
|
|||
width = xmax - xmin;
|
||||
height = ymax - ymin;
|
||||
|
||||
if (tr.vrParms.valid) {
|
||||
/* if (dest->stereoFrame == STEREO_LEFT) {
|
||||
memcpy(&dest->projectionMatrix, &tr.vrParms.projectionL, sizeof(dest->projectionMatrix));
|
||||
}
|
||||
else */
|
||||
{
|
||||
memcpy(&dest->projectionMatrix, &tr.vrParms.projection, sizeof(dest->projectionMatrix));
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
* offset the view origin of the viewer for stereo rendering
|
||||
* by setting the projection matrix appropriately.
|
||||
*/
|
||||
if(stereoSep != 0)
|
||||
{
|
||||
if(dest->stereoFrame == STEREO_LEFT)
|
||||
stereoSep = zProj / stereoSep;
|
||||
else if(dest->stereoFrame == STEREO_RIGHT)
|
||||
stereoSep = zProj / -stereoSep;
|
||||
else
|
||||
stereoSep = 0;
|
||||
}
|
||||
memcpy(&dest->projectionMatrix, &tr.vrParms.projection, sizeof(dest->projectionMatrix));
|
||||
|
||||
dest->projectionMatrix[0] = 2 * zProj / width;
|
||||
dest->projectionMatrix[4] = 0;
|
||||
dest->projectionMatrix[8] = (xmax + xmin + 2 * stereoSep) / width;
|
||||
dest->projectionMatrix[12] = 2 * zProj * stereoSep / width;
|
||||
|
||||
dest->projectionMatrix[1] = 0;
|
||||
dest->projectionMatrix[5] = 2 * zProj / height;
|
||||
dest->projectionMatrix[9] = ( ymax + ymin ) / height; // normally 0
|
||||
dest->projectionMatrix[13] = 0;
|
||||
|
||||
dest->projectionMatrix[3] = 0;
|
||||
dest->projectionMatrix[7] = 0;
|
||||
dest->projectionMatrix[11] = -1;
|
||||
dest->projectionMatrix[15] = 0;
|
||||
}
|
||||
|
||||
// Now that we have all the data for the projection matrix we can also setup the view frustum.
|
||||
if(computeFrustum)
|
||||
R_SetupFrustum( );//dest, xmin, xmax, ymax, zProj, zFar, stereoSep);
|
||||
|
@ -1196,7 +1170,7 @@ static qboolean SurfIsOffscreen( const drawSurf_t *drawSurf, vec4_t clipDest[128
|
|||
int j;
|
||||
unsigned int pointFlags = 0;
|
||||
|
||||
R_TransformModelToClip( tess.xyz[i], tr.or.modelMatrix, tr.viewParms.projectionMatrix, eye, clip );
|
||||
R_TransformModelToClip( tess.xyz[i], tr.or.eyeViewMatrix[2], tr.viewParms.projectionMatrix, eye, clip );
|
||||
|
||||
for ( j = 0; j < 3; j++ )
|
||||
{
|
||||
|
@ -1736,6 +1710,8 @@ void R_RenderView (viewParms_t *parms) {
|
|||
|
||||
R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue);
|
||||
|
||||
GLSL_PrepareShaders();
|
||||
|
||||
R_GenerateDrawSurfs();
|
||||
|
||||
// if we overflowed MAX_DRAWSURFS, the drawsurfs
|
||||
|
@ -2519,7 +2495,7 @@ void R_RenderSunShadowMaps(const refdef_t *fd, int level)
|
|||
R_SortDrawSurfs( tr.refdef.drawSurfs + firstDrawSurf, tr.refdef.numDrawSurfs - firstDrawSurf );
|
||||
}
|
||||
|
||||
Mat4Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.modelMatrix, tr.refdef.sunShadowMvp[level]);
|
||||
Mat4Multiply(tr.viewParms.projectionMatrix, tr.viewParms.world.eyeViewMatrix[2], tr.refdef.sunShadowMvp[level]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -318,7 +318,7 @@ void RB_SunRays(FBO_t *srcFbo, ivec4_t srcBox, FBO_t *dstFbo, ivec4_t dstBox)
|
|||
mat4_t trans, model;
|
||||
|
||||
Mat4Translation( backEnd.viewParms.or.origin, trans );
|
||||
Mat4Multiply( backEnd.viewParms.world.modelMatrix, trans, model );
|
||||
Mat4Multiply( backEnd.viewParms.world.eyeViewMatrix[2], trans, model );
|
||||
Mat4Multiply(backEnd.viewParms.projectionMatrix, model, mvp);
|
||||
|
||||
dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
|
||||
|
@ -327,7 +327,7 @@ void RB_SunRays(FBO_t *srcFbo, ivec4_t srcBox, FBO_t *dstFbo, ivec4_t dstBox)
|
|||
}
|
||||
|
||||
// project sun point
|
||||
//Mat4Multiply(backEnd.viewParms.projectionMatrix, backEnd.viewParms.world.modelMatrix, mvp);
|
||||
//Mat4Multiply(backEnd.viewParms.projectionMatrix, backEnd.viewParms.world.eyeViewMatrix[2], mvp);
|
||||
Mat4Transform(mvp, pos, hpos);
|
||||
|
||||
// transform to UV coords
|
||||
|
|
|
@ -548,7 +548,7 @@ void RE_RenderScene( const refdef_t *fd ) {
|
|||
parms.fovX = tr.refdef.fov_x;
|
||||
parms.fovY = tr.refdef.fov_y;
|
||||
|
||||
parms.stereoFrame = tr.refdef.stereoFrame;
|
||||
//parms.stereoFrame = tr.refdef.stereoFrame;
|
||||
|
||||
VectorCopy( fd->vieworg, parms.or.origin );
|
||||
VectorCopy( fd->viewaxis[0], parms.or.axis[0] );
|
||||
|
|
|
@ -113,8 +113,9 @@ static void DrawTris (shaderCommands_t *input) {
|
|||
vec4_t color;
|
||||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
//GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
VectorSet4(color, 1, 1, 1, 1);
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color);
|
||||
GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0);
|
||||
|
@ -352,7 +353,8 @@ static void ProjectDlightTexture( void ) {
|
|||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
//GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);
|
||||
|
||||
|
@ -581,9 +583,9 @@ static void ComputeFogValues(vec4_t fogDistanceVector, vec4_t fogDepthVector, fl
|
|||
fog = tr.world->fogs + tess.fogNum;
|
||||
|
||||
VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local );
|
||||
fogDistanceVector[0] = -backEnd.or.modelMatrix[2];
|
||||
fogDistanceVector[1] = -backEnd.or.modelMatrix[6];
|
||||
fogDistanceVector[2] = -backEnd.or.modelMatrix[10];
|
||||
fogDistanceVector[0] = -backEnd.or.eyeViewMatrix[2][2];
|
||||
fogDistanceVector[1] = -backEnd.or.eyeViewMatrix[2][6];
|
||||
fogDistanceVector[2] = -backEnd.or.eyeViewMatrix[2][10];
|
||||
fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] );
|
||||
|
||||
// scale the fog vectors based on the fog's thickness
|
||||
|
@ -691,7 +693,8 @@ static void ForwardDlight( void ) {
|
|||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
//GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin);
|
||||
GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin);
|
||||
|
||||
|
@ -844,7 +847,8 @@ static void ProjectPshadowVBOGLSL( void ) {
|
|||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
//GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
VectorCopy(origin, vector);
|
||||
vector[3] = 1.0f;
|
||||
|
@ -920,7 +924,8 @@ static void RB_FogPass( void ) {
|
|||
|
||||
fog = tr.world->fogs + tess.fogNum;
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
//GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);
|
||||
|
||||
|
@ -1094,7 +1099,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
|
|||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
//GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin);
|
||||
GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin);
|
||||
|
||||
|
@ -1413,7 +1419,7 @@ static void RB_RenderShadowmap( shaderCommands_t *input )
|
|||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
// GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
|
||||
|
|
|
@ -686,9 +686,9 @@ void RB_CalcFogTexCoords( float *st ) {
|
|||
|
||||
// all fogging distance is based on world Z units
|
||||
VectorSubtract( backEnd.or.origin, backEnd.viewParms.or.origin, local );
|
||||
fogDistanceVector[0] = -backEnd.or.modelMatrix[2];
|
||||
fogDistanceVector[1] = -backEnd.or.modelMatrix[6];
|
||||
fogDistanceVector[2] = -backEnd.or.modelMatrix[10];
|
||||
fogDistanceVector[0] = -backEnd.or.eyeViewMatrix[2][2];
|
||||
fogDistanceVector[1] = -backEnd.or.eyeViewMatrix[2][6];
|
||||
fogDistanceVector[2] = -backEnd.or.eyeViewMatrix[2][10];
|
||||
fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] );
|
||||
|
||||
// scale the fog vectors based on the fog's thickness
|
||||
|
|
|
@ -438,8 +438,9 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
|
|||
vec4_t vector;
|
||||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
//GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
color[0] =
|
||||
color[1] =
|
||||
|
@ -796,14 +797,14 @@ void RB_DrawSun( float scale, shader_t *shader ) {
|
|||
return;
|
||||
}
|
||||
|
||||
//qglLoadMatrixf( backEnd.viewParms.world.modelMatrix );
|
||||
//qglLoadMatrixf( backEnd.viewParms.world.eyeViewMatrix[2] );
|
||||
//qglTranslatef (backEnd.viewParms.or.origin[0], backEnd.viewParms.or.origin[1], backEnd.viewParms.or.origin[2]);
|
||||
{
|
||||
// FIXME: this could be a lot cleaner
|
||||
mat4_t translation, modelview;
|
||||
|
||||
Mat4Translation( backEnd.viewParms.or.origin, translation );
|
||||
Mat4Multiply( backEnd.viewParms.world.modelMatrix, translation, modelview );
|
||||
Mat4Multiply( backEnd.viewParms.world.eyeViewMatrix[2], translation, modelview );
|
||||
GL_SetModelviewMatrix( modelview, qtrue );
|
||||
}
|
||||
|
||||
|
|
|
@ -226,8 +226,9 @@ void RB_InstantQuad(vec4_t quadVerts[4])
|
|||
VectorSet2(texCoords[3], 0.0f, 1.0f);
|
||||
|
||||
GLSL_BindProgram(&tr.textureColorShader);
|
||||
|
||||
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
//GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);
|
||||
|
||||
RB_InstantQuad2(quadVerts, texCoords);
|
||||
|
@ -538,8 +539,9 @@ static void RB_SurfaceBeam( void )
|
|||
RB_UpdateTessVao(ATTR_POSITION);
|
||||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
// GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_COLOR, colorRed);
|
||||
|
||||
|
|
|
@ -8,7 +8,11 @@
|
|||
|
||||
#include "vr_clientinfo.h"
|
||||
#include "vr_types.h"
|
||||
//#include "../SDL2/include/SDL_opengles2_gl2.h"
|
||||
|
||||
#include <EGL/egl.h>
|
||||
#include <EGL/eglext.h>
|
||||
#include <GLES3/gl3.h>
|
||||
#include <GLES3/gl3ext.h>
|
||||
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wstrict-prototypes"
|
||||
|
@ -81,18 +85,31 @@ void VR_GetResolution(engine_t* engine, int *pWidth, int *pHeight)
|
|||
}
|
||||
}
|
||||
|
||||
typedef void(GL_APIENTRY* PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)(
|
||||
GLenum target,
|
||||
GLenum attachment,
|
||||
GLuint texture,
|
||||
GLint level,
|
||||
GLint baseViewIndex,
|
||||
GLsizei numViews);
|
||||
|
||||
void VR_InitRenderer( engine_t* engine ) {
|
||||
#if ENABLE_GL_DEBUG
|
||||
glEnable(GL_DEBUG_OUTPUT);
|
||||
glDebugMessageCallback(VR_GLDebugLog, 0);
|
||||
#endif
|
||||
|
||||
PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC glFramebufferTextureMultiviewOVR =
|
||||
(PFNGLFRAMEBUFFERTEXTUREMULTIVIEWOVRPROC)eglGetProcAddress(
|
||||
"glFramebufferTextureMultiviewOVR");
|
||||
|
||||
int eyeW, eyeH;
|
||||
VR_GetResolution(engine, &eyeW, &eyeH);
|
||||
|
||||
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye) {
|
||||
framebuffer_t* framebuffer = &engine->framebuffers[eye];
|
||||
framebuffer->colorTexture = vrapi_CreateTextureSwapChain3(VRAPI_TEXTURE_TYPE_2D, GL_RGBA8,
|
||||
//for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye)
|
||||
{
|
||||
framebuffer_t* framebuffer = &engine->framebuffers;
|
||||
framebuffer->colorTexture = vrapi_CreateTextureSwapChain3(VRAPI_TEXTURE_TYPE_2D_ARRAY, GL_RGBA8,
|
||||
eyeW, eyeH, 1, 3);
|
||||
framebuffer->swapchainLength = vrapi_GetTextureSwapChainLength(framebuffer->colorTexture);
|
||||
framebuffer->depthBuffers = (GLuint*)malloc(framebuffer->swapchainLength * sizeof(GLuint));
|
||||
|
@ -103,21 +120,26 @@ void VR_InitRenderer( engine_t* engine ) {
|
|||
GLenum framebufferStatus;
|
||||
|
||||
colorTexture = vrapi_GetTextureSwapChainHandle(framebuffer->colorTexture, index);
|
||||
glBindTexture(GL_TEXTURE_2D, colorTexture);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, colorTexture);
|
||||
GLfloat borderColor[] = {0.0f, 0.0f, 0.0f, 0.0f};
|
||||
glTexParameterfv(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_BORDER_COLOR, borderColor);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||
glTexParameteri(GL_TEXTURE_2D_ARRAY, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
|
||||
|
||||
glGenRenderbuffers(1, &framebuffer->depthBuffers[index]);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, framebuffer->depthBuffers[index]);
|
||||
glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24, eyeW, eyeH);
|
||||
glBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
glGenTextures(1, &framebuffer->depthBuffers[index]);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, framebuffer->depthBuffers[index]);
|
||||
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 1, GL_DEPTH_COMPONENT24, eyeW, eyeH, 2);
|
||||
glBindTexture(GL_TEXTURE_2D_ARRAY, 0);
|
||||
|
||||
glGenFramebuffers(1, &framebuffer->framebuffers[index]);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, framebuffer->framebuffers[index]);
|
||||
glFramebufferRenderbuffer(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER,
|
||||
framebuffer->depthBuffers[index]);
|
||||
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0);
|
||||
|
||||
glFramebufferTextureMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
framebuffer->depthBuffers[index], 0, 0, 2);
|
||||
glFramebufferTextureMultiviewOVR(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
|
||||
colorTexture, 0, 0, 2);
|
||||
|
||||
framebufferStatus = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
|
||||
assert(framebufferStatus == GL_FRAMEBUFFER_COMPLETE);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
|
||||
|
@ -128,15 +150,15 @@ void VR_InitRenderer( engine_t* engine ) {
|
|||
void VR_DestroyRenderer( engine_t* engine ) {
|
||||
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye)
|
||||
{
|
||||
if (engine->framebuffers[eye].swapchainLength > 0) {
|
||||
glDeleteFramebuffers(engine->framebuffers[eye].swapchainLength,
|
||||
engine->framebuffers[eye].depthBuffers);
|
||||
free(engine->framebuffers[eye].depthBuffers);
|
||||
free(engine->framebuffers[eye].framebuffers);
|
||||
if (engine->framebuffers.swapchainLength > 0) {
|
||||
glDeleteFramebuffers(engine->framebuffers.swapchainLength,
|
||||
engine->framebuffers.depthBuffers);
|
||||
free(engine->framebuffers.depthBuffers);
|
||||
free(engine->framebuffers.framebuffers);
|
||||
|
||||
vrapi_DestroyTextureSwapChain(engine->framebuffers[eye].colorTexture);
|
||||
vrapi_DestroyTextureSwapChain(engine->framebuffers.colorTexture);
|
||||
|
||||
memset(&engine->framebuffers[eye], 0, sizeof(engine->framebuffers[eye]));
|
||||
memset(&engine->framebuffers, 0, sizeof(engine->framebuffers));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -207,8 +229,8 @@ ovrLayerCylinder2 BuildCylinderLayer(engine_t* engine, const int textureWidth, c
|
|||
{
|
||||
ovrMatrix4f modelViewMatrix = ovrMatrix4f_Multiply( &tracking->Eye[eye].ViewMatrix, &cylinderTransform );
|
||||
layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_Inverse( &modelViewMatrix );
|
||||
layer.Textures[eye].ColorSwapChain = engine->framebuffers[eye].colorTexture;
|
||||
layer.Textures[eye].SwapChainIndex = engine->framebuffers[eye].swapchainIndex;
|
||||
layer.Textures[eye].ColorSwapChain = engine->framebuffers.colorTexture;
|
||||
layer.Textures[eye].SwapChainIndex = engine->framebuffers.swapchainIndex;
|
||||
|
||||
// Texcoord scale and bias is just a representation of the aspect ratio. The positioning
|
||||
// of the cylinder is handled entirely by the TexCoordsFromTanAngles matrix.
|
||||
|
@ -312,17 +334,14 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
frameDesc.LayerCount = 1;
|
||||
frameDesc.Layers = layers;
|
||||
|
||||
const framebuffer_t* framebuffers = engine->framebuffers;
|
||||
|
||||
re.SetVRHeadsetParms(&projectionMatrix,
|
||||
framebuffers[0].framebuffers[framebuffers[0].swapchainIndex],
|
||||
framebuffers[1].framebuffers[framebuffers[1].swapchainIndex]);
|
||||
engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex]);
|
||||
|
||||
Com_Frame();
|
||||
|
||||
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye) {
|
||||
engine->framebuffers[eye].swapchainIndex = (engine->framebuffers[eye].swapchainIndex + 1) %
|
||||
engine->framebuffers[eye].swapchainLength;
|
||||
engine->framebuffers.swapchainIndex = (engine->framebuffers.swapchainIndex + 1) %
|
||||
engine->framebuffers.swapchainLength;
|
||||
}
|
||||
|
||||
// Hand over the eye images to the time warp.
|
||||
|
@ -340,26 +359,21 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
|
||||
|
||||
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye) {
|
||||
layer.Textures[eye].ColorSwapChain = engine->framebuffers[eye].colorTexture;
|
||||
layer.Textures[eye].SwapChainIndex = engine->framebuffers[eye].swapchainIndex;
|
||||
layer.Textures[eye].ColorSwapChain = engine->framebuffers.colorTexture;
|
||||
layer.Textures[eye].SwapChainIndex = engine->framebuffers.swapchainIndex;
|
||||
layer.Textures[eye].TexCoordsFromTanAngles = ovrMatrix4f_TanAngleMatrixFromProjection(&defaultProjection);
|
||||
}
|
||||
|
||||
|
||||
const framebuffer_t* framebuffers = engine->framebuffers;
|
||||
|
||||
VR_ClearFrameBuffer(framebuffers[0].framebuffers[framebuffers[0].swapchainIndex], eyeW, eyeH);
|
||||
VR_ClearFrameBuffer(framebuffers[1].framebuffers[framebuffers[1].swapchainIndex], eyeW, eyeH);
|
||||
VR_ClearFrameBuffer(engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex], eyeW, eyeH);
|
||||
|
||||
re.SetVRHeadsetParms(&projectionMatrix,
|
||||
framebuffers[0].framebuffers[framebuffers[0].swapchainIndex],
|
||||
framebuffers[1].framebuffers[framebuffers[1].swapchainIndex]);
|
||||
engine->framebuffers.framebuffers[engine->framebuffers.swapchainIndex]);
|
||||
|
||||
Com_Frame();
|
||||
|
||||
for (int eye = 0; eye < VRAPI_FRAME_LAYER_EYE_MAX; ++eye) {
|
||||
engine->framebuffers[eye].swapchainIndex = (engine->framebuffers[eye].swapchainIndex + 1) %
|
||||
engine->framebuffers[eye].swapchainLength;
|
||||
engine->framebuffers.swapchainIndex = (engine->framebuffers.swapchainIndex + 1) %
|
||||
engine->framebuffers.swapchainLength;
|
||||
}
|
||||
|
||||
const ovrLayerHeader2* layers[] = {
|
||||
|
|
|
@ -28,7 +28,7 @@ typedef struct {
|
|||
ovrJava java;
|
||||
double predictedDisplayTime;
|
||||
ovrTracking2 tracking;
|
||||
framebuffer_t framebuffers[VRAPI_FRAME_LAYER_EYE_MAX];
|
||||
framebuffer_t framebuffers;//[VRAPI_FRAME_LAYER_EYE_MAX];
|
||||
} engine_t;
|
||||
|
||||
typedef enum {
|
||||
|
|
|
@ -1,13 +1,22 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -11,7 +11,17 @@ uniform float u_Time;
|
|||
#endif
|
||||
|
||||
uniform vec4 u_Color;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
varying vec4 var_Color;
|
||||
|
@ -80,7 +90,7 @@ void main()
|
|||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
vec3 dist = u_DlightInfo.xyz - position;
|
||||
|
||||
|
|
|
@ -1,13 +1,23 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,17 @@ uniform float u_DeformParams[5];
|
|||
#endif
|
||||
|
||||
uniform float u_Time;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
|
@ -125,7 +135,7 @@ void main()
|
|||
position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
var_Scale = CalcFog(position) * u_Color.a * u_Color.a;
|
||||
}
|
||||
|
|
|
@ -42,7 +42,18 @@ uniform float u_DeformParams[5];
|
|||
uniform float u_Time;
|
||||
#endif
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
uniform vec4 u_BaseColor;
|
||||
uniform vec4 u_VertColor;
|
||||
|
||||
|
@ -227,7 +238,7 @@ void main()
|
|||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
#if defined(USE_TCGEN)
|
||||
vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1);
|
||||
|
|
|
@ -41,14 +41,21 @@ uniform vec4 u_DiffuseTexMatrix;
|
|||
uniform vec4 u_DiffuseTexOffTurb;
|
||||
#endif
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
uniform vec4 u_BaseColor;
|
||||
uniform vec4 u_VertColor;
|
||||
|
||||
#if defined(USE_MODELMATRIX)
|
||||
uniform mat4 u_ModelMatrix;
|
||||
#endif
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
#elif defined(USE_BONE_ANIMATION)
|
||||
|
@ -188,7 +195,7 @@ void main()
|
|||
var_TexCoords.xy = texCoords;
|
||||
#endif
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
#if defined(USE_MODELMATRIX)
|
||||
position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec3 attr_Normal;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
varying vec3 var_Position;
|
||||
varying vec3 var_Normal;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
|
||||
var_Position = attr_Position;
|
||||
var_Normal = attr_Normal;
|
||||
|
|
|
@ -16,9 +16,17 @@ uniform float u_DeformParams[5];
|
|||
//#endif
|
||||
|
||||
uniform float u_Time;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
|
@ -102,7 +110,7 @@ void main()
|
|||
|
||||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
|
||||
var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
|
||||
}
|
||||
|
|
|
@ -1,13 +1,25 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
|
||||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
|
||||
var_Tex1 = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -1,7 +1,18 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
uniform vec3 u_ToneMinAvgMaxLinear;
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
@ -21,7 +32,7 @@ float FilmicTonemap(float x)
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ModelViewProjectionMatrix * vec4(attr_Position, 1.0);
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
var_InvWhite = 1.0 / FilmicTonemap(u_ToneMinAvgMaxLinear.z - u_ToneMinAvgMaxLinear.x);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
setlocal
|
||||
|
||||
set BUILD_TYPE=release
|
||||
set BUILD_TYPE=debug
|
||||
set VERSION=0.27.1
|
||||
|
||||
@REM Define the following environment variables to sign a release build
|
||||
|
|
Loading…
Reference in a new issue