Tutorial 10, Post Processing
This tutorial builds on the first tutorial, so be sure to do that first!
[Tutorial 1, BlendELF Basics]
In this tutorial you will learn to use the BlendELF Post Processing system.
Step 1: Getting the tutorial resources
I assume you have already gotten yourself the BlendELF Development Kit, but if not, then head to
http://blendelf.com and get yourself a one! The BlendELF Development Kit contains the engine executables and the level files we will be using for this tutorial.
Step 2: Setting up the camera position
Here is our init.lua from Tutorial 1:
elf.LoadScene("level1.pak")
while elf.Run() == true do
end
Lets set up our camera position in a way that it will be easy for us to preview all of the effects.
scn = elf.LoadScene("level1.pak")
cam = elf.GetSceneActiveCamera(scn)
elf.SetActorPosition(cam, 0.5, 24.0, 5.0)
elf.SetActorRotation(cam, 75.0, 0.0, -180.0)
while elf.Run() == true do
end
Try running the code, you should see something like this:
Step 3: Adding some bloom
Lets add some bloom to our scene.
elf.SetBloom(0.35)
scn = elf.LoadScene("level1.pak")
cam = elf.GetSceneActiveCamera(scn)
elf.SetActorPosition(cam, 0.5, 24.0, 5.0)
elf.SetActorRotation(cam, 75.0, 0.0, -180.0)
while elf.Run() == true do
end
The reason why we set the bloom before doing anything else in the code is because doing it first will let the post processing buffers have the fastest memory available on the GPU.
The function elf.SetBloom takes one parameter, which is the threshold for what how much color gets through to the blooming pass. The smaller the value, the more bloom you get. The minimum of the value is 0.0001 and the maximum is 1.0.
Try running the code, you should see something like this:
Step 3: Adding some Depth of Field
Lets add some depth of field!
elf.SetBloom(0.35)
elf.SetDof(5.0, 18.0)
scn = elf.LoadScene("level1.pak")
cam = elf.GetSceneActiveCamera(scn)
elf.SetActorPosition(cam, 0.5, 24.0, 5.0)
elf.SetActorRotation(cam, 75.0, 0.0, -180.0)
while elf.Run() == true do
end
The first parameter of elf.SetDof is the range of the sharp area of the depth of field, meaning, the larger this value is, the more objects with be in the sharp area. The second parameter is the distance from the camera to the hotspot of the depth of field. Play with these values to see what exaclty they do ;).
Try running the code, you should see something like this:
Step 3: Adding some Light Shafts
Lets add some light shafts. For this we need to create a new light behind the entities so that the effect would look cooler ;).
elf.SetBloom(0.35)
elf.SetDof(5.0, 18.0)
elf.SetLightShafts(1.0)
scn = elf.LoadScene("level1.pak")
lig = elf.CreateLight("ShaftLight")
elf.SetActorPosition(lig, 0.0, -20.0, 0.0)
elf.SetLightColor(lig, 0.25, 0.5, 1.0, 0.0)
elf.SetLightShaft(lig, 4.0, 1.0, 0.1)
elf.AddLightToScene(scn, lig)
cam = elf.GetSceneActiveCamera(scn)
elf.SetActorPosition(cam, 0.5, 24.0, 5.0)
elf.SetActorRotation(cam, 75.0, 0.0, -180.0)
while elf.Run() == true do
end
First we set light shafts on with elf.SetLightShafts which takes one parameter: the global intensity of the light shafts. Then we create a light, set its position behind the scene geometry, set its color to blue, set the light shaft settings and finally add the light to the scene. The elf.SetLightShaft function takes four parameters: the ligth we want to modify, the size of the lights beacon, the intensity of the light shaft and the fade off. The larger size of the beacon, the more shafts you get. The stronger intensity, the brighter the shafts are. The smaller fade off, the longer shafts you get.
Try running the code, you should see something like this:
Nice eh? ;)
Thats it! I hope you enjoyed the tutorial, and if you have any comments about it, please post to the
forums.
Copyright © 2009-2010 Samuel Anjam