Tuesday, December 30, 2008

Visibility System And Shadow Casters

hi, last days i'v been working on my visibility system, rendering system and redesign few things related to them, also fix some low performance issues in big levels.
so in order to attack those issues i stared so see what could be optimized, one thing was the pvs data set which was basically a list of visible objects created from specific view point.
this pvs is needed for both camera and lights, also mirror materials needs to generate this set for the mirror generation pass.
those list was filled in few places but the thing is that we could do alot of the work in load time and achive better performance and still get the same thing.
so instead of keeping list of scene objects which could be changed doring the game (for example: another bot got in or out), i'm using a bit set for lights and camera pvs.
each entity update which areas they belong to, lights only update thier bit set when they move/change.
when i want to render the scene, i only need to check camera pvs bit set and see which areas are visible. to know which entity is visible is just a matter of checking the right bits in camera bit set.
in lighting pass we need to know which areas the current light influenced, so to get this info we need to do an AND bit operator between current light bit set and camera bit set, the result is the areas the light can influence and the camera can see.
the same thing is done for shadows generation, that using the same light bit set pvs with an exception.
when we are generating shadows we still need to consider shadows that comes from unvisible objects, object that is not visible still can cast visible shadow!
to solve this issue, we should check if the shadow volume of that object is intersecting our view frustum, if so it means this object needs to be rendered into the shadow map even if its not visible!.
if you dont handle those object you will get wrong shadows.
for example: if you have an open space scene with sun as the only light source and simple cave built from floor, ceiling and walls. when you enter the cave and look down (ceiling is not visible!) you still want to see the shadow of the ceiling.
here is screenshots from medium scene with unvisible shadow caster

shadows off

shadows generating from unvisible ceiling of this hallway

Sunday, December 14, 2008

Portals

hi, this time i had to recreate my portals visibility system, why? well i had some nasty bug that pop out when doing my pvs (possible visibility set) on complicated levels with lots of portals crossing each other.
i will try to explain the problem so when you see one you could attack it :)
little info about portals for some of you who don't familiar with it.
portals is related to visibility system because they help to cull scene areas, how?
think for a moment on a door that connecting two rooms room A and room B, if you stand in room A and looking through the door you only can a portion of room B.
now if you doesn't look through the door, you probably wont see room B (if you cant see the door, you cant see the room/s it leads to)
so portals basically hand placed (can be places automatically) in few places (not just corridors) as convex polygons (usually quads).
now, when you want to know which areas are visible, you start from camera area and check which portals inside this area, for each portal you clip your current frustum planes (the camera planes) against the portal and check again with the new clipped planes as the new frustum (yes its recursive function) and so on and on for each portal until there is nothing to see/visit.
now each portal you enter lead you to a new area so you flag this area so you know it is visible.
after you quit this function you end up with a list of areas that are potentially visible from camera area. this is the basic idea but few trick here and there could do this faster!
now that you know whats portals, i try to explain why i think recursive function for portals visibility are not so good in complicating levels with lots of portals!
the thing is that every portal you pass, the current frustum get clipped and pass for the next check, for every area you visit you also flag it so you wont check it again (this also helps to break the recursion, if not you can get stack overflow) because other portals can also leads to it.
because of this you can have few routes (in the recursion tree) that can lead to the same area! but not all of them will result in a visible area at the end! this is because we flag all the visited areas so the other routes that start like the first one but ends different (in terms of areas) wont even ends! meaning the area at the end of their route wont even visit because the first ones was flagged as visited - resulting in a none visible area that needs to be visible!!
i hope you didn't get lost in this long explanation and get the idea, so here is my solution to this problem:
the way i solve it is to look at the problem as a tree where the camera eye placed at the root, each portal is node, each branch is an area. (this is just how it help me to solve the problem).
i scan this tree by levels!, this way the areas are visited in a sorted order relative to eye pos (the root) and all the routes advance one step at a time and not allowing one route to get to the end (leaf) and others stay at the beginning.
here is few screenshots that shows portals in action:

visible portals in green, none visible in red

visible portals in green, none visible in red
yellow lines are current frustum planes
NOTE: portals are clipped against current frustum thats why part of the portal is red and the other part is green

Wednesday, December 3, 2008

Gamma Correction

