All Blog Entries

All blog entries, ordered from most recent. Entry count: 973.

Pages: 1 2 3 ... 122 >

Jul 2014

Making Tilt-Shift Photo in GIMP

There is an interesting photographic effect called Tilt-Shift. It makes a photo of city panorama looking like a miniature due to small depth of field. Wikipedia says it can be obtained optically with some advanced techniques, but it can also be approximated with postprocessing.

Yesterday I visited St. Dominic's Fair in Gdańsk, where I had an opportunity to enter a Ferris wheel and take a photo of my city from some height. Here is my experiment with tilt-shift. I've made it GIMP.

Gdańsk Tilt-Shift

To do it, top and bottom of the photo needs to be blurred. But an out of focus photo is not the same thing as standard Gaussian blur. That's why a special kind of blur is needed. There is a GIMP plugin for it: Focus Blur (Windows binary can be found HERE). In Photoshop, the effect is available as Lens Blur.

Image needs to be blurred more the closer a pixel is to the top or bottom edge of the image. But I have no idea how to do blur (or any other effect) with intensity varying over image location, so here is the trick: We can use only two layers - normal and heavily blurred - and blend between them using layer mask.

So to add tilt-shift effect to your photo using GIMP:

  1. Choose a photo of a city panorama. Open it in GIMP.
  2. Use Crop Tool to crop it so no horizon line or sky is visible, only ground.
  3. In Layers panel, click appropriate button to duplicate layer.
  4. Make sure the top layer ("copy") is selected. Select Filters > Blur > Focus Blur. Change radius to some higher value (I used something around 10-16 for image in Full HD resolution). Confirm with OK.
  5. Now right-click on the top layer and select Add Layer Mask. Mask is created for this layer and selected so now drawing will change layer transparency instead of color.
  6. Select Blend Tool (the one for drawing gradients).
  7. In Tool Options panel, select gradient "FG to BG (RGB)" and change Shape to Bi-linear. Make sure current colors are: foreground = black, background = white.
  8. Draw the gradient by pressing left mouse button in the center of the image, dragging cursor to the top or bottom (hold Ctrl to draw perfect vertical line) and releasing it there.

If you've done everything right, you should now already have blending between layers applied so that top and bottom of the image looks like out of focus. Now you can:

  1. Flatten image by right-clicking on top layer and selecting Merge Down.
  2. Enhance colors. You can, for example, increase saturation and contrast.
  3. Export image with File > Export As.

Comments (0) | Tags: photography | Author: Adam Sawicki | Share

Jun 2014

Rendering Video Special Effects in GLSL

Rendering real-time, hardware accelerated 3D graphics is one aspect of computer graphics, but there are others too. Recently I became interested in video editing. I wanted to add some special effects to a video and was looking for a technology to do that. Of course video editing software usually has some effects built-in, like different filters or transition effects, some borders or gradients. But I wanted something different. If I had and I knew how to use software like Adobe After Effects, I'm sure that would be the best and easiest way to make any effect imaginable. But as I don't, I decided to use what I already know - to write a shader :)

