support multipass env mapping for systems without multitexturing

This commit is contained in:
Glenn Maynard
2005-01-04 05:38:44 +00:00
parent a1be0fdb33
commit 32bb778e22
+38 -13
View File
@@ -344,18 +344,43 @@ void Model::DrawPrimitives()
DISPLAY->TextureTranslate( fScrollX, fScrollY, 0 ); DISPLAY->TextureTranslate( fScrollX, fScrollY, 0 );
} }
// render the first pass with texture 1 /* There's some common code that could be folded out here, but it seems
DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() ); * clearer to keep it separate. */
DISPLAY->SetSphereEnironmentMapping( mat.diffuse.m_bSphereMapped ); if( DISPLAY->GetNumTextureUnits() < 2 )
// render the second pass with texture 2
if( mat.alpha.GetCurrentTexture() )
{ {
DISPLAY->SetTexture( 1, mat.alpha.GetCurrentTexture() ); // render the diffuse texture
DISPLAY->SetSphereEnironmentMapping( mat.alpha.m_bSphereMapped ); DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() );
// UGLY: This overrides the Actor's BlendMode DISPLAY->SetSphereEnironmentMapping( mat.diffuse.m_bSphereMapped );
DISPLAY->SetTextureModeAdd(); DrawMesh( i );
DISPLAY->SetTextureFiltering( true );
// render the additive texture
if( mat.alpha.GetCurrentTexture() )
{
DISPLAY->SetTexture( 0, mat.alpha.GetCurrentTexture() );
DISPLAY->SetSphereEnironmentMapping( mat.alpha.m_bSphereMapped );
// UGLY: This overrides the Actor's BlendMode
DISPLAY->SetBlendMode( BLEND_ADD );
DISPLAY->SetTextureFiltering( true );
DrawMesh( i );
}
}
else
{
// render the diffuse texture with texture unit 1
DISPLAY->SetTexture( 0, mat.diffuse.GetCurrentTexture() );
DISPLAY->SetSphereEnironmentMapping( mat.diffuse.m_bSphereMapped );
// render the additive texture with texture unit 2
if( mat.alpha.GetCurrentTexture() )
{
DISPLAY->SetTexture( 1, mat.alpha.GetCurrentTexture() );
DISPLAY->SetSphereEnironmentMapping( mat.alpha.m_bSphereMapped );
DISPLAY->SetTextureModeAdd();
DISPLAY->SetTextureFiltering( true );
}
/* go */
DrawMesh( i );
} }
} }
else else
@@ -368,11 +393,11 @@ void Model::DrawPrimitives()
DISPLAY->SetMaterial( emissive, ambient, diffuse, specular, shininess ); DISPLAY->SetMaterial( emissive, ambient, diffuse, specular, shininess );
DISPLAY->ClearAllTextures(); DISPLAY->ClearAllTextures();
DISPLAY->SetSphereEnironmentMapping( false ); DISPLAY->SetSphereEnironmentMapping( false );
DrawMesh( i );
} }
DrawMesh( i );
DISPLAY->SetSphereEnironmentMapping( false ); DISPLAY->SetSphereEnironmentMapping( false );
DISPLAY->SetBlendMode( BLEND_NORMAL );
DISPLAY->TexturePopMatrix(); DISPLAY->TexturePopMatrix();
} }
} }