Use a fragment shader as well as a vertex shader for the skinned meshes.

I tracked the ATI slowdown down to using a vertex shader in combination 
with fixed function fog.  Also cleaned up ShaderConfig a little.


git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@244 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
Andrzej Kapolka
2007-05-14 20:13:39 +00:00
parent 6b07087c31
commit 124af1e0b1
4 changed files with 151 additions and 26 deletions
@@ -408,7 +408,7 @@ public class SkinMesh extends ModelMesh
if (bonesPerVertex > MAX_SHADER_BONES_PER_VERTEX) {
return;
}
_sconfig = new SkinShaderConfig(scache, bonesPerVertex);
_sconfig = new SkinShaderConfig(scache, bonesPerVertex, _emissiveMap != null);
if (_sconfig.update(getBatch(0).states)) {
setShaderAttributes();
setRenderState(_sconfig.getState());
@@ -647,10 +647,19 @@ public class SkinMesh extends ModelMesh
/** Tracks the configuration of a skin shader. */
protected static class SkinShaderConfig extends ShaderConfig
{
public SkinShaderConfig (ShaderCache scache, int bonesPerVertex)
public SkinShaderConfig (ShaderCache scache, int bonesPerVertex, boolean emissiveMapped)
{
super(scache);
_bonesPerVertex = bonesPerVertex;
_emissiveMapped = emissiveMapped;
// set bindings from texture units to samplers
if (emissiveMapped) {
_state.setUniform("diffuseMap", 1);
_state.setUniform("emissiveMap", 0);
} else {
_state.setUniform("diffuseMap", 0);
}
}
public int getBonesPerVertex ()
@@ -664,11 +673,20 @@ public class SkinMesh extends ModelMesh
return "media/jme/skin.vert";
}
@Override // documentation inherited
protected String getFragmentShader ()
{
return "media/jme/skin.frag";
}
@Override // documentation inherited
protected void getDefinitions (ArrayList<String> defs)
{
super.getDefinitions(defs);
defs.add("BONES_PER_VERTEX " + _bonesPerVertex);
if (_emissiveMapped) {
defs.add("EMISSIVE_MAPPED");
}
}
@Override // documentation inherited
@@ -679,6 +697,7 @@ public class SkinMesh extends ModelMesh
}
protected int _bonesPerVertex;
protected boolean _emissiveMapped;
}
/** A stored frame used for linear blending. */