3D Lighting and Fog

This section details all the functions available to you for lighting the 3D scene.

Scenes you draw with the GameMaker: Studio functions may look rather flat because there is no lighting to give them realism and life, meaning that the colour of the faces is equal all over, independent of their orientation or position. Therefore, to create more realistically looking scenes you must enable lighting and place lights at the correct places within the 3D world, and this section outlines the functions available to help you achieve that:

  1. d3d_set_fog
  2. d3d_set_lighting
  3. d3d_set_shading
  4. d3d_light_define_direction
  5. d3d_light_define_point
  6. d3d_light_enable
  7. d3d_light_define_ambient

It is worth noting that all targets except Android use smooth shading for lighting, but on Android this is hard shading. On the Windows platform this can be changed using the d3d_set_shading() function, but for all other platforms you should use a shader to create different lighting types.

Vertex Normal Functions

The way an object reflects light depends on the angle between the light direction and the normal of the surface, that is, the vector pointing away from the surface. Hence, to create lit objects you need not only provide the position of the vertices but also their normals. For this four additional functions are available to define the vertices of primitives (for the basic shapes that you can draw the normals are automatically set correctly):

  1. d3d_vertex_normal
  2. d3d_vertex_normal_colour
  3. d3d_vertex_normal_texture
  4. d3d_vertex_normal_texture_colour

The above functions are used to define a primitive in the same was as that outlined in the section 3D Drawing.


Back: Working With 3D
Next: 3D Models
© Copyright YoYo Games Ltd. 2018 All Rights Reserved