diff --git a/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c b/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c index c4c3c57..49ebb18 100644 --- a/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c +++ b/Projects/Android/jni/Doom3Quest/Doom3Quest_SurfaceView.c @@ -1365,15 +1365,15 @@ void VR_Init() long renderThreadCPUTime = 0; -void Doom3Quest_prepareEyeBuffer(int eye ) +void Doom3Quest_prepareEyeBuffer( ) { - renderThreadCPUTime = GetTimeInMilliSeconds(); - ovrRenderer *renderer = Doom3Quest_useScreenLayer() ? &gAppState.Scene.CylinderRenderer : &gAppState.Renderer; ovrFramebuffer *frameBuffer = &(renderer->FrameBuffer); ovrFramebuffer_SetCurrent(frameBuffer); + renderThreadCPUTime = GetTimeInMilliSeconds(); + GL(glEnable(GL_SCISSOR_TEST)); GL(glDepthMask(GL_TRUE)); GL(glEnable(GL_DEPTH_TEST)); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/Item.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/Item.cpp index c7e63ac..97ae952 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/Item.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/Item.cpp @@ -139,10 +139,10 @@ idItem::UpdateRenderEntity */ bool idItem::UpdateRenderEntity( renderEntity_s *renderEntity, const renderView_t *renderView ) const { -/* if ( lastRenderViewTime == renderView->time ) { + if ( lastRenderViewTime == renderView->time ) { return false; } -*/ + lastRenderViewTime = renderView->time; // check for glow highlighting if near the center of the view diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/PlayerView.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/PlayerView.cpp index 1802f3a..b202398 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/PlayerView.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/PlayerView.cpp @@ -468,7 +468,7 @@ void idPlayerView::SingleView( idUserInterface *hud, const renderView_t *view ) player->DrawHUD(hud); } - renderSystem->CaptureRenderToImage( "_hudImage" ); + //renderSystem->CaptureRenderToImage( "_hudImage" ); // place the sound origin for the player gameSoundWorld->PlaceListener( view->vieworg, view->viewaxis, player->entityNumber + 1, gameLocal.time, hud ? hud->State().GetString( "location" ) : "Undefined" ); @@ -727,32 +727,19 @@ idPlayerView::RenderPlayerView void idPlayerView::RenderPlayerView( idUserInterface *hud ) { const renderView_t *view = player->GetRenderView(); - { - renderView_t *eyeView = view ? new renderView_t(*view) : NULL; - -/* if (eyeView && - !game->InCinematic()) - { - eyeView->vieworg += (vr_eye.GetInteger() == 0 ? 1.0f : -1.0f) * eyeView->viewaxis[1] * - (vr_ipd.GetFloat() / 2.0f) * vr_worldscale.GetFloat(); - }*/ - if (g_skipViewEffects.GetBool()) { - SingleView(hud, eyeView); + SingleView( hud, view ); } else { if (player->GetInfluenceMaterial() || player->GetInfluenceEntity()) { - InfluenceVision(hud, eyeView); + InfluenceVision( hud, view ); } else if (gameLocal.time < dvFinishTime) { - DoubleVision(hud, eyeView, dvFinishTime - gameLocal.time); + DoubleVision( hud, view, dvFinishTime - gameLocal.time ); } else if (player->PowerUpActive(BERSERK)) { - BerserkVision(hud, eyeView); + BerserkVision( hud, view ); } else { - SingleView(hud, eyeView); + SingleView( hud, view ); } ScreenFade(); - } - - delete eyeView; } if ( net_clientLagOMeter.GetBool() && lagoMaterial && gameLocal.isClient ) { diff --git a/Projects/Android/jni/d3es-multithread-master/neo/game/SmokeParticles.cpp b/Projects/Android/jni/d3es-multithread-master/neo/game/SmokeParticles.cpp index e9d4d5b..e63307d 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/game/SmokeParticles.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/game/SmokeParticles.cpp @@ -170,8 +170,7 @@ bool idSmokeParticles::EmitSmoke( const idDeclParticle *smoke, const int systemS return false; } - if ( !gameLocal.isNewFrame ) - { + if ( !gameLocal.isNewFrame ) { return false; } @@ -298,11 +297,10 @@ bool idSmokeParticles::UpdateRenderEntity( renderEntity_s *renderEntity, const r return false; } - // Need to regenerate smoke particles for each eye - commented this out or you only get smoke in the left eye! -/* if ( renderView->time == currentParticleTime && !renderView->forceUpdate && !renderView->forceSmokeUpdate ) { + // don't regenerate it if it is current + if ( renderView->time == currentParticleTime && !renderView->forceUpdate ) { return false; - }*/ - + } currentParticleTime = renderView->time; particleGen_t g; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/GuiModel.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/GuiModel.cpp index 2c1ba4b..2658fdc 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/GuiModel.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/GuiModel.cpp @@ -193,7 +193,7 @@ void idGuiModel::EmitSurface( guiModelSurface_t *surf, float modelMatrix[16], fl viewEntity_t *guiSpace = (viewEntity_t *)R_ClearedFrameAlloc( sizeof( *guiSpace ) ); memcpy( guiSpace->modelMatrix, modelMatrix, sizeof( guiSpace->modelMatrix ) ); - memcpy( guiSpace->modelViewMatrix, modelViewMatrix, sizeof( guiSpace->modelViewMatrix ) ); + memcpy(guiSpace->viewMatrix, modelViewMatrix, sizeof( guiSpace->viewMatrix ) ); guiSpace->weaponDepthHack = depthHack; // add the surface, which might recursively create another gui @@ -209,13 +209,13 @@ void idGuiModel::EmitToCurrentView( float modelMatrix[16], bool depthHack ) { float modelViewMatrix[48]; //Left Eye - myGlMultMatrix( modelMatrix, tr.viewDef->worldSpace.eyeModelViewMatrix[0], + myGlMultMatrix( modelMatrix, tr.viewDef->worldSpace.eyeViewMatrix[0], modelViewMatrix ); //Right Eye - myGlMultMatrix( modelMatrix, tr.viewDef->worldSpace.eyeModelViewMatrix[1], + myGlMultMatrix( modelMatrix, tr.viewDef->worldSpace.eyeViewMatrix[1], modelViewMatrix + 16); //Center Eye - myGlMultMatrix( modelMatrix, tr.viewDef->worldSpace.eyeModelViewMatrix[2], + myGlMultMatrix( modelMatrix, tr.viewDef->worldSpace.eyeViewMatrix[2], modelViewMatrix + 32); for ( int i = 0 ; i < surfaces.Num() ; i++ ) { @@ -281,12 +281,22 @@ void idGuiModel::EmitFullScreen( void ) { viewDef->projectionMatrix[15] = 1.0f; for (int i = 0; i < 3; ++i) { - viewDef->worldSpace.eyeModelViewMatrix[i][0] = 1.0f; - viewDef->worldSpace.eyeModelViewMatrix[i][5] = 1.0f; - viewDef->worldSpace.eyeModelViewMatrix[i][10] = 1.0f; - viewDef->worldSpace.eyeModelViewMatrix[i][15] = 1.0f; + viewDef->worldSpace.eyeViewMatrix[i][0] = 1.0f; + viewDef->worldSpace.eyeViewMatrix[i][5] = 1.0f; + viewDef->worldSpace.eyeViewMatrix[i][10] = 1.0f; + viewDef->worldSpace.eyeViewMatrix[i][15] = 1.0f; } + viewDef->worldSpace.viewMatrix[0] = 1.0f; + viewDef->worldSpace.viewMatrix[5] = 1.0f; + viewDef->worldSpace.viewMatrix[10] = 1.0f; + viewDef->worldSpace.viewMatrix[15] = 1.0f; + + viewDef->worldSpace.modelMatrix[0] = 1.0f; + viewDef->worldSpace.modelMatrix[5] = 1.0f; + viewDef->worldSpace.modelMatrix[10] = 1.0f; + viewDef->worldSpace.modelMatrix[15] = 1.0f; + viewDef->maxDrawSurfs = surfaces.Num(); viewDef->drawSurfs = (drawSurf_t **)R_FrameAlloc( viewDef->maxDrawSurfs * sizeof( viewDef->drawSurfs[0] ) ); viewDef->numDrawSurfs = 0; @@ -296,7 +306,7 @@ void idGuiModel::EmitFullScreen( void ) { // add the surfaces to this view for ( int i = 0 ; i < surfaces.Num() ; i++ ) { - EmitSurface( &surfaces[i], viewDef->worldSpace.modelMatrix, viewDef->worldSpace.modelViewMatrix, false ); + EmitSurface(&surfaces[i], viewDef->worldSpace.modelMatrix, viewDef->worldSpace.viewMatrix, false ); } tr.viewDef = oldViewDef; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.cpp index 09f2f79..0c4809a 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderSystem.cpp @@ -260,8 +260,8 @@ void R_LockSurfaceScene( viewDef_t *parms ) { for (vModel = tr.lockSurfacesCmd.viewDef->viewEntitys; vModel; vModel = vModel->next) { for (int eye = 0; eye < 3; ++eye) { myGlMultMatrix(vModel->modelMatrix, - tr.lockSurfacesCmd.viewDef->worldSpace.eyeModelViewMatrix[eye], - vModel->eyeModelViewMatrix[eye]); + tr.lockSurfacesCmd.viewDef->worldSpace.eyeViewMatrix[eye], + vModel->eyeViewMatrix[eye]); } } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderWorld_portals.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderWorld_portals.cpp index 04e6289..cad6a6c 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderWorld_portals.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/RenderWorld_portals.cpp @@ -128,10 +128,10 @@ bool idRenderWorldLocal::PortalIsFoggedOut( const portal_t *p ) { a = -0.5f / alpha; } - forward[0] = a * tr.viewDef->worldSpace.eyeModelViewMatrix[2][2]; - forward[1] = a * tr.viewDef->worldSpace.eyeModelViewMatrix[2][6]; - forward[2] = a * tr.viewDef->worldSpace.eyeModelViewMatrix[2][10]; - forward[3] = a * tr.viewDef->worldSpace.eyeModelViewMatrix[2][14]; + forward[0] = a * tr.viewDef->worldSpace.eyeViewMatrix[2][2]; + forward[1] = a * tr.viewDef->worldSpace.eyeViewMatrix[2][6]; + forward[2] = a * tr.viewDef->worldSpace.eyeViewMatrix[2][10]; + forward[3] = a * tr.viewDef->worldSpace.eyeViewMatrix[2][14]; w = p->w; for ( i = 0 ; i < w->GetNumPoints() ; i++ ) { diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/draw_gles2.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/draw_gles2.cpp index 170eaa2..1ee1a6a 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/draw_gles2.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/draw_gles2.cpp @@ -259,6 +259,8 @@ static void RB_GLSL_GetUniformLocations(shaderProgram_t* shader) { GL_UseProgram(shader); shader->localLightOrigin = qglGetUniformLocation(shader->program, "u_lightOrigin"); + + //May need to move this to the shader matrices uniform block? shader->localViewOrigin = qglGetUniformLocation(shader->program, "u_viewOrigin"); shader->lightProjection = qglGetUniformLocation(shader->program, "u_lightProjection"); shader->bumpMatrixS = qglGetUniformLocation(shader->program, "u_bumpMatrixS"); @@ -276,8 +278,11 @@ static void RB_GLSL_GetUniformLocations(shaderProgram_t* shader) { shader->alphaTest = qglGetUniformLocation(shader->program, "u_alphaTest"); shader->specularExponent = qglGetUniformLocation(shader->program, "u_specularExponent"); - GLuint shaderMatricesUniformLocation = glGetUniformBlockIndex(shader->program, "ShaderMatrices"); + shader->projectionMatrix = qglGetUniformLocation(shader->program, "u_projectionMatrix"); + shader->modelMatrix = qglGetUniformLocation(shader->program, "u_modelMatrix"); + //Shader Matrices for the View Matrix + GLuint shaderMatricesUniformLocation = glGetUniformBlockIndex(shader->program, "ShaderMatrices"); int numBufferBindings = 0; shader->shaderMatricesBinding = numBufferBindings++; glUniformBlockBinding( @@ -518,12 +523,12 @@ void R_ReloadGLSLPrograms_f(const idCmdArgs& args) { /* ================= -RB_ComputeMVP +RB_ComputeProjection -Compute the model view matrix, with eventually required projection matrix depth hacks +Compute the required projection matrix depth hacks ================= */ -void RB_ComputeMVP( const drawSurf_t * const surf, float mvp[32] ) { +void RB_ComputeProjection(const drawSurf_t * const surf, float *projection) { // Get the projection matrix float localProjectionMatrix[16]; memcpy(localProjectionMatrix, backEnd.viewDef->projectionMatrix, sizeof(localProjectionMatrix)); @@ -536,8 +541,7 @@ void RB_ComputeMVP( const drawSurf_t * const surf, float mvp[32] ) { localProjectionMatrix[14] = backEnd.viewDef->projectionMatrix[14] - surf->space->modelDepthHack; } - myGlMultMatrix(surf->space->eyeModelViewMatrix[0], localProjectionMatrix, mvp); - myGlMultMatrix(surf->space->eyeModelViewMatrix[1], localProjectionMatrix, (mvp + 16) ); + memcpy(projection, localProjectionMatrix, sizeof(localProjectionMatrix)); } /* @@ -817,9 +821,17 @@ static void RB_GLSL_CreateDrawInteractions(const drawSurf_t* surf, const viewLig // perform setup here that will not change over multiple interaction passes if ( surf->space != backEnd.currentSpace ) { - float mvp[32]; - RB_ComputeMVP(surf, mvp); - GL_UniformBuffer(offsetof(shaderProgram_t, shaderMatricesBuffer), mvp); + float projection[16]; + RB_ComputeProjection(surf, projection); + GL_UniformMatrix4fv(offsetof(shaderProgram_t, projectionMatrix), projection); + GL_UniformMatrix4fv(offsetof(shaderProgram_t, modelMatrix), surf->space->modelMatrix); + + if (!backEnd.glState.currentProgram->shaderMatricesBufferSet) + { + // We can set the uniform now as it shader is already bound + GL_UniformBuffer(offsetof(shaderProgram_t, shaderMatricesBuffer), backEnd.viewDef->worldSpace.viewMatrix); + backEnd.glState.currentProgram->shaderMatricesBufferSet = true; + } } // Hack Depth Range if necessary @@ -977,10 +989,18 @@ void RB_GLSL_RenderDrawSurfChainWithFunction(const drawSurf_t* drawSurfs, // Change the MVP matrix if needed if ( drawSurf->space != backEnd.currentSpace ) { - float mvp[32]; - RB_ComputeMVP(drawSurf, mvp); + float projection[16]; + RB_ComputeProjection(drawSurf, projection); + GL_UniformMatrix4fv(offsetof(shaderProgram_t, projectionMatrix), projection); + GL_UniformMatrix4fv(offsetof(shaderProgram_t, modelMatrix), drawSurf->space->modelMatrix); + // We can set the uniform now, as the shader is already bound - GL_UniformBuffer(offsetof(shaderProgram_t, shaderMatricesBuffer), mvp); + if (!backEnd.glState.currentProgram->shaderMatricesBufferSet) + { + // We can set the uniform now as it shader is already bound + GL_UniformBuffer(offsetof(shaderProgram_t, shaderMatricesBuffer), backEnd.viewDef->worldSpace.viewMatrix); + backEnd.glState.currentProgram->shaderMatricesBufferSet = true; + } } // Hack Depth Range if necessary @@ -1052,7 +1072,7 @@ void RB_GLSL_StencilShadowPass(const drawSurf_t* drawSurfs, const viewLight_t* v GL_UseProgram(&stencilShadowShader); glBindBufferBase( - GL_UNIFORM_BUFFER, + GL_UNIFORM_BUFFER, backEnd.glState.currentProgram->shaderMatricesBinding, backEnd.glState.currentProgram->shaderMatricesBuffer); @@ -1290,15 +1310,15 @@ void RB_GLSL_FogPass(const drawSurf_t* drawSurfs, const drawSurf_t* drawSurfs2, // It is expected to be already active globalImages->fogImage->Bind(); - fogPlanes[0][0] = a * backEnd.viewDef->worldSpace.eyeModelViewMatrix[2][2]; - fogPlanes[0][1] = a * backEnd.viewDef->worldSpace.eyeModelViewMatrix[2][6]; - fogPlanes[0][2] = a * backEnd.viewDef->worldSpace.eyeModelViewMatrix[2][10]; - fogPlanes[0][3] = a * backEnd.viewDef->worldSpace.eyeModelViewMatrix[2][14]; + fogPlanes[0][0] = a * backEnd.viewDef->worldSpace.eyeViewMatrix[2][2]; + fogPlanes[0][1] = a * backEnd.viewDef->worldSpace.eyeViewMatrix[2][6]; + fogPlanes[0][2] = a * backEnd.viewDef->worldSpace.eyeViewMatrix[2][10]; + fogPlanes[0][3] = a * backEnd.viewDef->worldSpace.eyeViewMatrix[2][14]; - fogPlanes[1][0] = a * backEnd.viewDef->worldSpace.eyeModelViewMatrix[2][0]; - fogPlanes[1][1] = a * backEnd.viewDef->worldSpace.eyeModelViewMatrix[2][4]; - fogPlanes[1][2] = a * backEnd.viewDef->worldSpace.eyeModelViewMatrix[2][8]; - fogPlanes[1][3] = a * backEnd.viewDef->worldSpace.eyeModelViewMatrix[2][12]; + fogPlanes[1][0] = a * backEnd.viewDef->worldSpace.eyeViewMatrix[2][0]; + fogPlanes[1][1] = a * backEnd.viewDef->worldSpace.eyeViewMatrix[2][4]; + fogPlanes[1][2] = a * backEnd.viewDef->worldSpace.eyeViewMatrix[2][8]; + fogPlanes[1][3] = a * backEnd.viewDef->worldSpace.eyeViewMatrix[2][12]; // texture 1 is the entering plane fade correction GL_SelectTexture(1); @@ -1659,10 +1679,17 @@ void RB_GLSL_FillDepthBuffer(drawSurf_t** drawSurfs, int numDrawSurfs) { // Change the MVP matrix if needed if ( drawSurf->space != backEnd.currentSpace ) { - float mvp[32]; - RB_ComputeMVP(drawSurf, mvp); - // We can set the uniform now as it shader is already bound - GL_UniformBuffer(offsetof(shaderProgram_t, shaderMatricesBuffer), mvp); + float projection[16]; + RB_ComputeProjection(drawSurf, projection); + GL_UniformMatrix4fv(offsetof(shaderProgram_t, projectionMatrix), projection); + GL_UniformMatrix4fv(offsetof(shaderProgram_t, modelMatrix), drawSurf->space->modelMatrix); + + if (!backEnd.glState.currentProgram->shaderMatricesBufferSet) + { + // We can set the uniform now as it shader is already bound + GL_UniformBuffer(offsetof(shaderProgram_t, shaderMatricesBuffer), backEnd.viewDef->worldSpace.viewMatrix); + backEnd.glState.currentProgram->shaderMatricesBufferSet = true; + } } // Hack Depth Range if necessary @@ -1722,7 +1749,7 @@ RB_GLSL_T_RenderShaderPasses This is also called for the generated 2D rendering ================== */ -void RB_GLSL_T_RenderShaderPasses(const drawSurf_t* surf, const float mvp[16]) { +void RB_GLSL_T_RenderShaderPasses(const drawSurf_t* surf, const float projection[16]) { // global constants static const GLfloat zero[1] = { 0 }; @@ -1970,13 +1997,13 @@ void RB_GLSL_T_RenderShaderPasses(const drawSurf_t* surf, const float mvp[16]) { GL_VertexAttribPointer(offsetof(shaderProgram_t, attr_TexCoord), 3, GL_FLOAT, false, sizeof(idDrawVert), ac->normal.ToFloatPtr()); - // Setup the modelViewMatrix, we will need it to compute the reflection - GL_UniformMatrix4fv(offsetof(shaderProgram_t, modelViewMatrix), surf->space->eyeModelViewMatrix[2]); + // Setup the viewMatrix, we will need it to compute the reflection + GL_UniformMatrix4fv(offsetof(shaderProgram_t, modelViewMatrix), surf->space->eyeViewMatrix[2]); - // Setup the texture matrix like original D3 code does: using the transpose modelViewMatrix of the view + // Setup the texture matrix like original D3 code does: using the transpose viewMatrix of the view // NB: this is curious, not sure why this is done like this.... float mat[16]; - R_TransposeGLMatrix(backEnd.viewDef->worldSpace.eyeModelViewMatrix[2], mat); + R_TransposeGLMatrix(backEnd.viewDef->worldSpace.eyeViewMatrix[2], mat); GL_UniformMatrix4fv(offsetof(shaderProgram_t, textureMatrix), mat); } else { // TG_EXPLICIT // Otherwise, this is just regular surface shader with explicit texcoords @@ -2020,8 +2047,15 @@ void RB_GLSL_T_RenderShaderPasses(const drawSurf_t* surf, const float mvp[16]) { // MVP if ( !bMVPSet[pStage->texture.texgen] ) { - // Setup the MVP uniform - GL_UniformBuffer(offsetof(shaderProgram_t, shaderMatricesBuffer), mvp); + GL_UniformMatrix4fv(offsetof(shaderProgram_t, projectionMatrix), projection); + GL_UniformMatrix4fv(offsetof(shaderProgram_t, modelMatrix), surf->space->modelMatrix); + + if (!backEnd.glState.currentProgram->shaderMatricesBufferSet) + { + // We can set the uniform now as it shader is already bound + GL_UniformBuffer(offsetof(shaderProgram_t, shaderMatricesBuffer), backEnd.viewDef->worldSpace.viewMatrix); + backEnd.glState.currentProgram->shaderMatricesBufferSet = true; + } bMVPSet[pStage->texture.texgen] = true; } } @@ -2197,7 +2231,7 @@ int RB_GLSL_DrawShaderPasses(drawSurf_t** drawSurfs, int numDrawSurfs) { // For each surface loop ///////////////////////// - float mvp[32]; + float projection[16]; backEnd.currentSpace = NULL; int i; @@ -2226,7 +2260,7 @@ int RB_GLSL_DrawShaderPasses(drawSurf_t** drawSurfs, int numDrawSurfs) { // Change the MVP matrix if needed if ( drawSurfs[i]->space != backEnd.currentSpace ) { - RB_ComputeMVP(drawSurfs[i], mvp); + RB_ComputeProjection(drawSurfs[i], projection); // We can't set the uniform now, as we still don't know which shader to use } @@ -2240,7 +2274,7 @@ int RB_GLSL_DrawShaderPasses(drawSurf_t** drawSurfs, int numDrawSurfs) { //////////////////// // Do the real work //////////////////// - RB_GLSL_T_RenderShaderPasses(drawSurfs[i], mvp); + RB_GLSL_T_RenderShaderPasses(drawSurfs[i], projection); if (bNeedRestoreDepthRange) { qglDepthRangef(0.0f, 1.0f); @@ -2508,6 +2542,20 @@ void RB_GLSL_PrepareShaders(void) { // No shaders set by default GL_UseProgram(NULL); + //Indicate that none have the view matrix set yet + interactionShader.shaderMatricesBufferSet = false; + interactionShader.shaderMatricesBufferSet = false; + interactionPhongShader.shaderMatricesBufferSet = false; + fogShader.shaderMatricesBufferSet = false; + blendLightShader.shaderMatricesBufferSet = false; + zfillShader.shaderMatricesBufferSet = false; + zfillClipShader.shaderMatricesBufferSet = false; + diffuseMapShader.shaderMatricesBufferSet = false; + diffuseCubeShader.shaderMatricesBufferSet = false; + skyboxCubeShader.shaderMatricesBufferSet = false; + reflectionCubeShader.shaderMatricesBufferSet = false; + stencilShadowShader.shaderMatricesBufferSet = false; + // Always enable the vertex, color and texcoord attributes arrays GL_EnableVertexAttribArray(ATTR_VERTEX); GL_EnableVertexAttribArray(ATTR_COLOR); diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/blendLightShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/blendLightShaderVP.cpp index c12ee2c..f1b0ac9 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/blendLightShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/blendLightShaderVP.cpp @@ -33,8 +33,10 @@ in highp vec4 attr_Vertex; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_fogMatrix; // Out @@ -44,7 +46,7 @@ out vec2 var_TexFogEnter; void main() { - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); // What will be computed: // diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/diffuseCubeShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/diffuseCubeShaderVP.cpp index ed725fa..8d21885 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/diffuseCubeShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/diffuseCubeShaderVP.cpp @@ -35,8 +35,10 @@ in vec3 attr_TexCoord; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_textureMatrix; uniform lowp float u_colorAdd; uniform lowp float u_colorModulate; @@ -56,6 +58,6 @@ void main() var_Color = (attr_Color * u_colorModulate) + vec4(u_colorAdd); } - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); } )"; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/diffuseMapShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/diffuseMapShaderVP.cpp index ccae28d..b247a63 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/diffuseMapShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/diffuseMapShaderVP.cpp @@ -36,8 +36,10 @@ in vec4 attr_TexCoord; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_textureMatrix; uniform lowp float u_colorAdd; uniform lowp float u_colorModulate; @@ -57,6 +59,6 @@ void main() var_Color = (attr_Color * u_colorModulate) + vec4(u_colorAdd); } - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); } )"; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/fogShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/fogShaderVP.cpp index 685191f..85e563b 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/fogShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/fogShaderVP.cpp @@ -33,8 +33,10 @@ in highp vec4 attr_Vertex; // input Vertex Coordinates // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_fogMatrix; // fogPlanes 0, 1, 3 (CATION: not 2!), 2 // Out @@ -44,7 +46,7 @@ out vec2 var_TexFogEnter; // output FogEnter TexCoord void main() { - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); // What will be computed: // diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/interactionPhongShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/interactionPhongShaderVP.cpp index e855447..f591ee7 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/interactionPhongShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/interactionPhongShaderVP.cpp @@ -38,8 +38,10 @@ in vec3 attr_Normal; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_lightProjection; uniform lowp float u_colorModulate; uniform lowp float u_colorAdd; @@ -92,6 +94,6 @@ void main() var_Color = (attr_Color * u_colorModulate) + vec4(u_colorAdd); } - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); } )"; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/interactionShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/interactionShaderVP.cpp index 6f19c26..421bf52 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/interactionShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/interactionShaderVP.cpp @@ -38,8 +38,10 @@ in vec3 attr_Normal; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_lightProjection; uniform lowp float u_colorModulate; uniform lowp float u_colorAdd; @@ -93,6 +95,6 @@ void main() var_Color = (attr_Color * u_colorModulate) + vec4(u_colorAdd); } - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); } )"; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/reflectionCubeShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/reflectionCubeShaderVP.cpp index b91482d..cddf83a 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/reflectionCubeShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/reflectionCubeShaderVP.cpp @@ -42,8 +42,10 @@ in vec3 attr_TexCoord; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_modelViewMatrix; uniform mat4 u_textureMatrix; uniform lowp float u_colorAdd; @@ -67,6 +69,6 @@ void main() var_Color = (attr_Color * u_colorModulate) + vec4(u_colorAdd); } - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); } )"; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/skyboxCubeShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/skyboxCubeShaderVP.cpp index fd8d371..4285f3e 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/skyboxCubeShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/skyboxCubeShaderVP.cpp @@ -34,8 +34,10 @@ in lowp vec4 attr_Color; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_textureMatrix; uniform lowp float u_colorAdd; uniform lowp float u_colorModulate; @@ -56,6 +58,6 @@ void main() var_Color = (attr_Color * u_colorModulate) + vec4(u_colorAdd); } - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); } )"; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/stencilShadowShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/stencilShadowShaderVP.cpp index 5ac13f4..3a229f4 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/stencilShadowShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/stencilShadowShaderVP.cpp @@ -33,8 +33,10 @@ in highp vec4 attr_Vertex; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform vec4 u_lightOrigin; // Out @@ -42,6 +44,6 @@ uniform vec4 u_lightOrigin; void main() { - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * (attr_Vertex.w * u_lightOrigin + attr_Vertex - u_lightOrigin); + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * (attr_Vertex.w * u_lightOrigin + attr_Vertex - u_lightOrigin))); } )"; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/zfillClipShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/zfillClipShaderVP.cpp index 7730f4d..ce3e585 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/zfillClipShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/zfillClipShaderVP.cpp @@ -34,8 +34,10 @@ in vec4 attr_TexCoord; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_textureMatrix; uniform vec4 u_clipPlane; @@ -50,6 +52,6 @@ void main() var_TexClip = vec2( dot( u_clipPlane, attr_Vertex), 0.5 ); - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); } )"; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/zfillShaderVP.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/zfillShaderVP.cpp index 9adb954..58d0f81 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/zfillShaderVP.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/glsl/zfillShaderVP.cpp @@ -34,8 +34,10 @@ in vec4 attr_TexCoord; // Uniforms uniform ShaderMatrices { - uniform highp mat4 modelViewProjectionMatrix[NUM_VIEWS]; + uniform highp mat4 viewMatrix[NUM_VIEWS]; } u_shaderMatrices; +uniform highp mat4 u_modelMatrix; +uniform highp mat4 u_projectionMatrix; uniform mat4 u_textureMatrix; // Out @@ -46,6 +48,6 @@ void main() { var_TexDiffuse = (u_textureMatrix * attr_TexCoord).xy; // Homogeneous coordinates of textureMatrix supposed to be 1 - gl_Position = u_shaderMatrices.modelViewProjectionMatrix[gl_ViewID_OVR] * attr_Vertex; + gl_Position = u_projectionMatrix * (u_shaderMatrices.viewMatrix[gl_ViewID_OVR] * (u_modelMatrix * attr_Vertex)); } )"; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_light.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_light.cpp index 213d48d..561a0f3 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_light.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_light.cpp @@ -273,8 +273,8 @@ viewEntity_t* R_SetEntityDefViewEntity(idRenderEntityLocal* def) { // we may not have a viewDef if we are just creating shadows at entity creation time if ( tr.viewDef ) { for (int eye = 0; eye <= 2; ++eye) { - myGlMultMatrix(vModel->modelMatrix, tr.viewDef->worldSpace.eyeModelViewMatrix[eye], - vModel->eyeModelViewMatrix[eye]); + myGlMultMatrix(vModel->modelMatrix, tr.viewDef->worldSpace.eyeViewMatrix[eye], + vModel->eyeViewMatrix[eye]); } vModel->next = tr.viewDef->viewEntitys; @@ -630,8 +630,8 @@ idScreenRect R_ClippedLightScissorRectangle(viewLight_t* vLight) { idPlane eye, clip; idVec3 ndc; - R_TransformModelToClip(w[j].ToVec3(), tr.viewDef->worldSpace.eyeModelViewMatrix[2], tr.viewDef->projectionMatrix, eye, - clip); + R_TransformModelToClip(w[j].ToVec3(), tr.viewDef->worldSpace.eyeViewMatrix[2], tr.viewDef->projectionMatrix, eye, + clip); if ( clip[3] <= 0.01f ) { clip[3] = 0.01f; @@ -695,7 +695,7 @@ idScreenRect R_CalcLightScissorRectangle(viewLight_t* vLight) { tri = vLight->lightDef->frustumTris; for ( int i = 0; i < tri->numVerts; i++ ) { - R_TransformModelToClip(tri->verts[i].xyz, tr.viewDef->worldSpace.eyeModelViewMatrix[2], + R_TransformModelToClip(tri->verts[i].xyz, tr.viewDef->worldSpace.eyeViewMatrix[2], tr.viewDef->projectionMatrix, eye, clip); // if it is near clipped, clip the winding polygons to the view frustum @@ -1052,9 +1052,9 @@ idRenderModel* R_EntityDefDynamicModel(idRenderEntityLocal* def) { if ( def->dynamicModel && model->DepthHack() != 0.0f && tr.viewDef ) { idPlane eye, clip; idVec3 ndc; - R_TransformModelToClip(def->parms.origin, tr.viewDef->worldSpace.eyeModelViewMatrix[2], tr.viewDef->projectionMatrix, - eye, - clip); + R_TransformModelToClip(def->parms.origin, tr.viewDef->worldSpace.eyeViewMatrix[2], tr.viewDef->projectionMatrix, + eye, + clip); R_TransformClipToDevice(clip, tr.viewDef, ndc); def->parms.modelDepthHack = model->DepthHack() * ( 1.0f - ndc.z ); } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h index 864aa04..cad39cd 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_local.h @@ -372,9 +372,9 @@ typedef struct viewEntity_s { union { // local coords to left/right/center eye coords - float eyeModelViewMatrix[3][16]; + float eyeViewMatrix[3][16]; // Can also be treated as a float[48] - float modelViewMatrix[48]; + float viewMatrix[48]; }; } viewEntity_t; @@ -1259,8 +1259,10 @@ typedef struct shaderProgram_s { GLint alphaTest; GLint specularExponent; -// GLint modelViewProjectionMatrix; - //New for multiview + GLint modelMatrix; + GLint projectionMatrix; + //New for multiview - The view matrix uniform + bool shaderMatricesBufferSet; GLuint shaderMatricesBuffer; GLuint shaderMatricesBinding; diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_main.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_main.cpp index c1982bc..7c98cb9 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_main.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_main.cpp @@ -737,10 +737,10 @@ void R_GlobalToNormalizedDeviceCoordinates( const idVec3 &global, idVec3 &ndc ) for ( i = 0 ; i < 4 ; i ++ ) { view[i] = - global[0] * tr.primaryView->worldSpace.eyeModelViewMatrix[2][ i + 0 * 4 ] + - global[1] * tr.primaryView->worldSpace.eyeModelViewMatrix[2][ i + 1 * 4 ] + - global[2] * tr.primaryView->worldSpace.eyeModelViewMatrix[2][ i + 2 * 4 ] + - tr.primaryView->worldSpace.eyeModelViewMatrix[2][ i + 3 * 4 ]; + global[0] * tr.primaryView->worldSpace.eyeViewMatrix[2][i + 0 * 4 ] + + global[1] * tr.primaryView->worldSpace.eyeViewMatrix[2][i + 1 * 4 ] + + global[2] * tr.primaryView->worldSpace.eyeViewMatrix[2][i + 2 * 4 ] + + tr.primaryView->worldSpace.eyeViewMatrix[2][i + 3 * 4 ]; } for ( i = 0 ; i < 4 ; i ++ ) { @@ -755,10 +755,10 @@ void R_GlobalToNormalizedDeviceCoordinates( const idVec3 &global, idVec3 &ndc ) for ( i = 0 ; i < 4 ; i ++ ) { view[i] = - global[0] * tr.viewDef->worldSpace.eyeModelViewMatrix[2][ i + 0 * 4 ] + - global[1] * tr.viewDef->worldSpace.eyeModelViewMatrix[2][ i + 1 * 4 ] + - global[2] * tr.viewDef->worldSpace.eyeModelViewMatrix[2][ i + 2 * 4 ] + - tr.viewDef->worldSpace.eyeModelViewMatrix[2][ i + 3 * 4 ]; + global[0] * tr.viewDef->worldSpace.eyeViewMatrix[2][i + 0 * 4 ] + + global[1] * tr.viewDef->worldSpace.eyeViewMatrix[2][i + 1 * 4 ] + + global[2] * tr.viewDef->worldSpace.eyeViewMatrix[2][i + 2 * 4 ] + + tr.viewDef->worldSpace.eyeViewMatrix[2][i + 3 * 4 ]; } @@ -913,7 +913,7 @@ void R_SetViewMatrix( viewDef_t *viewDef ) { // convert from our coordinate system (looking down X) // to OpenGL's coordinate system (looking down -Z) - myGlMultMatrix(viewerMatrix, s_flipMatrix, world->eyeModelViewMatrix[eye]); + myGlMultMatrix(viewerMatrix, s_flipMatrix, world->eyeViewMatrix[eye]); } } } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_shadowbounds.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_shadowbounds.cpp index 2966956..d16c194 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_shadowbounds.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_shadowbounds.cpp @@ -473,10 +473,10 @@ void world_to_hclip( const viewDef_t *viewDef, const idVec4 &global, idVec4 &cli for ( i = 0 ; i < 4 ; i ++ ) { view[i] = - global[0] * viewDef->worldSpace.eyeModelViewMatrix[2][ i + 0 * 4 ] + - global[1] * viewDef->worldSpace.eyeModelViewMatrix[2][ i + 1 * 4 ] + - global[2] * viewDef->worldSpace.eyeModelViewMatrix[2][ i + 2 * 4 ] + - global[3] * viewDef->worldSpace.eyeModelViewMatrix[2][ i + 3 * 4 ]; + global[0] * viewDef->worldSpace.eyeViewMatrix[2][i + 0 * 4 ] + + global[1] * viewDef->worldSpace.eyeViewMatrix[2][i + 1 * 4 ] + + global[2] * viewDef->worldSpace.eyeViewMatrix[2][i + 2 * 4 ] + + global[3] * viewDef->worldSpace.eyeViewMatrix[2][i + 3 * 4 ]; } diff --git a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_subview.cpp b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_subview.cpp index 735a764..91f5fb5 100644 --- a/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_subview.cpp +++ b/Projects/Android/jni/d3es-multithread-master/neo/renderer/tr_subview.cpp @@ -125,7 +125,7 @@ bool R_PreciseCullSurface( const drawSurf_t *drawSurf, idBounds &ndcBounds ) { int j; unsigned int pointFlags; - R_TransformModelToClip( tri->verts[i].xyz, drawSurf->space->eyeModelViewMatrix[2], + R_TransformModelToClip( tri->verts[i].xyz, drawSurf->space->eyeViewMatrix[2], tr.viewDef->projectionMatrix, eye, clip ); pointFlags = 0;