Page 1 of 1

Advice needed for Game 3D Model Design

Posted: Fri Dec 02, 2005 9:33 am
by sphinkie
Hi

We have designe a nice spaceship for our game, but we have some framerate issue with some objects.

For example, we have in the scene :
  • - Space Ship = object with a simple material : colormap (10.000 poly)
    - A nearby planet = Objects with a complex material (hlsl) : colormap + normalmap (2.000 poly)
    - The Ship Engine = Objects with more complex material : colormap + normalmap+specularmap+shadowmap (20.000 poly)
When all objects are textured with only a colormap (30.000 poly), the framerate is OK, but when whe use the vertex programs, the camera freezes several seconds every time a new object enters the field of view.

Also (because of blender), the textures are not tiled, but large and covering the entire object.

I would like to know what is recommended ?

- Should we lower the number of polygons of the scene ?
- Should we texture hi-poly with a simple colormap, and only low-poly with multi-texture colormap ?
- should we reduce the size of the texture ?
- Should we use the same shader for all the objects ?

Also we notice that in Blender an object may have 16.000 triangles, and ogre says 30.000.
Does Ogre counts the triangle twice if they have multi-texture ?

Thanks for your advice.

PS:
(I can post some screenshots, or the shader code, if needed)

Posted: Fri Dec 02, 2005 10:53 am
by Lee04
I think you should be able to push out 1 million polys on a modern card
with not so many tricks.

The lates ATI demo succeds in pushing out virtually displaying 15 million
polys by lodding and streaming from the disk. In there new temple scene demo. Very amazing demo the technology is freely avaliable from them.

I would like to see it incorperated in Ogre :) some one up for a challange?

I saw this demo in Seoul.


cheers

Lee04

Posted: Fri Dec 02, 2005 5:53 pm
by Rixeh
The difference in polys is because blender counts quads (squares) as 1 poly, and Ogre counts a poly as a triangle. Everything is triangulated when it loads in ogre, so each square gets cut in two and you get double the number. I *believe* when people talk about "poly count", they mean the number of triangles and not the number of quads.

Posted: Fri Dec 02, 2005 11:22 pm
by Jerky
It could be the quads/tri thing, ot it could be multiple passes. Are you using any shaders in your materials? Multiple passes = multiple times of the same poly number.

Posted: Sat Dec 03, 2005 10:06 am
by Lee04
Multiple passes = multiple times of the same poly number.
Yes, if you put several passes of shaders into one shader (ubershader) then you are back on the same poly count and you can render even more.
But that works only on Nvidia 6800 that has MRT Multiple Render Targets for temporal storage of the passes... but can be well spent optimization for some applications.

Posted: Mon Dec 05, 2005 10:07 am
by sphinkie
Yes, we use the following shader (that comes from the ogre forum):
but I don't know how many passes it takes:

Code: Select all

// FxMap vertex shader  : FXMap_HLSL.vert

float4x4 worldViewProj_matrix; 
float3 lightPosition; 
float3 eyePosition;

struct VS_OUTPUT 
{
  float4 Pos : POSITION;
  float2 UV : TEXCOORD0; 
  float3 LightDir : TEXCOORD1; 
  float3 HalfAngle : TEXCOORD2; 
}; 

VS_OUTPUT main(float4 Pos : POSITION, float2 Tex : TEXCOORD0, float3 Normal : NORMAL, float3 Tangent : TEXCOORD1 ) 
{ 
  VS_OUTPUT Out = (VS_OUTPUT)0; 
  // transform Position 
  Out.Pos = mul(worldViewProj_matrix, Pos); 

  Out.UV = Tex.xy; 

  // calculate tangent space light vector 
  // Get object space light direction 
  float3 lightDir = lightPosition - Pos.xyz; 
  float3 eyeDir = eyePosition - Pos.xyz; 

  // compute the 3x3 tranform matrix 
  // to transform from object space to tangent space 
  float3x3 rotation; 
  rotation[0] = Tangent; 
  // calculate the binormal (NB we assume both normal and tangent are 
  // already normalised) 
  rotation[1] = cross(Tangent, Normal); 
  rotation[2] = Normal; 

  // rotate the light and eye vectors according to tangent space rotation matrix 
  lightDir = normalize(mul(rotation, lightDir)); 
  eyeDir = normalize( mul(rotation, eyeDir) ); 

  Out.LightDir = lightDir; 
  Out.HalfAngle = normalize(eyeDir + lightDir); 

  return Out; 
} 
and

Code: Select all

// Fx Map pixel shader : FXMap_HLSL.frag

float4 ambientColor; 
sampler normalMap; 
sampler diffuseMap; 
sampler fxMap; 
/* 
  Fx Map has the following data in the color channels 
  RED: specular intensity 
  GREEN: specular size (power exponent) 
  BLUE: diffuse intensity 
  ALPHA: ambient/emmisive intensity (optional) 
*/ 

float diffuse(float3 LightDir, float3 N, float diffLevel) 
{ 
  return max(dot(normalize(LightDir), N), 0.0) * diffLevel; 
} 

float specular(float3 HalfAngle, float3 N, float specLevel, float specPower) 
{ 
  return specLevel * pow(max( dot( normalize(HalfAngle), N), 0.0), 128.0 * specPower ) ; 
} 


float4 main(float2 UV: TEXCOORD0, float3 LightDir : TEXCOORD1, 
float3 HalfAngle : TEXCOORD2) : COLOR 
{ 
  float4 texdiff = tex2D(diffuseMap, UV); 
  // expand the normal vector from the normal map form 0..1 to -1..1 
  float3 N = tex2D(normalMap, UV).xyz * 2 - 1; 
  float4 fxVals = tex2D(fxMap, UV); 

  return texdiff * (ambientColor * fxVals.w + diffuse(LightDir, N, fxVals.z)) + specular(HalfAngle, N, fxVals.x, fxVals.y); 
} 
Lee: 1 million polygon: are you joking or serious ?

Posted: Wed Dec 07, 2005 11:09 am
by KO
I think he's very serious.