I’ve been playing around with my models trying to see the affect Unshaded vs VertexLighting has on the performance of our app.
When I use Unshaded material, I get the following:
[java]
06-05 12:39:15.350 11310 11323 I mygame.Main: INFO Main 12:39:15 PM elapsedTime: 5.003, numFrames: 298, fps: 59.564, numVertices: 6,775, numTriangles: 3,133
06-05 12:39:15.998 10519 10519 D dalvikvm: GC_EXPLICIT freed 9K, 43% free 3082K/5379K, external 2357K/2773K, paused 35ms
06-05 12:39:19.162 11310 11314 D dalvikvm: GC_CONCURRENT freed 1358K, 56% free 4174K/9479K, external 3206K/3958K, paused 3ms+4ms
06-05 12:39:20.365 11310 11323 I mygame.Main: INFO Main 12:39:20 PM elapsedTime: 5.015, numFrames: 302, fps: 60.224, numVertices: 6,743, numTriangles: 3,117
[/java]
When I switch to use VertexLighting, I get the following:
[java]
06-05 12:41:16.857 11439 11460 I mygame.Main: INFO Main 12:41:16 PM elapsedTime: 5.021, numFrames: 205, fps: 40.827, numVertices: 12,522, numTriangles: 5,752
06-05 12:41:17.568 11439 11443 D dalvikvm: GC_CONCURRENT freed 1396K, 56% free 4234K/9543K, external 3197K/3958K, paused 2ms+3ms
06-05 12:41:19.631 11439 11443 D dalvikvm: GC_CONCURRENT freed 1381K, 56% free 4233K/9543K, external 3197K/3958K, paused 2ms+2ms
06-05 12:41:21.475 11344 11344 D dalvikvm: GC_EXPLICIT freed 118K, 44% free 3054K/5379K, external 2357K/2773K, paused 31ms
06-05 12:41:21.693 11439 11443 D dalvikvm: GC_CONCURRENT freed 1375K, 56% free 4233K/9543K, external 3197K/3958K, paused 2ms+3ms
06-05 12:41:21.873 11439 11460 I mygame.Main: INFO Main 12:41:21 PM elapsedTime: 5.015, numFrames: 203, fps: 40.478, numVertices: 12,522, numTriangles: 5,752
[/java]
I’m wondering if a 20fps hit is normal for Vertex Lighting and why the number of vertices double with Vertex Lighting. Is that normal?
@nehon - I’m not sure if this relates to this post or not, but the time between log entries for the frame rate is 5 sec. I captured all the GC log entries within that 5 seconds.
The objects are loaded via a j3o file imported from blender into the SDK using whatever material it defaults to (Lighting I believe).
The routine I’m using to enable unshaded or vertexlighting is the following (fyi, not sure if this is the right way or not):
[java]
public class GeometryUtils {
private static final Logger logger = Logger.getLogger(GeometryUtils.class.getName());
public static void switchToUnshaded(Spatial spatial) {
SceneGraphVisitorAdapter v = new SceneGraphVisitorAdapter() {
@Override
public void visit(Node node) {
}
@Override
public void visit(Geometry geometry) {
MatParam tmpMatParam = new MatParam();
ColorRGBA diffuseColor = new ColorRGBA();
AssetManager assetManager = geometry.getMaterial().getMaterialDef().getAssetManager();
Material tmpMaterial = geometry.getMaterial();
String materialDefName = tmpMaterial.getMaterialDef().getName();
if ((materialDefName != null) && (materialDefName.contains(“Lighting”))) {
tmpMatParam = tmpMaterial.getParam(“Diffuse”);
if (tmpMatParam != null) {
diffuseColor = ((ColorRGBA)tmpMatParam.getValue());
tmpMaterial = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
tmpMaterial.setColor(“Color”, diffuseColor);
}
if (geometry.getMaterial().getParam(“DiffuseMap”) != null) {
String diffuseMap = geometry.getMaterial().getParam(“DiffuseMap”).getValueAsString();
String textureMode = new String();
String textureName = new String();
if (diffuseMap.contains(“Repeat”)) {
textureMode = diffuseMap.substring(0,diffuseMap.lastIndexOf(" “));
textureName = diffuseMap.substring(diffuseMap.lastIndexOf(” ")+1);
} else {
textureMode = “Other”;
textureName = diffuseMap;
}
TextureKey key = new TextureKey(textureName,false);
key.setGenerateMips(true);
Texture tex = assetManager.loadTexture(key);
if (textureMode.equals(“Repeat”)) {
tex.setWrap(WrapMode.Repeat);
}
tmpMaterial.setTexture(“ColorMap”, tex);
}
geometry.setMaterial(tmpMaterial);
}
}
};
spatial.breadthFirstTraversal(v);
}
public synchronized static void enableVertexLighting(Spatial spatial) {
SceneGraphVisitorAdapter v = new SceneGraphVisitorAdapter() {
@Override
public void visit(Node node) {
}
@Override
public void visit(Geometry geometry) {
Material tmpMaterial = geometry.getMaterial();
String materialDefName = tmpMaterial.getMaterialDef().getName();
if ((materialDefName != null) && (materialDefName.contains(“Lighting”))) {
tmpMaterial.setBoolean(“VertexLighting”, true);
tmpMaterial.setReceivesShadows(false);
}
}
};
spatial.breadthFirstTraversal(v);
}
}
[/java]
You probably have 2 lights in your scene.
Geometries are rendered once per light. Unshaded does not use lights.
Try to use only one light.
This GC thing really bothers me…