Kaip iš minuso pliusą ištraukti

Autorius nežinomas (tiksliau neatskleistas), šios eilės buvo padeklamuotos per 2012 metų KTU Fundamentaliųjų Mokslų Fakulteto diplomų įteikimo šventę, kaip dalis studentų atstovybės sveikinamojo žodžio.

Aš tiek daug kartų ir tiek daug valandų galvojau,
Kad matematikos gyvenime aš nenaudosiu,
Bet pirmą kart nubausta namų mokyklos suole sudėjau pyktį, skausmą
Ir traukiu šaknį iš tikėjimo, vilties ir noro.
Kiek kartų buvo man kartota, sutraukt panašiuosius narius nebus man sunku,
Kiek kartų buvo man kartota, padauginti ir tai aš galiu,
Bet kaip iš minuso pliusą ištraukti, kai nelyginiai dūžiai širdies,
Kaip ištraukti vieną vienintelį teigiamą ženklą,
Jeigu x ne mano lygties,
O kaip man meilę atskliausti,
O skliaustuose man uždaryti nervus,
Kiek laimės ir pykčio procentų
Šį kartą gausiu išsinešt į namus.

Playground for graphics

Deferred rendering

During my experience in various commercial and non-commercial projects I’ve came across some interesting CG ideas, algorithms and approaches. Some of them I get to implement on those projects, some of those are already implemented and I just have to use them. Those that are left behind are still lingering in my mind with the label “I wanna do this”. That’s how I’ve decided to create a playground for myself.

First, it would be used to have slightly more organized (than regular drafty piece of code while trying something out) collection of various methods, tools and algorithms relating to 3D rendering and CG. Although it is way slower than just to bash some lines of code, but trying to fit methods I want into somewhat nice framework and pipeline is part of the task. In other words, it’s not really a playground, but more like a tool for myself, were I can play around with new CG and 3D stuff.

Another reason why I wanted to do this is to have a playground for shaders. There are plenty of shader authoring tools on the vast Internet, but I still haven’t found one that would fit my needs. At the moment I am using a set of ShaderMaker, Shader Toy and Shdr. Having my own environment suited for my style and needs is something I was misssing.

I’ve started it as a very simple “load and show” program. Since I had OBJ file loader implemented some time ago (here), I’ve started with using/adapting/adjusting the same code. And, implemented simple Phong shading with forward rendering using OpenGL. I did some more stuff on top of that, such as some GUI implementation, some abstract classes to support extensibility to some sort, etc.

Finally, as my next step (and one of those “I wanna do it”), I’ve started with deferred rendering. And I had my ups and downs. Idea is extremely simply. But it took me a lot of time to figure out and find that rendering empty vector of light objects results in empty/dark scene. Stupid me. Anyways, picture above is current screenshot of my test scene rendered with 500+ point lights and couple of objects. This is still not optimized version of the algorithm so frametimes are just around 15ms.

Coming up next: the shadow! Probably. Well, first I will optimize the rendering and then most likely will want to go for shadows. Or some spotlight implementation and some other cool stuff related to that. Argh, so much stuff, so little time… 🙂

BoxBots

Actually, this game is slightly earlier than BattleShades. I was playing around with libgdx and Box2D physics engine and decided to make something “driving and shooting” style. I managed that and then I decided to restructure code a bit to make modular and stuff and ended up not reaching the previous functionality. Although you can nicely drive and at least spin up the miniguns on top of the awesomely drawn combat vehicle 😀

Controls are: Arrow keys for driving, Space for spining up weapons.

Unfortunately, for some unknown reason steering is not working from up start. Try to relaunch if it doesn’t. I might some time return to this thing to play around more…

Current binary is here.

BattleShades

Once upon a time, a small idea for a game popped into my head. One or two evenings later I have realized that it does not pan out as I was expecting (and imagining) in my head, but something was already produced.

Idea is rather simple: You start as a colored fighter (box yeah!). You fight against other colored fighters. But the fighting is technically “stealing”. You steal the color from another fighter. How much and what kind of color you steal depends from both fighters in clash.

Unfortunately, gameplay was not as dynamic as I was expecting 🙁 And the current state is a crude prototype, no gui, no menu, no nothing…

Controls: WASD for movement, mouse for aiming, space for shooting.

Binaries you can get here.

While source is available at my Bitbucket repo.

Tiny Tools To Turbocharge Thy Transistors

I have decided to post a list of a certain freeware (usually at least for personal/non-commercial use) software that I am using or have ever used. I will probably exclude all the fancy and popular enough software tools such as Dropbox or Evernote which might be already known.

The reason is that sometimes you have no idea that you can do something efficiently or more comfortably, thus you never consider looking for the solution. That’s how most of the time I’ve got hold of all these programs. Continue reading

Network I/O Graph

Some time ago I’ve encountered a need of tracking current utilization of my network interface. Just to diagnose if I am running out of throughput or network is weirdly slow. After short search, I found a neat freeware tool – NetSpeedMonitor – which would display a small “gadget” on the taskbar with current used throughput on selected network interface. It is quite customizable – selecting scale of measurements (bytes/kilobytes/kibibytes/etc), labeling differently and adjusting the look’n’feel of the aforementioned “gadget” (I am quoting “gadget” because it is NOT regular Windows Gadget. Nor it is just system tray icon.)

Furthermore, it does not only shows the current utilization, it collects statistics on how much data you actually sent/received on selected interface. It can monitor only one interface at the same time, but technically it is possible to switch and “monitor” any and all interfaces, as long as not several at the same time.
So, I have been using it for some time and I have quite a lot of data at the moment and I was wondering – why not to put it into charts? That should look cool 😀 So, here it is, my first digital traffic statistics 🙂

Conclusions

I was kind of aware of my probable maximum and minimum daily throughput. I was actually surprised on my “average” statistics. I am really wondering how it adds up to 15 gigabytes of data per day on average… Of course, it might be the fact that data is not very “smooth”, and dispersion is enormous… Maybe those several days with outrageous traffic mess everything up 🙂 Let’s wait for more data…

N.B. #1 Although it might not be 100% accurate because I was monitoring only my WiFi interface (and not the Cable interface), but I have used WiFi almost all the time and probably Cable connection would be a fraction of a percent of overall traffic.

N.B. #2 The tool for generating those awesome HTML5/JS charts is from here http://www.highcharts.com/. Although I kind of lazily implemented it in my blog… (shame on me)

Plebiscitum – friend or foe?

It’s hard to go by in our times without hearing something about politics. New law here, meeting of the heads there, corruption scandal over there. But usually it all starts with one and the same thing – elections. If you want to get in and stay in “the game”, you have to get elected. That is what this game is all about – winning the elections. Any means necessary.

This is the game me, Alessandro Suraci and Cyrill Averbeck have created during Gameplay Design course at Chalmers University. The game revolves around the world of politics, parties and elections. The whole essence of the game is the decision between standing up for your party or… well, yourself. This game is played in teams (which are considered to be political parties) and in order to win you have to be both the best within your party and your party has to be the best. This leads to amount of interesting dilemmas – should you try to crush opposing party or backstab your colleague, should you try to be hard working and honest politician or go dirty and expect to get away with it. It is fun, addictive, beautiful and sarcastic game for anyone who is at least a little bit aware of the politics!

We have published our game on The Game Crafter website. It’s quite expensive, unless you are living in the USA. Here is the link:

Plebiscitum @ The Game Crafter

Card Game Desktop

I am gamer. And as it comes sometimes, I have some stupid idea that I want to create a game. And once I figured that it would be cool to have a nice board/card/rpg game. And then I made my first prototype, printed it out, cut all the cards. It took me a lot of time, a lot of printer toner and a lot of paper. That’s when I tried to come up with an easier solution – find a software which would allow to play various card games. But I couldn’t find any. This is why I’ve decided to try to create my own. For starters it had only two feature requirements: 1) you can add any image from your computer as card to the playing field. 2) you can move around, scale up or down and flip up or down the card. Essentially, that is the only things that you would need for a simulation of any card based game. For some time I’ve developed it a bit further, but then I’ve got carried away with the rest of my life and it got stuck. Furthermore, I was/am using quite out-dated engine for doing all the drawings (I liked it back then), which discourages even more from continuing it as it is now. But if I would migrate it to some other engine, who knows…

Screenshot 1 - CGD Screenshot 2 - CGD Screenshot 3 - CGD Screenshot 3 - CGD

Since it is kind of in development, binaries are not ready for distribution, but you could build (it’s buildable and runnable in debug mode) from source yourself and play around. The source code is freely available here:

Card Game Desktop @ Drags’ Bitbucket

As I said, it depends on external library which you could get from the link below. And in general, you can contact me if there are any problems 🙂

GTGE Homepage

Spherical Harmonics and Tanks

Alas, the first year of my master program has ended and I have decided to share one additional project I have been working on the last half of the year.

Actually, the course that I want to talk is Advanced Computer Graphics, which was extending through out both Study Periods of this semester, thus I am posting about it just now, when it is finished.

The course was essentially about doing a project work in a field of computer graphics with a chosen topic. And I chose spherical harmonics, because I was fascinated after our teacher introduced it. How powerful and fast it could be to make nice effects, such as world-space ambient occlusion and inter-reflection. Thus I have been working ever since the first seminars of this course in the end of February.

I’ve decided to try to work with OpenGL wrapper for Java – LWJGL. Thus I was able to work quite seamlessly both on my Windows and Linux installation (which I switched quite often). To begin with, I’ve wrote some helper classes to hold the information about vertices, vertex array objects and so on. But then the first problem occurred – I couldn’t find a decent model file loader for Java. Thus, I wrote one myself. I’ve spent quite a lot of time, but I wrote an OBJ file loader including with materials and textures. It is not fully finished (e.g. doesn’t support smoothing groups and such), but it was and is working for my needs. Later on I’ve implemented the classical rendering (the switch between classical and spherical harmonics could be seen in first part of the demo). I did that because I wanted to have some kind of point of origin, with what I could compare results of spherical harmonics (SH) rendering. And I wanted to test my OBJ loader without delving deep into SH calculations. After I’ve completed the classical rendering and OBJ loader, I’ve continued to work with implementation of SH.

I am not going to explain all the mathematics behind the SH because even for the course mates it was boring 😀 Thus I will tell what I have done with SH implementation. First of all, I’ve implemented all the methods required to calculate and use SH, but then, with increasing complexity of models, calculation times were going over the top. To construct SH for simple model with <1000 triangles would take about a minute or so. Thus I proceeded with research and implementation of ray tracing acceleration structures. That is construction of SH heavily relies on ray tracing from each of the model’s vertices. Because I’ve already had a small class representing axis aligned bounding box (AABB), I’ve decided to go for hierarchical AABB acceleration structure. According to my research it is not the most efficient structure, but it was efficient enough for me. After I have completed that, super complex models with hundreds of thousands triangles would be ray traced in a matter of minutes, thus it was sufficient enough. But still, the result of ray tracing is more or less pre-processing of the model.

That is why I have implemented SH saving/loading. Very simple and plain text format (I was inspired by OBJ format, thus very similar) which stores all the coefficients for SH for a certain OBJ file. If SH file is not found or is not representing the OBJ file (hash check! 🙂 ), all the SH harmonics are recalculated and saved again. This literally reduced pre-processing time almost to zero. Because of some complex models and high amount of spherical harmonics data, sometimes files with SH coefficients exceeds hundreds of megabytes, thus it takes a bit of time to load them up.

So, after core technology was done, I headed for the implementation of somewhat of a game. Downloaded several freeware models, created some myself. Created some what system for having complex models with separate parts, implemented interface, AI for enemy tank and even added fog effect so that background would blend seamlessly. I was almost ready to go. Almost.

After the supervision it was suggested for me to make something more, thus I have additionally implemented a skybox. It was rather easy to implement, but actually I was impressed about how it changed the feeling of the game. Because the skybox changed the ambient color of the background, I had to change the color of the fog and tweak the fog itself, but it was worth it. Then I have continued with the most interesting suggestion for me – screen-space post-process pass for volumetric shadows. Technically  it is simple radial blur, but after some struggle with framebuffer objects I have implemented it and combined with the skybox it ended up to look super cool. At last, as a final touch I’ve added some textures to make it less plain and a small bar for displaying player’s health.

Below you can see the tech demo – a small video which I have compiled out of all small videos which I’ve taken through out the development.

And here you can download binaries:

ACG project binaries

And if you want to take a look at the source, it is here:

Drags’ ACG project @ Bitbucket

Steam Fortress 2

Study Period 2 is nearing to it’s end, thus I decided to post about what I’ve been doing. Well, I’ll post only half of the stuff what I have been doing, because the other half is still in progress as one of the courses I read this SP is going to span over the next SP, too.

So, what I was doing? Simulation Engines. Course where we were supposed to build a simulation engine. We were working in teams, quite large, I would say. My team was made out of 6 members. After initial discussions we decided to make a fun “build and shoot” game, where you have a cannon, which you shoot, a heart, which you protect, and a bunch of building blocks which you use to protect your heart. Oh, by the way, each member had to implement different part of the engine, and in our case, those parts were software engineering (gluing part), artificial intelligence (smart part), physics (realistic part), graphics (cool part), multimedia (sounds and GUI part) and networking (social part). And I was responsible for the social part, networking. My extension idea and purpose was to create seamless connection between players, so that there would be no hosting or joining, nor lobbies or master servers. But that’s enough of talking. Here are some screenshots. And, of course, download links are below.

EDIT: oh, I forgot the gameplay video 😀

Cannon Ball

aiss copy

ai shooting

ai miss ai build ai fire!

Downloads:

P.S. If you wonder how you can play with another player over network, just start two games on the same network. Second player will automatically connect and replace AI 🙂

GGJ – Heart Traffic

So. Happened that my university was one of the GGJ locations. I was planning to participate anyways, but still 🙂 It was really entertaining 48 hours and I had chance to try something new and get more experience. And the result is here 😀 By the way, theme this year was literally a sound of beating heart 🙂 Not kidding, what we’ve got was just a black screen with heart beating in the background 🙂

You can check it out directly at GGJ website – Heart Traffic or just download executables from down below (both APK for Androids above 2.2 and JAR for anything that has Java Runtime Environment 7).

Heart Traffic screenshot

Downloads: