If i turn the camera away from the geometry so that nothing is visible FPS increases up to 30 and GPU idle time is 20-25%
Here is the code of my shaders:
/*VERTEX_PROGRAM*/
varying vec2 TexCoord0;
varying vec2 TexCoord1;
varying vec4 TexCoord2;
varying vec3 Normal;
varying vec3 Tangent;
varying vec3 Binormal;
varying vec3 LightDir;
varying vec3 VertexPosition;
uniform mat4 SHADOW_PROJECTION;
void main()
{
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
TexCoord0 = vec2(gl_MultiTexCoord0);
TexCoord1 = vec2(gl_MultiTexCoord1);
TexCoord2 = SHADOW_PROJECTION * gl_ModelViewMatrix * gl_Vertex;
VertexPosition = vec3(gl_Vertex);
LightDir = vec3(gl_ModelViewMatrix * vec4(0.08248, 0.08249, -0.816497, 0.0) );
/* Compute fake tangent space */
Normal = vec3( 0.0, 0.0, 1.0 );
Binormal = normalize(cross(Normal + vec3(3.0,2.0,1.0), Normal));
Tangent = normalize(cross(Normal, Binormal));
}
/*FRAGMENT_PROGRAM*/
uniform sampler2D Texture0; /* diffuse */
uniform sampler2D Texture1; /* lightmap */
uniform sampler2D Texture2; /* shadow map */
uniform sampler2D Texture3; /* detail blending */
uniform sampler2D Texture4; /* detail1 */
uniform sampler2D Texture5; /* detail2 */
uniform sampler2D Texture6; /* detail3 */
uniform sampler2D Texture7; /* detail4 */
varying vec2 TexCoord0;
varying vec2 TexCoord1;
varying vec4 TexCoord2;
varying vec3 Normal;
varying vec3 Tangent;
varying vec3 Binormal;
varying vec3 LightDir;
varying vec3 VertexPosition;
vec4 Ambient;
vec4 Diffuse;
uniform vec4 LIGHT_POS;
void PointLight(vec3 BumpNormal)
{
/* Compute vector from surface to light position */
vec3 VP = vec3(LIGHT_POS) - VertexPosition;
/* Compute distance between surface and light position */
float d = length(VP);
/* Normalize the vector from surface to light position */
VP = normalize(VP);
/* Compute attenuation */
float constAttenuation = 0.01;
float linearAttenuation = 0.001;
float quadraticAttenuation = 0.002;
float attenuation = 1.0 / (constAttenuation +
linearAttenuation * d +
quadraticAttenuation * d * d);
float nDotVP = max(0.0, dot(BumpNormal, VP));
vec4 ambient = vec4( 0.05, 0.01, 0.05, 0.0 );
vec4 diffuse = vec4( 0.5, 0.1, 0.7, 0.0 );
Ambient += ambient * attenuation;
Diffuse += diffuse * nDotVP * attenuation;
}
void main()
{
Ambient = vec4( 0.0, 0.0, 0.0, 0.0 );
Diffuse = vec4( 0.0, 0.0, 0.0, 0.0 );
vec2 Coord = vec2( TexCoord0.x, 1.0 - TexCoord0.y );
vec4 Color = texture2D( Texture0, Coord );
vec4 Lightmap = texture2D( Texture1, Coord );
vec4 DetailBlend = texture2D( Texture3, Coord );
vec3 BumpMap = - (vec3(texture2D(Texture5, Coord)) * 2.0 - 1.0);
BumpMap = BumpMap.x * normalize(Tangent.xyz) +
BumpMap.y * normalize(Binormal.xyz) +
BumpMap.z * normalize(Normal.xyz);
vec3 lightDir = normalize(LightDir);
vec3 normal = normalize( BumpMap );
PointLight( normal );
float diffuse = max( 0.0, 0.4 * dot(lightDir, normal) ) + 0.6;
/* calculate details */
vec4 Detail1 = texture2D( Texture4, TexCoord1*0.25 );
vec4 Detail2 = texture2D( Texture5, TexCoord1*0.2 );
vec4 Detail3 = texture2D( Texture6, TexCoord1*0.3 );
vec4 Detail4 = texture2D( Texture7, TexCoord1*0.05 );
float Sum = dot( DetailBlend, vec4( 1.0, 1.0, 1.0, 1.0 ) );
if ( Sum < 1.0 ) Sum = 1.0;
vec4 Detail = ((DetailBlend.x * Detail1 +
DetailBlend.y * Detail2 +
DetailBlend.z * Detail3)*1.4 +
DetailBlend.w * Detail4*0.6) / Sum;
Detail = Detail - vec4( 0.5, 0.5, 0.5, 0.0 );
gl_FragColor = ( diffuse + Diffuse ) * 0.9 * Color * Lightmap + 0.25*Detail;
}