Author Topic: Tutorial: Artificial sun lighting for outside 3D world  (Read 2726 times)


  • Jr. Member
  • **
  • Posts: 69
  • Karma: +5/-0
    • View Profile
    • Saturn Team
Tutorial: Artificial sun lighting for outside 3D world
« on: November 07, 2017, 06:50:59 pm »
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: [Select]
static float        use_light = true;

Part 2: Add apply_effect function.
Code: [Select]
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);

Part 3: In the jo_main function, we will add the light source variable and the executable line.
Code: [Select]
    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(); */

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.
Founder of Saturn Team


  • Administrator
  • Full Member
  • *****
  • Posts: 189
  • Karma: +19/-3
    • View Profile
    • Jo Engine
Re: Tutorial: Artificial sun lighting for outside 3D world
« Reply #1 on: November 07, 2017, 09:58:22 pm »
Thx for sharing  ;)


Sitemap 1 2 3 4 5 6 7 8 9 10