Paweł Mogiła's game development blog

GRIMIND logo and game playtest May 21, 2012

Filed under: gamedev,GRIMIND,videos — szaman @ 02:10
Tags: , ,

Yeah, as you noticed above GRIMIND now has it own logo which is designed and drawn by my friend Marcin Dragan. thank you Marcin, I like it very much. It fits well into game theme =dark | scary | horror like.

Since the last post ie. form GRIMIND alpha release, I got huge feedback from people. Not only from my close friends and academic community, but also from people I don’t know personally. That’s good, I like it. The most noteworthy is the video created by the user Pandara from tigsource.com. He’s hardcore tester, I really enjoyed watching his video review. Generally, many people gave me lots of helpful tips (I am waiting for more) that will take into account when creating the next levels of GRIMIND. Here is the Pandara’s play-test:

Advertisements
 

water February 11, 2012

Filed under: gamedev,videos — szaman @ 19:57
Tags:

Hello

It’s been long time since last post, but it wasn’t wasted (i hope so). I fixed a lot of bugs and made few changes that improves performance of engine. Most important upgrade applies to lighting – previously I was clearing screen alpha component for each visible light with glClear(…) then i noticed that this is the bottleneck of lighting system, now I’m just drawing quad with certain dimensions  which set alpha to zero – this approach is faster. Additionally i restrict shadow drawing area to AABB of current light via glScissior(…)  – this helps because shadows were projected to “infinity” (far away of light) what consumes a lot of fillrate.

OK that was not interesting part of work I have done. Let’s look closer on new features (yey) I added.The easiest to  see and most complex is water. To really to talk about it, we must to split it into two planes:

graphics part: which is responsible for general outlook of water so looking wavy and… splashes when something is getting into water or out of water. Splashes are made of particles of which I have mentioned some time ago. Simply – physics part of water reports when, where and how big splash (determined by velocity) should be shown. Splash also is modifying water surface to generate waves on water which are simulated by modified algorithm described in presentation Real Time Fluids in Games (link) by Matthias Müller which general rule goes like this:

u[N] - water surface peaks
v[N] - velocity of peaks

for(unsigned int i=1;i<N-1;++i)
{
    v[i] +=(u[i-1] + u[i+1])/2 – u[i];
    v[i] *= 0.99;
    u[i] += v[i] *delta_time;
}

when splash occurs i simply add velocity to certain group of vertices, negative velocity when something falls into water, positive otherwise.
– physics part – responsible for applying “fake” buoyancy force. Linear buoyancy itself isn’t hard – just add central force to body. The problem  is with correct rotating body in water which is not so obvious. I was searching  how to do that, i found that is implemented in bullet but it was not enough flexible and complicated (complicated = much lines of code = probably slow 🙂 ) I was looking for something lightweight. I also found that someone implemented buoyancy controller in box2d (see http://personal.boristhebrave.com/project/b2buoyancycontroller and flash demo) but this also was to heavy (computing centroid including rotations). So I came up with my own solution, very approximate btw. It’ based only on AABB of objects so it’s very quick. Most of physics engines uses AABB so i have more than half at the beginning. Next step is to try to minimize object AABB if it is floating on water by applying torque in specific direction. That’s all. As I said,  it has nothing with real buoyancy  but for my purposes it is enough (we all know game programing is art of cheating). Moreover I added new parameter for physics objects which decide if object would sink or float (x<1.f sink ; x>1.f float ; x=1.f stay).

I got some concepts for levels with water… and maybe You have ideas for some puzzles with such mechanics? (yes fluids can also kill like toxic water or immortal lava <pshhhh>).

On video you can see actual state of game / engine. I added some interesting items to this map like trampoline (on the left in beginning) but during video recording I forgot about jumping on it several times to show how it behaves. I collected also new nice textures and climatic ambient sounds that creates climatic scary atmosphere. Of course you should enable full screen for better look.

 

lighting December 22, 2011

Filed under: gamedev,tutorials,videos — szaman @ 15:22

Welcome everybody!                                 
Last time I made something for outlook of my game. Previously  I was able to darken environment via manually setting color per each vertex, now besides that, I can also specify global ambient color which is darkening level. Furthermore, it is possible to attach light spot to any object on scene, then every objects that are in certain radius from light are illuminated. Additionally, I implemented shadow casting algorithm basing on this article. But let’s start from the beginning, general recipe for that effect looks pretty simple:

1. Clear screen with ambient color
2. For each lightgradient
     a) set drawing only to alpha channel
     b) remove existing on screen alpha channel
     c) set blending to additive
     d) for each object near light: render shadow using only alpha color
     e) set drawing only to r g b channels
     f) render light only where, there is no shadow
