#Models receive shadows now, including self-shadows.

This is a huge patch, including:
* add a LitRenderModifier abstract base class for RenderModifiers with
  shadow+light
* add LitRenderModifiers for all types of models
* add STREAM_TEXGENTOUV1 to request generation of shadow map texcoords
  for models
* create facilities to pass the texture matrix from the
  RenderModifier (fragment stage) to the ModelRenderer (vertex stage)
* split ambient and diffuse terms of lighting until further down in the
  pipeline; this is necessary since shadowed regions receive only
ambient light
* small improvement in how RenderPathVertexShader scales to a greater
  number of vertex shaders

This was SVN commit r3690.
This commit is contained in:
prefect
2006-03-26 00:54:20 +00:00
parent 0bd5778536
commit e2bbd9a654
28 changed files with 1292 additions and 330 deletions
+27 -8
View File
@@ -149,7 +149,8 @@ void ModelRenderer::BuildPositionAndNormals(
void ModelRenderer::BuildColor4ub(
CModel* model,
VertexArrayIterator<CVector3D> Normal,
VertexArrayIterator<SColor4ub> Color)
VertexArrayIterator<SColor4ub> Color,
bool onlyDiffuse)
{
PROFILE( "lighting vertices" );
@@ -159,13 +160,27 @@ void ModelRenderer::BuildColor4ub(
CColor shadingColor = model->GetShadingColor();
RGBColor tempcolor;
for (uint j=0; j<numVertices; j++)
if (onlyDiffuse)
{
lightEnv.EvaluateUnit(Normal[j], tempcolor);
tempcolor.X *= shadingColor.r;
tempcolor.Y *= shadingColor.g;
tempcolor.Z *= shadingColor.b;
*(u32*)&Color[j] = ConvertRGBColorTo4ub(tempcolor);
for (uint j=0; j<numVertices; j++)
{
lightEnv.EvaluateDirect(Normal[j], tempcolor);
tempcolor.X *= shadingColor.r;
tempcolor.Y *= shadingColor.g;
tempcolor.Z *= shadingColor.b;
*(u32*)&Color[j] = ConvertRGBColorTo4ub(tempcolor);
}
}
else
{
for (uint j=0; j<numVertices; j++)
{
lightEnv.EvaluateUnit(Normal[j], tempcolor);
tempcolor.X *= shadingColor.r;
tempcolor.Y *= shadingColor.g;
tempcolor.Z *= shadingColor.b;
*(u32*)&Color[j] = ConvertRGBColorTo4ub(tempcolor);
}
}
}
@@ -451,8 +466,12 @@ void BatchModelRenderer::Render(RenderModifierPtr modifier, u32 flags)
do
{
uint streamflags = modifier->BeginPass(pass);
const CMatrix3D* texturematrix = 0;
m->vertexRenderer->BeginPass(streamflags);
if (streamflags & STREAM_TEXGENTOUV1)
texturematrix = modifier->GetTexGenMatrix(pass);
m->vertexRenderer->BeginPass(streamflags, texturematrix);
m->RenderAllModels(modifier, flags, pass, streamflags);