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
+56
View File
@@ -0,0 +1,56 @@
//
// $Id: ImageCache.java 158 2007-02-24 00:38:17Z mdb $
//
// Nenya library - tools for developing networked games
// Copyright (C) 2002-2007 Three Rings Design, Inc., All Rights Reserved
// http://www.threerings.net/code/nenya/
//
// This library is free software; you can redistribute it and/or modify it
// under the terms of the GNU Lesser General Public License as published
// by the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
/** The diffuse texture map. */
uniform sampler2D diffuseMap;
/** The emissive texture map. */
#ifdef EMISSIVE_MAPPED
uniform sampler2D emissiveMap;
#endif
/** The amount of fog. */
#ifdef FOG
varying float fogAlpha;
#endif
/**
* Fragment shader for skinned meshes.
*/
void main ()
{
// start with the diffuse color
vec4 fragColor = texture2D(diffuseMap, gl_TexCoord[0].st);
// modulate by the light color
#ifdef EMISSIVE_MAPPED
fragColor *= (gl_Color + vec4(texture2D(emissiveMap, gl_TexCoord[0].st).rgb, 0.0));
#else
fragColor *= gl_Color;
#endif
// blend between the computed color and the fog color
#ifdef FOG
gl_FragColor = mix(gl_Fog.color, fragColor, fogAlpha);
#else
gl_FragColor = fragColor;
#endif
}
+8 -3
View File
@@ -38,6 +38,11 @@ attribute ATTRIB_TYPE boneIndices;
/** The bone weights. */
attribute ATTRIB_TYPE boneWeights;
/** The amount of fog. */
#ifdef FOG
varying float fogAlpha;
#endif
/**
* Vertex shader for skinned meshes.
*/
@@ -65,12 +70,12 @@ void main ()
vec3 eyeVertex = vec3(gl_ModelViewMatrix * modelVertex);
vec3 eyeNormal = normalize(vec3(gl_ModelViewMatrixInverseTranspose * modelNormal));
// eye space 'z' is the standard fog coordinate
gl_FogFragCoord = -eyeVertex.z;
// set gl_FrontColor based on vertex, normal and light parameters
SET_FRONT_COLOR
// set the varying texture coordinates
SET_TEX_COORDS
// set the fog alpha based on the eye space vertex
SET_FOG_ALPHA
}