mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2025-03-15 06:30:54 +00:00
Still ongoing (with little improvement)
This commit is contained in:
parent
170f32709b
commit
6506c96194
13 changed files with 85 additions and 66 deletions
|
@ -2797,20 +2797,24 @@ void CG_DrawActive( void ) {
|
|||
if ( cg.demoPlayback || CG_IsThirdPersonFollowMode(VRFM_THIRDPERSON_1))
|
||||
{
|
||||
worldscale *= SPECTATOR_WORLDSCALE_MULTIPLIER;
|
||||
trap_Cvar_SetValue("vr_worldscaleScaler", SPECTATOR_WORLDSCALE_MULTIPLIER);
|
||||
//Just move camera down about 20cm
|
||||
heightOffset = -0.2f;
|
||||
}
|
||||
else if (CG_IsDeathCam() || CG_IsThirdPersonFollowMode(VRFM_THIRDPERSON_2))
|
||||
{
|
||||
worldscale *= SPECTATOR2_WORLDSCALE_MULTIPLIER;
|
||||
trap_Cvar_SetValue("vr_worldscaleScaler", SPECTATOR2_WORLDSCALE_MULTIPLIER);
|
||||
//Just move camera down about 50cm
|
||||
heightOffset = -0.5f;
|
||||
}
|
||||
else
|
||||
{
|
||||
float zoomCoeff = ((2.5f-vr->weapon_zoomLevel)/1.5f); // normally 1.0
|
||||
trap_Cvar_SetValue("vr_worldscaleScaler", zoomCoeff);
|
||||
}
|
||||
|
||||
|
||||
float ipd = trap_Cvar_VariableValue("r_stereoSeparation") / 1000.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)
|
||||
{
|
||||
//Do nothing to view height if we are following in first person
|
||||
|
@ -2848,9 +2852,6 @@ void CG_DrawActive( void ) {
|
|||
}
|
||||
}
|
||||
|
||||
float zoomCoeff = ((2.5f-vr->weapon_zoomLevel)/1.5f);
|
||||
VectorMA(cg.refdef.vieworg, -separation * zoomCoeff, cg.refdef.viewaxis[1], cg.refdef.vieworg);
|
||||
|
||||
// draw 3D view
|
||||
trap_R_RenderScene( &cg.refdef );
|
||||
|
||||
|
|
|
@ -1543,6 +1543,7 @@ int trap_Milliseconds( void );
|
|||
void trap_Cvar_Register( vmCvar_t *vmCvar, const char *varName, const char *defaultValue, int flags );
|
||||
void trap_Cvar_Update( vmCvar_t *vmCvar );
|
||||
void trap_Cvar_Set( const char *var_name, const char *value );
|
||||
void trap_Cvar_SetValue( const char *var_name, const float value );
|
||||
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize );
|
||||
float trap_Cvar_VariableValue( const char *var_name );
|
||||
|
||||
|
|
|
@ -69,6 +69,12 @@ void trap_Cvar_Set( const char *var_name, const char *value ) {
|
|||
syscall( CG_CVAR_SET, var_name, value );
|
||||
}
|
||||
|
||||
void trap_Cvar_SetValue( const char *var_name, const float value ) {
|
||||
char buffer[256];
|
||||
Com_sprintf(buffer, 255, "%g", value);
|
||||
syscall( CG_CVAR_SET, var_name, buffer );
|
||||
}
|
||||
|
||||
void trap_Cvar_VariableStringBuffer( const char *var_name, char *buffer, int bufsize ) {
|
||||
syscall( CG_CVAR_VARIABLESTRINGBUFFER, var_name, buffer, bufsize );
|
||||
}
|
||||
|
|
|
@ -197,11 +197,13 @@ void main()
|
|||
|
||||
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;
|
||||
normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz;
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
vec3 bitangent = cross(normal, tangent) * attr_Tangent.w;
|
||||
|
@ -211,8 +213,10 @@ void main()
|
|||
vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w);
|
||||
#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
vec3 L = attr_LightDirection;
|
||||
#if defined(USE_MODELMATRIX)
|
||||
L = (u_ModelMatrix * vec4(L, 0.0)).xyz;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHTMAP)
|
||||
var_TexCoords.zw = attr_TexCoord1.st;
|
||||
|
|
|
@ -409,6 +409,8 @@ void RB_BeginDrawingView (void) {
|
|||
plane2[2] = DotProduct (backEnd.viewParms.or.axis[2], plane);
|
||||
plane2[3] = DotProduct (plane, backEnd.viewParms.or.origin) - plane[3];
|
||||
#endif
|
||||
|
||||
//TODO: This probably won't work at the moment!!
|
||||
GL_SetModelviewMatrix( s_flipMatrix );
|
||||
}
|
||||
}
|
||||
|
@ -735,7 +737,6 @@ 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_MODELMATRIX, glState.modelview);
|
||||
GLSL_BindBuffers(&tr.textureColorShader);
|
||||
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);
|
||||
|
|
|
@ -431,7 +431,7 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
|
|||
|
||||
tr.refdef.stereoFrame = stereoFrame;
|
||||
|
||||
GLSL_PrepareShaders();
|
||||
GLSL_PrepareUniformBuffers();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1313,7 +1313,7 @@ void GLSL_InitGPUShaders(void)
|
|||
|
||||
if (i & LIGHTDEF_ENTITY_VERTEX_ANIMATION)
|
||||
{
|
||||
Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n");
|
||||
Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n#define USE_MODELMATRIX\n");
|
||||
attribs |= ATTR_POSITION2 | ATTR_NORMAL2;
|
||||
|
||||
if (r_normalMapping->integer)
|
||||
|
@ -1323,6 +1323,7 @@ void GLSL_InitGPUShaders(void)
|
|||
}
|
||||
else if (i & LIGHTDEF_ENTITY_BONE_ANIMATION)
|
||||
{
|
||||
Q_strcat(extradefines, 1024, "#define USE_MODELMATRIX\n");
|
||||
Q_strcat(extradefines, 1024, va("#define USE_BONE_ANIMATION\n#define MAX_GLSL_BONES %d\n", glRefConfig.glslMaxAnimatedBones));
|
||||
attribs |= ATTR_BONE_INDEXES | ATTR_BONE_WEIGHTS;
|
||||
}
|
||||
|
@ -1625,35 +1626,42 @@ void GLSL_ShutdownGPUShaders(void)
|
|||
GLSL_DeleteGPUShader(&tr.depthBlurShader[i]);
|
||||
}
|
||||
|
||||
void GLSL_PrepareShaders(void)
|
||||
void GLSL_PrepareUniformBuffers(void)
|
||||
{
|
||||
static qboolean first = qtrue;
|
||||
static float defaultProjection[16];
|
||||
if (first)
|
||||
int width, height;
|
||||
if (glState.currentFBO)
|
||||
{
|
||||
width = glState.currentFBO->width;
|
||||
height = glState.currentFBO->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = glConfig.vidWidth;
|
||||
height = glConfig.vidHeight;
|
||||
}
|
||||
|
||||
static qboolean first = qtrue;
|
||||
static float defaultProjection[16];
|
||||
if (first)
|
||||
{
|
||||
first = qfalse;
|
||||
memset(defaultProjection, 0, 16 * sizeof(float));
|
||||
}
|
||||
|
||||
static int vidWidth = 1;
|
||||
static int vidHeight = 1;
|
||||
if (vidWidth != width || vidHeight != height)
|
||||
{
|
||||
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);
|
||||
Mat4Ortho(0, vidWidth, vidHeight, 0, 0, 1, orthoProjectionMatrix);
|
||||
|
||||
//ortho projection matrix
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[ORTHO_PROJECTION],
|
||||
orthoProjectionMatrix);
|
||||
|
||||
first = qfalse;
|
||||
vidWidth = width;
|
||||
vidHeight = height;
|
||||
}
|
||||
|
||||
//We only need to do the following if the default projection changes
|
||||
|
@ -1691,18 +1699,21 @@ void GLSL_BindProgram(shaderProgram_t * program)
|
|||
static GLuint GLSL_CalculateProjection() {
|
||||
GLuint result = NORMAL_PROJECTION;
|
||||
|
||||
mat4_t matrix;
|
||||
Mat4Ortho(0, glConfig.vidWidth, glConfig.vidHeight, 0, 0, 1, matrix);
|
||||
int width, height;
|
||||
if (glState.currentFBO)
|
||||
{
|
||||
width = glState.currentFBO->width;
|
||||
height = glState.currentFBO->height;
|
||||
}
|
||||
else
|
||||
{
|
||||
width = glConfig.vidWidth;
|
||||
height = glConfig.vidHeight;
|
||||
}
|
||||
|
||||
if (
|
||||
//Is this set up as an orthographic projection?
|
||||
glState.projection[0] == matrix[0] &&
|
||||
glState.projection[5] == matrix[5] &&
|
||||
glState.projection[10] == matrix[10] &&
|
||||
glState.projection[12] == matrix[12]&&
|
||||
glState.projection[13] == matrix[13] &&
|
||||
glState.projection[14] == matrix[14] &&
|
||||
glState.projection[15] == matrix[15])
|
||||
mat4_t matrix;
|
||||
Mat4Ortho(0, width, height, 0, 0, 1, matrix);
|
||||
if (memcmp(glState.projection, matrix, sizeof(float) * 16) == 0)
|
||||
{
|
||||
result = ORTHO_PROJECTION;
|
||||
}
|
||||
|
|
|
@ -107,13 +107,10 @@ 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 eyeViewMatrix[2][16];
|
||||
union {
|
||||
float eyeViewMatrix[3][16];
|
||||
float viewMatrix[48];
|
||||
};
|
||||
|
||||
float transformMatrix[16];
|
||||
} orientationr_t;
|
||||
|
||||
// Ensure this is >= the ATTR_INDEX_COUNT enum below
|
||||
|
@ -2240,7 +2237,7 @@ GLSL
|
|||
*/
|
||||
|
||||
void GLSL_InitGPUShaders(void);
|
||||
void GLSL_PrepareShaders(void);
|
||||
void GLSL_PrepareUniformBuffers(void);
|
||||
void GLSL_ShutdownGPUShaders(void);
|
||||
void GLSL_VertexAttribPointers(uint32_t attribBits);
|
||||
void GLSL_BindProgram(shaderProgram_t * program);
|
||||
|
|
|
@ -25,6 +25,8 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
|
||||
#include <string.h> // memcpy
|
||||
|
||||
#include "../vr/vr_base.h"
|
||||
|
||||
trGlobals_t tr;
|
||||
|
||||
static float s_flipMatrix[16] = {
|
||||
|
@ -36,6 +38,8 @@ static float s_flipMatrix[16] = {
|
|||
0, 0, 0, 1
|
||||
};
|
||||
|
||||
extern cvar_t *vr_worldscale;
|
||||
extern cvar_t *vr_worldscaleScaler;
|
||||
|
||||
refimport_t ri;
|
||||
|
||||
|
@ -532,8 +536,9 @@ void R_RotateForEntity( const trRefEntity_t *ent, const viewParms_t *viewParms,
|
|||
glMatrix[11] = 0;
|
||||
glMatrix[15] = 1;
|
||||
|
||||
Mat4Copy(glMatrix, or->transformMatrix);
|
||||
myGlMultMatrix( glMatrix, viewParms->world.eyeViewMatrix[2], or->eyeViewMatrix[2] );
|
||||
for (int eye = 0; eye <= 2; ++eye) {
|
||||
myGlMultMatrix( glMatrix, viewParms->world.eyeViewMatrix[eye], or->eyeViewMatrix[eye] );
|
||||
}
|
||||
|
||||
// calculate the viewer origin in the model's space
|
||||
// needed for fog, specular, and environment mapping
|
||||
|
@ -579,10 +584,10 @@ void R_RotateForViewer (void)
|
|||
vec3_t origin;
|
||||
VectorCopy(tr.viewParms.or.origin, origin);
|
||||
|
||||
if (eye < 2)
|
||||
if (eye < 2 && !VR_useScreenLayer())
|
||||
{
|
||||
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);
|
||||
float scale = ((r_stereoSeparation->value / 1000.0f) / 2.0f) * vr_worldscale->value * vr_worldscaleScaler->value;
|
||||
VectorMA(origin, (eye == 0 ? 1.0f : -1.0f) * scale, tr.viewParms.or.axis[1], origin);
|
||||
}
|
||||
|
||||
viewerMatrix[0] = tr.viewParms.or.axis[0][0];
|
||||
|
@ -726,23 +731,11 @@ R_SetupProjection
|
|||
*/
|
||||
void R_SetupProjection(viewParms_t *dest, float zProj, float zFar, qboolean computeFrustum)
|
||||
{
|
||||
float xmin, xmax, ymin, ymax;
|
||||
float width, height, stereoSep = r_stereoSeparation->value;
|
||||
|
||||
ymax = zProj * tan(dest->fovY * M_PI / 360.0f);
|
||||
ymin = -ymax;
|
||||
|
||||
xmax = zProj * tan(dest->fovX * M_PI / 360.0f);
|
||||
xmin = -xmax;
|
||||
|
||||
width = xmax - xmin;
|
||||
height = ymax - ymin;
|
||||
|
||||
memcpy(&dest->projectionMatrix, &tr.vrParms.projection, sizeof(dest->projectionMatrix));
|
||||
|
||||
// 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);
|
||||
R_SetupFrustum( );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1708,9 +1701,9 @@ void R_RenderView (viewParms_t *parms) {
|
|||
// set viewParms.world
|
||||
R_RotateForViewer ();
|
||||
|
||||
R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue);
|
||||
GLSL_PrepareUniformBuffers();
|
||||
|
||||
GLSL_PrepareShaders();
|
||||
R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue);
|
||||
|
||||
R_GenerateDrawSurfs();
|
||||
|
||||
|
|
|
@ -1421,8 +1421,6 @@ static void RB_RenderShadowmap( shaderCommands_t *input )
|
|||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
// GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelview);
|
||||
GLSL_BindBuffers(sp);
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
static engine_t vr_engine;
|
||||
|
||||
cvar_t *vr_worldscale = NULL;
|
||||
cvar_t *vr_worldscaleScaler = NULL;
|
||||
cvar_t *vr_hudDepth = NULL;
|
||||
cvar_t *vr_righthanded = NULL;
|
||||
cvar_t *vr_switchThumbsticks = NULL;
|
||||
|
@ -60,6 +61,7 @@ void VR_InitCvars( void )
|
|||
{
|
||||
Cvar_Get ("skip_ioq3_credits", "0.0", CVAR_ARCHIVE);
|
||||
vr_worldscale = Cvar_Get ("vr_worldscale", "32.0", CVAR_ARCHIVE);
|
||||
vr_worldscaleScaler = Cvar_Get ("vr_worldscaleScaler", "1.0", CVAR_ARCHIVE);
|
||||
vr_hudDepth = Cvar_Get ("vr_hudDepth", "3", CVAR_ARCHIVE);
|
||||
vr_righthanded = Cvar_Get ("vr_righthanded", "1", CVAR_ARCHIVE);
|
||||
vr_switchThumbsticks = Cvar_Get ("vr_switchThumbsticks", "0", CVAR_ARCHIVE);
|
||||
|
|
|
@ -136,6 +136,7 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
|
|||
|
||||
Log.d(TAG, "setting env");
|
||||
try {
|
||||
//commandLineParams += " +map q3dm6";
|
||||
setenv("commandline", commandLineParams, true);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
|
|
@ -197,11 +197,13 @@ void main()
|
|||
|
||||
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;
|
||||
normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz;
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
vec3 bitangent = cross(normal, tangent) * attr_Tangent.w;
|
||||
|
@ -211,8 +213,10 @@ void main()
|
|||
vec3 L = u_LightOrigin.xyz - (position * u_LightOrigin.w);
|
||||
#elif defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
vec3 L = attr_LightDirection;
|
||||
#if defined(USE_MODELMATRIX)
|
||||
L = (u_ModelMatrix * vec4(L, 0.0)).xyz;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHTMAP)
|
||||
var_TexCoords.zw = attr_TexCoord1.st;
|
||||
|
|
Loading…
Reference in a new issue