hi, after reading the article "the importance of being linear" in gpu gems 3, i decided that its a good thing to add gamma correction into my engine.
by setting the right gamma value everything will look more real and the colors get the right felling.
there is few tecniques to do that, i decided to do it as a post process on the final pixel color by applying the function:
gammaCorrectedColor = pow(finalColor, 1/gammaValue)
as a bonus we can now optimize light interaction because the light bounds doesn't need to be big in order to make the effected area more clear and bright.
also, its a good idea to make the gamma value controllable so every player could set it as needed, i'm using the console to change it.
here is a screenshot of the effect:

without gamma correction

with gamma correction

Saturday, November 22, 2008

Mini Map

hi, one of the things that was missing for me in fps game is the way to know where i am, where do i need to go and where the hell is my enemies that keep shooting at me.
so i thought to add this mini map feature which shows you the level (from top), you and the enemies near you, this including orientation so you know where they look at.
for now its just shows you where is the bots in the map (including you) but eventually it will show you:
1. your objectives
2. war zones
3. special items
4. shortcuts
and more, this list is changing from day to day but i think you got the idea :)
here is a screenshot the shows the mini map inside the game (top left)

yellow icon is you, red icons is other bots
note that the detail is not so good because the image compression

Saturday, November 15, 2008

Swinging Lights

hi, this time i just added new feature to my articulate figure system that i'm using for ragdolls, the new feature allow me to define any model to be physical so to test it i tried to use it for lights so i could interact with them.
its very simple to define, just one .af script to define the bodies & constraints and one 3d model to attach the .af script to.
here is a small video to show this in action:

video

Sunday, November 2, 2008

Advanced Shadows

hi, last post i talked about the new render system and the improved shadow and lighting system, so here is few screenshots that shows some action:

soft particles with per pixel lighting and shadowing,
notice the green shadows on the wall

this is not projected light effect, this is true shadows generated from the fench

first picture shows some green smoke effect that cast green shadows, this is not precomputed effect or projected video, this is real shadows producing by the particles.
here i show this on particles but it will work perfectly for glass and other translucent materials.
the second picture shows shadows created from semi transparent materials, here i show this on fence but it will work for any semi transparent materials such as trees, grass etc.
i also added some optimizations to point light shadowing by skipping cube face passes by determine if face frustum is not intersecting camera frustum.

Monday, October 27, 2008

New Render System

Hi, recently i worked on a new render system, the old system created at the first stages of the engine just so i could render some geometry.
the old system wasn't generic and fast, it didn't support alpha blend surfaces very well and optimize material and stage binds, also shadows for special media wasn't supported and was hard to add (shadows for translucent surfaces for example).
those things result in lower fps and unrealistic scene, so i decided to create new system to overcome those problems.
the new system manage all scene rendering using special batches, each render object need to generate those batches and feed the system, then the system manage and optimize those batches for fast rendering and lower material and stage binds.
also the system support few render options so it will be easy and fast to render special passes such as shadows, ambient light etc.
the good thing with this system is that it doesn't need to know about the objects being rendered, it works only on those special batches and thats it, so if i need to add new support for 3ds object for example, i just need to make sure it will generate the batches and it will automatically get all the features (shadows, lighting, post process effects etc)
i also improved my lighting and shadowing system to support some new features:
1. light interaction of translucent surfaces
2. shadows for translucent surfaces, for example: glass and smoke will cast shadows depending on how translucent it is, red smoke will cast red shadows.
next time i will upload some screenshots...

Sunday, October 19, 2008

Debug in Release

hi, this time i talk about something i "bump into" while trying to run my engine in release mode (after i changed all engine class design and such) and get a crash into my face, oops not good.
at first i thought it something i mess with, i had no clue where to begin because the change was so big so i start shooting all over with no luck.
so i created exception handler lib which will catch exceptions and just before it will crash it will generate two files:
1) log file about the stack, modules, user, and the must important is the eip, which is the instruction pointer where the crash was happened.
2) mini dump file which is generated using dbghelp.dll, this is basically a snapshot of the program before it crashed, and it can be opened via vs or windbg and it will show you the exact line that cause the crash (very useful)
after having this kind of tool i started debugging and check what the hack cause the crash, i saw that there was uninitialized pointers such as d3ddevice interface, which wasn't make any sense because in the log i saw that textures and other data was loaded.
this turn on the red alert, what is wrong with my code, and why it is working in debug and not in release (and it was working!!)
i watch the engine log and see that the constructor of some managers was called twice which wasn't possible and make sens because they are singletons!! after digging a bit i notice that if you create static inline singletons (scott mayers singletongs) the compiler (which is vs2003 not 2005/2008) generating wrong code when optimization is on, and make the constructor called twice or more if you include the header in more then one object file and you call the static inline function that return the singleton instance/object.
if you move the implementation to the .cpp code the compiler generate "good" code.
because those managers are heavily used i didn't want the overhead of the function calls, so i dig a little bit more and i found a trick that works.
NOTE: this only happened on vc6 and 2003, in 2005 they fix the problem.
so if you are used to create singletons like this:
class CTest
{
public:
static CTest &GetInstance()
{
static CTest instance;
return instance;
}
}
you should now use this trick:
class CTest
{
public:
struct tDummy
{
static CTest &getInst()
{
static CTest instance;
return instance;
}
}
static CTest &GetInstance()
{
static tDummy instance;
return instance.getInst();
}
}
vc2003 deals fine with static var which contained in a non-static inline method.
so what i found is that i didn't mess anything and the code was fine and the compiler wasn't
after all it was good practice to wrote the tools and i think they will be useful in the future - i hope i wont need to use them :)

Wednesday, October 15, 2008

Lights And Sound Shake Data

hi, on my last posts about sounds i talked about shake data which defines the intensity of the sound at a given time/point, so i thought it will be nice to add sound to lights, but then i want the intensity of the light to be changed based on what we hear.
for example: if we hear sound of blinking light we want the light intensity to blink and sync with that sound - this is where shake data comes in use.
i wrote some helper function that gives me the exact shake value and i use it as scale factor when i compute the light color.
so now i can set sounds for lights and the intensity of the light will be sync with sound shake data and gives really nice and creepy effect :)
watch the video to see it in action:

video

Saturday, October 4, 2008

Loading Screen

hi, this time i added loading screen feature so we see when the loading process while level data is loaded and cached.
i also added the feature to load new maps on runtime via cvar, so i could check other maps while the core engine i initialize and cached so i wont need to stop and run the project every time i want to check other/new map.
this was mainly an engine redesign process so everything related to level map could be released and initialized on demand.
the loading screen i based on my gui system so its just a matter of designing the loading script and load it and update the variable and call triggers when needed.
here is some of the code in the loading gui script:
windowDef p_load_bar
{
rect 235,431,( "gui::map_loading" * 405 ),26
visible 1
windowDef load_bar
{
rect 0,0,405,26
visible 1
background "gfx/guis/mainmenu/load_bar"
matcolor 0.878,0.423,0,0.5
}
}
this window i the loading progress bar we see while we wait for the level to start, notice the 'gui::map_loading' variable in the rect definition of the window 'p_load_bar', this variable used to control the visibility of window 'load_bar'.
because i have parent/child design, the parent window also scissor his child, that means the child windows can be visible only inside their parent rect.
when i'm loading level/map data i'm setting this variable to the right value [0..1] and when i'm finished i'm triggering the event 'FinishedLoading' that changed the text near the loading to
'click to continue'
also i added script file per map, so i could define map related parameters such as the loading image. thumb image etc.
when i need to load specific map i'm checking if the map has a script file, if so i'm getting the image that i need to load and set it as 'gui::loading_bkgnd' in the loading gui, here is the loadimg window declared inside the script:
windowDef loadimg
{
rect 0,0,640,480
visible 1
background "gui::loading_bkgnd"
matcolor 1,1,1,1
}
the window is responsible to display the loading background image.
here is a screenshot of one of my test levels:

map doesn't have loading image
notice the click to continue text which shown when the map finished loading

Sunday, September 28, 2008

Sound Occlusion Per Material

hi, i did small update to sound occlusion which defines sound occlusion properties via script file.
so now i can define reverb and direct occlusion for each material.
the script is very simple: (for short only 2 materials)
none =
{
"0.5", -- directOcclusion
"0.5" -- reverbOcclusion
}

stone =
{
"1.0", -- directOcclusion
"1.0" -- reverbOcclusion
}

none - is the default occlusion properties if material not defined/found/exist
the rest is direct and reverb occlusion values per material (using material name)
when creating the sound geometry the occlusion properties will set based on material and his values from the script.

Monday, September 15, 2008

Caching Data

hi, this time i added new script file that will contain all the data that needed to be cached before the game start.
the engine designed to load data on demand so when i'm checking things i don't need to wait until all map data will be loaded, so if for example you are not shooting at all, then the sounds and effects for the shooting wont be loaded (it will be loaded and cached when you shot at the first time)
this is very nice and good when you are testing things but when you want to play the game this is very annoying as the game will freeze a little when you do some actions (firing/jumping etc)
the script is very simple, it contains data to be loaded and cached per category: sounds/effects/animations.
example for sounds category:
SoundShaders =
{
"pickup_weapon"
}
this we cached only the "pickup_weapon" sound shader before the game start.
for now i'm using only one cache file, but it will be extended to support few cache files - one for each map so every map will have its own data that needed to be cached before playing it.

