• Create Account

#Actualbombshell93

Posted 24 March 2013 - 07:58 PM

okay I've given it a go and expanded the rendering engine in general, but I have a problem, for sake of testing I'm drawing 27 instances of a single model (which is fairly low poly), and my framerate is through the floor at 16 FPS.
the problem seems to be updating the vertex buffer (per second taking up over half of the second)
Here is the part taking up the most time, though its worth noting both rendering the shadow map and rendering the scene itself is taking up 12% of the second each too.


Model model = assetManager.getModel(m);
if (!buffers.ContainsKey(m) || models[m].Count > modelCount[m])
{
if (!buffers.ContainsKey(m))
{
}
else
buffers[m].Dispose();

modelCount[m] = models[m].Count;
if (modelCount[m] < 10)
modelCount[m] = 10;
buffers[m] = new DynamicVertexBuffer(graphicsDevice, vertexDeclaration,
modelCount[m], BufferUsage.None);
int i;
for (i = 0; i < models[m].Count; i++)
{
instances[m][i] = new Instance(models[m][i].transform,
camera, models[m][i].textureCoord);
models[m][i].index = i;
}
for (; i < modelCount[m]; i++)
{
instances[m][i] = new Instance(Matrix.CreateScale(0),
camera, Vector2.Zero);
}
buffers[m].SetData(instances[m]);
}
else
{
int i = 0;
for (i = 0; i < models[m].Count; i++)
{
instances[m][i].transform =
Matrix.Transpose(models[m][i].transform);
instances[m][i].worldViewIT =
Matrix.Transpose(Matrix.Invert(instances[m][i].transform * camera.View));
models[m][i].index = i;
}
//for (; i < modelCount[m]; i++)
//{
//	instances[i] = new Instance(Matrix.CreateScale(0), camera, Vector2.Zero);
//}

buffers[m].SetData(instances[m]);
}
}


I'm obviously doing something wrong but I'm not all that familiar with how to efficiently use instancing,
if anyone can spare some advice or references on the matter it would be a great help.

My mistake, my stopwatch was placed awkwardly giving me false times, I was also sending a bad value to the draw call telling it to draw thousands of instances.

#1bombshell93

Posted 24 March 2013 - 05:05 PM

okay I've given it a go and expanded the rendering engine in general, but I have a problem, for sake of testing I'm drawing 27 instances of a single model (which is fairly low poly), and my framerate is through the floor at 16 FPS.
the problem seems to be updating the vertex buffer (per second taking up over half of the second)
Here is the part taking up the most time, though its worth noting both rendering the shadow map and rendering the scene itself is taking up 12% of the second each too.


Model model = assetManager.getModel(m);
if (!buffers.ContainsKey(m) || models[m].Count > modelCount[m])
{
if (!buffers.ContainsKey(m))
{
}
else
buffers[m].Dispose();

modelCount[m] = models[m].Count;
if (modelCount[m] < 10)
modelCount[m] = 10;
buffers[m] = new DynamicVertexBuffer(graphicsDevice, vertexDeclaration,
modelCount[m], BufferUsage.None);
int i;
for (i = 0; i < models[m].Count; i++)
{
instances[m][i] = new Instance(models[m][i].transform,
camera, models[m][i].textureCoord);
models[m][i].index = i;
}
for (; i < modelCount[m]; i++)
{
instances[m][i] = new Instance(Matrix.CreateScale(0),
camera, Vector2.Zero);
}
buffers[m].SetData(instances[m]);
}
else
{
int i = 0;
for (i = 0; i < models[m].Count; i++)
{
instances[m][i].transform =
Matrix.Transpose(models[m][i].transform);
instances[m][i].worldViewIT =
Matrix.Transpose(Matrix.Invert(instances[m][i].transform * camera.View));
models[m][i].index = i;
}
//for (; i < modelCount[m]; i++)
//{
//	instances[i] = new Instance(Matrix.CreateScale(0), camera, Vector2.Zero);
//}

buffers[m].SetData(instances[m]);
}
}


I'm obviously doing something wrong but I'm not all that familiar with how to efficiently use instancing,
if anyone can spare some advice or references on the matter it would be a great help.

PARTNERS