New games every week!
📚-02-Illumination Blog
2nd March 2025
For last week's Patreon First game, Cow Down, there's a nice little lighting effect that lights up the isometric grid.
I thought you might like to see how it's achieved.

-=-=-

We start with an isometric grid, built up using separate sides and a top.
The three sprites are Top, Left and Right, and when combined they make an isometric cube.



We can draw a screenfull of these isometric cubes in a fairly simple fashion, just be sure that, every other y-line, we offset the x-position of the cubes by half a cube.
That way, the cubes all tesselate nicely on the screen, and we get a nice isometric grid of cubes.

// Isometric Illumination // by Jayenkai // Created 2025/3/1 Symbol 0,"1__0/330_0,3!0@3_30.3_3?03_3/03_3?0.3_30@3!0_0,33"; Symbol 1,"1__0_0_0_0_0_0_0_0_0@30_0!3,0_0.3?0_003/0_3@0@3@0@3@0_3/0_003?0_0.3,0_0!3"; Symbol 2,"1__0_0_0_0_0_0_0_0_0_0_0?30_0.3,0_003?0_3/0@3@0@3@0@3@0@3/0_3?0_003,0_0.3"; Graphics 320,240,3 Repeat CLS;AA False for x=0 to 9 for y=0 to 9 dx=x*34;dy=y*26 if y%2==0 then dx=dx+17 // For every other y line, we offset the tiles by half DrawImg dx,dy,0 DrawImg dx,dy,1 DrawImg dx,dy,2 next next Flip Forever



Now for some light. Since we're drawing to a black background, we can use Alpha to make the cubes semi-transparent, which reduces the brightness of the cube.
Let's start with basic light and darkness.
We can use Pythagorus to work out the distance from the mouse, limit it between two values, and then invert the distance and divide to get a nice Alpha value.
(That sounds complicated but it's only two lines!)

far=Limit(240-Pyth(dx-MouseX(),dy-MouseY()),0,240)
alpha=far/240


// Isometric Illumination // by Jayenkai // Created 2025/3/1 Symbol 0,"1__0/330_0,3!0@3_30.3_3?03_3/03_3?0.3_30@3!0_0,33"; Symbol 1,"1__0_0_0_0_0_0_0_0_0@30_0!3,0_0.3?0_003/0_3@0@3@0@3@0_3/0_003?0_0.3,0_0!3"; Symbol 2,"1__0_0_0_0_0_0_0_0_0_0_0?30_0.3,0_003?0_3/0@3@0@3@0@3@0@3/0_3?0_003,0_0.3"; Graphics 320,240,3 Repeat CLS;AA False for x=0 to 9 for y=0 to 9 dx=x*34;dy=y*26 far=Limit(240-Pyth(dx-MouseX(),dy-MouseY()),0,240) alpha=far/240 SetAlpha alpha if y%2==0 then dx=dx+17 // For every other y line, we offset the tiles by half DrawImg dx,dy,0 DrawImg dx,dy,1 DrawImg dx,dy,2 next next Flip Forever



This gives us the ability to move the mouse around and see the cubes at different light values, but we've still no depth, so lets add that next.

For this example we'll keep things simplistic, but the general gist is, if the "light" is below the cube, the top should be half as bright.
Similarly if the "light" if to the left of a cube, the right of the cube should be darker, and if it's to the right of a cube, the left should be darker.

depth=0.5;
toplight=alpha;if MouseY()>dy then toplight=alpha*depth
leftlight=alpha;if MouseX()>dx then leftlight=alpha*depth
rightlight=alpha;if MouseX()<dx then rightlight=alpha*depth


We'll throw this in, and set the Alpha using these new values.

// Isometric Illumination // by Jayenkai // Created 2025/3/1 Symbol 0,"1__0/330_0,3!0@3_30.3_3?03_3/03_3?0.3_30@3!0_0,33"; Symbol 1,"1__0_0_0_0_0_0_0_0_0@30_0!3,0_0.3?0_003/0_3@0@3@0@3@0_3/0_003?0_0.3,0_0!3"; Symbol 2,"1__0_0_0_0_0_0_0_0_0_0_0?30_0.3,0_003?0_3/0@3@0@3@0@3@0@3/0_3?0_003,0_0.3"; Graphics 320,240,3 Repeat CLS;AA False depth=0.5 for x=0 to 9 for y=0 to 9 dx=x*34;dy=y*26 far=Limit(240-Pyth(dx-MouseX(),dy-MouseY()),0,240) alpha=far/240 toplight=alpha;if MouseY()>dy then toplight=alpha*depth leftlight=alpha;if MouseX()>dx then leftlight=alpha*depth rightlight=alpha;if MouseX()<dx then rightlight=alpha*depth if y%2==0 then dx=dx+17 // For every other y line, we offset the tiles by half SetAlpha toplight; DrawImg dx,dy,0 SetAlpha leftlight; DrawImg dx,dy,1 SetAlpha rightlight;DrawImg dx,dy,2 next next Flip Forever



And that's the general gist of how that works.
For the final game I added a little smoothness to the values, and on occasions it can look more than a little patchy, but it serves the purpose, and it's a nice enough effect.
.. I think.
... Maybe.

It's just a shame that JSE can't quite keep up with it at full speed with a larger environment.
That would be nice..

More Optimisationalism required, methinks.


Cow Down is currently a Patreon First game, but will be unlocked on Monday 2nd March 2025. (Tomorrow!)

A.I. Corner


Lyrics : By me
Sound Imported : Liquid Horseradish
> Reveal 🔎

: Download | Suno Link

Alternative version
: Download | Suno Link
Sung by Suno


"CGI render by blender, Cartoon CGI Derek shines a torch towards a grid of isometric retro neon cubes, lighting them up, cinematic lighting, volumetric" by Replicate/Flux

> Reveal 🔎
Views 707, Upvotes 13  
Daily Blog , Gamedev
New games every week!
Site credits : Jayenkai, one crazy fool who has far too much time on his hands.
(c) Jayenkai 2023 and onwards, RSS feed 89

Blog - 📚-02-Illumination - AGameAWeek