Want to make a 3D top-down shading effect for your game? Read this artical.

Firstly - take a look at my CrazyGolf game (or the screenshots) to see what this effect will look like.
Is this the effect you want? Continue reading...

You should know:

o How to use basic array functions
o How to use fastloops
o How to use the draw or overlay object OR use Jamagic screen rendering functions.

This effect requires an array of heights for the grid. (basicly an array with Xpos of pixel,ypos of pixel = height.

Set a loop for the Y dimension (Start MyYLoop for 180 loops)
In this loop start the X loop (Start MyXLoop for 320 loops)

<center>JAMAGIC CODE:</center>

In the loop write:

Window.SetPixel(MyXLoop,MyYLoop,RenderMap(MyXLoop,MyYLoop));

And make a function called RenderMap.

In the function Write:

// read the related heights
Var Counter1 = MyArray[X-2,Y-2,0];
Var Counter2 = MyArray[X-1,Y-1,0];
Var Counter3 = MyArray[X,Y,0];
Var Counter4 = MyArray[X+1,Y+1,0];
Var Counter5 = MyArray[X+2,Y+2,0];

// return the highlight value (from 0 to 255)
Var Highlight = (((Counter1 - Counter3)*2 + (Counter1 - Counter2)) - ((Counter1 - Counter5)*2 + (Counter1 - Counter4))) * 20 + 128;

// finds the RGB value to return
Var Colour = GetRGB((red * Highlight) / 255,(green * Highlight) / 255,(blue * Highlight) / 255);

// returns the colour
Return Colour;


This will render in jamagic.

<center>MMF</center>

In MMF you use the same code but adapted for fusions interface:

In the loop:

Counter 1 = Get value XYZ (MyArray, Get Loop Index(MyXLoop) - 2, Get Loop Index(MyYLoop) - 2, 0)
Counter 2 = Get value XYZ (MyArray, Get Loop Index(MyXLoop) - 1, Get Loop Index(MyYLoop) - 1, 0)
Counter 3 = Get value XYZ (MyArray, Get Loop Index(MyXLoop), Get Loop Index(MyYLoop), 0)
Counter 4 = Get value XYZ (MyArray, Get Loop Index(MyXLoop) + 1, Get Loop Index(MyYLoop) + 1, 0)
Counter 5 = Get value XYZ (MyArray, Get Loop Index(MyXLoop) + 2, Get Loop Index(MyYLoop) + 2, 0)

ColourCounter = (((Counter 1 - Counter 3)*2 + (Counter 1 - Counter 2)) - ((Counter 1 - Counter 5)*2 + (Counter 1 - Counter 4))) * 20 + 128

SetPenColour(MyDrawObject, GetRGB((red * ColourCounter) / 255,(green * ColourCounter) / 255,(blue * ColourCounter) / 255))

DrawLine(MyDrawObject, Get Loop Index(MyXLoop), Get Loop Index(MyYLoop), Get Loop Index(MyXLoop), Get Loop Index(MyYLoop)+1)

Complicated isn't it

Don't worry - you don't have to understand it. I've done all the work you can just copy the code. (remember to change the RED, GREEN and BLUE bits to the base colour.