mirror of
https://github.com/DrBeef/ioq3quest.git
synced 2024-11-26 05:52:03 +00:00
Squashed commit of the following:
commitb10fb5aae4
Author: Simon <simonbrown77@googlemail.com> Date: Sat Apr 2 23:40:44 2022 +0100 Update pakQ3Q.pk3 commitffc5546f0c
Merge:5a6a7cfd
67016999
Author: Simon <simonbrown77@googlemail.com> Date: Sat Apr 2 23:36:00 2022 +0100 Merge branch 'master' into multiview commit5a6a7cfd66
Author: Simon <simonbrown77@googlemail.com> Date: Sat Apr 2 23:34:11 2022 +0100 Lots of changes - Hacky fix for weird "out-of-body" issue when not drawing hud - HUD is now drawn as a world sprite (this has its own issues, but is mostly there) - Package the pk3 as part of the build commit3639fc6d6a
Author: Simon <simonbrown77@googlemail.com> Date: Wed Mar 30 23:27:55 2022 +0100 Update tr_glsl.c commit3cc8918328
Merge:3bb87ecb
fe180129
Author: Simon <simonbrown77@googlemail.com> Date: Wed Mar 30 22:10:54 2022 +0100 Merge branch 'master' into multiview commit3bb87ecbe6
Author: Simon <simonbrown77@googlemail.com> Date: Wed Mar 30 20:05:14 2022 +0100 Some small tweaks to shaders following trunk merge commit2b2748b9f9
Merge:aeb45adc
a750c2e5
Author: Simon <simonbrown77@googlemail.com> Date: Wed Mar 30 19:17:00 2022 +0100 Merge branch 'master' into multiview commitaeb45adcd8
Author: Simon <simonbrown77@googlemail.com> Date: Tue Mar 29 23:23:33 2022 +0100 Small changes following the merge from master - and also removed a couple of bits of my hacking commit3f5226aa85
Merge:e8da7431
bcf9287a
Author: Simon <simonbrown77@googlemail.com> Date: Tue Mar 29 23:05:01 2022 +0100 Merge branch 'master' into multiview commite8da743153
Author: Simon <simonbrown77@googlemail.com> Date: Tue Mar 29 22:41:36 2022 +0100 Orthographic projection now working the main fix is in tr_glsl.c, the other changes are peripheral and probably contribute nothing commite1a16cbeb2
Author: Simon <simonbrown77@googlemail.com> Date: Tue Mar 29 19:53:00 2022 +0100 Correct pointer offset commit12987c20b9
Author: Simon <simonbrown77@googlemail.com> Date: Mon Mar 28 23:16:19 2022 +0100 Few small changes might add slight perf improvements as there was some buffer swap stuff not needed commite06ba21101
Author: Simon <simonbrown77@googlemail.com> Date: Mon Mar 28 19:30:55 2022 +0100 World entities now drawing in the right places ..next up is the 2D stuff commite2a5472667
Author: Simon <simonbrown77@googlemail.com> Date: Sun Mar 27 23:19:16 2022 +0100 Small progress world is now rendering correctly, but.. - All items in world are rendering in the wrong place - no 2D still commit71708ee91e
Author: Simon <simonbrown77@googlemail.com> Date: Sun Mar 27 18:08:51 2022 +0100 Restored missing matrix commit6506c96194
Author: Simon <simonbrown77@googlemail.com> Date: Sun Mar 27 17:46:42 2022 +0100 Still ongoing (with little improvement) commit170f32709b
Author: Simon <simonbrown77@googlemail.com> Date: Sat Mar 26 23:31:03 2022 +0000 Now rendering! 2D stuff doesn't draw, and 3D is all wonky, but this is progress! commitd6ade0215f
Author: Simon <simonbrown77@googlemail.com> Date: Sat Mar 26 19:02:03 2022 +0000 Ensure multiview is only applied to vertex shaders commiteec5efe237
Author: Simon <simonbrown77@googlemail.com> Date: Sat Mar 26 12:11:55 2022 +0000 Make main a C file in prep for the next step commitb2fece761e
Author: Simon <simonbrown77@googlemail.com> Date: Fri Mar 25 19:34:44 2022 +0000 Make context create correctly commite1a04d2200
Author: Simon <simonbrown77@googlemail.com> Date: Fri Mar 25 00:05:11 2022 +0000 Not working yet
This commit is contained in:
parent
6701699932
commit
326ddd1764
62 changed files with 1075 additions and 523 deletions
Binary file not shown.
|
@ -5,7 +5,7 @@ set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}")
|
|||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -Werror")
|
||||
link_directories(../jniLibs/arm64-v8a)
|
||||
|
||||
add_library(main SHARED main.cpp)
|
||||
add_library(main SHARED main.c)
|
||||
|
||||
SET(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configs" FORCE)
|
||||
SET(BUILD_FOLDER release-android-aarch64)
|
||||
|
|
|
@ -2761,6 +2761,34 @@ static void CG_Draw2D()
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// HACK HACK HACK
|
||||
//
|
||||
//Render an empty scene - seems to sort the weird out-of-body thing
|
||||
//when the HUD isn't being drawn. Need to get to the bottom of this
|
||||
//it shouldn't cost frames, but it is ugly
|
||||
static void CG_EmptySceneHackHackHack( void )
|
||||
{
|
||||
refdef_t refdef;
|
||||
memset( &refdef, 0, sizeof( refdef ) );
|
||||
|
||||
refdef.rdflags = RDF_NOWORLDMODEL;
|
||||
AxisClear( refdef.viewaxis );
|
||||
|
||||
refdef.fov_x = 30;
|
||||
refdef.fov_y = 30;
|
||||
|
||||
refdef.x = 0;
|
||||
refdef.y = 0;
|
||||
refdef.width = cgs.glconfig.vidWidth;
|
||||
refdef.height = cgs.glconfig.vidHeight;
|
||||
|
||||
refdef.time = cg.time;
|
||||
|
||||
trap_R_ClearScene();
|
||||
trap_R_RenderScene( &refdef );
|
||||
}
|
||||
|
||||
/*
|
||||
=====================
|
||||
CG_DrawActive
|
||||
|
@ -2797,20 +2825,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 = 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,16 +2880,50 @@ 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);
|
||||
//Now draw the HUD shader in the world
|
||||
{
|
||||
refEntity_t ent;
|
||||
trace_t trace;
|
||||
vec3_t viewaxis[3];
|
||||
vec3_t weaponangles;
|
||||
vec3_t origin, endpos;
|
||||
|
||||
float scale = trap_Cvar_VariableValue("vr_worldscaleScaler");
|
||||
float dist = (trap_Cvar_VariableValue("vr_hudDepth")+1) * 6 * scale;
|
||||
float radius = dist / 3.0f;
|
||||
|
||||
VectorMA(cg.refdef.vieworg, dist, cg.refdef.viewaxis[0], endpos);
|
||||
VectorMA(endpos, trap_Cvar_VariableValue("vr_hudYOffset") / 20, cg.refdef.viewaxis[2], endpos);
|
||||
|
||||
memset(&ent, 0, sizeof(ent));
|
||||
ent.reType = RT_SPRITE;
|
||||
ent.renderfx = RF_DEPTHHACK;
|
||||
|
||||
VectorCopy(endpos, ent.origin);
|
||||
|
||||
ent.radius = radius;
|
||||
ent.invert = qtrue;
|
||||
ent.customShader = cgs.media.hudShader;
|
||||
|
||||
trap_R_AddRefEntityToScene(&ent);
|
||||
}
|
||||
|
||||
// draw 3D view
|
||||
trap_R_RenderScene( &cg.refdef );
|
||||
|
||||
VectorCopy( baseOrg, cg.refdef.vieworg );
|
||||
|
||||
// draw status bar and other floating elements
|
||||
CG_Draw2D();
|
||||
{
|
||||
//Tell renderer we want to draw to the HUD buffer
|
||||
trap_R_HUDBufferStart();
|
||||
|
||||
// draw status bar and other floating elements
|
||||
CG_Draw2D();
|
||||
|
||||
trap_R_HUDBufferEnd();
|
||||
}
|
||||
|
||||
CG_EmptySceneHackHackHack();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -44,28 +44,33 @@ CG_AdjustFrom640
|
|||
Adjusted for resolution and screen aspect ratio
|
||||
================
|
||||
*/
|
||||
void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
||||
|
||||
if (vr->virtual_screen ||
|
||||
vr->weapon_zoomed)
|
||||
void CG_AdjustFrom640( float *x, float *y, float *w, float *h )
|
||||
{
|
||||
/* if ( cg.snap == NULL ||
|
||||
cg.snap->ps.pm_type != PM_INTERMISSION)*/
|
||||
{
|
||||
// scale for screen sizes
|
||||
*x *= cgs.screenXScale;
|
||||
*y *= cgs.screenYScale;
|
||||
*w *= cgs.screenXScale;
|
||||
*h *= cgs.screenYScale;
|
||||
if (hudflags & HUD_FLAGS_DRAWMODEL)
|
||||
{
|
||||
*w *= (cgs.screenXScale * 2.0f);
|
||||
*x -= (*w / 3);
|
||||
*h *= (cgs.screenYScale * 2.0f);
|
||||
*y -= (*h / 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
*w *= cgs.screenXScale;
|
||||
*h *= cgs.screenYScale;
|
||||
}
|
||||
}
|
||||
/*
|
||||
else // scale to clearly visible portion of VR screen
|
||||
{
|
||||
float screenXScale = cgs.screenXScale / 2.75f;
|
||||
float screenYScale = cgs.screenYScale / 2.25f;
|
||||
|
||||
const auto depth = (int)trap_Cvar_VariableValue( "vr_hudDepth" );
|
||||
int xoffset = 120 - (depth * 20);
|
||||
if (cg.stereoView == STEREO_RIGHT) {
|
||||
xoffset *= -1;
|
||||
}
|
||||
|
||||
*x *= screenXScale;
|
||||
*y *= screenYScale;
|
||||
if (hudflags & HUD_FLAGS_DRAWMODEL)
|
||||
|
@ -73,7 +78,7 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
|||
*w *= (cgs.screenXScale * 2.0f);
|
||||
*x -= (*w / 3);
|
||||
*h *= (cgs.screenYScale * 2.0f);
|
||||
*y -= (*h / 3);
|
||||
*y -= (*h / 3);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -81,9 +86,11 @@ void CG_AdjustFrom640( float *x, float *y, float *w, float *h ) {
|
|||
*h *= screenYScale;
|
||||
}
|
||||
|
||||
*x += (cg.refdef.width - (640 * screenXScale)) / 2.0f + xoffset;
|
||||
*y += (cg.refdef.height - (480 * screenYScale)) / 2.0f - trap_Cvar_VariableValue( "vr_hudYOffset" );
|
||||
*x += (cg.refdef.width - (640 * screenXScale)) / 2.0f;
|
||||
*y += (cg.refdef.height - (480 * screenYScale)) / 2.0f -
|
||||
trap_Cvar_VariableValue("vr_hudYOffset");
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -833,6 +833,8 @@ typedef struct {
|
|||
qhandle_t invulnerabilityPowerupModel;
|
||||
#endif
|
||||
|
||||
qhandle_t hudShader;
|
||||
|
||||
// scoreboard headers
|
||||
qhandle_t scoreboardName;
|
||||
qhandle_t scoreboardPing;
|
||||
|
@ -1544,6 +1546,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 );
|
||||
|
||||
|
@ -1659,6 +1662,9 @@ int trap_R_LerpTag( orientation_t *tag, clipHandle_t mod, int startFrame, int
|
|||
void trap_R_RemapShader( const char *oldShader, const char *newShader, const char *timeOffset );
|
||||
qboolean trap_R_inPVS( const vec3_t p1, const vec3_t p2 );
|
||||
|
||||
void trap_R_HUDBufferStart( void );
|
||||
void trap_R_HUDBufferEnd( void );
|
||||
|
||||
// The glconfig_t will not change during the life of a cgame.
|
||||
// If it needs to change, the entire cgame will be restarted, because
|
||||
// all the qhandle_t are then invalid.
|
||||
|
|
|
@ -1055,6 +1055,9 @@ static void CG_RegisterGraphics( void ) {
|
|||
cgs.media.reticleShader = trap_R_RegisterShader( "gfx/weapon/scope" );
|
||||
cgs.media.vignetteShader = trap_R_RegisterShader( "gfx/vignette" );
|
||||
|
||||
//HUD
|
||||
cgs.media.hudShader = trap_R_RegisterShader( "sprites/vr/hud" );
|
||||
|
||||
//Used for the weapon selector
|
||||
cgs.media.smallSphereModel = trap_R_RegisterModel("models/powerups/health/small_sphere.md3");
|
||||
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -166,6 +166,8 @@ typedef enum {
|
|||
CG_FS_SEEK,
|
||||
|
||||
CG_HAPTICEVENT,
|
||||
CG_R_HUDBUFFER_START,
|
||||
CG_R_HUDBUFFER_END,
|
||||
|
||||
/*
|
||||
CG_LOADCAMERA,
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
@ -282,6 +288,14 @@ void trap_R_RenderScene( const refdef_t *fd ) {
|
|||
syscall( CG_R_RENDERSCENE, fd );
|
||||
}
|
||||
|
||||
void trap_R_HUDBufferStart( void ) {
|
||||
syscall( CG_R_HUDBUFFER_START );
|
||||
}
|
||||
|
||||
void trap_R_HUDBufferEnd( void ) {
|
||||
syscall( CG_R_HUDBUFFER_END );
|
||||
}
|
||||
|
||||
void trap_R_SetColor( const float *rgba ) {
|
||||
syscall( CG_R_SETCOLOR, rgba );
|
||||
}
|
||||
|
|
|
@ -745,7 +745,7 @@ static int CG_CalcViewValues( ) {
|
|||
VectorCopy(cg.refdef.vieworg, cg.vr_vieworigin);
|
||||
}
|
||||
|
||||
if (vr->use_fake_6dof && cg.stereoView == STEREO_LEFT && !vr->virtual_screen)
|
||||
if (vr->use_fake_6dof && !vr->virtual_screen)
|
||||
{
|
||||
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();
|
||||
|
|
|
@ -697,6 +697,12 @@ intptr_t CL_CgameSystemCalls( intptr_t *args ) {
|
|||
case CG_HAPTICEVENT:
|
||||
VR_HapticEvent( VMA(1), args[2], args[3], args[4], VMF(5), VMF(6) );
|
||||
return 0;
|
||||
case CG_R_HUDBUFFER_START:
|
||||
re.HUDBufferStart();
|
||||
return 0;
|
||||
case CG_R_HUDBUFFER_END:
|
||||
re.HUDBufferEnd();
|
||||
return 0;
|
||||
|
||||
|
||||
default:
|
||||
|
|
|
@ -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) \
|
||||
|
||||
|
|
|
@ -75,6 +75,8 @@ typedef struct {
|
|||
void (*AddLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
|
||||
void (*AddAdditiveLightToScene)( const vec3_t org, float intensity, float r, float g, float b );
|
||||
void (*RenderScene)( const refdef_t *fd );
|
||||
void (*HUDBufferStart)( void );
|
||||
void (*HUDBufferEnd)( void );
|
||||
|
||||
void (*SetColor)( const float *rgba ); // NULL = 1,1,1,1
|
||||
void (*DrawStretchPic) ( float x, float y, float w, float h,
|
||||
|
@ -91,7 +93,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,
|
||||
|
|
|
@ -118,6 +118,7 @@ typedef struct {
|
|||
// extra sprite information
|
||||
float radius;
|
||||
float rotation;
|
||||
qboolean invert;
|
||||
} refEntity_t;
|
||||
|
||||
|
||||
|
|
|
@ -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,18 @@ uniform float u_Time;
|
|||
#endif
|
||||
|
||||
uniform vec4 u_Color;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
varying vec4 var_Color;
|
||||
|
@ -80,7 +91,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,24 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -15,13 +15,14 @@ uniform vec4 u_FogDistance;
|
|||
uniform vec4 u_FogDepth;
|
||||
uniform float u_FogEyeT;
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_DEFORM_VERTEXES)
|
||||
uniform int u_DeformGen;
|
||||
uniform float u_DeformParams[5];
|
||||
#endif
|
||||
|
||||
uniform float u_Time;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
|
@ -31,6 +32,16 @@ uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
|||
|
||||
uniform vec4 u_Color;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying float var_Scale;
|
||||
|
||||
#if defined(USE_DEFORM_VERTEXES)
|
||||
|
@ -125,7 +136,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;
|
||||
}
|
||||
|
|
|
@ -36,13 +36,15 @@ uniform float u_FogEyeT;
|
|||
uniform vec4 u_FogColorMask;
|
||||
#endif
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_DEFORM_VERTEXES)
|
||||
uniform int u_DeformGen;
|
||||
uniform float u_DeformParams[5];
|
||||
uniform float u_Time;
|
||||
#endif
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform vec4 u_BaseColor;
|
||||
uniform vec4 u_VertColor;
|
||||
|
||||
|
@ -61,6 +63,16 @@ uniform float u_VertexLerp;
|
|||
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
||||
#endif
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying vec2 var_DiffuseTex;
|
||||
varying vec4 var_Color;
|
||||
|
||||
|
@ -227,7 +239,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,13 +41,12 @@ uniform vec4 u_DiffuseTexMatrix;
|
|||
uniform vec4 u_DiffuseTexOffTurb;
|
||||
#endif
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
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;
|
||||
|
@ -67,6 +66,16 @@ uniform vec4 u_PrimaryLightOrigin;
|
|||
uniform float u_PrimaryLightRadius;
|
||||
#endif
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying vec4 var_TexCoords;
|
||||
|
||||
varying vec4 var_Color;
|
||||
|
@ -188,14 +197,14 @@ 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;
|
||||
normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz;
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
|
@ -206,9 +215,9 @@ 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)
|
||||
#if defined(USE_MODELMATRIX)
|
||||
L = (u_ModelMatrix * vec4(L, 0.0)).xyz;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHTMAP)
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec3 attr_Normal;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
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;
|
||||
|
|
|
@ -10,15 +10,17 @@ attribute vec4 attr_BoneIndexes;
|
|||
attribute vec4 attr_BoneWeights;
|
||||
#endif
|
||||
|
||||
|
||||
// Uniforms
|
||||
|
||||
//#if defined(USE_DEFORM_VERTEXES)
|
||||
uniform int u_DeformGen;
|
||||
uniform float u_DeformParams[5];
|
||||
//#endif
|
||||
|
||||
uniform float u_Time;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
|
@ -26,6 +28,15 @@ uniform float u_VertexLerp;
|
|||
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
||||
#endif
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying vec3 var_Position;
|
||||
|
||||
vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
|
||||
|
@ -102,7 +113,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
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
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,9 +1,21 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
uniform vec3 u_ToneMinAvgMaxLinear;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
varying float var_InvWhite;
|
||||
|
||||
|
@ -21,7 +33,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);
|
||||
}
|
||||
|
|
|
@ -270,29 +270,11 @@ void GL_State( unsigned long stateBits )
|
|||
void GL_SetProjectionMatrix(mat4_t matrix)
|
||||
{
|
||||
Mat4Copy(matrix, glState.projection);
|
||||
Mat4Multiply(glState.projection, glState.modelview, glState.modelviewProjection);
|
||||
}
|
||||
|
||||
|
||||
void GL_SetModelviewMatrix(mat4_t matrix, qboolean applyStereoView)
|
||||
void GL_SetModelMatrix(mat4_t matrix)
|
||||
{
|
||||
/*
|
||||
if (applyStereoView)
|
||||
{
|
||||
if (tr.refdef.stereoFrame == STEREO_LEFT) {
|
||||
Mat4Multiply(tr.vrParms.viewL, matrix, glState.modelview);
|
||||
} else if (tr.refdef.stereoFrame == STEREO_RIGHT) {
|
||||
Mat4Multiply(tr.vrParms.viewR, matrix, glState.modelview);
|
||||
} else {
|
||||
Mat4Copy(matrix, glState.modelview);
|
||||
}
|
||||
} else
|
||||
*/
|
||||
{
|
||||
Mat4Copy(matrix, glState.modelview);
|
||||
}
|
||||
|
||||
Mat4Multiply(glState.projection, glState.modelview, glState.modelviewProjection);
|
||||
Mat4Copy(matrix, glState.modelMatrix);
|
||||
}
|
||||
|
||||
|
||||
|
@ -427,7 +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
|
||||
GL_SetModelviewMatrix( s_flipMatrix, qtrue );
|
||||
|
||||
GL_SetModelMatrix( s_flipMatrix );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -546,7 +529,8 @@ 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_SetModelMatrix( backEnd.or.modelMatrix );
|
||||
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
|
||||
|
||||
//
|
||||
// change depthrange. Also change projection matrix so first person weapon does not look like coming
|
||||
|
@ -556,26 +540,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
{
|
||||
if (depthRange)
|
||||
{
|
||||
if(backEnd.viewParms.stereoFrame != STEREO_CENTER)
|
||||
{
|
||||
if(isCrosshair)
|
||||
{
|
||||
if(oldDepthRange)
|
||||
{
|
||||
// was not a crosshair but now is, change back proj matrix
|
||||
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
viewParms_t temp = backEnd.viewParms;
|
||||
|
||||
R_SetupProjection(&temp, r_znear->value, 0, qfalse);
|
||||
|
||||
GL_SetProjectionMatrix( temp.projectionMatrix );
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
if(!oldDepthRange)
|
||||
glDepthRangef(0.0f, 0.3f);
|
||||
|
@ -586,11 +550,6 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
}
|
||||
else
|
||||
{
|
||||
if(!wasCrosshair && backEnd.viewParms.stereoFrame != STEREO_CENTER)
|
||||
{
|
||||
GL_SetProjectionMatrix( backEnd.viewParms.projectionMatrix );
|
||||
}
|
||||
|
||||
#ifdef __ANDROID__
|
||||
glDepthRangef(0.0f, 1.0f);
|
||||
#else
|
||||
|
@ -619,9 +578,9 @@ void RB_RenderDrawSurfList( drawSurf_t *drawSurfs, int numDrawSurfs ) {
|
|||
if (glRefConfig.framebufferObject)
|
||||
FBO_Bind(fbo);
|
||||
|
||||
// go back to the world modelview matrix
|
||||
// go back to the world model matrix
|
||||
|
||||
GL_SetModelviewMatrix( backEnd.viewParms.world.modelMatrix, qtrue );
|
||||
GL_SetModelMatrix( backEnd.viewParms.world.modelMatrix );
|
||||
|
||||
#ifdef __ANDROID__
|
||||
glDepthRangef(0, 1);
|
||||
|
@ -653,6 +612,7 @@ void RB_SetGL2D (void) {
|
|||
return;
|
||||
|
||||
backEnd.projection2D = qtrue;
|
||||
|
||||
backEnd.last2DFBO = glState.currentFBO;
|
||||
|
||||
if (glState.currentFBO)
|
||||
|
@ -673,7 +633,7 @@ void RB_SetGL2D (void) {
|
|||
Mat4Ortho(0, width, height, 0, 0, 1, matrix);
|
||||
GL_SetProjectionMatrix(matrix);
|
||||
Mat4Identity(matrix);
|
||||
GL_SetModelviewMatrix(matrix, false);
|
||||
GL_SetModelMatrix(matrix);
|
||||
|
||||
GL_State( GLS_DEPTHTEST_DISABLE |
|
||||
GLS_SRCBLEND_SRC_ALPHA |
|
||||
|
@ -755,8 +715,9 @@ void RE_StretchRaw (int x, int y, int w, int h, int cols, int rows, const byte *
|
|||
VectorSet2(texCoords[3], 0.5f / cols, (rows - 0.5f) / rows);
|
||||
|
||||
GLSL_BindProgram(&tr.textureColorShader);
|
||||
|
||||
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformMat4(&tr.textureColorShader, UNIFORM_MODELMATRIX, glState.modelMatrix);
|
||||
GLSL_BindBuffers(&tr.textureColorShader);
|
||||
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);
|
||||
|
||||
RB_InstantQuad2(quadVerts, texCoords);
|
||||
|
@ -1407,6 +1368,7 @@ const void *RB_SwapBuffers( const void *data ) {
|
|||
ri.Hunk_FreeTempMemory( stencilReadback );
|
||||
}
|
||||
|
||||
#if 0
|
||||
if (glRefConfig.framebufferObject)
|
||||
{
|
||||
if (!backEnd.framePostProcessed)
|
||||
|
@ -1423,14 +1385,16 @@ const void *RB_SwapBuffers( const void *data ) {
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if ( !glState.finishCalled ) {
|
||||
if ( !glState.finishCalled )
|
||||
{
|
||||
qglFinish();
|
||||
}
|
||||
|
||||
GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" );
|
||||
//GLimp_LogComment( "***************** RB_SwapBuffers *****************\n\n\n" );
|
||||
|
||||
GLimp_EndFrame();
|
||||
//GLimp_EndFrame();
|
||||
|
||||
backEnd.framePostProcessed = qfalse;
|
||||
backEnd.projection2D = qfalse;
|
||||
|
@ -1792,6 +1756,55 @@ const void* RB_SwitchEye( const void* data ) {
|
|||
return (const void*)(cmd + 1);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
RB_HUDBuffer
|
||||
====================
|
||||
*/
|
||||
const void* RB_HUDBuffer( const void* data ) {
|
||||
const hudBufferCommand_t *cmd = data;
|
||||
|
||||
// finish any 2D drawing if needed
|
||||
if(tess.numIndexes)
|
||||
RB_EndSurface();
|
||||
|
||||
if (cmd->start && tr.renderFbo->frameBuffer != tr.hudFbo->frameBuffer)
|
||||
{
|
||||
//keep record of current render fbo and switch to the hud buffer
|
||||
tr.backupFrameBuffer = tr.renderFbo->frameBuffer;
|
||||
tr.renderFbo->frameBuffer = tr.hudFbo->frameBuffer;
|
||||
|
||||
// Render to framebuffer
|
||||
GL_BindFramebuffer(GL_FRAMEBUFFER, tr.hudFbo->frameBuffer);
|
||||
qglBindRenderbuffer(GL_RENDERBUFFER, 0);
|
||||
qglFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, tr.hudImage->texnum, 0);
|
||||
|
||||
// Attach combined depth+stencil
|
||||
qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, tr.hudDepthImage->texnum);
|
||||
qglFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, tr.hudDepthImage->texnum);
|
||||
|
||||
GLenum result = qglCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if(result != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
ri.Error( "Error binding Framebuffer: %i\n", result );
|
||||
}
|
||||
|
||||
qglClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
|
||||
qglClear( GL_COLOR_BUFFER_BIT );
|
||||
}
|
||||
else if (tr.renderFbo->frameBuffer == tr.hudFbo->frameBuffer)
|
||||
{
|
||||
//restore the true render fbo
|
||||
tr.renderFbo->frameBuffer = tr.backupFrameBuffer;
|
||||
GL_BindFramebuffer(GL_FRAMEBUFFER, tr.renderFbo->frameBuffer);
|
||||
}
|
||||
|
||||
glState.currentFBO = tr.renderFbo;
|
||||
|
||||
return (const void*)(cmd + 1);
|
||||
}
|
||||
|
||||
/*
|
||||
====================
|
||||
RB_ExecuteRenderCommands
|
||||
|
@ -1845,6 +1858,9 @@ void RB_ExecuteRenderCommands( const void *data ) {
|
|||
case RC_SWITCH_EYE:
|
||||
data = RB_SwitchEye(data);
|
||||
break;
|
||||
case RC_HUD_BUFFER:
|
||||
data = RB_HUDBuffer(data);
|
||||
break;
|
||||
case RC_END_OF_LIST:
|
||||
default:
|
||||
// finish any 2D drawing if needed
|
||||
|
|
|
@ -410,129 +410,22 @@ void RE_BeginFrame( stereoFrame_t stereoFrame ) {
|
|||
ri.Error(ERR_FATAL, "RE_BeginFrame() - glGetError() failed (0x%x)!", err);
|
||||
}
|
||||
|
||||
if (glConfig.stereoEnabled) {
|
||||
{
|
||||
if (tr.renderFbo && tr.vrParms.renderBufferOriginal == 0) {
|
||||
tr.vrParms.renderBufferOriginal = tr.renderFbo->frameBuffer;
|
||||
}
|
||||
|
||||
if ( stereoFrame == STEREO_LEFT ) {
|
||||
{
|
||||
if (tr.vrParms.valid == qtrue) {
|
||||
if (tr.renderFbo) {
|
||||
switchEyeCommand_t* sec;
|
||||
if (!(sec = R_GetCommandBuffer(sizeof(*sec))))
|
||||
return;
|
||||
sec->commandId = RC_SWITCH_EYE;
|
||||
sec->eye = tr.vrParms.renderBufferL;
|
||||
sec->eye = tr.vrParms.renderBuffer;
|
||||
sec->stereoFrame = stereoFrame;
|
||||
}
|
||||
}
|
||||
} else if ( stereoFrame == STEREO_RIGHT ) {
|
||||
if (tr.vrParms.valid == qtrue) {
|
||||
if (tr.renderFbo) {
|
||||
switchEyeCommand_t* sec;
|
||||
if (!(sec = R_GetCommandBuffer(sizeof(*sec))))
|
||||
return;
|
||||
sec->commandId = RC_SWITCH_EYE;
|
||||
sec->eye = tr.vrParms.renderBufferR;
|
||||
sec->stereoFrame = stereoFrame;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if(r_anaglyphMode->integer)
|
||||
{
|
||||
if(r_anaglyphMode->modified)
|
||||
{
|
||||
// clear both, front and backbuffer.
|
||||
qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
backEnd.colorMask[0] = GL_FALSE;
|
||||
backEnd.colorMask[1] = GL_FALSE;
|
||||
backEnd.colorMask[2] = GL_FALSE;
|
||||
backEnd.colorMask[3] = GL_FALSE;
|
||||
|
||||
if (glRefConfig.framebufferObject)
|
||||
{
|
||||
// clear all framebuffers
|
||||
if (tr.msaaResolveFbo)
|
||||
{
|
||||
FBO_Bind(tr.msaaResolveFbo);
|
||||
qglClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
if (tr.renderFbo)
|
||||
{
|
||||
FBO_Bind(tr.renderFbo);
|
||||
qglClear(GL_COLOR_BUFFER_BIT);
|
||||
}
|
||||
|
||||
FBO_Bind(NULL);
|
||||
}
|
||||
|
||||
qglDrawBuffer(GL_FRONT);
|
||||
qglClear(GL_COLOR_BUFFER_BIT);
|
||||
qglDrawBuffer(GL_BACK);
|
||||
qglClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
r_anaglyphMode->modified = qfalse;
|
||||
}
|
||||
|
||||
if(stereoFrame == STEREO_LEFT)
|
||||
{
|
||||
if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) )
|
||||
return;
|
||||
|
||||
if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) )
|
||||
return;
|
||||
}
|
||||
else if(stereoFrame == STEREO_RIGHT)
|
||||
{
|
||||
clearDepthCommand_t *cldcmd;
|
||||
|
||||
if( !(cldcmd = R_GetCommandBuffer(sizeof(*cldcmd))) )
|
||||
return;
|
||||
|
||||
cldcmd->commandId = RC_CLEARDEPTH;
|
||||
|
||||
if( !(colcmd = R_GetCommandBuffer(sizeof(*colcmd))) )
|
||||
return;
|
||||
}
|
||||
else
|
||||
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is enabled, but stereoFrame was %i", stereoFrame );
|
||||
|
||||
R_SetColorMode(colcmd->rgba, stereoFrame, r_anaglyphMode->integer);
|
||||
colcmd->commandId = RC_COLORMASK;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(stereoFrame != STEREO_CENTER)
|
||||
ri.Error( ERR_FATAL, "RE_BeginFrame: Stereo is disabled, but stereoFrame was %i", stereoFrame );
|
||||
|
||||
if( !(cmd = R_GetCommandBuffer(sizeof(*cmd))) )
|
||||
return;
|
||||
}
|
||||
|
||||
if(cmd)
|
||||
{
|
||||
cmd->commandId = RC_DRAW_BUFFER;
|
||||
|
||||
if(r_anaglyphMode->modified)
|
||||
{
|
||||
qglColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
backEnd.colorMask[0] = 0;
|
||||
backEnd.colorMask[1] = 0;
|
||||
backEnd.colorMask[2] = 0;
|
||||
backEnd.colorMask[3] = 0;
|
||||
r_anaglyphMode->modified = qfalse;
|
||||
}
|
||||
|
||||
if (!Q_stricmp(r_drawBuffer->string, "GL_FRONT"))
|
||||
cmd->buffer = (int)GL_FRONT;
|
||||
else
|
||||
cmd->buffer = (int)GL_BACK;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -579,6 +472,36 @@ void RE_EndFrame( int *frontEndMsec, int *backEndMsec ) {
|
|||
backEnd.pc.msec = 0;
|
||||
}
|
||||
|
||||
void RE_HUDBufferStart( void )
|
||||
{
|
||||
hudBufferCommand_t *cmd;
|
||||
|
||||
if ( !tr.registered ) {
|
||||
return;
|
||||
}
|
||||
cmd = R_GetCommandBufferReserved( sizeof( *cmd ), 0 );
|
||||
if ( !cmd ) {
|
||||
return;
|
||||
}
|
||||
cmd->start = qtrue;
|
||||
cmd->commandId = RC_HUD_BUFFER;
|
||||
}
|
||||
|
||||
void RE_HUDBufferEnd( void )
|
||||
{
|
||||
hudBufferCommand_t *cmd;
|
||||
|
||||
if ( !tr.registered ) {
|
||||
return;
|
||||
}
|
||||
cmd = R_GetCommandBufferReserved( sizeof( *cmd ), 0 );
|
||||
if ( !cmd ) {
|
||||
return;
|
||||
}
|
||||
cmd->start = qfalse;
|
||||
cmd->commandId = RC_HUD_BUFFER;
|
||||
}
|
||||
|
||||
//#if __ANDROID__
|
||||
void R_Mat4Transpose( const float in[4][4], float* out ) {
|
||||
int i, j;
|
||||
|
@ -591,10 +514,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
|
||||
|
|
|
@ -306,6 +306,21 @@ void FBO_Init(void)
|
|||
qglClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
|
||||
}
|
||||
|
||||
{
|
||||
tr.hudFbo = FBO_Create("_hud", tr.hudImage->width, tr.hudImage->height);
|
||||
FBO_AttachImage(tr.hudFbo, tr.hudImage, GL_COLOR_ATTACHMENT0, 0);
|
||||
FBO_AttachImage(tr.hudFbo, tr.hudDepthImage, GL_DEPTH_ATTACHMENT, 0);
|
||||
R_CheckFBO(tr.hudFbo);
|
||||
|
||||
// clear render buffer
|
||||
if (tr.hudFbo)
|
||||
{
|
||||
GL_BindFramebuffer(GL_FRAMEBUFFER, tr.hudFbo->frameBuffer);
|
||||
qglClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (tr.screenScratchImage)
|
||||
{
|
||||
tr.screenScratchFbo = FBO_Create("screenScratch", tr.screenScratchImage->width, tr.screenScratchImage->height);
|
||||
|
@ -440,14 +455,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 +591,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, glState.modelMatrix);
|
||||
GLSL_BindBuffers(shaderProgram);
|
||||
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.modelView,
|
||||
backEnd.viewParms.projectionMatrix, eye, clip );
|
||||
|
||||
// check to see if the point is completely off screen
|
||||
|
@ -472,7 +472,7 @@ void RB_RenderFlares (void) {
|
|||
flare_t *f;
|
||||
flare_t **prev;
|
||||
qboolean draw;
|
||||
mat4_t oldmodelview, oldprojection, matrix;
|
||||
mat4_t oldmodelmatrix, oldprojection, matrix;
|
||||
|
||||
if ( !r_flares->integer ) {
|
||||
return;
|
||||
|
@ -527,9 +527,9 @@ void RB_RenderFlares (void) {
|
|||
}
|
||||
|
||||
Mat4Copy(glState.projection, oldprojection);
|
||||
Mat4Copy(glState.modelview, oldmodelview);
|
||||
Mat4Copy(glState.modelMatrix, oldmodelmatrix);
|
||||
Mat4Identity(matrix);
|
||||
GL_SetModelviewMatrix(matrix, qtrue);
|
||||
GL_SetModelMatrix(matrix);
|
||||
Mat4Ortho( backEnd.viewParms.viewportX, backEnd.viewParms.viewportX + backEnd.viewParms.viewportWidth,
|
||||
backEnd.viewParms.viewportY, backEnd.viewParms.viewportY + backEnd.viewParms.viewportHeight,
|
||||
-99999, 99999, matrix );
|
||||
|
@ -544,7 +544,7 @@ void RB_RenderFlares (void) {
|
|||
}
|
||||
|
||||
GL_SetProjectionMatrix(oldprojection);
|
||||
GL_SetModelviewMatrix(oldmodelview, qtrue);
|
||||
GL_SetModelMatrix(oldmodelmatrix);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -23,6 +23,9 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
#include "tr_local.h"
|
||||
|
||||
#include "tr_dsa.h"
|
||||
#include "../vr/vr_base.h"
|
||||
#include "../vr/vr_clientinfo.h"
|
||||
|
||||
|
||||
extern const char *fallbackShader_bokeh_vp;
|
||||
extern const char *fallbackShader_bokeh_fp;
|
||||
|
@ -53,6 +56,9 @@ extern const char *fallbackShader_texturecolor_fp;
|
|||
extern const char *fallbackShader_tonemap_vp;
|
||||
extern const char *fallbackShader_tonemap_fp;
|
||||
|
||||
extern cvar_t *vr_hudDepth;
|
||||
extern vr_clientinfo_t vr;
|
||||
|
||||
typedef struct uniformInfo_s
|
||||
{
|
||||
char *name;
|
||||
|
@ -60,6 +66,20 @@ typedef struct uniformInfo_s
|
|||
}
|
||||
uniformInfo_t;
|
||||
|
||||
typedef enum {
|
||||
// STEREO_ORTHO_PROJECTION, // An orthographic projection with slight stereo view matrix
|
||||
HUD_ORTHO_PROJECTION, // Orthographic projection and no stereo view
|
||||
VR_PROJECTION,
|
||||
|
||||
PROJECTION_COUNT
|
||||
} projection_t;
|
||||
|
||||
GLuint viewMatricesBuffer[PROJECTION_COUNT];
|
||||
GLuint projectionMatricesBuffer[PROJECTION_COUNT];
|
||||
|
||||
float orthoProjectionMatrix[16];
|
||||
|
||||
|
||||
// These must be in the same order as in uniform_t in tr_local.h.
|
||||
static uniformInfo_t uniformsInfo[] =
|
||||
{
|
||||
|
@ -121,8 +141,7 @@ static uniformInfo_t uniformsInfo[] =
|
|||
{ "u_FogEyeT", GLSL_FLOAT },
|
||||
{ "u_FogColorMask", GLSL_VEC4 },
|
||||
|
||||
{ "u_ModelMatrix", GLSL_MAT16 },
|
||||
{ "u_ModelViewProjectionMatrix", GLSL_MAT16 },
|
||||
{ "u_ModelMatrix", GLSL_MAT16 },
|
||||
|
||||
{ "u_Time", GLSL_FLOAT },
|
||||
{ "u_VertexLerp" , GLSL_FLOAT },
|
||||
|
@ -160,6 +179,88 @@ typedef enum
|
|||
}
|
||||
glslPrintLog_t;
|
||||
|
||||
|
||||
/*
|
||||
====================
|
||||
GLSL_ViewMatricesUniformBuffer
|
||||
====================
|
||||
*/
|
||||
static void GLSL_ViewMatricesUniformBuffer(const float value[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 HUD_ORTHO_PROJECTION:
|
||||
{
|
||||
if (vr.virtual_screen)
|
||||
{
|
||||
vec3_t translate;
|
||||
VectorSet(translate, -10, 0, 0);
|
||||
Mat4Translation( translate, viewMatrices );
|
||||
VectorSet(translate, 10, 0, 0);
|
||||
Mat4Translation( translate, viewMatrices + 16 );
|
||||
}
|
||||
else
|
||||
{
|
||||
Mat4Identity( viewMatrices );
|
||||
Mat4Identity( viewMatrices + 16 );
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
memcpy((char *) viewMatrices, value, 32 * sizeof(float));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -243,6 +344,15 @@ static void GLSL_GetShaderHeader( GLenum shaderType, const GLchar *extra, char *
|
|||
// HACK: abuse the GLSL preprocessor to turn GLSL 1.20 shaders into 1.30 ones
|
||||
#ifdef __ANDROID__
|
||||
Q_strcat(dest, size, "#version 300 es\n");
|
||||
|
||||
if(shaderType == GL_VERTEX_SHADER)
|
||||
{
|
||||
//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");
|
||||
}
|
||||
|
||||
Q_strcat(dest, size, "precision mediump float;\n");
|
||||
|
||||
if(shaderType == GL_VERTEX_SHADER)
|
||||
|
@ -481,7 +591,7 @@ static int GLSL_LoadGPUShaderText(const char *name, const char *fallback,
|
|||
{
|
||||
ri.FS_FreeFile(buffer);
|
||||
}
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -656,6 +766,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++)
|
||||
{
|
||||
|
@ -663,7 +790,7 @@ void GLSL_InitUniforms(shaderProgram_t *program)
|
|||
|
||||
if (uniforms[i] == -1)
|
||||
continue;
|
||||
|
||||
|
||||
program->uniformBufferOffsets[i] = size;
|
||||
|
||||
switch(uniformsInfo[i].type)
|
||||
|
@ -750,7 +877,7 @@ void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat valu
|
|||
}
|
||||
|
||||
*compare = value;
|
||||
|
||||
|
||||
qglProgramUniform1fEXT(program->program, uniforms[uniformNum], value);
|
||||
}
|
||||
|
||||
|
@ -944,12 +1071,34 @@ void GLSL_InitGPUShaders(void)
|
|||
|
||||
ri.Printf(PRINT_ALL, "------- GLSL_InitGPUShaders -------\n");
|
||||
|
||||
for (int i = 0; i < PROJECTION_COUNT; ++i)
|
||||
{
|
||||
//Generate buffer for 2 * view matrices
|
||||
qglGenBuffers(1, &viewMatricesBuffer[i]);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, viewMatricesBuffer[i]);
|
||||
qglBufferData(
|
||||
GL_UNIFORM_BUFFER,
|
||||
2 * 16 * sizeof(float),
|
||||
NULL,
|
||||
GL_STATIC_DRAW);
|
||||
qglBindBuffer(GL_UNIFORM_BUFFER, 0);
|
||||
|
||||
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();
|
||||
|
||||
for (i = 0; i < GENERICDEF_COUNT; i++)
|
||||
{
|
||||
{
|
||||
if ((i & GENERICDEF_USE_VERTEX_ANIMATION) && (i & GENERICDEF_USE_BONE_ANIMATION))
|
||||
continue;
|
||||
|
||||
|
@ -1007,7 +1156,7 @@ void GLSL_InitGPUShaders(void)
|
|||
{
|
||||
ri.Error(ERR_FATAL, "Could not load texturecolor shader!");
|
||||
}
|
||||
|
||||
|
||||
GLSL_InitUniforms(&tr.textureColorShader);
|
||||
|
||||
GLSL_SetUniformInt(&tr.textureColorShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP);
|
||||
|
@ -1069,7 +1218,7 @@ void GLSL_InitGPUShaders(void)
|
|||
}
|
||||
|
||||
GLSL_InitUniforms(&tr.dlightShader[i]);
|
||||
|
||||
|
||||
GLSL_SetUniformInt(&tr.dlightShader[i], UNIFORM_DIFFUSEMAP, TB_DIFFUSEMAP);
|
||||
|
||||
GLSL_FinishGPUShader(&tr.dlightShader[i]);
|
||||
|
@ -1199,7 +1348,7 @@ void GLSL_InitGPUShaders(void)
|
|||
|
||||
if (i & LIGHTDEF_ENTITY_VERTEX_ANIMATION)
|
||||
{
|
||||
Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n#define USE_MODELMATRIX\n");
|
||||
Q_strcat(extradefines, 1024, "#define USE_VERTEX_ANIMATION\n#define USE_MODELMATRIX\n");
|
||||
attribs |= ATTR_POSITION2 | ATTR_NORMAL2;
|
||||
|
||||
if (r_normalMapping->integer)
|
||||
|
@ -1209,7 +1358,7 @@ void GLSL_InitGPUShaders(void)
|
|||
}
|
||||
else if (i & LIGHTDEF_ENTITY_BONE_ANIMATION)
|
||||
{
|
||||
Q_strcat(extradefines, 1024, "#define USE_MODELMATRIX\n");
|
||||
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;
|
||||
}
|
||||
|
@ -1278,7 +1427,7 @@ void GLSL_InitGPUShaders(void)
|
|||
{
|
||||
ri.Error(ERR_FATAL, "Could not load pshadow shader!");
|
||||
}
|
||||
|
||||
|
||||
GLSL_InitUniforms(&tr.pshadowShader);
|
||||
|
||||
GLSL_SetUniformInt(&tr.pshadowShader, UNIFORM_SHADOWMAP, TB_DIFFUSEMAP);
|
||||
|
@ -1295,7 +1444,7 @@ void GLSL_InitGPUShaders(void)
|
|||
{
|
||||
ri.Error(ERR_FATAL, "Could not load down4x shader!");
|
||||
}
|
||||
|
||||
|
||||
GLSL_InitUniforms(&tr.down4xShader);
|
||||
|
||||
GLSL_SetUniformInt(&tr.down4xShader, UNIFORM_TEXTUREMAP, TB_DIFFUSEMAP);
|
||||
|
@ -1359,7 +1508,7 @@ void GLSL_InitGPUShaders(void)
|
|||
|
||||
GLSL_FinishGPUShader(&tr.calclevels4xShader[i]);
|
||||
|
||||
numEtcShaders++;
|
||||
numEtcShaders++;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1383,7 +1532,7 @@ void GLSL_InitGPUShaders(void)
|
|||
{
|
||||
ri.Error(ERR_FATAL, "Could not load shadowmask shader!");
|
||||
}
|
||||
|
||||
|
||||
GLSL_InitUniforms(&tr.shadowmaskShader);
|
||||
|
||||
GLSL_SetUniformInt(&tr.shadowmaskShader, UNIFORM_SCREENDEPTHMAP, TB_COLORMAP);
|
||||
|
@ -1432,7 +1581,7 @@ void GLSL_InitGPUShaders(void)
|
|||
{
|
||||
ri.Error(ERR_FATAL, "Could not load depthBlur shader!");
|
||||
}
|
||||
|
||||
|
||||
GLSL_InitUniforms(&tr.depthBlurShader[i]);
|
||||
|
||||
GLSL_SetUniformInt(&tr.depthBlurShader[i], UNIFORM_SCREENIMAGEMAP, TB_COLORMAP);
|
||||
|
@ -1464,8 +1613,8 @@ void GLSL_InitGPUShaders(void)
|
|||
|
||||
endTime = ri.Milliseconds();
|
||||
|
||||
ri.Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n",
|
||||
numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders,
|
||||
ri.Printf(PRINT_ALL, "loaded %i GLSL shaders (%i gen %i light %i etc) in %5.2f seconds\n",
|
||||
numGenShaders + numLightShaders + numEtcShaders, numGenShaders, numLightShaders,
|
||||
numEtcShaders, (endTime - startTime) / 1000.0);
|
||||
}
|
||||
|
||||
|
@ -1512,20 +1661,76 @@ void GLSL_ShutdownGPUShaders(void)
|
|||
GLSL_DeleteGPUShader(&tr.depthBlurShader[i]);
|
||||
}
|
||||
|
||||
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 matrix
|
||||
/* GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[STEREO_ORTHO_PROJECTION],
|
||||
orthoProjectionMatrix);
|
||||
*/
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[HUD_ORTHO_PROJECTION],
|
||||
orthoProjectionMatrix);
|
||||
|
||||
//VR projection matrix
|
||||
GLSL_ProjectionMatricesUniformBuffer(projectionMatricesBuffer[VR_PROJECTION],
|
||||
tr.vrParms.projection);
|
||||
|
||||
//Set up the buffers that won't change this frame
|
||||
GLSL_ViewMatricesUniformBuffer(tr.viewParms.world.eyeViewMatrix);
|
||||
}
|
||||
|
||||
void GLSL_BindProgram(shaderProgram_t * program)
|
||||
{
|
||||
GLuint programObject = program ? program->program : 0;
|
||||
char *name = program ? program->name : "NULL";
|
||||
GLuint programObject = program ? program->program : 0;
|
||||
char *name = program ? program->name : "NULL";
|
||||
|
||||
if(r_logFile->integer)
|
||||
{
|
||||
// don't just call LogComment, or we will get a call to va() every frame!
|
||||
GLimp_LogComment(va("--- GLSL_BindProgram( %s ) ---\n", name));
|
||||
}
|
||||
if (r_logFile->integer)
|
||||
{
|
||||
// don't just call LogComment, or we will get a call to va() every frame!
|
||||
GLimp_LogComment(va("--- GLSL_BindProgram( %s ) ---\n", name));
|
||||
}
|
||||
|
||||
if (GL_UseProgram(programObject))
|
||||
backEnd.pc.c_glslShaderBinds++;
|
||||
}
|
||||
|
||||
static GLuint GLSL_CalculateProjection() {
|
||||
GLuint result = VR_PROJECTION;
|
||||
|
||||
if (Mat4Compare(&orthoProjectionMatrix, glState.projection))
|
||||
{
|
||||
result = HUD_ORTHO_PROJECTION;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
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]);
|
||||
|
||||
if (GL_UseProgram(programObject))
|
||||
backEnd.pc.c_glslShaderBinds++;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -2784,6 +2784,9 @@ void R_CreateBuiltinImages( void ) {
|
|||
|
||||
tr.renderImage = R_CreateImage("_render", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, hdrFormat);
|
||||
|
||||
tr.hudImage = R_CreateImage("hudImage", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat);
|
||||
tr.hudDepthImage = R_CreateImage("*hudDepth", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, GL_DEPTH_COMPONENT24);
|
||||
|
||||
if (r_shadowBlur->integer)
|
||||
tr.screenScratchImage = R_CreateImage("screenScratch", NULL, width, height, IMGTYPE_COLORALPHA, IMGFLAG_NO_COMPRESSION | IMGFLAG_CLAMPTOEDGE, rgbFormat);
|
||||
|
||||
|
|
|
@ -1654,6 +1654,8 @@ refexport_t *GetRefAPI ( int apiVersion, refimport_t *rimp ) {
|
|||
re.AddLightToScene = RE_AddLightToScene;
|
||||
re.AddAdditiveLightToScene = RE_AddAdditiveLightToScene;
|
||||
re.RenderScene = RE_RenderScene;
|
||||
re.HUDBufferStart = RE_HUDBufferStart;
|
||||
re.HUDBufferEnd = RE_HUDBufferEnd;
|
||||
|
||||
re.SetColor = RE_SetColor;
|
||||
re.DrawStretchPic = RE_StretchPic;
|
||||
|
|
|
@ -108,7 +108,8 @@ typedef struct {
|
|||
vec3_t axis[3]; // orientation in world
|
||||
vec3_t viewOrigin; // viewParms->or.origin in local coordinates
|
||||
float modelMatrix[16];
|
||||
float transformMatrix[16];
|
||||
float modelView[16];
|
||||
float eyeViewMatrix[2][16];
|
||||
} orientationr_t;
|
||||
|
||||
// Ensure this is >= the ATTR_INDEX_COUNT enum below
|
||||
|
@ -671,7 +672,6 @@ typedef enum
|
|||
UNIFORM_FOGCOLORMASK,
|
||||
|
||||
UNIFORM_MODELMATRIX,
|
||||
UNIFORM_MODELVIEWPROJECTIONMATRIX,
|
||||
|
||||
UNIFORM_TIME,
|
||||
UNIFORM_VERTEXLERP,
|
||||
|
@ -714,6 +714,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 +840,13 @@ typedef struct {
|
|||
vec3_t visBounds[2];
|
||||
float zFar;
|
||||
float zNear;
|
||||
stereoFrame_t stereoFrame;
|
||||
stereoFrame_t stereoFrame;
|
||||
} viewParms_t;
|
||||
|
||||
typedef struct {
|
||||
qboolean valid;
|
||||
float projection[16];
|
||||
int renderBufferL;
|
||||
int renderBufferR;
|
||||
int renderBuffer;
|
||||
int renderBufferOriginal;
|
||||
} vrParms_t;
|
||||
|
||||
|
@ -1384,9 +1387,9 @@ typedef struct {
|
|||
uint32_t vertexAttribsEnabled; // global if no VAOs, tess only otherwise
|
||||
FBO_t *currentFBO;
|
||||
vao_t *currentVao;
|
||||
mat4_t modelview;
|
||||
|
||||
mat4_t modelMatrix;
|
||||
mat4_t projection;
|
||||
mat4_t modelviewProjection;
|
||||
} glstate_t;
|
||||
|
||||
typedef enum {
|
||||
|
@ -1527,6 +1530,7 @@ typedef struct {
|
|||
image_t *renderImage;
|
||||
image_t *sunRaysImage;
|
||||
image_t *renderDepthImage;
|
||||
image_t *hudDepthImage;
|
||||
image_t *pshadowMaps[MAX_DRAWN_PSHADOWS];
|
||||
image_t *screenScratchImage;
|
||||
image_t *textureScratchImage[2];
|
||||
|
@ -1539,7 +1543,8 @@ typedef struct {
|
|||
image_t *screenSsaoImage;
|
||||
image_t *hdrDepthImage;
|
||||
image_t *renderCubeImage;
|
||||
|
||||
image_t *hudImage;
|
||||
|
||||
image_t *textureDepthImage;
|
||||
|
||||
FBO_t *renderFbo;
|
||||
|
@ -1557,6 +1562,7 @@ typedef struct {
|
|||
FBO_t *screenSsaoFbo;
|
||||
FBO_t *hdrDepthFbo;
|
||||
FBO_t *renderCubeFbo;
|
||||
FBO_t *hudFbo;
|
||||
|
||||
shader_t *defaultShader;
|
||||
shader_t *shadowShader;
|
||||
|
@ -1566,6 +1572,8 @@ typedef struct {
|
|||
shader_t *sunShader;
|
||||
shader_t *sunFlareShader;
|
||||
|
||||
shader_t *hudShader;
|
||||
|
||||
int numLightmaps;
|
||||
int lightmapSize;
|
||||
image_t **lightmaps;
|
||||
|
@ -1583,6 +1591,8 @@ typedef struct {
|
|||
int shiftedEntityNum; // currentEntityNum << QSORT_REFENTITYNUM_SHIFT
|
||||
model_t *currentModel;
|
||||
|
||||
int backupFrameBuffer;
|
||||
|
||||
//
|
||||
// GPU shader programs
|
||||
//
|
||||
|
@ -1918,7 +1928,7 @@ void GL_CheckErrs( char *file, int line );
|
|||
#define GL_CheckErrors(...) GL_CheckErrs(__FILE__, __LINE__)
|
||||
void GL_State( unsigned long stateVector );
|
||||
void GL_SetProjectionMatrix(mat4_t matrix);
|
||||
void GL_SetModelviewMatrix(mat4_t matrix, qboolean applyStereoView);
|
||||
void GL_SetModelMatrix(mat4_t matrix);
|
||||
void GL_Cull( int cullType );
|
||||
|
||||
#define GLS_SRCBLEND_ZERO 0x00000001
|
||||
|
@ -2235,9 +2245,11 @@ GLSL
|
|||
*/
|
||||
|
||||
void GLSL_InitGPUShaders(void);
|
||||
void GLSL_PrepareUniformBuffers(void);
|
||||
void GLSL_ShutdownGPUShaders(void);
|
||||
void GLSL_VertexAttribPointers(uint32_t attribBits);
|
||||
void GLSL_BindProgram(shaderProgram_t * program);
|
||||
void GLSL_BindBuffers( shaderProgram_t * program );
|
||||
|
||||
void GLSL_SetUniformInt(shaderProgram_t *program, int uniformNum, GLint value);
|
||||
void GLSL_SetUniformFloat(shaderProgram_t *program, int uniformNum, GLfloat value);
|
||||
|
@ -2310,7 +2322,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 );
|
||||
|
||||
|
@ -2451,6 +2463,11 @@ typedef struct {
|
|||
stereoFrame_t stereoFrame;
|
||||
} switchEyeCommand_t;
|
||||
|
||||
typedef struct {
|
||||
int commandId;
|
||||
qboolean start;
|
||||
} hudBufferCommand_t;
|
||||
|
||||
typedef enum {
|
||||
RC_END_OF_LIST,
|
||||
RC_SET_COLOR,
|
||||
|
@ -2465,7 +2482,8 @@ typedef enum {
|
|||
RC_CAPSHADOWMAP,
|
||||
RC_POSTPROCESS,
|
||||
RC_EXPORT_CUBEMAPS,
|
||||
RC_SWITCH_EYE
|
||||
RC_SWITCH_EYE,
|
||||
RC_HUD_BUFFER
|
||||
} renderCommand_t;
|
||||
|
||||
|
||||
|
@ -2509,8 +2527,11 @@ 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_HUDBufferStart( void );
|
||||
void RE_HUDBufferEnd( void );
|
||||
|
||||
void RE_SaveJPG(char * filename, int quality, int image_width, int image_height,
|
||||
unsigned char *image_buffer, int padding);
|
||||
size_t RE_SaveJPGToBuffer(byte *buffer, size_t bufSize, int quality,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -425,16 +429,16 @@ R_TransformModelToClip
|
|||
|
||||
==========================
|
||||
*/
|
||||
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 ) {
|
||||
int i;
|
||||
|
||||
for ( i = 0 ; i < 4 ; i++ ) {
|
||||
eye[i] =
|
||||
src[0] * modelMatrix[ i + 0 * 4 ] +
|
||||
src[1] * modelMatrix[ i + 1 * 4 ] +
|
||||
src[2] * modelMatrix[ i + 2 * 4 ] +
|
||||
1 * modelMatrix[ i + 3 * 4 ];
|
||||
src[0] * viewMatrix[ i + 0 * 4 ] +
|
||||
src[1] * viewMatrix[ i + 1 * 4 ] +
|
||||
src[2] * viewMatrix[ i + 2 * 4 ] +
|
||||
1 * viewMatrix[ i + 3 * 4 ];
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < 4 ; i++ ) {
|
||||
|
@ -532,8 +536,8 @@ 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.modelMatrix, or->modelMatrix );
|
||||
myGlMultMatrix( glMatrix, viewParms->world.modelMatrix, or->modelMatrix );
|
||||
myGlMultMatrix( glMatrix, viewParms->world.modelView, or->modelView );
|
||||
|
||||
// calculate the viewer origin in the model's space
|
||||
// needed for fog, specular, and environment mapping
|
||||
|
@ -566,7 +570,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 +577,64 @@ 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) && !VR_useScreenLayer())
|
||||
{
|
||||
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[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)
|
||||
if (eye < 2)
|
||||
{
|
||||
myGlMultMatrix(viewerMatrix, s_flipMatrix, tr.or.eyeViewMatrix[eye]);
|
||||
}
|
||||
else
|
||||
{
|
||||
//World Model View
|
||||
Mat4Copy(viewerMatrix, tr.or.modelMatrix);
|
||||
myGlMultMatrix(viewerMatrix, s_flipMatrix, tr.or.modelView);
|
||||
}
|
||||
}
|
||||
|
||||
tr.viewParms.world = tr.or;
|
||||
|
||||
#if 0
|
||||
Com_Printf("Origin = %g, %g, %g", tr.or.modelView[12], tr.or.modelView[13], tr.or.modelView[14]);
|
||||
//Com_Printf("Origin = %g, %g, %g", tr.viewParms.or.origin[0], tr.viewParms.or.origin[1], tr.viewParms.or.origin[2]);
|
||||
Com_Printf("Axis 0 = %g, %g, %g", tr.viewParms.or.axis[0][0], tr.viewParms.or.axis[0][1], tr.viewParms.or.axis[0][2]);
|
||||
Com_Printf("Axis 1 = %g, %g, %g", tr.viewParms.or.axis[1][0], tr.viewParms.or.axis[1][1], tr.viewParms.or.axis[1][2]);
|
||||
Com_Printf("Axis 2 = %g, %g, %g", tr.viewParms.or.axis[2][0], tr.viewParms.or.axis[2][1], tr.viewParms.or.axis[2][2]);
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -715,60 +747,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;
|
||||
memcpy(&dest->projectionMatrix, &tr.vrParms.projection, sizeof(dest->projectionMatrix));
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
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);
|
||||
R_SetupFrustum( );
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1196,7 +1179,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.modelView, tr.viewParms.projectionMatrix, eye, clip );
|
||||
|
||||
for ( j = 0; j < 3; j++ )
|
||||
{
|
||||
|
@ -1734,7 +1717,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();
|
||||
|
||||
R_SetupProjection(&tr.viewParms, r_zproj->value, tr.viewParms.zFar, qtrue);
|
||||
|
||||
R_GenerateDrawSurfs();
|
||||
|
||||
|
@ -2519,7 +2504,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.modelView, 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.modelView, trans, model );
|
||||
Mat4Multiply(backEnd.viewParms.projectionMatrix, model, mvp);
|
||||
|
||||
dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
|
||||
|
@ -327,7 +327,6 @@ 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);
|
||||
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, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
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, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
|
||||
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.modelView[2];
|
||||
fogDistanceVector[1] = -backEnd.or.modelView[6];
|
||||
fogDistanceVector[2] = -backEnd.or.modelView[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, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin);
|
||||
GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin);
|
||||
|
||||
|
@ -753,7 +756,8 @@ static void ForwardDlight( void ) {
|
|||
GL_State( GLS_SRCBLEND_ONE | GLS_DSTBLEND_ONE | GLS_DEPTHFUNC_EQUAL );
|
||||
GLSL_SetUniformInt(sp, UNIFORM_ALPHATEST, 0);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
|
||||
if (pStage->bundle[TB_DIFFUSEMAP].image[0])
|
||||
R_BindAnimatedImageToTMU( &pStage->bundle[TB_DIFFUSEMAP], TB_DIFFUSEMAP);
|
||||
|
@ -844,7 +848,8 @@ static void ProjectPshadowVBOGLSL( void ) {
|
|||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
|
||||
VectorCopy(origin, vector);
|
||||
vector[3] = 1.0f;
|
||||
|
@ -920,7 +925,8 @@ static void RB_FogPass( void ) {
|
|||
|
||||
fog = tr.world->fogs + tess.fogNum;
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
|
||||
GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);
|
||||
|
||||
|
@ -1094,7 +1100,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
|
|||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
GLSL_SetUniformVec3(sp, UNIFORM_VIEWORIGIN, backEnd.viewParms.or.origin);
|
||||
GLSL_SetUniformVec3(sp, UNIFORM_LOCALVIEWORIGIN, backEnd.or.viewOrigin);
|
||||
|
||||
|
@ -1210,7 +1217,8 @@ static void RB_IterateStagesGeneric( shaderCommands_t *input )
|
|||
}
|
||||
}
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, backEnd.or.transformMatrix);
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_NORMALSCALE, pStage->normalScale);
|
||||
|
||||
|
@ -1413,9 +1421,8 @@ static void RB_RenderShadowmap( 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_MODELMATRIX, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
|
||||
GLSL_SetUniformFloat(sp, UNIFORM_VERTEXLERP, glState.vertexAttribsInterpolation);
|
||||
|
||||
|
|
|
@ -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.modelView[2];
|
||||
fogDistanceVector[1] = -backEnd.or.modelView[6];
|
||||
fogDistanceVector[2] = -backEnd.or.modelView[10];
|
||||
fogDistanceVector[3] = DotProduct( local, backEnd.viewParms.or.axis[0] );
|
||||
|
||||
// scale the fog vectors based on the fog's thickness
|
||||
|
|
|
@ -3880,6 +3880,11 @@ static void CreateExternalShaders( void ) {
|
|||
tr.sunFlareShader = FinishShader();
|
||||
}
|
||||
|
||||
//Set some stuff on our HUD shader
|
||||
{
|
||||
tr.hudShader = R_FindShader("sprites/vr/hud", LIGHTMAP_2D, qfalse);
|
||||
tr.hudShader->stages[0]->bundle[0].image[0] = tr.hudImage;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -417,29 +417,16 @@ static void DrawSkySide( struct image_s *image, const int mins[2], const int max
|
|||
|
||||
// FIXME: A lot of this can probably be removed for speed, and refactored into a more convenient function
|
||||
RB_UpdateTessVao(ATTR_POSITION | ATTR_TEXCOORD);
|
||||
/*
|
||||
{
|
||||
shaderProgram_t *sp = &tr.textureColorShader;
|
||||
|
||||
GLSL_VertexAttribsState(ATTR_POSITION | ATTR_TEXCOORD);
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
color[0] =
|
||||
color[1] =
|
||||
color[2] = tr.identityLight;
|
||||
color[3] = 1.0f;
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_COLOR, color);
|
||||
}
|
||||
*/
|
||||
|
||||
{
|
||||
shaderProgram_t *sp = &tr.lightallShader[0];
|
||||
vec4_t vector;
|
||||
|
||||
GLSL_BindProgram(sp);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELVIEWPROJECTIONMATRIX, glState.modelviewProjection);
|
||||
|
||||
GLSL_SetUniformMat4(sp, UNIFORM_MODELMATRIX, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
|
||||
color[0] =
|
||||
color[1] =
|
||||
|
@ -796,15 +783,13 @@ void RB_DrawSun( float scale, shader_t *shader ) {
|
|||
return;
|
||||
}
|
||||
|
||||
//qglLoadMatrixf( backEnd.viewParms.world.modelMatrix );
|
||||
//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;
|
||||
mat4_t translation, modelmatrix;
|
||||
|
||||
Mat4Translation( backEnd.viewParms.or.origin, translation );
|
||||
Mat4Multiply( backEnd.viewParms.world.modelMatrix, translation, modelview );
|
||||
GL_SetModelviewMatrix( modelview, qtrue );
|
||||
Mat4Multiply( backEnd.viewParms.world.modelMatrix, translation, modelmatrix );
|
||||
GL_SetModelMatrix( modelmatrix );
|
||||
}
|
||||
|
||||
dist = backEnd.viewParms.zFar / 1.75; // div sqrt(3)
|
||||
|
@ -881,16 +866,16 @@ void RB_StageIteratorSky( void ) {
|
|||
// FIXME: this could be a lot cleaner
|
||||
mat4_t trans, product;
|
||||
|
||||
Mat4Copy( glState.modelview, oldmodelview );
|
||||
Mat4Copy( glState.modelMatrix, oldmodelview );
|
||||
Mat4Translation( backEnd.viewParms.or.origin, trans );
|
||||
Mat4Multiply( glState.modelview, trans, product );
|
||||
GL_SetModelviewMatrix( product, qtrue );
|
||||
Mat4Multiply( glState.modelMatrix, trans, product );
|
||||
GL_SetModelMatrix( product );
|
||||
|
||||
}
|
||||
|
||||
DrawSkyBox( tess.shader );
|
||||
|
||||
GL_SetModelviewMatrix( oldmodelview, qtrue );
|
||||
GL_SetModelMatrix( oldmodelview );
|
||||
}
|
||||
|
||||
// generate the vertexes for all the clouds, which will be drawn
|
||||
|
|
|
@ -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, glState.modelMatrix);
|
||||
GLSL_BindBuffers(&tr.textureColorShader);
|
||||
GLSL_SetUniformVec4(&tr.textureColorShader, UNIFORM_COLOR, colorWhite);
|
||||
|
||||
RB_InstantQuad2(quadVerts, texCoords);
|
||||
|
@ -249,7 +250,7 @@ static void RB_SurfaceSprite( void ) {
|
|||
radius = ent->e.radius;
|
||||
if ( ent->e.rotation == 0 ) {
|
||||
VectorScale( backEnd.viewParms.or.axis[1], radius, left );
|
||||
VectorScale( backEnd.viewParms.or.axis[2], radius, up );
|
||||
VectorScale( backEnd.viewParms.or.axis[2], ent->e.invert ? -radius : radius, up );
|
||||
} else {
|
||||
float s, c;
|
||||
float ang;
|
||||
|
@ -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, glState.modelMatrix);
|
||||
GLSL_BindBuffers(sp);
|
||||
|
||||
GLSL_SetUniformVec4(sp, UNIFORM_COLOR, colorRed);
|
||||
|
||||
|
|
|
@ -589,6 +589,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
|||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLEBUFFERS, samples ? 1 : 0 );
|
||||
SDL_GL_SetAttribute( SDL_GL_MULTISAMPLESAMPLES, samples );
|
||||
|
||||
#if 0
|
||||
if(r_stereoEnabled->integer)
|
||||
{
|
||||
glConfig.stereoEnabled = qtrue;
|
||||
|
@ -602,7 +603,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
|||
|
||||
SDL_GL_SetAttribute( SDL_GL_DOUBLEBUFFER, 1 );
|
||||
|
||||
#if 0 // if multisampling is enabled on X11, this causes create window to fail.
|
||||
// if multisampling is enabled on X11, this causes create window to fail.
|
||||
// If not allowing software GL, demand accelerated
|
||||
if( !r_allowSoftwareGL->integer )
|
||||
SDL_GL_SetAttribute( SDL_GL_ACCELERATED_VISUAL, 1 );
|
||||
|
@ -615,7 +616,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
|||
continue;
|
||||
}
|
||||
|
||||
if( fullscreen )
|
||||
if( qfalse ) //fullscreen )
|
||||
{
|
||||
SDL_DisplayMode mode;
|
||||
|
||||
|
@ -638,7 +639,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
|||
}
|
||||
}
|
||||
|
||||
SDL_SetWindowIcon( SDL_window, icon );
|
||||
//SDL_SetWindowIcon( SDL_window, icon );
|
||||
|
||||
if (!fixedFunction)
|
||||
{
|
||||
|
@ -648,7 +649,7 @@ static int GLimp_SetMode(int mode, qboolean fullscreen, qboolean noborder, qbool
|
|||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, &minorVersion);
|
||||
|
||||
ri.Printf(PRINT_ALL, "Trying to get an OpenGL 3.2 core context\n");
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 3);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
if ((SDL_glContext = SDL_GL_CreateContext(SDL_window)) == NULL)
|
||||
|
@ -1105,10 +1106,11 @@ Responsible for doing a swapbuffers
|
|||
*/
|
||||
void GLimp_EndFrame( void )
|
||||
{
|
||||
#if 0
|
||||
//swap window is implemented in VR API, no need to do it here
|
||||
if ( Q_stricmp( r_drawBuffer->string, "GL_FRONT" ) != 0 )
|
||||
{
|
||||
//SDL_GL_SwapWindow( SDL_window );
|
||||
SDL_GL_SwapWindow( SDL_window );
|
||||
}
|
||||
|
||||
if( r_fullscreen->modified )
|
||||
|
@ -1143,4 +1145,5 @@ void GLimp_EndFrame( void )
|
|||
|
||||
r_fullscreen->modified = qfalse;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
@ -61,6 +62,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);
|
||||
|
|
|
@ -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,18 +334,13 @@ 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.
|
||||
vrapi_SubmitFrame2(engine->ovr, &frameDesc);
|
||||
|
@ -340,27 +357,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);
|
||||
}
|
||||
layer.Header.Flags |= VRAPI_FRAME_LAYER_FLAG_CHROMATIC_ABERRATION_CORRECTION;
|
||||
|
||||
|
||||
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[] = {
|
||||
&layer.Header
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -6,20 +6,18 @@
|
|||
|
||||
#include <VrApi.h>
|
||||
#include <VrApi_Helpers.h>
|
||||
#include <string>
|
||||
|
||||
extern "C" {
|
||||
#include <client/keycodes.h>
|
||||
#include <qcommon/q_shared.h>
|
||||
#include <qcommon/qcommon.h>
|
||||
#include <vr/vr_base.h>
|
||||
#include <vr/vr_renderer.h>
|
||||
#include <unistd.h>
|
||||
#include <client/keycodes.h>
|
||||
#include <qcommon/q_shared.h>
|
||||
#include <qcommon/qcommon.h>
|
||||
#include <vr/vr_base.h>
|
||||
#include <vr/vr_renderer.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <SDL.h>
|
||||
|
||||
extern void CON_LogcatFn( void (*LogcatFn)( const char* message ) );
|
||||
|
||||
extern void CON_LogcatFn( void (*LogcatFn)( const char* message ) );
|
||||
}
|
||||
|
||||
#define LOGI(...) ((void)__android_log_print(ANDROID_LOG_INFO, "Quake3", __VA_ARGS__))
|
||||
#define LOGW(...) ((void)__android_log_print(ANDROID_LOG_WARN, "Quake3", __VA_ARGS__))
|
||||
|
@ -31,28 +29,24 @@ static JavaVM* g_JavaVM = NULL;
|
|||
static jobject g_ActivityObject = NULL;
|
||||
static bool g_HasFocus = true;
|
||||
|
||||
|
||||
extern "C"
|
||||
JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeCreate(JNIEnv* env, jclass cls, jobject thisObject)
|
||||
{
|
||||
JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeCreate(JNIEnv* env, jclass cls, jobject thisObject)
|
||||
{
|
||||
g_ActivityObject = env->NewGlobalRef(thisObject);
|
||||
g_ActivityObject = (*env)->NewGlobalRef(env, thisObject);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeFocusChanged(JNIEnv *env, jclass clazz, jboolean focus)
|
||||
{
|
||||
g_HasFocus = focus;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
{
|
||||
g_JavaVM = vm;
|
||||
if ((*g_JavaVM)->GetEnv(g_JavaVM, (void**) &g_Env, JNI_VERSION_1_4) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_com_drbeef_ioq3quest_MainActivity_nativeFocusChanged(JNIEnv *env, jclass clazz, jboolean focus)
|
||||
{
|
||||
g_HasFocus = focus;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void* reserved)
|
||||
{
|
||||
g_JavaVM = vm;
|
||||
if (g_JavaVM->GetEnv((void**) &g_Env, JNI_VERSION_1_4) != JNI_OK) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
return JNI_VERSION_1_4;
|
||||
}
|
||||
|
||||
static void ioq3_logfn(const char* msg)
|
||||
|
@ -64,13 +58,13 @@ static ovrJava engine_get_ovrJava() {
|
|||
ovrJava java;
|
||||
java.Vm = g_JavaVM;
|
||||
java.ActivityObject = g_ActivityObject;
|
||||
java.Vm->AttachCurrentThread(&java.Env, NULL);
|
||||
(*java.Vm)->AttachCurrentThread(java.Vm, &java.Env, NULL);
|
||||
return java;
|
||||
}
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
ovrJava java = engine_get_ovrJava();
|
||||
engine_t* engine = nullptr;
|
||||
engine_t* engine = NULL;
|
||||
engine = VR_Init(java);
|
||||
|
||||
//sleep(30);
|
|
@ -136,6 +136,7 @@ public class MainActivity extends SDLActivity // implements KeyEvent.Callback
|
|||
|
||||
Log.d(TAG, "setting env");
|
||||
try {
|
||||
//commandLineParams += " +map q3dm7";
|
||||
setenv("commandline", commandLineParams, true);
|
||||
} catch (Exception e) {
|
||||
}
|
||||
|
|
6
android/app/src/main/make_pakQ3Q.bat
Normal file
6
android/app/src/main/make_pakQ3Q.bat
Normal file
|
@ -0,0 +1,6 @@
|
|||
cd assets
|
||||
del pakQ3Q.pk3
|
||||
cd ..
|
||||
powershell Compress-Archive pakQ3Q/* pakQ3Q.zip
|
||||
rename pakQ3Q.zip pakQ3Q.pk3
|
||||
move pakQ3Q.pk3 assets/
|
|
@ -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,18 @@ uniform float u_Time;
|
|||
#endif
|
||||
|
||||
uniform vec4 u_Color;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying vec2 var_Tex1;
|
||||
varying vec4 var_Color;
|
||||
|
@ -80,7 +91,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,24 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -15,13 +15,14 @@ uniform vec4 u_FogDistance;
|
|||
uniform vec4 u_FogDepth;
|
||||
uniform float u_FogEyeT;
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_DEFORM_VERTEXES)
|
||||
uniform int u_DeformGen;
|
||||
uniform float u_DeformParams[5];
|
||||
#endif
|
||||
|
||||
uniform float u_Time;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
|
@ -31,6 +32,16 @@ uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
|||
|
||||
uniform vec4 u_Color;
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying float var_Scale;
|
||||
|
||||
#if defined(USE_DEFORM_VERTEXES)
|
||||
|
@ -125,7 +136,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;
|
||||
}
|
||||
|
|
|
@ -36,13 +36,15 @@ uniform float u_FogEyeT;
|
|||
uniform vec4 u_FogColorMask;
|
||||
#endif
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_DEFORM_VERTEXES)
|
||||
uniform int u_DeformGen;
|
||||
uniform float u_DeformParams[5];
|
||||
uniform float u_Time;
|
||||
#endif
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform vec4 u_BaseColor;
|
||||
uniform vec4 u_VertColor;
|
||||
|
||||
|
@ -61,6 +63,16 @@ uniform float u_VertexLerp;
|
|||
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
||||
#endif
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying vec2 var_DiffuseTex;
|
||||
varying vec4 var_Color;
|
||||
|
||||
|
@ -227,7 +239,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,13 +41,12 @@ uniform vec4 u_DiffuseTexMatrix;
|
|||
uniform vec4 u_DiffuseTexOffTurb;
|
||||
#endif
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
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;
|
||||
|
@ -67,6 +66,16 @@ uniform vec4 u_PrimaryLightOrigin;
|
|||
uniform float u_PrimaryLightRadius;
|
||||
#endif
|
||||
|
||||
// Uniforms
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying vec4 var_TexCoords;
|
||||
|
||||
varying vec4 var_Color;
|
||||
|
@ -188,14 +197,14 @@ 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;
|
||||
normal = (u_ModelMatrix * vec4(normal, 0.0)).xyz;
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
tangent = (u_ModelMatrix * vec4(tangent, 0.0)).xyz;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHT) && !defined(USE_FAST_LIGHT)
|
||||
|
@ -206,9 +215,9 @@ 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)
|
||||
#if defined(USE_MODELMATRIX)
|
||||
L = (u_ModelMatrix * vec4(L, 0.0)).xyz;
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(USE_LIGHTMAP)
|
||||
|
|
|
@ -1,14 +1,24 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec3 attr_Normal;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
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;
|
||||
|
|
|
@ -10,15 +10,17 @@ attribute vec4 attr_BoneIndexes;
|
|||
attribute vec4 attr_BoneWeights;
|
||||
#endif
|
||||
|
||||
|
||||
// Uniforms
|
||||
|
||||
//#if defined(USE_DEFORM_VERTEXES)
|
||||
uniform int u_DeformGen;
|
||||
uniform float u_DeformParams[5];
|
||||
//#endif
|
||||
|
||||
uniform float u_Time;
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
|
||||
uniform mat4 u_ModelMatrix;
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
#if defined(USE_VERTEX_ANIMATION)
|
||||
uniform float u_VertexLerp;
|
||||
|
@ -26,6 +28,15 @@ uniform float u_VertexLerp;
|
|||
uniform mat4 u_BoneMatrix[MAX_GLSL_BONES];
|
||||
#endif
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
varying vec3 var_Position;
|
||||
|
||||
vec3 DeformPosition(const vec3 pos, const vec3 normal, const vec2 st)
|
||||
|
@ -102,7 +113,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
|
||||
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
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,9 +1,21 @@
|
|||
attribute vec3 attr_Position;
|
||||
attribute vec4 attr_TexCoord0;
|
||||
|
||||
uniform mat4 u_ModelViewProjectionMatrix;
|
||||
// Uniforms
|
||||
uniform highp mat4 u_ModelMatrix;
|
||||
|
||||
uniform vec3 u_ToneMinAvgMaxLinear;
|
||||
|
||||
layout(shared) uniform ViewMatrices
|
||||
{
|
||||
uniform highp mat4 u_ViewMatrices[NUM_VIEWS];
|
||||
};
|
||||
layout(shared) uniform ProjectionMatrix
|
||||
{
|
||||
uniform highp mat4 u_ProjectionMatrix;
|
||||
};
|
||||
|
||||
|
||||
varying vec2 var_TexCoords;
|
||||
varying float var_InvWhite;
|
||||
|
||||
|
@ -21,7 +33,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);
|
||||
}
|
||||
|
|
13
android/app/src/main/pakQ3Q/scripts/vr.shader
Normal file
13
android/app/src/main/pakQ3Q/scripts/vr.shader
Normal file
|
@ -0,0 +1,13 @@
|
|||
|
||||
//
|
||||
// VR Hud Shader Sprite - the image is just a placeholder and is replaced in code
|
||||
//
|
||||
|
||||
sprites/vr/hud
|
||||
{
|
||||
cull disable
|
||||
{
|
||||
clampmap sprites/plasmaa.tga
|
||||
blendfunc GL_ONE GL_ONE
|
||||
}
|
||||
}
|
|
@ -3,7 +3,7 @@
|
|||
setlocal
|
||||
|
||||
set BUILD_TYPE=release
|
||||
set VERSION=0.28.1
|
||||
set VERSION=0.29.1-multiview
|
||||
|
||||
@REM Define the following environment variables to sign a release build
|
||||
@REM set KEYSTORE=
|
||||
|
@ -29,6 +29,11 @@ if %BUILD_TYPE%==debug (
|
|||
set GRADLE_BUILD_TYPE=:app:assembleDebug
|
||||
)
|
||||
|
||||
REM package our special pk3
|
||||
pushd android\app\src\main
|
||||
call make_pakQ3Q.bat
|
||||
popd
|
||||
|
||||
echo #define Q3QVERSION "%VERSION%" > .\android\app\src\main\cpp\code\vr\vr_version.h
|
||||
|
||||
pushd %~dp0\..
|
||||
|
|
Loading…
Reference in a new issue