Friday, September 12, 2008

Sound Geometry And Occlusion

hi, i added sound occlusion effect which takes scene geometry into consideration when trying to play sound with his properties.
i created new class called CSoundGeometry which contains the geometry the sound need to consider when we are playing it.
all sound geometry classes separated by material properties so i can give different sound occlusion and reverberation properties based on the material.
for example: stone will occlude more sound then glass.
for now i didn't setup the properties table for each material, so every material will block the sound in 100% (so no reverberation for now).
i added debug rendering for the sounds so i know when sound is occlude and how much by rendering red to green color circle interpolated from the min to max distance property of the sound, so if the sound have 10 to 100 (min, max distance) and it is occluded it is shown in red, if not it is shown in green, if it is 50% occluded it is shown a circle radius of 45 and with 50% color between red and green.
note that only one room has sound in it so only when the door is opened we can hear it, you can also hear the steps sound and gear when you are moving.
the door also have few sounds for few states: open/opened/closes/locked
here is screenshots and short movie that shows sound occlusion in action.

sounds shown in green spheres, occluded sounds in red

min/max distances of sounds shown in green circles, occluded sounds in red
the door is opened at 50% so the top sound is occluded 50% meaning 50% between red to green

video

Light Leaks

hi, small update about something i saw while working on sound occlusion.
i created small level containing 2 rooms with a door separating them, while playing with this level i saw some lights leaks near the door and at the sides of one of the rooms room (the one without a light) it appears that some of the light from the lighten room leaked into the dark room - very strange, because i'm using vsm for shadowing the scene and i'm using some thresholds to solve the light bleeding problem i thought to give a second check to this threshold.
so what i did is increasing the light bleeding threshold and everything look good now :)
here is few screenshots showing the problem before and after solving it:

close door - leaks on sides and near door

open door - leaks on sides

close door - no leaks

open door - no leaks

Sunday, September 7, 2008

Ambience Sounds

hi, this week i added ambience sounds, so i could place sounds in the scene which will be played based on their properties defined in the map file.
unlike other sounds, those sounds usually played automatically (some ambient creepy sounds), or by triggering some triggers/events (like opening a door, or using an elevator)
here is an example of sound entity defined in the map:
{
"origin" "753.48 2078.26 66.7"
"classname" "speaker"
"angle" "315.181274"
"s_shader" "sound/ambience/music.ogg"
"s_looping" "1"
"s_shakes" "0.000000"
"name" "speaker_2"
"s_volume" "-6.000000"
"s_mindistance" "512.000000"
"s_maxdistance" "1200.000000"
"s_occlusion" "0"
"s_waitfortrigger" "0"
"soundgroup" ""
"wait" "0.000000"
"random" "0.000000"
"s_global" "0"
}

ok, so what are all those properties do? here is a quick info:
origin - the position in 3d space of the sound (if ambient this will be ignored)
classname - internal use, basically its the type of the entity
angle - control the spread of the sound
s_shader - sound shader or sound media file (.wav, .ogg, .mp3)
s_looping - need to loop or not (repeat the sound over and over)
s_shakes - shake factor controlling how strong the view will be shake when playing the sound (also based on the loudness of the sound)
name - name of the sound/speaker entity
s_volume - volume of sound (in decibels)
s_mindistance, s_maxdistance - minimum and maximum audible distance for the sound
s_occlusion - is this sound need to take care of geometry occlusion or not
s_waitfortrigger - sound will be played only when the right trigger will be triggered
soundgroup - the group the sound belongs to, useful for setting volume for few sounds, for example, all music sounds added to group "music" so if we want to mute the music in the game we just mute the group called "musics" and its done.
wait - delay between playing the sound again
random - random factor added to wait when needing to play the sound again
s_global - is this sound need to be heard every where (makes the sound ambient - used for music), if its ambient the sound will ignore his 3d properties.
so as you can see it is very easy to define ambient sounds in the scene, those sounds adding alot to the game play and make the game more realistic.
for now, geometry occlusion is not supported maybe i will add it next time.

Saturday, August 30, 2008

Convex Decomposition

