KrisVDM Posted October 25, 2010 Author Share Posted October 25, 2010 Hmm, it seems that if users selects "Keep original image", then you just skip invisible parts of the shadow - this speeds things dramatically. Is that correct? Mostly. To be precise, when "keep original image" is on, I do an alpha blend of the original image over the shadow. The optimization is that I don't calculate the shadow if the alpha for the original pixel is 255, and just render the original pixel. I spent a lot of time over the years optimizing this. Various techniques are used. I guess the most important one is that I use partial evaluation. Basically, the first step of the process is to calculate the algorithm that will be executed, based on the parameter values. Then I execute that algorithm. For example, if the widening parameter is zero, the widening step isn’t in the algorithm being executed. The same is true for the blur step (and others). If widening and blur are both being used, I need what you could think of as an intermediate surface, but I need it only in that case. It simply isn’t there if at least one of those parameters is zero. The same is true for the “keep original image” functionality BTW. When that is off, the algorithm lacks the alpha blend step. Creating the algorithm on the fly yields a faster algorithm, because I don’t need “if” statements for every individual pixel, as might be the case in a static program. As it happens, I’ve done a lot of performance work over the last few months. Expect an even faster version soon. Quote Kris VandermottenDownload my Paint.NET Effects Link to comment Share on other sites More sharing options...
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.