Let there be light

Web August 3rd, 2007

Lighting model used in dojox.gfx3d is merged from Eugene’ s 2D lighting utility library. We take a simplified Phong reflection model to gear towards the vector graphics:

  • All light sources are infinitely far away
  • No shadow support
  • Second-order reflections is not accounted
Cylinders in sunshine

The reflection from a surface is divided into three subcomponents, specular reflection, diffuse reflection, and ambient reflection. Due to the effect of parallel light, a polygon surface is ubiquitously the same since the angle between the light and the normal vector is the same. The curved surface in Cylinder can be imitated by the linear gradient. Here is an example how the cylinder looks like in the sunshine.

Here is the snapshot of development. They look real, but we still need more calculation to verify whether the lighting model is precise or not.

Share and Enjoy:
  • Print this article!
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

5 Comments to “Let there be light”

  1. Gavin Doughtie | August 6th, 2007 at 1:29 pm

    Sigh — can you post a live demo link for some of these? This looks really cool and I want to play with it without, you know, working….

  2. Masashi | August 8th, 2007 at 7:39 am

    Will perspective and a sphere object be implemented?

  3. bookstack | August 9th, 2007 at 1:00 pm

    Gavin,

    Good to hear you again. I am working on a big refactor of the code. Next week, I could work on some show case to promote this library.

  4. bookstack | August 9th, 2007 at 1:06 pm

    To Masashi,

    Current implementation simplify a lot to make the performance bearable. For example, the light sources are placed indefinitely far away, Perspective may bring some complexity that prevent us releasing the library on time. We may consider the possibility once this library merged into the trunk.

    Sphere is achievable in SVG side, however, MSIE could not render the radientGradient correctly, hope some VML developers could pick up the ball.

  5. Martinez Marchand | March 28th, 2009 at 7:23 am

    Think of all one could do if this was used to create a nice little game for others to enjoy.

Leave a Comment