1. To run a shader, some hosting app is needed. Of course I could write one in C++, but for the purpose of this work it was enough to use Live Coding Compo Framework (a demoscene tool created by bonzaj, which was used during last year's WeCan demoparty). This simple and free package contains rendering application and preconfigured Visual Studio solution. Having VS installed (it works with Express version as well), all I needed to do was to edit "Run.bat" file to point to directory with VS installation in my system. Next, I just executed "Run.bat", and two programs were launched. On the left monitor I had fullscreen "Live Coding Preview", on the right: Visual Studio with special solution opened. I could then edit any of the GLSL fragment shaders contained in the solution. Every time I hit Compile (Ctrl+F7), the shader was compiled and displayed in the preview.

2. Being able to render my effect in real-time, next I needed to capture it to a video. Probably the most popular app for this is FRAPS. I ran it, set Video Capture Settings to frame rate that I was going to use in my final video (which was 29.97 fps) and then captured appropriate period of time of rendering my effect, starting and stopping recording with F9 hotkey.

3. Video captured by FRAPS is in full, original resolution and encoded with some strange codec, so next I needed to convert it to desired format. To do this, I used VLC media player. Some may think that it's just a video player, but in fact it's incredibly powerful and flexible video transmitting and processing software. (I once had an opportunity to work with libVLC - its features exposed as C library.) Its greatest advantage is that it has its own collection of codecs, so it doesn't care whether you have appropriate codecs installed in your system. To convert a video file, I selected: Media > Convert / Save..., selected my AVI file captured by FRAPS, pressed "Convert / Save" button, selected Profile: "Video - H.264 + MP3 (MP4)", customized it using "Edit selected profile" image button, selecting: Encapsulation = MP4/MOV, Video codec = MPEG-4 (on Resolution tab, I could also set new resolution to scale the content, my choice was 1280px x 720px), Audio disabled, Subtitles disabled. Then after pressing "Save", selecting path to destination file, pressing "Start" and waiting some time, I had my video converted to more standard MPEG-4 format (and more than 5 times smaller than the original one recorded by FRAPS).

4. Finally I could insert this video onto a new track in my video editing software and enable blending with underlying layer to achieve desired effect (I used "Overlay" blending mode and 50% opacity).

There are some details that I intentionally skipped here (like video bitrate) not to make this post even longer, but I hope you learned something new from it. My effect looked like this, and here is the source code: Low freq fx.glsl

By the way, here is another tutorial about how to make GIF like this from a video (using only free tools this time):

1. To capture video frames as images, use VLC media player:

 2. To merge images into animated GIF, use GIMP:

Comments (1) | Tags: rendering video tools | Author: Adam Sawicki | Share

Jun 2014

Pixel Heaven 2014 - My Photos

Here is the gallery of my photos from Pixel Heaven 2014:

Pixel Heaven 2014

Comments (0) | Tags: gallery events demoscene atari | Author: Adam Sawicki | Share

Jun 2014

Pixel Heaven 2014 - My Impressions

31 May - 1 June I've been in Warsaw on Pixel Heaven. As I haven't been on previous edition, I didn't really know what to expect. Timetable was full of various activities - lectures, competitions or just opportunities to play some games. Would it be only about retro games, or also modern games? Only about indie games, or AAA games too? Is it more for gamers, or for professional game developers? What about demoscene? Either way, I decided to go there.

I'm not really into these retro platforms, so I planned to go listen to lectures about indie game development. I've seen and heard many interesting stuff there, like Adrian Chmielarz from The Astronauts presenting their game - The Vanishing of Ethan Carter - for the first time!

But as it turned out, I met so many interesting people there (some of them I haven't seen for years) that I've spent most of the time talking with someone :) It's a coincidence that just recently I've heard stories of several people who work for many (some more than 10) years in just one company. Very often that's their first job after graduating university. They speak with confidence like they know a lot about doing career. Surely after all these years they were promoted many times. But at same time, I think sometimes such people preceive possibilities and limitations of their job as something obvious, its rules as something critically important, like it was whole world. I don't think it's good attitude and I want to avoid that.

On the other hand, noone can try in his life every possibility in terms of work and career. For example, someone who already has a house and spouse and children and mortgage many not be willing to move to different city or country or try to make his living from doing a startup or indie gamedev studio. That's why I think it's so important to talk to many different people and hear their stories. Knowing how working for some other company looks like, whether your competition or in completely different business, or how totally different may someone's work and lifestyle be (e.g. freelancing, working from home, being a consultant, traveling to different countries to do different projects, making a startup) is mind-expanding because it makes you think about your own career with all its pros and cons in the context of bigger picture of what's possible.

Back to the Pixel Heaven, I recommend this party to anyone who is interested in either retro games or indie games. There is a lot of things to do all the time so noone should be bored.

Comments (0) | Tags: career atari demoscene events | Author: Adam Sawicki | Share

May 2014

Offensive Programming :)

Generally, defensive programming is a very good idea. But many times I've seen this following C++ code explained as an example of defensive programming:

if(pointer != NULL) {
   // Some other things with pointer.

If the pointer here is expected to always point to a valid object and not NULL, otherwise it's a programmer's bug somewhere else in the code, then I believe such practice is very, very bad. I think there should be an assertion instead, like this:

assert(pointer != NULL);
// Some other things with pointer.

First of all, assertion is compiled only in debug configuration, while condition would be additional code executed in all builds, unnecessarily impacting performance. Second and more important argument is that when there is a bug and the pointer is NULL, we should know about it as soon as possible and be able to debug this particular place. That's easy when we put an assert. That's also easy when we dereference NULL pointer, because then the application would crash, which is also possible to catch in the debugger. On the other hand, when there is a condition around code using this pointer and the pointer is NULL, the code inside is just not executed, which may somehow corrupt or just propagate corrupted state of the program, hide the bug or defer its appearance for later time and to different place of the code, making it harder to find. Recommending to crash the app could sound radical, so let's call this "offensive programming" :)

Comments (5) | Tags: c++ | Author: Adam Sawicki | Share

May 2014

Simple 2-digit Method of Task Management

Managing some list of tasks to do (or "TODO list") is very important skill that helps in both work and everyday life. I usually use GTD (Getting Things Done) method. But sometimes, like on the recent Hack3city competition, a simpler method is more suitable.

A lot could be said about this subject (maybe some day I write an article or prepare a presentation about it). Generally, tasks to do can be organized based on different criteria, like:

Even after "filtering" only tasks that you can do and you should as soon as possible, they can be sorted in three different "dimensions":

  1. Difficulty: how difficult/big/time consuming the task is.
  2. Importance: How important is it to do this or consequences of not doing it.
  3. Urgency: How much this task should be done as soon as possible.

It's obvious that not all the tasks will be done. During a 2-day programmers' competition, just like in everyday life, writing down ideas for doing things is good, but there is never enough time to complete them all. That's why there is a need for some method of deciding what to do next. During Hack3city, I came up with a simple, ad hoc method, which I want to describe here. The goal of developing it was to make the bookkeeping of the list as quick and easy as possible.

During a hackathon like Hack3city, where we created most of our game in just 2 days, the 3rd dimension is not important. Sure sometimes something must be coded quickly because artist or level designer is waiting for it to be able to continue his work. Then I do this first. But otherwise all tasks are equally urgent - they should be done in the short amount of time, during the event. So what I did was I opened the system Notepad and started writing down tasks and all ideas that should be/could be added to our game, one line each. But instead of starting a line with "-" for just a bullet, I started it with two digits, meaning:

Normally I just delete lines with tasks I finished, but since some time during the event, I started to move them to "DONE" section instead to show them later in this post. So here is partial task list from our game:

23 smoke effect when player falls onto the ground
22 flashlight rotates when player dies
23 flashlight rotates following player walking animation
31 spear, shooting from a wall when player pushes a button
12 delay appearance of "game over" text
22 push button
12 door that can be opened
13 red eye of zombie should pulse and blink
13 graphics in the menu instead of text
31 sound effects
33 fix ladder climbing animation
31 fix double-jump bug
22 walking sound effects should be played randomly
12 parallax for moving background
21 bug: player death animation doesn't work
11 playsoft logo
12 music
12 zombie: add hysteresis to the decision weather approach the player
21 death from the spikes
12 turning flashlight on and off
22 there are some bugs/spiders walking on the floor
33 a spiked ball on a chain, hanging and swinging from the ceiling

Of course the list of tasks was constantly changing as artist, level designer and me came up with new ideas or decided that something is more or less important, found new bugs during testing etc. But I tried to concentrate on finishing one thing at time. When finished, I picked up next task to do according to following rule: I reviewed whole list to find a task with the smallest sum of its numbers. So the order in which I was doing the tasks was:

This way we managed to accomplish most of the tasks we planned so we were quite satisfied with our game as it looked and worked pretty much as we planned. That's why I believe this simple 2-digit method of managing task list is good for hectic, time-constraint and constantly changing work environment.

Comments (0) | Tags: events competitions productivity hack3city | Author: Adam Sawicki | Share

May 2014

Hack3city 2014 - Review

5-11 May 2014 there was first edition of Hack3city - a hackathon in Gdańsk, Poland. It was interesting and unusual in many ways. First of all, there were 4 different tracks, so each developer could choose what is interesting to him.

Teams could have up to 3 people. Of course I was in the Playsoft track. We made a game together with Arek Duchnowski and Marcin Szymczak, who work in aideMMedia.

On Monday evening there was an official beginning (and free beer :) That's when themes of each track were announced. During the week we could work on our projects from home. On Saturday and Sunday (including the night) we were invited to work all together in an open space in Starter.

Also on Saturday organizers announced additional "diversifiers" (like on Global Game Jam). Fulfilling them was additional plus. For games, they were like "graphics is black and white", "game is controlled with one button" or... "game includes Playsoft logo". You could imagine how such logo might be used in a game themed "fear of the dark" :)

