Saturday, December 22, 2007

Per pixel lit particles

Hi, i added nice feature: per pixel lit particles.
i can now set if particles emitter needed per pixel lighting via effects file, so this emitter will effected by scene lights.
the effect rendered with shader model 3, so i could gather more than one light and render the particles in one pass.
for example: if i create smoke particles and the particles goes through red light, the particles will get some of the red color from the light.
here is few screenshots:

left: unlit smoke, right: lit smoke

Under water effects

I did some changes in the rendering order, because when i worked with scenes with water surfaces i notice that particles and decals effects doesn't rendered correctly under water, so few fixes here and there, moving fews functions to the right place fixed the problem :)
here is few screenshots:

under water blast

under water smoke

Thursday, December 13, 2007

Weapons Lighting Effects

hi, last weeks was very stressed because finally the baby comes out :) - yes i'm now officially a father, this i very new to me and i'm trying to adjust myself to the new situation, can't tell you how happy i'm, this is amazing feeling :)

for now i'm finding few minutes here and there so this new update i just a new feature i added to the effects system, this feature allow you to create and attach dynamic light to specific effect.
for example: when you fire your weapon you see the muzzle flash effects a small area around it, this is because the muzzle flash is a real light and it lights the area around it.
to create this realistic effect i changed effects script and add dynamic light with small radius for x milliseconds for the muzzle flash effect, this way the area near the flash will be lighted.
i also changed rocket effect so it will create light attach to the rocket and cast shadows.
here is few screenshots:

muzzle flash lights the area around
muzzle flash lights the character
rocket cast shadows and lights the area around

Saturday, December 1, 2007

Freezing the scene

hi, it became very difficult to debug AI and effects, so i thought it will be nice if i could freeze the scene and move with my camera to see things from closer view.
so i added the new feature along with few options:
1. freezing the scene and get a free camera so i could move around, good for debugging effects from different view.
2. do one update step so i could see how things get updated, good for AI debugging.
3. keep my free camera and let the scene updated for a while, good to see how bots moves and fight.
here is few screenshots that couldn't be captured without freezing the scene.

Sunday, November 25, 2007

Input Manager

Input manager is not the main thing you need but its certainly a thing you should have, and its not so complicated to do, so i created input manager class that will handle questions like:
IsMouseButtonGoingDown/Up? IsMouseBottunUp?
IsKeyGoingDown/Up? IsKeyDown?
the 'going' notation is to indicate that we want to know if specific action is about to be triggered, for example: if we want to know when specific key is pressed, we use IsKeyGoingDown, but if the key already pushed and we want to now when we released him we use IsKeyGoingUp, at last if we want to perform some action as long as the key is down we just use IsKeyDown (same for mouse functions).
the input manager uses directinput8 to communicate with hardware devices such keyboard, mouse, joystick (for now i'm using only keyboard and mouse devices).
i also add support for keyboard layout, which allow me to distinguish between different input languages, so now you can type in other languages besides english.
still, i need to match the right font file in order to see the right characters, but this is just a matter of exporting new font texture.

Saturday, November 24, 2007

Weapon Effects

i'v just finished setting weapons effects script.
i added muzzle flash effect per weapon, each weapon have its own muzzle flash effect.
for example: machinegun flashes different and more frequently than shotgun, shotgun also lives some smoke after the shot.
impact effect also added per weapon, each weapon bolt/projectile lives its own mark and create different effect.
for example: rocket effect is the most complicated, it creates smoke trails, fire trails, heat effect (because fire and smoke), sparks and rocket flash.
i also worked on weapon handling, when weapon clip is finished reload sequence is started so you cant shot until finished.
here is few screenshots:
reload and impact effect
note: the red color on the weapon is the gui that
shows how much bolts you have
shotgun - muzzle flash
machinegun - muzzle flash

Friday, November 23, 2007


hi, recently i have worked on game play, one of the things i'v added is hud (heads up display).
at the bottom of the screen you will see which weapon you are using, how much ammo left, health and armor, also when your are hit by something you will see red mark on the screen that will fade out.
the hud is based on the gui system i was worked on, while adding the hud i found couple of bugs in the gui system, some of them was critical, but i fixed them :).
until now, all gui rendering was handled by id3dxsprite interface, and gui elements didn't have full material like i'v used on 3d surface (they have just the texture so i could display it).
one of the changes i'v done was the removing of id3dxsprite interface from gui renderer and adding my own sprite renderer with specific gui shader.
i also removed the texture and add full material support like i'v used on 3d surfaces, so each 2d gui surface will support all the features on 3d surface material.

Saturday, November 10, 2007


i always liked the cut scene in games when you see few agents walking in a dark room and you see their flashlight moves.
flashlight is really cool effect i wanted to add long time but i always had something more important to add, last week i finally add it.
to polish this effect i added flashlight beam/volume to create the illusion of volume lighting, and last thing - every flashlight cast shadows.

