1) Manipulate the bits of the image directly in memory as an array of bytes (or int / whatever, depending on your target color depth). Do not use anything that GetsPixel () from the image every time.
2) Minimize your math. For plasma effects, you usually use a lot of trigger functions, which are pretty slow when you do them (heightwidthframerate) once per second. Either use the fast dedicated math library for your calories or, even better, cache the calculations at the beginning and use the lookup table during the effect to completely cut out the math from each frame.
3). One of the things that made the effects of the old-school plasma so fast was the palette. I don’t know how to replicate this (or the palettes in general) using SFML directly, but you can use GLSL shaders to get the same result without a big increase in performance. Something like that:
float4 PS_ColorShift(float2 Tex : TEXCOORD0) : COLOR0
{
float4 color = tex2D(colorMap, Tex);
color.r = color.r+sin(colorshift_timer+0.01f);
color.g = color.g+sin(colorshift_timer+0.02f);
color.b = color.b+sin(colorshift_timer+0.03f);
color.a = 1.0f;
saturate(color);
return color;
}
source
share