On Saturday and Sunday we have 3 meals - all for free (and free beer at the end :) There were mentors representing the sponsoring companies available in place so we could ask them for help.

There were totally 19 teams participating in all tracks. Most of them were in the gamedev track. Projects were evaluated by a jury based on a 5-minute presentation and there were winners selected in each track. Some teams just presented their applications, while others focused on delivering a PowerPoint presentation. Finally we took 3rd place. See also more about Our game from Hack3city 2014.

Among teams that were creating a game, Unity was the most popular technology. That's also what we have used. But there were different technologies present too, like C++ with Marmalade (which was officially recommended and the prize for 1st place was a license for this library), JavaScript and... Lisp (or Scheme, to be more specific). During work, many interesting stuff could be learn and overheard, like what do artist say when they want to insult programmers: "lerpuj kwaterniona", which means: "go lerp quaternion" :)

But the event was not only about programming. Maybe because it was organized by and in the Starter, it had a "startup feeling". For me it looked like many people, while being programmers, were more focused on money and business than technology. Maybe the culmination of it was presentation of an application that helps with first aid - shows information about how to help injured person, helps measuring rate of artifical respiration etc. Someone from the audience asked a question: "Do you have business model?" Someone else from the audience answered jokingly: "If you want to save someone's life, please first watch this ad".

Overall I think the event was well organized. Rules and general feeling was somehow similar to Global Game Jam, still quite unique and different in many details. I don't know if it's a good idea to announce the theme on Monday and allow working during whole week. Developers with lots of free time have advantage over these who study, have family or a full-time job. I also didn't like the idea of presenting each project 3 times instead of only at the end. It took lots of precious time that we could spend on coding and also made the final presentation less of a suprise. Everything else was great (did I mention free beer?), so I recommend attending this event when it will be organized next time!

Comments (1) | Tags: hack3city competitions events | Author: Adam Sawicki | Share

May 2014

Hack3city 2014 - Our Game

I just came back from Hack3city - a programming competition. Participants had to develop their applications over this week - Monday to Friday working from home, while Saturday and Sunday working in Starter, Gdańsk. There were 4 tracks. We participated in track organized by Playsoft, where we had to create a game. The theme of this competition was "fear of the dark". We took 3rd place.

As I promised to some of you, I publish playable version of our game today. The game is created in Unity and can be run in web browser if you have Unity Player installed.



Our game is called "Jason McBrady Dark Adventure". It's a 2D platform game. It's about an adventure seeker exploring ancient tombs full of dangers like zombies, who want to kill you, but run away from from the light. It's quite difficult :)

We called our team NOQA. Credits are:

In the next post, I will write more about Hack3city. See: Hack3city 2014 - Review

Comments (0) | Tags: unity hack3city competitions productions | Author: Adam Sawicki | Share

Pages: 1 2 3 ... 122 >

STAT NO AD [Stat] [Admin] [STAT NO AD] [pub] [Mirror] Copyright © 2004-2014 Adam Sawicki
Copyright © 2004-2014 Adam Sawicki