3. copy light-map  existing  on screen to texture
4. clear screen
5. draw scene normally
6. set multiplicative blending ( wherever light-map is black  there will be dark)
7. draw quad with dimensions of  screen textured with light-map
8. bonus:  if emissive light needed draw it again with additive blending

Re 2.f

just draw quad with light gradient texture like image on right, you may also change light color by glColor…

Re 1, 2.b and 4

in opengl we can clear screen by using glClear(GL_COLOR_BUFFER_BIT)  function as long in this case we aren’t using depth and stencil buffers. Additionally  we can set global ambient color via  glClearColor(ambientR,ambientG,ambientB,0.f);  so it will immediately fill screen with wanted color

Re 2.a 2.e

setting true or  false in parameters enables or disables drawing to that channel  glColorMask(red,green,blue,alpha); Re 3 we can copy pixels to texture by using glCopyTexSubImage2D function or… we can skip this point if we previously set rendering directly to texture via FrameBufferObjects (FBO) then we can avoid copping pixels from  screen to texture. It seems to be large optimization, In by case glCopyTexSubImage2D works faster than FBO and everywhere people are writing that it should be slower. I don’t know why this is so. I suspect that it can be because my old integrated graphics card (intel GMA X3100)

Re 2.c 2.f and 6

blend function so the way how existing color of pixel and currently drawing is mixed we can set by glBlendFunc(enum ,enum) it is still bit confusing to me but I understood couple of setups

  • multiplicative: previous color * actual color  = glBlendFunc(GL_DST_COLOR, GL_ZERO)
  • additive: previous color + actual color =  glBlendFunc(GL_ONE, GL_ONE)
  • drawing inversely proportional to amount of alpha =  glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE)

Note: this lighting system was done without any shaders,  only pure OpenGL with fixed pipeline. The essence is to know how to generate light texture and using appropriate blending functions

2.d is most complicated step. It consist in drawing shadows only with alpha set to 1.0. Firstly my must find all overlapping objects with light, I have done that by comparing axis aligned bounding boxes. Then for each vertex in found object we must calculate vector from light, next we perform dot product on it and object edge normal to determine if this vertex is necessary to cast shadow. After that,  draw each found vertex and vertex casted outside light. As performance optimization we can set glScissor test to save some fill rate.

 

triggers, switches, levers – custom actions November 8, 2011

Filed under: gamedev,videos — szaman @ 08:01

Hello

Last time, I started to make my game more unpredictable. To achieve that i created my internal “script language” which is integrated into my editor and allows me to make custom actions. For now I see many uses, for example :

  • controlling moving platforms
  • opening doors
  • spawning monsters  (yep, monsters are already implemented)
  • changing music, playing suitable sounds ( mystical sound when when entering the room)

How it’s made?

Simply, first in editor I create my level, next i write formula on new script window ( yeah, it will grow to  something like UDK 🙂 ) then I can attach this formula to any object on scene like bottom of switch. After that my chosen object gains new functionality, which is executed every physics update. Especially, typical  trigger checks every update if something collide with it, than if collision occurs, it executes selected action e.g. formula like :

TRIGGER REVERSE OBJ1

mean,  if something touches the object then reverse motor of object which name is “OBJ1”. Of course OBJ1 must have joint with motor enabled, without that nothing will happen. And one more thing is needed to get it to work – object OBJ1 must exist on scene, so we must choose object and name it:

NAME OBJ1