hi, this time i fixed my physics objects support so i could add more complicated objects to the scene not just box, sphere etc, but also concave models.
physx does not support dynamic concave objects but it support multiple collision shape per obj so in order to support concave objects we must do something called: convex decomposition which break down or split the mesh into few convex meshes.
the data is stored in xml file which include all the info to create the convex mesh shapes that describe to render model.
i created new function in the physics manager that creates physics obj directly from this xml file, also i add the ability to specify collision script file (this xml) to every render model exist in the scene.
to work with xml files i use tinyXml which is very small and easy to use.
here is few screenshots that shows perfect collision with concave objects:

tables lies on the inner part of other tables
note the left table edge placed on the right table

tables placed on the inner parts of other tables

Saturday, August 23, 2008

Sound Manager

hi, this time i worked on the sound system, there is a lot of sound libs such as openal, bass, fmod, miles.
i chosed to use fmod ex because it is very advanced system and very easy to use.
i created sound manager to manage all sound creation in the game, i also add something called sound shader which is very similar to my material script.
sound shader is a script that let you to define specific parameters to one or few sounds and when you want to play the sound/s in that shader you just call CreateSoundFromShader(shaderNameInScript) which is a function inside sound manager and it will be played with all the attributes you specified in the script.
for example:
sound weapon_blaster_fire
{
minDistance 393
maxDistance 1181
volumeDb -2
frequentlyused

sound/weapons/blaster/fire01
shakeData 0 zzzztsolggeedccbbbaaaaaaaa
sound/weapons/blaster/fire02
shakeData 1 zzzztsolggeedccbbbaaaaaaaa
}
1) weapon_blaster_fire is sound shader name which we called from the code
min/max distance is the distance which the sound is audible
2) volumeDb is volume in decibels
3) frequentlyused is one of few flags that allow me to control few sound attributes such as occlusion, looping etc. this is used to cache the sound so it will be played from memory and wont be decompressed every time we want to play it
4) sound/weapons/blaster/fire01 and sound/weapons/blaster/fire02 is 2 sound files we wish to play while activating this sound shader. by default we chose randomly one of them.
5) shakeData is intensity of the sound in ascii form (z is loud, a is complete silence), i use it to change camera view based on the sound volume.
few of the sounds in the game must be played in relation to model animations, so to make it possible i created something called frame based event system, which allows you to specify events that will be triggered on specific animation frame/s.
for example, this is how i created shotgun reload sound events:
VIEW_RELOAD_CMD =
{
"RELOAD", "9", "sound", "weapon_shotgun_clipout",
"RELOAD", "22", "sound", "weapon_shotgun_clipin",
"RELOAD", "35", "sound", "weapon_shotgun_pump1",
"RELOAD", "38", "sound", "weapon_shotgun_pump2"
}
"RELOAD" is animation name
"9", "22", "35", "38" is frames to trigger the event
"sound" event type - all of them is sound
the last parameter is based on event type, in sound events its sound shader name

Saturday, August 16, 2008

Material Hit Effect

hi, this week i fix my projectiles hit effects so they support per surface material effect,
until now, i had only one impact effect per projectile for all surface types, this was very unnatural when you hit water surface because it was applied the same effect on it, so you saw decal rendered on the water, yes - very strange so now if you hit glass surface the effect will be different when you hit stone or liquid surfaces, depending on what you defined in the weapon script.
here is a screenshot that shows the effect on stone, glass surfaces:

left: stone hits, right: glass hits

Saturday, August 2, 2008

Weapons Sniper Scope

hi, i'm still working on weapons features, this time i added sniper scope with nice radial blur effect.
to create this radial effect i needed to add few features to material system so i could define which shader to use in which stage and which shader parameters and samplers i need to bind when binding this shader.
i also add the option to use current back buffer image as one of the samplers i'm binding to the shader, so i could create post process effects.
the effect i chosed is radial blur so everything outside our zoom area will be blurred and stretched.
i also change aim accuracy based on zoom, the more we zoom in the more we get accurate.
here is screenshots of the effect.


Wednesday, July 23, 2008

Weapon Sight and Lock mode

hi
i worked on some game play features that allows you to control your weapon more easy.
1. adding weapon sight on the screen so you know where you are aiming at also when you are aiming on game entity (for now bots) you will see the name of the bot and the distance near your sight icon.
note that each weapon have its own sight icon.
2. weapon lock mode, allows you to lock your weapon to your shoulder, and set your view with weapon sight for more accurate aiming, also it increase weapon accuracy while shoting.
here his few screenshots:
note: hud removed from those sceenshots.

