Skip to content

Part 1 : the scene

haedri edited this page Mar 13, 2015 · 4 revisions

Part 1 : the scene

The project

This project is a simple LibGdx project with PC, Android & iOS support. If you are not familiar with LibGdx you can explore the code, it should be easy enough and well documented.

There is just one big project for the whole tutorial, but each part is separated in its own package, you can choose which part should be launched by modifying the ShadowMapping class (com.microbasic.sm in the core project).

Everything is customized as we will have to personalize stuffs later, so for example we don't use the included shaders, we just use our own passthrough shader that will be completed later on. It might seem useless for now, but it will be used later.

If you need help importing the project please refer to the LibGdx documentation: http://libgdx.badlogicgames.com/documentation.html

If you already have an environment ready just import the gradle project like any other LibGdx project and you are done.

The project zip can be downloaded here: http://www.microbasic.net/tutorials/shadow-mapping/shadow-mapping.zip

The scene

The scene we will use is just a complex enough test case :

  • One directional light (spot on the wall)
  • Two point lights (fire & torch)
  • Multiple objects
  • Floating objects
  • High vertex count

It's just a single big model that contains everything, it uses some elements created for one of my games that I just randomly put together to get this scene.

This is a voxel scene with around 36 000 voxels (in the original file, before export), slightly optimized (19 060 vertices, 10 123 faces). This vertices count is high enough to notice when bad optimization happen, and low enough to not disturb development.

By default it uses a FirstPersonCameraController from LibGdx to move around freely.

You can press the F2 key to take screenshots, they will be saved in the desktop/bin folder (on PC)

The shader

Current shader is a simple pass through that adds some internal shadows on faces depending on their normal (just to guess the volume of objects)

The shader program (SimpleTextureShader) is a simplified version of the default LibGdx shader program that removes everything we don't need.

Tool classes

  • IntFirstPersonCameraController : just a copy/paste of LibGdx FirstPersonCameraController but adding support for azerty keyboards & sprinting (using left shift or left ctrl)
  • FrameBufferCubeMap : copy of LibGdx FrameBuffer but with CubeMap support, this class might not be disposed correctly when exiting program.
  • ScreenshotFactory : copy of the sample screenshot factory from LibGdx documentation, adding support for specific width/height (to get a screenshot from a frame buffer) and filename prefix.
Clone this wiki locally