flashlight volume/beam
correct order
top view - player flashlight is off so no shadow
top view - player flashlight cast shadow

Saturday, November 3, 2007

Soft Shadows continued

like all shadow map algorithms, VSM also suffer from something called light bleeding (instead of shadows you will see some light color pops at the middle), this is due to the fact that its a probabilistic algorithm.
when the variance over a filter region is high we probably see light bleeding artifacts, we more likely to see LB in scenes where depth complexity is high.
the good news is that VSM have a lot more advantages than disadvantages if we compare it to other pixel based shadows algorithm, also we can reduce the light bleeding issue by doing a smoothstep with the variance value and some threshold.
some of the advantages:
1. we can use mip maps on the "shadow map" texture (the variance map).
2. we can blur it like regular texture blurring (no pcf needed), and because of that we can use hardware filtering so as linear, anisotropic etc.
3. we can get good soft shadows a lot faster and smoother than using pcf.

i have added softness for both spot and point lights, point light is a little bit tricky :)
here is few screenshots:
no soft applied
with soft applied
no soft applied
with soft applied

Saturday, October 27, 2007

Soft Shadows

i have added soft shadows using variance shadow map (VSM) for both point and spot lights, i also convert shadow code to use this new shadow technique because stencil shadows is fill rate/cpu intensive, especially for dynamic scene.

Saturday, October 20, 2007

Different Head

i fix huge bug in md5 model, it seams that when i converted it to the new design i forgot update the transformation matrices (of the bones) after loading the mesh so every model that didn't had animation controller or bind animation will be wrong and distorted.
i found this while trying to add different head models (to same body model), and i so that the transformations matrices was identity!
here is screenshots marine model with different head:

Saturday, October 13, 2007

Dynamic Fluid on GPU

i'v added dynamic water/fluid interaction on GPU using 2 render target and simple wave equation, so when you fire on water/fluid surfaces you will see the waves the bullet cause.
here is a screenshot:

Saturday, September 29, 2007

Water surfaces

a lot of features and bug fixes, one of them is water surfaces.
i'v added water surfaces at the beginning but there was no lights interaction with it, i just rendered it last and it doesn't looks real, one of the main changes i made is recreating the material system so each material stage could use different shader, also each shader need to have few techniques if light interaction is needed.
after all shaders recreated for this new material system, every surface in the game could define how light interaction will effect the surface, so water will effected by lights.
i'v also fix refraction mask generation, i'm using ambient pass to generate refraction map, after that i'm rendering water surface into alpha channel of this map so i could mask pixels that doesn't need to be effected by water pertubation effect.
here is few screenshots of water inside the game.

ambient and point light
flash light interaction
refraction (close look)

Saturday, September 15, 2007

Soft Particles

one of DX10 features is the ability to read from depth buffer, in DX9 you can't do it unless you are generating it by yourself and pass it as texture.
in my ambient pass i'm using multiple render target, one for color buffer and one for depth, after that i'm setting it as texture and use it when needed in the pixel shader.
for soft particle effect, i'm reading the depth value from depth buffer rt and compare it with particle depth, then i'm compute new alpha value based on the difference between those values, (closest particle to level surfaces = more transparent).
here is few screenshots of the effect.
i marked in red the area the particles intersect with level surfaces.

Saturday, September 8, 2007


after seeing id tech 5 mega texturing, i though how the heal he did that?
so i start digging and reading a lot about clipmaps and streaming and i succeeded creating mega texturing.
to create the huge textures i'm using L3DT (pro trial version) i'v created 8k and 16k, the 16k texture took more than 12 hours to complete and with 5 mip levels its takes 1 giga.
my computer have only 1 giga ram so it's not impossible to use this texture in system mem.
here is few screenshots showing the difference between using mega texturing and not.
note that this is just sample app using engine features but for now its isn't integrated inside.
the app uses 16k streaming texture with about 20 mb gpu mem.
the fps difference is big because mega texture ps takes 74 instructions (not optimized)

using mega texture

not using mega texture (very blurry)

Sunday, August 12, 2007

Fixed time step