bot name and distance

lock mode active

Monday, July 14, 2008

SSAO Integration

hi
last time i was playing with SSAO effect inside render monkey, after i was pleased with the results i started to integrate it into my engine.
it was very easy to integrate it because my flexible material system, the only thing i needed to do is to scale the parameters to fit my scene scale.
i still think there is few tiny things to fix (i don't know if i would fix them), but still it adds very nice global illumination effect :)
here is few screenshots:

shadows without ssao

shadows with ssao

ssao texture at top left corner

Friday, July 11, 2008

Screen Space Ambient Occlusion (SSAO)

hi, since the game crysis (by crytek) every talks about it, so i thought to give it a try :)
ambient occlusion is a global shading method that computes how much a certain point need to be illuminated based on the surrounding objects.
in computer graphics we can calculated this by taking specific point in space and cast x rays in random directions from that point and for every ray hit we check add or subtract "illumination value" from that point based on the closeness of the object the ray hit.
the closest the surface we hit, the point will be less illuminated, so if we have a point in space surrounded by alot of objects the point will be darken while other point that does not have a lot of objects around will be lighten.
ssao approximate this by using the depth buffer, for every pixel we check/sample few pixels around and try to compute the amount of occlusion from those points based on the difference in the depth of the current pixel and the pixels around, this technique has a lot of tiny things to set up before you could make it looks good, because of that i'v chosen to use ati render monkey application to create and test my shaders.
i'm glade to say the after one day and a half i got it, and it looks very good.
here is a screenshot from my results:


Saturday, June 28, 2008

Physics in Action

hi
with the new physics engine and ragdoll i added damage system, so if you hit the head you will damage the bot a lot more if you hit the leg or arm.
also if the bot kills you the camera change from first to third person mode so you could see ragdoll physics in action when you fall on the ground.
few bugs here and there but the new system is really cool :)
few videos that shows the new physics engine in action:

video

video

Thursday, June 19, 2008

NVidia PhysX Integration

hi
while trying to create advanced ragdoll physics i found that my physics engine isn't so stable.
for example: if i throw ragdoll from high place to the ground, it could get very unstable due to my simple solver.
as you all know, nvidia acquired ageia physx and they also have 2 new cards geforce 260/280 thats have build in physics accelerator. (based on ageia physx technologies)
i think is great solution, buying one card that support graphics and physics is cool.
the solution to my physics problems was very simple:
1. i could spend few more weeks to fix and some few other things on the way
2. integrate some of the commercial physics libs. (havok/physx)
i decided that it is best to go with option 2.
another question was havok or physx? i decided to go with physx as it is very understandable, easy and have tons of samples.
the integration went very smooth, i change my physics manager to support their function and the ragdoll is very stable now.

Saturday, May 31, 2008

Ragdoll Physics

hi, long time without updates...
while shooting and killing bots i notice that something isn't right, something is missing - die animation or something like that.
so to fix that i thought i to create some new animation sets but that isn't perfect, so i decided to add ragdoll physics which have some drawbacks but is better then animation sets.
i added new script file like id does (.af files) which defines the physics bodies and properties also constraints between those bodies.
i also add new class that will read and manage the info and create the physics model from it.
after that i created two main functions:
1. setup physics bodies from current animation set - this is very useful function because you don't have to care about model pose and how to set physics from it, you just call this function and it will set the physics bodies to match current model animation.
2. set animation set from physics pose - used to alter model skeleton so everything applied to the physics bodies will change the visual model.
NOTE: when i setup physics bodies from skeleton i use T pose so it will be easy to setup physics bodies and constraints.
here is screenshot of ragdoll setup using T pose (red/green spheres is constraints)

Saturday, April 26, 2008

Jumping, Climbing, Crouching in Action

hi, as i promised from the last post, here is movie that shows the bot in action using the new areas features (showing crouching and jumping)

video

i also add the ability of climbing and crouching to the player.
note that the bot can also climb a ladder, i'm not showing it in the video because i dont have climbing animation and it looks like flying on it and not climbing.
also nice feature i added to collision system is the ability to know which type of material i collided with so for example: if a bolt hit a stone it will leave different mark if it hits liquid.

Tuesday, April 22, 2008

Jumping, Climbing, Crouching and more

hi
this is holidays time so i had some time to dig into some cool AI stuff, basically i added the ability to edit AI data in run-time with a mini AI editor.
what this means is that i can add special features between areas such as, jumping, climbing a ladder, teleporting etc.
here is a screen shot of the mini editing tool:

