Sega Saturn Development > Share your code

Tutorial: Artificial sun lighting for outside 3D world

(1/1)

SaturnTeam:
This tutorial is for 3D first-person, third-person, or top-down games. This will emulate the sun. It will get the job done, but not look as nice as current-generation game engines. The effect should be used on a decently-sized 3D map, as the light is bright at the source.

Part 1: Add global float variable underneath the includes.

--- Code: ---
static float        use_light = true;
--- End code ---

Part 2: Add apply_effect function.

--- Code: ---
void        apply_effect(void)

    jo_3d_set_mesh_light(&MeshCube, use_light); /* Collada or Wavefront model */
    if (use_texture)
        jo_3d_set_mesh_texture(&MeshCube, 0);

    jo_3d_set_light(&plane, use_light); /* Ground/Floor flat double-sided texture */
    if (use_texture)
        jo_3d_set_texture(&plane, 1);


--- End code ---

Part 3: In the jo_main function, we will add the light source variable and the executable line.

--- Code: ---
    jo_3d_light(1.0, 1.0, 1.0); /* Float integers (static seem to be too unwieldy). Change numbers to suit your game. */

    apply_effect(); /* add above jo_core_run(); */

--- End code ---

Notes: This code is assuming that you've already placed your landscape items into your code, and have the textures listed in jo_main. Additionally, I came up with error-free code to shine light on a drawn cube, but, for some reason, it won't take effect. Perhaps, someone else will figure that one out.

mindslight:
Thx for sharing  ;)

Navigation

[0] Message Index

Sitemap 1 2 3 4 5 6 7 8 9 10 
Go to full version