Because the first draft of this project has become so popular, I’ve gone ahead and built a new and MUCH faster version. Updates include: DIB sections for flame drawing, look-up tables, optimized randomization, and custom flame coloring. On my old 1.6ghz laptop this version runs over 4x faster than version 1.0. Enjoy!
Whether working on an old-school RPG or a state-of-the-art FPS, every game programmer needs a fast, cool fire effect at some point in his/her career. In this example, I’ve opted for a straightforward and easy-to-understand method for generating real-time flames. No pre-built images or palettes are used, making the code quite small (only 11kb, including a demo exe) and very easy to reuse. Coloring and flame generation is done using only math and a little cleverness…
Real-time transparency has become so commonplace in modern games and PC applications that it’s almost taken for granted. However, the specific formula that performs this now-ubiquitous effect is worth understanding. Transparency is simply a weighted average between the color values of two pixels. As an example, consider the following two colors: Pure red, or RGB(255, [...]
Color shifting is a very fast, very simple effect that can greatly simplify the work of game artists. (Above is a demonstration using a classic StarCraft Siege Tank.) It is also extremely simple to implement – all we do is shift the red, green, and blue values of each pixel to the right or left. This allows us to generate two additional color variations on a source image without any extra work. (Read the rest of the article for details and sample code…)
Because gray-toned values have RGB values that are identical (or nearly identical), color shifting doesn’t change the appearance of gray pixels. This is pretty clear on the siege tanks above, as the color shifting merely adjusted the subtle hues of the gray regions…
This is one of my all-time favorite image effects – a simulated blacklight that looks GREAT on any image with people in it. I invented this algorithm myself, and the provided code will allow you to test the effect in real-time on any image below 2MB. (The sample image is Squall from FF8 – the greatest RPG ever made, btw…)
This is the first of its kind in VB: accurate, real-time image level adjustment. Image levels provide better control over luminance than strict brightness/contrast methods, but not quite as much control as a well-built Curves Dialog. Adjusting an image using input/output/midtone levels is useful for brightening or darkening an image without losing detail at either end of the luminance spectrum. I’ve included simple histogram drawing code (as the screenshot shows) so you can see the effect that adjusting levels has on an image’s histogram. The code is well-commented and fast – please post comments and/or requests for future VB graphics projects.
By request, here is the first of its kind in VB: a fast, accurate, real-time image curves dialog. (This should be familiar to any PhotoShop users out there :) Curves is similar in theory both “Image Levels” post and standard gamma correction, but it provides a much more powerful interface for adjusting the luminance of an image. This project provides results very similar to Photoshop’s, and it allows the creation of more spline knots (32 instead of 16). The code is well-commented and very fast – please post comments, requests for future Photoshop-related code, and many heaps of praise (as this was a complicated routine to sort out…)!
This program demonstrates how to create a smooth color gradient between any two colors on any size of form. While gradients are often used for visual effects, perhaps the most useful aspect of this project is the gradient algorithm itself. Many other algorithms (like image resampling) use variations of the gradient algorithm – so learn [...]
Resampling uses specialized interpolation algorithms when resizing an image to minimize any negative impacts to image quality. For example, when you resize a 50×50 image to 500×500, the image looks horrible – like a bunch of giant squares. Resampling reduces that “blockiness” by interpolating pixels, so the image looks rounded even after being resized. If [...]
Here’s the first (and still the best!) VB-based example that demonstrates how to correctly adjust an image’s contrast. I use DIB sections to maximize speed; it’s also worth mentioning that to perfectly determine contrast, you would have to first find the average brightness of the image – I use the shortcut method and assume that [...]