1. the red/green spheres on the edge is the start/end points of the jump feature
2. the right side shows me which features the area the mouse on support, this is marked by the floating green sphere.
few keys to do some basic stuff such as set start/end points, set current feature, reset and save the data.
next time i will upload movie that shows the bot in action.

Saturday, April 5, 2008

Console

hi, another post this weekend.
this time is the console, allows me to change engine variables (cvars) at runtime, such as AI params, renderer params etc.
support auto complete, history, keyboard and mouse wheel scrolling, not much to say - just a console.
here is a screenshot:

before execute shadowmapblur=1

after before execute shadowmapblur=1

Profiler Improvement

hi, this weekend i improve my profiler.
i have simple profiling that let me mark places in the code with PROFILER_BEGIN/END commands and then it shows me the results in a tree view.
while trying to profile some area in the renderer i found a bug in the timing, i cast the time value to dword while i should not.
i also added the feature which mark in red the worst time node in the tree and in orange the worst time leaf in the tree, this way i can see very clearly where the optimization needs to be.
one area i know for sure that needs to be optimize is make skinning. so here is a screenshot of the profiler shows you the results.

Sunday, March 23, 2008

Dynamic Obstacle Avodance Integration

hi, this task wasn't easy, a lot of tiny things that needed to be fix - as i said in my last post :)
but now i'm very pleased with the result, i can drop any number of dynamic obstacles in the scene and the bot/entity will navigate around them.
one very important thing is to make your bot move smoothly and try to take shortcuts when possible, if you wont do it your bot will move around obstacles edges while you can see for sure he can take shortcut, this will make him looks very unnatural and robotic.
here is some screenshots that shows the system in action:
NOTES:
* purple lines shows the from the precomputed ai data the bot aware of, this is convex area so the bot knows he can walk in straight line to any other point in that area.
* small green sphere, goal position the bot need to be at the end
* medium green sphere is the point the bot will move to on the path resulting from dynamic obstacles system, this point is the result of path smoothing. the yellow lines is the path around obstacles without smoothing.
* white boxes is dynamic obstacles (dynamic rigid bodies in debug mode), the green lines around them is the expanding edges of their box.

Simple scene (1 area) this is what the bot aware of

One obstacle added and path generated from the system

Few more added and you can see the new path generated

stress test - start of movement

stress test - middle of movement.
if you watch closely you can see the bot is not moving along the yellow lines and take shortcuts where possible, this can be seen from the bot direction toward medium green sphere.

Monday, March 3, 2008

Dynamic Obstacle Avoidance

Hi, after setting up some basics in my physics engine i realize that my AI system isn't aware of any dynamic object created from the physics engine so i started to think about some generic solution to solve the problem of dynamic avoidance.
until now, i had some basic dynamic obstacle avoidance inside my steering system that check against obstacles on the way and if it found some, it add avoidance forces so the agent while try to steer around the obstacle (works fine for the bots)
the main advantage of this system is that its very simple to implement and it very fast, the disadvantage is that it tries to steer around one obstacle at a time, so if you have few obstacles one after another, it will steer around the first and return, steer around the second and return and so on (does not look very smart), also it doesn't handle the case where few obstacles block our path, it doesn't find a path that goes a around them (if exists) it just tries to steer around the first on the way but end up bumping against them until they moved (and if they wont move you are stuck)
this is unacceptable when you can have a lot of dynamic objects that moves around and could block our path, so i started to build some generic solution to this problem.
the main idea is that i trace a line from my current position to my current goal position (path line), and any obstacle that founded in my way, added to a list of obstacles.
then i check this list against my path line and build "edges graph"/"path tree" from the bounding edges of intersected obstacles and my path line fractions.
this tree is just a graph containing all the combination paths from my current position to my current goal, so then i found the shortest path in the graph and save it as a local path around the obstacles.
of course this is just a brief of the algorithm, there is a lot of tiny things that you need to consider when creating the graph, and also how you can optimize it so you have only few edges to run the shortest path algorithm on.
after i finish the algorithm i had time only to test it against rigid bodies that i throw inside the scene and it really perform well (still need to add few things here and there), i didn't had time to integrate it into my AI system :(
no pictures/movies maybe next time...
BTW: i today i got game programming gems 7, so i have a lot of things to dig into :)

Saturday, February 16, 2008

Rigid Body Physics #4

