OpenGL2: Fix black planar projection shadows (cg_shadows 3)

Restore MD3 code for cg_shadows 2 and 3 like other model formats.
Fix planar projection shadow deform (cg_shadows 3) to use correct
light direction. I fixed light direction for stencil shadows
(cg_shadows 2) but it's still broken.
This commit is contained in:
Zack Middleton 2017-06-30 13:48:38 -05:00
parent 09a23e0417
commit 102c79eb49
2 changed files with 23 additions and 7 deletions

View File

@ -385,12 +385,28 @@ void R_AddMD3Surfaces( trRefEntity_t *ent ) {
shader = tr.shaders[ surface->shaderIndexes[ ent->e.skinNum % surface->numShaderIndexes ] ];
}
// don't add third_person objects if not viewing through a portal
if(!personalModel)
{
srfVaoMdvMesh_t *vaoSurface = &model->vaoSurfaces[i];
// we will add shadows even if the main object isn't visible in the view
R_AddDrawSurf((void *)vaoSurface, shader, fogNum, qfalse, qfalse, cubemapIndex );
// stencil shadows can't do personal models unless I polyhedron clip
if ( !personalModel
&& r_shadows->integer == 2
&& fogNum == 0
&& !(ent->e.renderfx & ( RF_NOSHADOW | RF_DEPTHHACK ) )
&& shader->sort == SS_OPAQUE ) {
R_AddDrawSurf( (void *)&model->vaoSurfaces[i], tr.shadowShader, 0, qfalse, qfalse, 0 );
}
// projection shadows work fine with personal models
if ( r_shadows->integer == 3
&& fogNum == 0
&& (ent->e.renderfx & RF_SHADOW_PLANE )
&& shader->sort == SS_OPAQUE ) {
R_AddDrawSurf( (void *)&model->vaoSurfaces[i], tr.projectionShadowShader, 0, qfalse, qfalse, 0 );
}
// don't add third_person objects if not viewing through a portal
if ( !personalModel ) {
R_AddDrawSurf((void *)&model->vaoSurfaces[i], shader, fogNum, qfalse, qfalse, cubemapIndex );
}
surface++;

View File

@ -162,7 +162,7 @@ void RB_ShadowTessEnd( void ) {
return;
}
VectorCopy( backEnd.currentEntity->lightDir, lightDir );
VectorCopy( backEnd.currentEntity->modelLightDir, lightDir );
// project vertexes away from light direction
for ( i = 0 ; i < tess.numVertexes ; i++ ) {
@ -302,7 +302,7 @@ void RB_ProjectionShadowDeform( void ) {
groundDist = backEnd.or.origin[2] - backEnd.currentEntity->e.shadowPlane;
VectorCopy( backEnd.currentEntity->lightDir, lightDir );
VectorCopy( backEnd.currentEntity->modelLightDir, lightDir );
d = DotProduct( lightDir, ground );
// don't let the shadows get too long or go negative
if ( d < 0.5 ) {