Maarten Baert's website

Game Maker / C++ projects

Home Model Creator ExtremePhysics Game Maker DLLs SimpleScreenRecorder AlterPCB Quadcopters   Recent comments Search

Last modified: Fri, 12 Mar 2010
Refresh

The renderer

Image: rendered-sphere.png

A model of a sphere rendered with the renderer

The renderer is a very powerful tool. It allows you to create perfect 2D sprites using 3D models. This is very useful when creating an isometric game, as this will create all the subimages at once. The renderer uses a parallel raytracing algorithm, which is a lot slower than DirectX, but is also a lot more precise. The renderer is more advanced than GM's 3D functions: it supports ambient, directional and specular lighting, and it uses per-pixel lighting. The renderer can also use anti-aliasing and can create alpha masks (the real alpha value of the pixels - not just 1 or 0). The renderer saves the result as a 32-bit BMP file with alpha channel (which can be loaded directly using sprite_add_alpha), and the alpha mask as a 24-bit BMP file.

The actual rendering is done in a DLL because GM is way too slow. Because of this, Model Creator will freeze while rendering. If the rendering takes very long, it is even possible that Windows shows a 'not responding' message. If this happens, just ignore it: the program will respond again as soon as the rendering is finished.

Image: renderer-screen.png

Origin X, Origin Y

This setting sets the position of the origin on the sprite. The model will be translated so the origin of the model will be at this position. Most of the time this should be the center of the sprite.

Width, Height

Sets the size of the sprite.

Frames, Frames/row

Sets the total number of frames that should be rendered. Frames/row indicates the number of images per row in the strip.

Ambient lighting color

The color of the ambient lighting. This light will be applied to all parts of the model, so the model will not be completely black if it isn't lighted. Set this to (0,0,0) if you don't want to use ambient lighting.

Directional lighting color

The color of the directional (normal) lighting. Set this to (0,0,0) if you don't want to use directional lighting.

Specular lighting color

The color of the specular lighting. This color indicates the color and intensity of the highlights. Very shiny materials have stronger highlights. Set this to (0,0,0) if you don't want to use specular lighting.

Specular exponent

This indicates the size of the highlights. The higher this value, the smaller the highlights will be. Very smooth materials (like gold and silver) have smaller (and stronger) highlights, softer materials (like plastic) have larger (and softer) highlights.

Transparent color

This indicates the color that will be used for transparent areas of the sprite. If you are using the alpha mask, this is not important, but if you are using single color transparency you should set this to a color that is not used in the sprite itself.

Scale

The model will be scaled with this factor. If you set this to one, the original size of the model is used (one unit equals one pixel).

Camera longitude, Camera latitude, Camera longitude increment

This indicates the camera direction. Longitude indicates the horizontal directiong, latitude indicates the elevation. The camera longitude will be incremented by the third value each frame. This way you can make rotation sequences. Note that the camera distance is not relevant as the renderer uses a parallel projection.

Light longitude, Light latitude, Light longitude increment

This indicates the direction of the directional light. The values are the same as for the camera. This means you can also create different subimages for different lighting angles. If you are already rotating the camera, you probably want to rotate the light the same way (this is done in most professional games).

Samples

This indicates the number of samples taken on each axis. The more samples you set, the better the edges of the model will be rendered. Be careful with this setting, though: setting this to 3 will create 3*3=9 samples for each pixel, meaning the rendering will be 9 times slower!

Jitter, seed value

Jitter will add some randomness to the coordinates of the samples. This can help to avoid artifacts near the edges of the model. The seed value will be used to generate the random numbers (most of the time this is not important).

Compensate for alpha

If this is switched on, the color of the pixels will be divided by their alpha value to compensate for the blending used in Game Maker. This means a face with color (50,50,50,0.5) will create pixels with color (50,50,50,0.5), which is what you want most of the time. If you turn this of, pixels with color (25,25,25,0.5) will be created. You should turn this off if you want to use premultiplied alpha. Some special blend mode tricks (like additive blending and motion blur) are a lot easier if you use premultiplied alpha. I recommend turning this off if you use additive blending.

Save separate alpha mask

If this is switched on, a second BMP image containing the alpha mask of the sprites will be saved too. You can turn this off if you are loading the sprites externally (using sprite_add_alpha) or if you are using single color transparency.

Set edge pixel colors

When using texture interpolation, the color of the pixels near the edges is sometimes shown. When this option is enabled, the renderer will change the color of all transparent pixels near the edges to make them match the actual sprite. Don't turn this on if you are using single-color transparency. Game Maker will fix this automatically if you turn on transparency for the sprite. Again, if you use premultiplied alpha, this is not required (which is probably the best reason for using premultiplied alpha: the results will look better in some cases)

Save/load settings

These buttons will save/load the current settings. This is useful to save time if you are rendering lots of sprites for the same game (because they will probably use almost the same settings).


Comments

There are no comments yet.

Write a comment