To reduce shader state changes and compilations, just use the
four-bone-per-vertex configuration for all skinned meshes. Depending on the models we have, it may be worth compiling a separate one for two bones per vertex. Added a hook to customize the material color (for per-vertex colors, e.g.) git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@245 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -240,12 +240,8 @@ public abstract class ShaderConfig
|
||||
|
||||
// add snippets for each of the lights
|
||||
for (int ii = 0; ii < _lights.length; ii++) {
|
||||
LightConfig light = _lights[ii];
|
||||
if (light.type == Light.LT_POINT) {
|
||||
buf.append(POINT_LIGHT_SNIPPET.replace("%", Integer.toString(ii)));
|
||||
} else if (light.type == Light.LT_DIRECTIONAL) {
|
||||
buf.append(DIRECTIONAL_LIGHT_SNIPPET.replace("%", Integer.toString(ii)));
|
||||
}
|
||||
String snippet = getLightSnippet(_lights[ii].type);
|
||||
buf.append(snippet.replace("%", Integer.toString(ii)));
|
||||
}
|
||||
|
||||
// the alpha value comes from the diffuse color in the material
|
||||
@@ -281,6 +277,21 @@ public abstract class ShaderConfig
|
||||
ddefs.add(buf.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a code snippet that adds the influence of a light of the specified type (after
|
||||
* replacing '%' with the light index).
|
||||
*/
|
||||
protected String getLightSnippet (int type)
|
||||
{
|
||||
if (type == Light.LT_POINT) {
|
||||
return POINT_LIGHT_SNIPPET;
|
||||
} else if (type == Light.LT_DIRECTIONAL) {
|
||||
return DIRECTIONAL_LIGHT_SNIPPET;
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
/** The configuration of a single light in a {@link LightState}. */
|
||||
protected static class LightConfig
|
||||
implements Cloneable
|
||||
|
||||
Reference in New Issue
Block a user