hi, last weeks i created the physics engine with general constraints, and i though it will be fun to play with them a little, so i added more constraints to the system so i could build more complex systems with it.
the constraints the system support:
1. ball and socket - constraint two bodies to one common point
2. body to body - constraint point on one body to a point on another body
3. body to body with distance - same as 2 but maintain a specific distance between the points
4. body to world - constraint point on a body to be fixed on specific world position
5. body to plane - constraint a body to move inside specific plane
6. body to line - constraint point on a body to move along specific line
7. hinge - constraint point on one body to a point on another body along specific axis with angle limits.
8. universal - same as 1 but constraint an extra degree of freedom, if we specify one axis on body0 and another axis (perpendicular to the first axis) on body1 it keeps them perpendicular.
here is few movies that demonstrate few of the constraints in action:
NOTE: the movies captured in debug mode of the physics system so you'll see some lines and spheres that shows constraints info.

body to line
video

body to plane
video

body to world position
video

body to body
video

Hinge
video

Saturday, February 2, 2008

Rigid Body Physics #3

hi, still working on rigid body physics (not an easy task).
i have finished few constraints, (ball & socket, hinge and universal) fixed some collision bugs, improve stability and collision system.
with the new constraints i could start creating rag dolls (maybe next time),
to test the constraints i created simple rope simulation using few universal constraints, and some swinging light, real cool :)
i also added rigid body interactions with other entities like the bots and weapons.
for example: when we shot on a box, the box will be respond to the hit like a real box.
here is few videos that demonstrate the new features:

Weapons interaction
video

video

Skeleton of simple rope physics
video

Saturday, January 19, 2008

Rigid Body Physics #2

hi
i fixed some bugs in the physics engine related to inertia tensor calculations and collisions.
i also add it to my fixed time step scheme, so it will be more smooth.
while checking performance i found a bug in my particle system related to profiler sections, it seems that profiler section started but wasn't ended so it damaged the profiler (this isn't related to rigid body physics but because of this i added nice feature to the profiler so it will show me if sections are not closed properly).
anyway, i founded that my collision system needs optimizations (because of the mesh vs mesh collision), so i searched the net to find some info about generic convex mesh collision and i found something called: GJK algorithm.
i also so that its good to build AABB/OBB trees for the meshes for fast culling.
i already implement AABB tree in my engine for some collision testing at the beginning, now i found some useful area to use it.
as for GJK, i need to read more about it and see how it goes.
in my last update i uploaded screenshots, and its time to add some nice movie to show my physics in action:

video

Saturday, January 12, 2008

Rigid Body Physics

hi, i decided to add some rigid body physics.
there is a lot of physics engines out there that i could integrate into my engine, so i have checked few engines such as Agiea PhysX, newton dynamics and ode.
Agiea PhysX seems to be very fast and stable, and it comes with great sdk with tons of examples, so i decided to give it a try.
while trying t integrate i have founded that its not so great for me, because i already have very good and fast collision system that i'm using in my AI, projectiles,camera collision and more, so to make use of external lib i must change all the places that use my system to use theirs.
this wasn't an option because i need to check that everything that was working is still works after the change.
i could use their engine with my own systems but it required to duplicate the data, the scene for example must be known by both systems so they and mine could do collisions.
also, i just want simple physics and i wont even use all the features that Agiea PhysX support so i decided to write my own physics engine so the integration will be smooth and clean, this will take some time to do but i think its worth the a effort, i also will learn from the process :)
my physics system is impulsed based, that means that in order to move an object an impulse to act on the object on a certain point.
i choose to use impulsed base physics engine so i wont need to solve big linear equations system every frame, also i could give x ms for the physics engine and things that didn't solved correctly in current frame will get a chance next frame.
also in impulsed base, constraints system isn't stiff, that means the constraints is trying to be preserved by applying forces every frame/iteration, this is different from linear systems (implicit method) because if the system can't be solved (for example: one of the constraint needs very big forces to be preserved) the system will explode.
after reading some materials and got refreshed in my calculus, i'v started to wrote the engine.
i have finished the integration, also add simple shapes: sphere, box, cylinder
the collision system is also finished and support rigid body vs scene and rigid body vs rigid body collision.
for now each rigid body is a mesh, so the collision basically does mesh vs mesh collision, this simplify the things a lot because i don't need to a lot of collision functions based on rigid bodies type.
i also started working on few joint constraints: ball & socket, hinge and universal, next time i hope i will finish it and put some screenshots :)
here is few screenshots of the rigid bodies in action (wireframe mode).

box stacks
one of the stacks lost balance and fall