i have added fixed time step with new interagor (midpoint or rk4) to the physics simulation (objects movement), until now i used the frame dt with euler (yes euler - very lame) integration and the results was very bad, the movement was very jerky (very noticeable when fps goes down and up during the game).
the problem is this, when we are using numerical integrations the result depends on the dt, the larger the dt the less accurate result we get, so if develop our simulation to run at 60 fps (dt = 1/60) and at some point the frame rate drops to 10 fps then the result we get is very inaccurate and results very odd movement (or even exploding), this is true for advance integrations as well - verlet, midpoint, rk4 etc...
with the new fixed dt, i assure the physics simulation runs at the same speed as the display frame rate (sync with it), so if the display frame rate is 30 fps and the physics design to run in 60 fps then we need to do 2 physics steps for every display update to make physics in sync.
i also added a final touch that interpolate between 2 physics states (previous and current) based on some alpha.
interpolation is needed to handle cases when the physics frame rate is not divided by display frame rate (without a remainder), for example the frame rate is 50 fps and the physics is 60 fps, so every frame the algorithm will have to alternate between 2 physics steps or one, this will be good enough to keep it in sync but visually it looks jerky.

Saturday, July 28, 2007

Outdoor scenes

hi, a a lot of updates i have integrated the GUI on weapons, also add option to add terrian models to map, see pictures below:

Sunday, June 24, 2007

GUI Continued

there is a lot of updates, the must important ones is: events and if expressions.
here is the list of events supported by the system:
onTime - Runs the event at T+

Saturday, April 28, 2007

More on GUI

in the last weeks, i was working on the gui, it is more complicated then i thought but i'm now supporting almost all the features. the best way to explain what this .gui file can do is by giving an example so here is one:
windowDef Desktop
rect 0,0,640,480
backcolor 0,0,0,1
visible 1
windowDef raven
rect 120,40,400,400
visible 1
background "gfx/guis/mainmenu/raven_1"
matcolor 0,0,0,1

the system based on nested windows and events. there is one top level window called 'Desktop' then one or more windows that are 'children' of the desktop, then zero or more windows that are children of the children, etc... (every window/event has it own params)
here we define the top must window 'Desktop' positioned at 0,0 with size of 640 n 480 (width and height), we set his background color to black and make sure he is visible.
we then create a second window, which is child on desktop positioned at 120,40 with size 400,400, make sure this one also visible and also set his background image to some texture.
'matcolor' is texture color, so here we set it to black so later we could create a transition effect so it fades in and out.
the lines below define transitions on texture color of raven window (they should be inside 'Desktop' brackets)
windowDef anim_credits
rect 0,0,1,1
visible 1
notime 0

onTime 0 {
transition "raven::matcolor" "0,0,0,1" "0.839,1,0.658,1" "1000" ;

onTime +3000 {
transition "raven::matcolor" "0.839,1,0.658,1" "0,0,0,1" "1000" ;

ok, i said we could define some events so here we define the 'onTime' events which runs the actions/sets inside is brackets every T+

Saturday, April 7, 2007

GUI files

this week i added GUI so i could use it for displaying hud/weapons ammo/power ups etc.
id uses .gui files which basically a script that allows you to define elements to display on the gui such as windows/text boxs/images etc, you can also set there properties like rect, color, text, font and more - this is very easy and fast way to create GUI's.
after you have the GUI script you can render the GUI on a 3d surface in the game.
for example: you can use it to display player info like health, power ups (on 2d screen), or on 3d surface of a weapon to show ammo info.
here is a screen shots of .gui files from id quake4 folder that i'm loading from my engine, for now its rendered on the screen, but next time i will show it inside the game.


Saturday, March 31, 2007

Bitmap fonts

hi, long time i didnt post anything because i didnt had time to.
after i return from my vacation in the far east, thailand - amazing country, i needed couple of weeks to return to the real world :)
ok, now the weapons works fine, but in some weapons the ammo left should be rendered in specific place on the entity model.
id defines something called entitygui shader for surfaces that should be display gui, so what i'm going to do is to support this cool thing.
i'm supporting the shader definition, so now all surfaces with entitygui shaders suppose to render their gui on that surface (texture)
i also added bitmap fonts, until now i use d3dxfont lib but it is not so fast and i cant render textured characters.
to genrate font data i'm using: bitmap font builder by thom wetzel.
next time i hope i will finish some gui controls.

Sunday, February 18, 2007

Profiling stuff

i didin't have time to add new features, instead i run the game on few maps and do some profiling, and i saw that on some maps the fps drop down to 20-30 fps - what the...
at first i thought its the rendering, but after checking the profiling data i saw its the bots update function, i checked it out and see its the skinning stuff :(
well, in the beginning i wrote some slow functions just to make it work and now its coming back, so i think i will need to rewrite those functions and add some asm code.
in the next 3/4 week i wont updating because i will be on vacation :)

Saturday, February 10, 2007

First person mode and torso,legs synchronization

ok, first updates from last week.
i added synchronization with torso & legs to allow the bots to aim at direction x and walk in other direction y, this is very important when the bots fight (because if the bot could not do that i will looks very robotic).
this week i added first person mode, which is better than third person if you need very accurate aiming, i also synchronize the animation with the third person mode so when you look at mirror you see yourself.
here is few screen shots: