So some more testing tonight. To get some idea of what it takes to choke a pixel shader, we made a bunch of animated circles. There is again only two triangles here (which draw the the background), and all animation/rendering is done by checking the x,y of a pixel against some set of data, and rendering its color accordingly.
In this case the data is a bunch of animation 2D points, and the formula checks if the distance from its pixel to one of the points is within a certain bounds (using distance, ouch). If it is close enough it flips the color, if not it leaves it alone. This creates a bunch of bouncing circles.
float4 CircleShader (VertexToPixel PSIn) : Color0
{
float4 result = PSIn.Color;
float dist = 0.05f;
for(int i = 0; i < circleCount; i++)
{
if( distance(points[i], PSIn.TexCoord) < dist)
{
result = 1.0f - result;
}
}
return result;
}
First, let me just say in spite of this choking after about 20 circles, it is a-m-a-z-i-n-g the amount of grief you can send at a video card without a hiccup. This formula is run on every pixel on the screen, going over every point in the array, many times a second. Alas all good things have limits, and at first blush it seems the limit for this technique will be well short of Flash style animation.
ZMan sent along a very interesting link, to a paper from MS labs where they are still using triangles, but they are based on quadratic bezier data, and the edges are 'rounded' to fit the curves. This seems somewhat more hopeful, but I'd still like to at least do a brickout game or something with this technique : ).
Download sample project
|
|
Works like a champ.
|
Chokes like a bastard.
|
posted on Thursday, July 19, 2007 5:34 AM