"It is more blessed to give than to receive."
- Acts 20:35

Updated the particle trimmer
Sunday, May 24, 2009 | Permalink

I've made the particle trimmer a bit more robust, a bit faster, and added a few extra features. I also made it handle some cases with a perfect circle better where you get a lot of edges in the convex hull. Before attempting to find the optimal polygon it'll reduce the hull size to at most a provided number of edges (default is 50), which should make it complete in a relatively short amount of time even for 8 vertices. The reduction in efficiency of doing this is either zero or in the worst case a tiny fraction of a percentage point in my tests.
The tool can now also scale and bias the result to put the coordinate in the range you want it or perhaps just to flip the y coordinate.
I've also added a dilate filter option so that the texture can initially be dilated a specified number of times. This could be useful if there's a sharp edge rather than a smooth gradient towards the threshold value and the texture is filtered and/or mipmapped, in which case you might need a more conservative trimming to not get a visible cut.
The tool should now also handle non-square textures better and the computations are now done in texel units rather than in normalized coordinates. Normalization is instead done on the final results, which are then scaled and biased with the provided values.

Update 2009-05-27:
I've updated the tool again because the last release was kind of broken with atlases. It should now work properly.

Name

Comment

Enter the code below



LogicalError
Monday, May 25, 2009

Just a crazy idea, would it be useful to differentiate between semi-transparent and completely non-transparent pixels? the fully non-transparent triangles could be drawn in a separate pass.. just a random (probably bad) idea

Humus
Tuesday, May 26, 2009

I suppose. Could be good as a pre-Z pass if you have lots of overdraw. That would require a different algorithm though since we would then be looking to find the largest convex polygon that's completely inside the particle.

Jackis
Wednesday, May 27, 2009

This full non transparent part of texture may be multiplied then by attenuated alpha of fading smoke or whatever, so it wouldn't help. Only with particles, whose alphas aren't getting modulated by some evaluated attenuation, and that's not very common case.

Humus
Thursday, May 28, 2009

On the other hand, you could in your pre-z pass only render particles that also have attenuation alpha >= 1.0.

Remage
Tuesday, July 7, 2009

Also, rendering particles in pre-z pass might affect the shading of other particles if the depth-buffer is used (soft-particles, for example).