GeeXLab and Two Sided Lighting

GeeXLab - two sided lighting demo

What? Two sided lighting? Isn’t it the old OpenGL 1.2 feature that allows lighting calculation on both sides of a triangle? Yes it is!

I spend most my time in the Vulkan renderer (which gets better and better), so don’t panic, it’s not a new killer feature of GeeXLab. I just added this feature for the needs of this article: NVIDIA Quadro P5000 vs GeForce GTX 1080.

Two sided lighting is a feature used in many CAD softwares and NVIDIA Quadro cards are particularly fast in rendering polygons with two sided lighting enabled. According to my tests, a Quadro is around 7 times faster (up to 20 times faster in some cases) than the equivalent GeForce graphics card. Some results are available HERE.

GeeXLab supports OpenGL 2, 3 and 4 (as well as DX12 and Vulkan). GeeXLab is based on a low level API that allows more or less a direct control of the rendering and it’s easy to render an OpenGL scene with fixed pipeline functions only: just render objects without shaders. You can also enable / disable some OpenGL states if you need.

To properly support two sided lighting, I added the following functions to the gh_renderer lib (in Lua only):
– light_model_double_side()
– light_set_ambient()
– light_set_diffuse()
– light_set_specular()
– light_set_position()
– material_set_ambient()
– material_set_specular()
– material_set_diffuse()

The gh_renderer.light_model_double_side() function is nothing more than a wrapper around:


I’m sure that I wasted my time adding these functions because GeeXLab comes with LuaGL that should support these old functions. An example of LuaGL is available in the gl-21/lua-gl/ folder of the code sample pack. It doesn’t matter because I quickly coded these functions.

Here is the FRAME script of the two sided lighting demo that shows how to use these functions:

local elapsed_time = gh_utils.get_elapsed_time()


gh_camera.bind_v2(camera, 1, 1, 1, 1, 1)

gh_renderer.clear_color_depth_buffers(0.0, 0.0, 0.0, 1.0, 1.0)



gh_renderer.light_set_ambient(0, 0.2, 0.2, 0.2, 1.0)
gh_renderer.light_set_diffuse(0, 0.9, 0.9, 0.9, 1.0)
gh_renderer.light_set_specular(0, 0.0, 0.0, 0.0, 1.0)
gh_renderer.light_set_position(0, 2.0, 10.0, 30.0, 1.0)


gh_renderer.material_set_ambient(0.6, 0.6, 0.6, 1.0, POLYGON_FACE_BACK_FRONT)
gh_renderer.material_set_specular(0.0, 0.0, 0.0, 1.0, POLYGON_FACE_BACK_FRONT)
gh_renderer.material_set_diffuse(0.9, 0.2, 0.1, 1.0, POLYGON_FACE_FRONT)
gh_renderer.material_set_diffuse(0.2, 0.9, 0.1, 1.0, POLYGON_FACE_BACK)

gh_object.set_euler_angles(mesh_cyl, elapsed_time*10, elapsed_time*20, elapsed_time*30)

gh_object.set_euler_angles(mesh_cyl, elapsed_time*10, 90+elapsed_time*20, elapsed_time*30)

gh_object.set_euler_angles(mesh_cyl, elapsed_time*10, 45+elapsed_time*20, elapsed_time*30)

gh_object.set_euler_angles(mesh_cyl, elapsed_time*10, 135+elapsed_time*20, elapsed_time*30)



The two sided lighting function is available in the gl-21/two-sided-lighthing/ folder of the code sample pack.

GeeXLab comes with an improved Vulkan renderer and Intel GPUs are now supported. More information about GeeXLab and Vulkan in a future post. If you want to play with Vulkan, some demos are available in the vk/ folder of the code sample pack.

GeeXLab is only available for Windows 64-bit. As usual, you can download it from THIS PAGE.

Here is the changelog (full changelog is available HERE):

Version – 2017.05.12
+ added support of double sided lighting in the OpenGL renderer (old OpenGL, fixed pipeline).
! [WINDOWS] improved the Vulkan renderer plugin, support for Intel GPUs fixed.
* fixed a bug in gh_texture.get_texel_2d(), buffer offset was wrong.
! [WINDOWS] updated the GPU monitoring plugin with NVIDIA TITAN Xp.
! [WINDOWS] GPU monitoring plugin: updated Radeon RX 500 / RX 400 support.
! [WINDOWS] updated GPU Shark

Leave a Comment

Your email address will not be published. Required fields are marked *