Of course formulas can be combined to give various effects like:

TRIGGER REVERSE OBJ1 REVERSE OBJ2

reverse motor at OBJ1 and reverse motor at OBJ2. This is used in post video – opening horizontal gate
Or something like that:

TRIGGER REVERSE OBJ1 DELAY 300 REVERSE OBJ1

which can mean:  reverse motor at OBJ1 (open door) then wait 5 seconds (300 * physics fixed time-step (1/60 sec) ) then again reverse motor at OBJ1 – close the door. So player have limited time to pass through the door

Switches are made with usage benefits of bullet. Simply capsule-like shape with motor which pushes object in certain direction. Power of motor can be adjusted to the needs. If something is lying on capsule and it’s enough heavy to break power of the motor than it triggers the action. Other type of switch is made with weak motor and it triggers action twice: on collision begin and collision end. The difference of this two switches You can see on video.

Lever is a tricky part.  Every mechanics/logic work beyond eyes of player – lower part of lever  is obscured by non colliding terrain. In fact lever is composed of stick anchored in the middle and the trigger which is waiting for hit. And the only on object which is able to knock it is of course previously mentioned stick.

Especially, trigger doesn’t need to have graphical representation like switch or lever, it can be  also invisible trigger which can create situation like suddenly closed doors after entering new location and played scary sound.

 

 

 

Ps.  Success! first not jerking film!

 

ropes and ladders October 12, 2011

Filed under: gamedev,videos — szaman @ 09:49

I specialized a new type of object, that allows to stick on it. After physics tick if player wants to catch object, I’m looking on his physics object contact points and simply if there is something to grab – just stick together by adding suitable constraint in right place. When player is sticking something then I unlock his jump possibility, which gives ability to climb. In the video bellow you can see two climbing/sticking models, and as you probably noticed they are not behaving in typical way. I mean specifically that they don’t collide with other objects (especially with player)

in bullet, for turning off collisions per object you can do such things:

  • specify collision group and collision mask while adding object to the world via
btDynamicsWorld::addRigidBody (btRigidBody *body, short group, short mask)

but this is not the way, I use for my ropes, because it prevents collision in very early stage and contact points are not generated for these objects

  • set CF_NO_CONTACT_RESPONSE  flag while constructing body
mBody->setCollisionFlags(mBody->getCollisionFlags() |   btCollisionObject::CF_NO_CONTACT_RESPONSE));

contact points will be generated,  so if you don’t need them use previous method because of performance. My sticking objects use this method to let know about ability to grab

 

sound, springs, trees and bushes September 12, 2011

Filed under: gamedev,sound,videos — szaman @ 20:22

Ok, at last my game prototype has audio. To achieve that I used SDL_mixer which has quite easy api, and with this wasn’t problem. More difficult part was to determine when certain sound must be played. Of course I am not writing here about trivial cases like player jump, or when player shoots than play “boom” sound. The difficulty is in physics based sounds because of collision ambiguity.  I created two types of physical sound:

  • first is  impact sound e.g.  when box falls to the ground
  • second – sound of scratching e.g. when some object is sliding on ground

All this you can hear on video (sound was recorded little too loud, so there are some defects )

 

 

On the video you can also see upgraded graphics. Adding some plants can really refresh game appearance,  they don’t have physical body they can be displayed behind or before player (hiding places). They are only purely cosmetic aspect.

The last new thing is the spring implemented from bullet physics engine, which may have various frequency of oscillation.

Now I must think about player improvement. I am thinking about creating him legs or feet 🙂

 

incredible machine August 10, 2011

Filed under: gamedev,videos — szaman @ 01:57

Hello everyone!

Officially I must say that youtube sucks so much.. I moved to vimeo, which is great. Video is put on their site exactly as it is (some jerkiness on video below is from my fault). On the beginning you can see my new feature – forcefields that push objects inside them in chosen direction, here through the “pipe”. On the end, you probably won’t be able to see that (I zoomed out too much) but player is talking(ya, really! he reacted for ball hit). It’s my new target – to create logic-adventure-physics based-platform game with plot.