mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-04-18 06:11:18 +00:00
SpaceWarp motion vector rendering in progress
This commit is contained in:
parent
3646a8feab
commit
2d17e7d9b2
33 changed files with 239 additions and 322 deletions
|
@ -2,13 +2,9 @@ attribute vec3 attr_Position;
|
|||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
uniform mat4 u_ModelMatrix;
|
||||
|
||||
|
@ -17,6 +13,6 @@ varying vec2 var_TexCoords;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ attribute vec3 attr_Position;
|
|||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ varying vec2 var_TexCoords;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -15,13 +15,9 @@ uniform vec4 u_Color;
|
|||
uniform mat4 u_ModelMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
|
@ -91,7 +87,7 @@ void main()
|
|||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
vec3 dist = u_DlightInfo.xyz - position;
|
||||
|
||||
|
|
|
@ -4,13 +4,9 @@ attribute vec4 attr_TexCoord0;
|
|||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
@ -18,7 +14,7 @@ varying vec2 var_TexCoords;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -33,13 +33,9 @@ uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
|||
uniform vec4 u_Color;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying float var_Scale;
|
||||
|
@ -136,7 +132,7 @@ void main()
|
|||
position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
var_Scale = CalcFog(position) * u_Color.a * u_Color.a;
|
||||
}
|
||||
|
|
|
@ -64,13 +64,9 @@ uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
|||
#endif
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_DiffuseTex;
|
||||
|
@ -239,7 +235,7 @@ void main()
|
|||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
#if defined(USE_TCGEN)
|
||||
vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1);
|
||||
|
|
|
@ -515,5 +515,10 @@ void main()
|
|||
|
||||
#endif
|
||||
|
||||
// HACK: use in main menu simple light model (to prevent issue with missing models textures)
|
||||
#if defined(USE_MENU_LIGHT)
|
||||
gl_FragColor.rgb = diffuse.rgb * lightColor;
|
||||
#endif
|
||||
|
||||
gl_FragColor.a = alpha;
|
||||
}
|
||||
|
|
|
@ -67,13 +67,9 @@ uniform float u_PrimaryLightRadius;
|
|||
#endif
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec4 var_TexCoords;
|
||||
|
@ -197,7 +193,7 @@ void main()
|
|||
var_TexCoords.xy = texCoords;
|
||||
#endif
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
#if defined(USE_MODELMATRIX)
|
||||
position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
|
||||
|
|
|
@ -6,6 +6,8 @@ varying vec2 var_DiffuseTex;
|
|||
|
||||
varying vec4 var_Color;
|
||||
|
||||
varying highp vec4 clipPos;
|
||||
varying highp vec4 prevClipPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -27,8 +29,7 @@ void main()
|
|||
if (alpha < 0.5)
|
||||
discard;
|
||||
}
|
||||
|
||||
//TODO:implement motion vector
|
||||
gl_FragColor.rgb = var_Color.rgb;
|
||||
|
||||
gl_FragColor = ( clipPos / clipPos.w ) - ( prevClipPos / prevClipPos.w );
|
||||
gl_FragColor.a = alpha == 1.0 ? 1.0 : 0.0;
|
||||
}
|
||||
|
|
|
@ -11,26 +11,32 @@ uniform vec4 u_BaseColor;
|
|||
uniform vec4 u_VertColor;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
layout(shared) uniform PrevViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_PrevViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_DiffuseTex;
|
||||
varying vec4 var_Color;
|
||||
|
||||
varying highp vec4 clipPos;
|
||||
varying highp vec4 prevClipPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 position = attr_Position;
|
||||
vec3 normal = attr_Normal;
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
clipPos = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
prevClipPos = u_PrevViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
var_DiffuseTex = attr_TexCoord0.st;
|
||||
var_Color = u_VertColor * attr_Color + u_BaseColor;
|
||||
var_Color.rgb = var_Color.rgb * 0.1 + abs(normal.xyz) * 0.9;
|
||||
|
||||
gl_Position = clipPos;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,9 @@ attribute vec3 attr_Normal;
|
|||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec3 var_Position;
|
||||
|
@ -18,7 +14,7 @@ varying vec3 var_Normal;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
|
||||
var_Position = attr_Position;
|
||||
var_Normal = attr_Normal;
|
||||
|
|
|
@ -28,13 +28,9 @@ uniform float u_VertexLerp;
|
|||
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
||||
#endif
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec3 var_Position;
|
||||
|
@ -113,7 +109,7 @@ void main()
|
|||
|
||||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,9 @@ attribute vec4 attr_TexCoord0;
|
|||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
|
@ -19,7 +15,7 @@ varying vec2 var_Tex1;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
|
||||
var_Tex1 = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -6,13 +6,9 @@ uniform mat4 u_ModelMatrix;
|
|||
|
||||
uniform vec3 u_ToneMinAvgMaxLinear;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
|
||||
|
@ -33,7 +29,7 @@ float FilmicTonemap(float x)
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[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);
|
||||
}
|
||||
|
|
|
@ -77,8 +77,8 @@ typedef enum {
|
|||
PROJECTION_COUNT
|
||||
} projection_t;
|
||||
|
||||
GLuint viewMatricesBuffer[PROJECTION_COUNT];
|
||||
GLuint projectionMatricesBuffer[PROJECTION_COUNT];
|
||||
GLuint matrixBuffer[PROJECTION_COUNT];
|
||||
GLuint prevMatrixBuffer[PROJECTION_COUNT];
|
||||
|
||||
float orthoProjectionMatrix[16];
|
||||
|
||||
|
@ -196,97 +196,75 @@ shaderProgram_t* GLSL_OverrideShader(shaderProgram_t * program)
|
|||
return program;
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
GLSL_ViewMatricesUniformBuffer
|
||||
====================
|
||||
*/
|
||||
static void GLSL_ViewMatricesUniformBuffer(const float eyeView[32], const float modelView[32]) {
|
||||
|
||||
for (int i = 0; i < PROJECTION_COUNT; ++i)
|
||||
{
|
||||
// Update the scene matrices for when we are using a normal projection
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, viewMatricesBuffer[i]);
|
||||
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;
|
||||
}
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case FULLSCREEN_ORTHO_PROJECTION:
|
||||
case HUDBUFFER_ORTHO_PROJECTION:
|
||||
{
|
||||
Mat4Identity( viewMatrices );
|
||||
Mat4Identity( viewMatrices + 16 );
|
||||
}
|
||||
break;
|
||||
case STEREO_ORTHO_PROJECTION:
|
||||
{
|
||||
//This is a bit of a fiddle this calc.. it is just done like this to
|
||||
//make the HUD depths line up with the weapon wheel depth. I _know_ there
|
||||
//would be a proper calculation to do this exactly, but this is good enough
|
||||
//and I've just had enough messing about with this
|
||||
const auto depthOffset = (5-powf(vr_hudDepth->integer, 0.7f)) * 16;
|
||||
vec3_t translate;
|
||||
VectorSet(translate, depthOffset, 0, 0);
|
||||
Mat4Translation( translate, viewMatrices );
|
||||
|
||||
VectorSet(translate, -depthOffset, 0, 0);
|
||||
Mat4Translation( translate, viewMatrices + 16 );
|
||||
}
|
||||
break;
|
||||
case MIRROR_VR_PROJECTION:
|
||||
case VR_PROJECTION:
|
||||
{
|
||||
Mat4Copy(eyeView, viewMatrices);
|
||||
Mat4Copy(eyeView+16, viewMatrices+16);
|
||||
}
|
||||
break;
|
||||
case MONO_VR_PROJECTION:
|
||||
{
|
||||
Mat4Copy(modelView, viewMatrices);
|
||||
Mat4Copy(modelView, viewMatrices+16);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
qglUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
GLSL_ProjectionMatricesUniformBuffer
|
||||
====================
|
||||
*/
|
||||
static void GLSL_ProjectionMatricesUniformBuffer(GLint projectionMatricesBuffer, const float value[16]) {
|
||||
static void GLSL_MatricesUniformBuffer(GLint* buffer, int projection, const float value[16]) {
|
||||
|
||||
// Update the scene matrices.
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, projectionMatricesBuffer);
|
||||
float* projectionMatrix = (float*)qglMapBufferRange(
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, buffer[projection]);
|
||||
float* matrix = (float*)qglMapBufferRange(
|
||||
GL_UNIFORM_BUFFER,
|
||||
0,
|
||||
16 * sizeof(float),
|
||||
2 * 16 * sizeof(float),
|
||||
GL_MAP_WRITE_BIT | GL_MAP_INVALIDATE_BUFFER_BIT);
|
||||
|
||||
if (projectionMatrix == NULL)
|
||||
if (matrix == NULL)
|
||||
{
|
||||
ri.Error(ERR_DROP, "Projection Matrices Uniform Buffer is NULL");
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy((char*)projectionMatrix, value, 16 * sizeof(float));
|
||||
float viewMatrices[32];
|
||||
float modelView[16];
|
||||
float eyeView[32];
|
||||
memcpy(&modelView[0], &tr.viewParms.world.modelView[0], sizeof(float) * 16);
|
||||
memcpy(&eyeView[0], &tr.viewParms.world.eyeViewMatrix[0][0], sizeof(float) * 32);
|
||||
switch (projection)
|
||||
{
|
||||
case FULLSCREEN_ORTHO_PROJECTION:
|
||||
case HUDBUFFER_ORTHO_PROJECTION:
|
||||
{
|
||||
Mat4Identity( viewMatrices );
|
||||
Mat4Identity( viewMatrices + 16 );
|
||||
}
|
||||
break;
|
||||
case STEREO_ORTHO_PROJECTION:
|
||||
{
|
||||
//This is a bit of a fiddle this calc.. it is just done like this to
|
||||
//make the HUD depths line up with the weapon wheel depth. I _know_ there
|
||||
//would be a proper calculation to do this exactly, but this is good enough
|
||||
//and I've just had enough messing about with this
|
||||
const auto depthOffset = (5-powf(vr_hudDepth->integer, 0.7f)) * 16;
|
||||
vec3_t translate;
|
||||
VectorSet(translate, depthOffset, 0, 0);
|
||||
Mat4Translation( translate, viewMatrices );
|
||||
|
||||
qglUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
VectorSet(translate, -depthOffset, 0, 0);
|
||||
Mat4Translation( translate, viewMatrices + 16 );
|
||||
}
|
||||
break;
|
||||
case MIRROR_VR_PROJECTION:
|
||||
case VR_PROJECTION:
|
||||
{
|
||||
Mat4Copy(eyeView, viewMatrices);
|
||||
Mat4Copy(eyeView+16, viewMatrices+16);
|
||||
}
|
||||
break;
|
||||
case MONO_VR_PROJECTION:
|
||||
{
|
||||
Mat4Copy(modelView, viewMatrices);
|
||||
Mat4Copy(modelView, viewMatrices+16);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
myGlMultMatrix(viewMatrices, value, matrix);
|
||||
myGlMultMatrix(viewMatrices + 16, value, matrix + 16);
|
||||
|
||||
qglUnmapBuffer(GL_UNIFORM_BUFFER);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
}
|
||||
|
||||
|
@ -795,22 +773,26 @@ void GLSL_InitUniforms(shaderProgram_t *program)
|
|||
|
||||
GLint *uniforms = program->uniforms;
|
||||
|
||||
//Shader Matrices for the View Matrices
|
||||
GLuint viewMatricesUniformLocation = qglGetUniformBlockIndex(program->program, "ViewMatrices");
|
||||
//Shader Matrices for the View-Projection Matrices
|
||||
GLuint viewProjectionMatricesUniformLocation = qglGetUniformBlockIndex(program->program, "ViewProjectionMatrices");
|
||||
int numBufferBindings = 0;
|
||||
program->viewMatricesBinding = numBufferBindings++;
|
||||
qglUniformBlockBinding(
|
||||
program->program,
|
||||
viewMatricesUniformLocation,
|
||||
program->viewMatricesBinding);
|
||||
if (viewProjectionMatricesUniformLocation != GL_INVALID_INDEX) {
|
||||
program->viewProjectionMatrixBinding = numBufferBindings++;
|
||||
qglUniformBlockBinding(
|
||||
program->program,
|
||||
viewProjectionMatricesUniformLocation,
|
||||
program->viewProjectionMatrixBinding);
|
||||
}
|
||||
|
||||
//Shader Matrices for the Projection Matrix
|
||||
GLuint projectionMatrixUniformLocation = qglGetUniformBlockIndex(program->program, "ProjectionMatrix");
|
||||
program->projectionMatrixBinding = numBufferBindings++;
|
||||
qglUniformBlockBinding(
|
||||
program->program,
|
||||
projectionMatrixUniformLocation,
|
||||
program->projectionMatrixBinding);
|
||||
//Shader Matrices for the previous View-Projection Matrices
|
||||
GLuint prevViewProjectionMatricesUniformLocation = qglGetUniformBlockIndex(program->program, "PrevViewProjectionMatrices");
|
||||
if (prevViewProjectionMatricesUniformLocation != GL_INVALID_INDEX) {
|
||||
program->prevViewProjectionMatrixBinding = numBufferBindings++;
|
||||
qglUniformBlockBinding(
|
||||
program->program,
|
||||
prevViewProjectionMatricesUniformLocation,
|
||||
program->prevViewProjectionMatrixBinding);
|
||||
}
|
||||
|
||||
size = 0;
|
||||
for (i = 0; i < UNIFORM_COUNT; i++)
|
||||
|
@ -1126,9 +1108,9 @@ void GLSL_InitGPUShaders(void)
|
|||
|
||||
for (int i = 0; i < PROJECTION_COUNT; ++i)
|
||||
{
|
||||
//Generate buffer for 2 * view matrices
|
||||
qglGenBuffers(1, &viewMatricesBuffer[i]);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, viewMatricesBuffer[i]);
|
||||
//Generate buffer for 2 * view projection matrices
|
||||
qglGenBuffers(1, &matrixBuffer[i]);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, matrixBuffer[i]);
|
||||
qglBufferData(
|
||||
GL_UNIFORM_BUFFER,
|
||||
2 * 16 * sizeof(float),
|
||||
|
@ -1136,11 +1118,12 @@ void GLSL_InitGPUShaders(void)
|
|||
GL_STATIC_DRAW);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
|
||||
qglGenBuffers(1, &projectionMatricesBuffer[i]);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, projectionMatricesBuffer[i]);
|
||||
//Generate buffer for 2 * previous view projection matrices
|
||||
qglGenBuffers(1, &prevMatrixBuffer[i]);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, prevMatrixBuffer[i]);
|
||||
qglBufferData(
|
||||
GL_UNIFORM_BUFFER,
|
||||
16 * sizeof(float),
|
||||
2 * 16 * sizeof(float),
|
||||
NULL,
|
||||
GL_STATIC_DRAW);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
|
@ -1737,51 +1720,51 @@ void GLSL_ShutdownGPUShaders(void)
|
|||
GLSL_DeleteGPUShader(&tr.depthBlurShader[i]);
|
||||
|
||||
//Clean up buffers
|
||||
qglDeleteBuffers(PROJECTION_COUNT, viewMatricesBuffer);
|
||||
qglDeleteBuffers(PROJECTION_COUNT, projectionMatricesBuffer);
|
||||
qglDeleteBuffers(PROJECTION_COUNT, matrixBuffer);
|
||||
qglDeleteBuffers(PROJECTION_COUNT, prevMatrixBuffer);
|
||||
}
|
||||
|
||||
void GLSL_UniformMatrixBuffers(GLuint* buffer)
|
||||
{
|
||||
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 matrices
|
||||
GLSL_MatricesUniformBuffer(buffer, FULLSCREEN_ORTHO_PROJECTION, orthoProjectionMatrix);
|
||||
GLSL_MatricesUniformBuffer(buffer, STEREO_ORTHO_PROJECTION, orthoProjectionMatrix);
|
||||
|
||||
float hudOrthoProjectionMatrix[16];
|
||||
Mat4Ortho(0, 640, 480, 0, 0, 1, hudOrthoProjectionMatrix);
|
||||
GLSL_MatricesUniformBuffer(buffer, HUDBUFFER_ORTHO_PROJECTION, hudOrthoProjectionMatrix);
|
||||
|
||||
//VR projection matrix
|
||||
GLSL_MatricesUniformBuffer(buffer, VR_PROJECTION, tr.vrParms.projection);
|
||||
|
||||
//Mirror VR projection matrix
|
||||
GLSL_MatricesUniformBuffer(buffer, MIRROR_VR_PROJECTION, tr.vrParms.mirrorProjection);
|
||||
|
||||
//Used for drawing models
|
||||
GLSL_MatricesUniformBuffer(buffer, MONO_VR_PROJECTION, tr.vrParms.monoVRProjection);
|
||||
}
|
||||
|
||||
void GLSL_PrepareUniformBuffers(void)
|
||||
{
|
||||
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 matrices
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[FULLSCREEN_ORTHO_PROJECTION],
|
||||
orthoProjectionMatrix);
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[STEREO_ORTHO_PROJECTION],
|
||||
orthoProjectionMatrix);
|
||||
|
||||
float hudOrthoProjectionMatrix[16];
|
||||
Mat4Ortho(0, 640, 480, 0, 0, 1, hudOrthoProjectionMatrix);
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[HUDBUFFER_ORTHO_PROJECTION],
|
||||
hudOrthoProjectionMatrix);
|
||||
|
||||
//VR projection matrix
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[VR_PROJECTION],
|
||||
tr.vrParms.projection);
|
||||
|
||||
//Mirror VR projection matrix
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[MIRROR_VR_PROJECTION],
|
||||
tr.vrParms.mirrorProjection);
|
||||
|
||||
//Used for drawing models
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[MONO_VR_PROJECTION],
|
||||
tr.vrParms.monoVRProjection);
|
||||
|
||||
//Set all view matrices
|
||||
GLSL_ViewMatricesUniformBuffer(tr.viewParms.world.eyeViewMatrix, tr.viewParms.world.modelView);
|
||||
GLSL_UniformMatrixBuffers(matrixBuffer);
|
||||
if (!VR_RenderMotionVector())
|
||||
{
|
||||
GLSL_UniformMatrixBuffers(prevMatrixBuffer);
|
||||
}
|
||||
}
|
||||
|
||||
void GLSL_BindProgram(shaderProgram_t * program)
|
||||
|
@ -1836,14 +1819,16 @@ void GLSL_BindBuffers( shaderProgram_t * program )
|
|||
GLuint projection = GLSL_CalculateProjection();
|
||||
qglBindBufferBase(
|
||||
GL_UNIFORM_BUFFER,
|
||||
program->viewMatricesBinding,
|
||||
viewMatricesBuffer[projection]);
|
||||
|
||||
qglBindBufferBase(
|
||||
GL_UNIFORM_BUFFER,
|
||||
program->projectionMatrixBinding,
|
||||
projectionMatricesBuffer[projection]);
|
||||
program->viewProjectionMatrixBinding,
|
||||
matrixBuffer[projection]);
|
||||
|
||||
if (VR_RenderMotionVector())
|
||||
{
|
||||
qglBindBufferBase(
|
||||
GL_UNIFORM_BUFFER,
|
||||
program->prevViewProjectionMatrixBinding,
|
||||
prevMatrixBuffer[projection]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -720,8 +720,8 @@ typedef struct shaderProgram_s
|
|||
uint32_t attribs; // vertex array attributes
|
||||
|
||||
//New for multiview - The view and projection matrix uniforms
|
||||
GLuint projectionMatrixBinding;
|
||||
GLuint viewMatricesBinding;
|
||||
GLuint viewProjectionMatrixBinding;
|
||||
GLuint prevViewProjectionMatrixBinding;
|
||||
|
||||
// uniform parameters
|
||||
GLint uniforms[UNIFORM_COUNT];
|
||||
|
@ -2550,5 +2550,6 @@ size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality,
|
|||
void RE_TakeVideoFrame( int width, int height,
|
||||
byte *captureBuffer, byte *encodeBuffer, qboolean motionJpeg );
|
||||
|
||||
void myGlMultMatrix( const float *a, const float *b, float *out );
|
||||
|
||||
#endif //TR_LOCAL_H
|
||||
|
|
|
@ -23,6 +23,7 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include "tr_local.h"
|
||||
//#include "assert.h"
|
||||
#include "../vr/vr_renderer.h"
|
||||
|
||||
#define MAX_VERTS_ON_POLY 64
|
||||
|
||||
|
@ -259,6 +260,10 @@ R_MarkFragments
|
|||
*/
|
||||
int R_MarkFragments( int numPoints, const vec3_t *points, const vec3_t projection,
|
||||
int maxPoints, vec3_t pointBuffer, int maxFragments, markFragment_t *fragmentBuffer ) {
|
||||
|
||||
if( VR_RenderMotionVector() )
|
||||
return 0;
|
||||
|
||||
int numsurfaces, numPlanes;
|
||||
int i, j, k, m, n;
|
||||
surfaceType_t *surfaces[64];
|
||||
|
|
|
@ -393,7 +393,6 @@ void VR_RenderScene( engine_t* engine, XrFovf fov, qboolean motionVector ) {
|
|||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
|
||||
// Release framebuffer
|
||||
ovrFramebuffer_Resolve(frameBuffer, motionVector);
|
||||
ovrFramebuffer_Release(frameBuffer, motionVector);
|
||||
ovrFramebuffer_SetNone();
|
||||
}
|
||||
|
@ -503,12 +502,12 @@ void VR_DrawFrame( engine_t* engine ) {
|
|||
fullscreenMode = qfalse;
|
||||
}
|
||||
|
||||
VR_RenderScene( engine, fov, qfalse );
|
||||
if (vr_spacewarp->integer) {
|
||||
renderMotionVector = qtrue;
|
||||
VR_RenderScene( engine, fov, qtrue );
|
||||
renderMotionVector = qfalse;
|
||||
}
|
||||
VR_RenderScene( engine, fov, qfalse );
|
||||
|
||||
for (int eye = 0; eye < ovrMaxNumEyes; eye++) {
|
||||
ovrFramebuffer* frameBuffer = &engine->appState.Renderer.FrameBuffer;
|
||||
|
|
|
@ -310,17 +310,6 @@ void ovrFramebuffer_SetNone() {
|
|||
GL(glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0));
|
||||
}
|
||||
|
||||
void ovrFramebuffer_Resolve(ovrFramebuffer* frameBuffer, GLboolean isMotionVectorPass) {
|
||||
if (isMotionVectorPass) {
|
||||
// AppSpaceWarp Both depth and color buffer will be resolved for motion vector pass
|
||||
} else {
|
||||
// Discard the depth buffer, so the tiler won't need to write it back out to memory.
|
||||
const GLenum depthAttachment[1] = {GL_DEPTH_ATTACHMENT};
|
||||
glInvalidateFramebuffer(GL_DRAW_FRAMEBUFFER, 1, depthAttachment);
|
||||
// We now let the resolve happen implicitly.
|
||||
}
|
||||
}
|
||||
|
||||
void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer, GLboolean isMotionVectorPass) {
|
||||
// Acquire the swapchain image
|
||||
XrSwapchainImageAcquireInfo acquireInfo = {XR_TYPE_SWAPCHAIN_IMAGE_ACQUIRE_INFO, NULL};
|
||||
|
|
|
@ -172,7 +172,6 @@ void ovrApp_Destroy(ovrApp* app);
|
|||
GLboolean ovrApp_HandleXrEvents(ovrApp* app);
|
||||
|
||||
void ovrFramebuffer_Acquire(ovrFramebuffer* frameBuffer, GLboolean isMotionVectorPass);
|
||||
void ovrFramebuffer_Resolve(ovrFramebuffer* frameBuffer, GLboolean isMotionVectorPass);
|
||||
void ovrFramebuffer_Release(ovrFramebuffer* frameBuffer, GLboolean isMotionVectorPass);
|
||||
void ovrFramebuffer_SetCurrent(ovrFramebuffer* frameBuffer, GLboolean isMotionVectorPass);
|
||||
void ovrFramebuffer_SetNone();
|
||||
|
|
|
@ -2,13 +2,9 @@ attribute vec3 attr_Position;
|
|||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
uniform mat4 u_ModelMatrix;
|
||||
|
||||
|
@ -17,6 +13,6 @@ varying vec2 var_TexCoords;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@ attribute vec3 attr_Position;
|
|||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
|
@ -17,7 +17,7 @@ varying vec2 var_TexCoords;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -15,13 +15,9 @@ uniform vec4 u_Color;
|
|||
uniform mat4 u_ModelMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
|
@ -91,7 +87,7 @@ void main()
|
|||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
vec3 dist = u_DlightInfo.xyz - position;
|
||||
|
||||
|
|
|
@ -4,13 +4,9 @@ attribute vec4 attr_TexCoord0;
|
|||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
|
@ -18,7 +14,7 @@ varying vec2 var_TexCoords;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
|
||||
var_TexCoords = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -33,13 +33,9 @@ uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
|||
uniform vec4 u_Color;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying float var_Scale;
|
||||
|
@ -136,7 +132,7 @@ void main()
|
|||
position.xyz = DeformPosition(position.xyz, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
var_Scale = CalcFog(position) * u_Color.a * u_Color.a;
|
||||
}
|
||||
|
|
|
@ -64,13 +64,9 @@ uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
|||
#endif
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_DiffuseTex;
|
||||
|
@ -239,7 +235,7 @@ void main()
|
|||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
#endif
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
#if defined(USE_TCGEN)
|
||||
vec2 tex = GenTexCoords(u_TCGen0, position, normal, u_TCGen0Vector0, u_TCGen0Vector1);
|
||||
|
|
|
@ -67,13 +67,9 @@ uniform float u_PrimaryLightRadius;
|
|||
#endif
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec4 var_TexCoords;
|
||||
|
@ -197,7 +193,7 @@ void main()
|
|||
var_TexCoords.xy = texCoords;
|
||||
#endif
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
#if defined(USE_MODELMATRIX)
|
||||
position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
|
||||
|
|
|
@ -6,6 +6,8 @@ varying vec2 var_DiffuseTex;
|
|||
|
||||
varying vec4 var_Color;
|
||||
|
||||
varying highp vec4 clipPos;
|
||||
varying highp vec4 prevClipPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
|
@ -27,8 +29,7 @@ void main()
|
|||
if (alpha < 0.5)
|
||||
discard;
|
||||
}
|
||||
|
||||
//TODO:implement motion vector
|
||||
gl_FragColor.rgb = var_Color.rgb;
|
||||
|
||||
gl_FragColor = ( clipPos / clipPos.w ) - ( prevClipPos / prevClipPos.w );
|
||||
gl_FragColor.a = alpha == 1.0 ? 1.0 : 0.0;
|
||||
}
|
||||
|
|
|
@ -11,26 +11,32 @@ uniform vec4 u_BaseColor;
|
|||
uniform vec4 u_VertColor;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
layout(shared) uniform PrevViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_PrevViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_DiffuseTex;
|
||||
varying vec4 var_Color;
|
||||
|
||||
varying highp vec4 clipPos;
|
||||
varying highp vec4 prevClipPos;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec3 position = attr_Position;
|
||||
vec3 normal = attr_Normal;
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
clipPos = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
prevClipPos = u_PrevViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
var_DiffuseTex = attr_TexCoord0.st;
|
||||
var_Color = u_VertColor * attr_Color + u_BaseColor;
|
||||
var_Color.rgb = var_Color.rgb * 0.1 + abs(normal.xyz) * 0.9;
|
||||
|
||||
gl_Position = clipPos;
|
||||
}
|
||||
|
|
|
@ -3,13 +3,9 @@ attribute vec3 attr_Normal;
|
|||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec3 var_Position;
|
||||
|
@ -18,7 +14,7 @@ varying vec3 var_Normal;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
|
||||
var_Position = attr_Position;
|
||||
var_Normal = attr_Normal;
|
||||
|
|
|
@ -28,13 +28,9 @@ uniform float u_VertexLerp;
|
|||
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
||||
#endif
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec3 var_Position;
|
||||
|
@ -113,7 +109,7 @@ void main()
|
|||
|
||||
position = DeformPosition(position, normal, attr_TexCoord0.st);
|
||||
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(position, 1.0));
|
||||
|
||||
var_Position = (u_ModelMatrix * vec4(position, 1.0)).xyz;
|
||||
}
|
||||
|
|
|
@ -5,13 +5,9 @@ attribute vec4 attr_TexCoord0;
|
|||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
|
@ -19,7 +15,7 @@ varying vec2 var_Tex1;
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0));
|
||||
|
||||
var_Tex1 = attr_TexCoord0.st;
|
||||
}
|
||||
|
|
|
@ -6,13 +6,9 @@ uniform mat4 u_ModelMatrix;
|
|||
|
||||
uniform vec3 u_ToneMinAvgMaxLinear;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
layout(shared) uniform ViewProjectionMatrices
|
||||
{
|
||||
uniform mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform mat4 u_ProjectionMatrix;
|
||||
uniform mat4 u_ViewProjectionMatrices[NUM_VIEWS];
|
||||
};
|
||||
|
||||
|
||||
|
@ -33,7 +29,7 @@ float FilmicTonemap(float x)
|
|||
|
||||
void main()
|
||||
{
|
||||
gl_Position = u_ProjectionMatrix * (u_ViewMatrices[gl_ViewID_OVR] * (u_ModelMatrix * vec4(attr_Position, 1.0)));
|
||||
gl_Position = u_ViewProjectionMatrices[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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue