Skip navigation.

A Blag About Graphics and Programming

...and Stuff

Compiling PhysX.Net

,

NVidia is giving away PhysX for free for quite some time now. And since it has hardware acceleration on PhysX cards and on CUDA enabled GeForces and some fun features like cloth, soft bodies, why not try it?

Read more...

Global Game Jam


Appearently, you can make a game in 48 hours...
A bunch of people come together, brainstorm ideas, form teams and shake their computers until games fall out.
~20 people showed up in Lithuania and made 9 games. And so, I give you Trouble at the Mexican Border:
Made by Litho and yours truly. The idea is that you can freely cross the border and you need to get as many maxicans over to US as you can. If they get spotted by the spot lights- they are sent back. Each time you help them get across, their number grows, so if you play well, eventually there's a whole crowd following you.
(The only difference between BorderTrouble.zip and BorderTrouble_v101.zip is that v101 has DirectX End-User Runtime web installer bundled (if you don't have the latest runtime, you'll get a "encountered a problem and needs to close" message).

A couple of games I have to mention:
The Story- The art is very nicely done and the idea for the controls is brilliant!
Defcon - Global Rule- I love it. Compare it to Missing Peace, they both have the same basic idea, with latter being probably the most polished game of all (for christ's sake, it even has a credits screen!), but Defcon brings joy to my heart every time I see it. Sure, it's not very sophisticated but it delivers pure mindless fun!

This great event was possible thanks to Aras, Rej and Programmers of Vilnius. Kudos, guys!

Smart House 3D Visualization


A project that I've done for the company Jung Vilnius.

Read more...

SSAO: Double Fail

Was playing around with the SSAO shader (using SlimDX), and suddenly started getting "An error occurred while preparing to debug the shader." from PIX, so I enabled the "Debug Version of Direct3d 9" and got this sexy message. I do as I'm told, and find this in the log file:
Frame 000075 ........PRE: <this=0x073523d8>IDirect3DDevice9::DrawPrimitive(D3DPT_TRIANGLEFAN, 0, 2)
An unhandled exception occurred.
Notice that this happens in the 75'th frame and I'm not doing any dynamic creation/destruction of resources- everything is created at startup.
The fun thing is that when ran inside Visual Studio, debug output doesn't report any problems, but inside the first effect.Begin() of the first frame the line
HRESULT hr = InternalPointer->Begin( &passCount, 0 );
simply doesn't return- the program stops and memory usage goes through the roof, but no errors or exceptions.

So I think that I've managed to write an uber shader that pwns D3DX, I spend half of the day trying to pinpoint the problem in the shader, but that doesn't take me anywhere. Then I try to isolate the problem by removing stuff from the program and finally realize that it has something to do with my VertexDeclaration:
SlimDX.Direct3D9.VertexElement[] elem= new SlimDX.Direct3D9.VertexElement[]
{
   new SlimDX.Direct3D9.VertexElement(0, 0, SlimDX.Direct3D9.DeclarationType.Float3, SlimDX.Direct3D9.DeclarationMethod.Default, SlimDX.Direct3D9.DeclarationUsage.PositionTransformed, 0),
   SlimDX.Direct3D9.VertexElement.VertexDeclarationEnd
};
Ok, so the problem is that I'm using PositionTransformed and Float3 (xyz) when it should be Float4 (xyzw). I fix that and change my vertex structure accordingly.
Doesn't solve the problem.

Then I change to DeclarationUsage.Position- that seems to work.
I try using FVF instead of vertex declarations:
device.VertexFormat = SlimDX.Direct3D9.VertexFormat.PositionRHW;
//which should be the same as
device->SetFVF(D3DFVF_XYZRHW);
This also doesn't work.
But
device.VertexFormat = SlimDX.Direct3D9.VertexFormat.PositionW;
works.
AGH!1 What the..? Why can't I use transformed position with debug runtime?

Then it dawned on me to try the Reference device... Yep, that hit the spot. Apparently, my old ati/amd/toshiba drivers pooped on themselves.

Spending several hours doing pointless debugging: fail.

SSAO The Wrong Way


Apparently everybody and their uncle is doing screen-space ambient occlusion, so I've decided to hack-up my own version. As you can tell from the screenshot, I failed.

The basic idea is that you take the depth of a pixel and compare it to depths of pixels that are around it. If they are closer to the camera- the pixel is occluded and therefore receives less ambient light.
I can see two main problems:
  1. If a surface is almost parallel to the viewing direction (like the "floor" in the screenshot), It "occludes" itself: take the depth of a pixel, and compare it to the depth of a pixel just below it. It is closer to the camera, and ends up "occluding" the pixel above it. This is obviously wrong.
  2. Occlusion factor grows as you get further away from the camera, because the difference in depth of two neighbouring pixels becomes bigger (this can also be seen on the "floor"- it becomes darker as it's getting further away).
    I think this could be solved, by scaling something somewhere according to depth, just have to guess what and where...
The first problem is a bit more complicated, I have a feeling that you need to have information about surface normals.

Better Late Than Never

Happy New Year...

The end of 2008 was interesting:
  • An epic project for the Software Engineering/Team Software Process class at the university. Yes, we did have tree months for it, but it's just more fun to do everything during the last five weeks :wink: Working in a six-man team was a great experience.
    In case anyone is looking for a free SVN server that allows closed-source projects: Origo FTW!

  • Wrote a simple soccer "playing" robot for the Autonomic Robot class using Microsoft Robotics Studio and Soccer Simulation for Microsoft Robotics Studio.
    The assignment was to code a robot that can score a goal from any "reasonable position" in under a minute.

    Did I mention that the robot only has a 320x240 "webcam"? And that for some reason the entire robot depends on the webcam? The webcam has a new image? That means it's time to update. You still haven't finished responding to the the last image? Doesn't matter, it's time to update!
    Oh, and there's no collision between the ball and the camera, so the camera gets inside the ball, and, suddenly, there's no ball visible! Great times...
    This was one of the most painful pieces of code I've ever written.
    Anyway, a dramatic screenshot:

  • Finished "the thing that I was working on" and have ranted a couple of times. More about this sometime in the future.
  • Became a proud member of the xbox360 owners club. MS_Fanboy++;
    Anybody wants to be my Xbox Live buddy and pwn some n00bs in Battlefield:Bad Company?


And to start 2009 on a proper note, my next semester's term paper will be on "Implementation and Research of Educational Software for Creating Affine and Projective Transformations". (This is the best translation I could come up with)

3DS Max + X

Sometimes, after exporting a model from max to X with the Panda X exporter, some objects get messed up(either geometry or UV's).
Solution: select that object in 3ds max, "export selected" to .obj, delete the object, import from .obj, apply the original material.
Problem solved.

Go figure...

*gasp* Linux...

I'm a Microsoft fanboy: I use Visual Studio, DirectX, Windows Media Player, I like Vista and I think that C# and .NET are great.
But there's a geek in me who wants to see how the latest and greatest Linux distributions look like. I have a 10GB partition just for that. I install Linux, play around with it for a couple of hours and never boot it up again for the next half a year until a newer and greater version comes out.

My latest evaluation checklist looks something like this:
  • How difficult is it to access my NTFS partition;
  • Connecting to my home wireless network;
  • Setting up proper(1280x800) screen resolution;
  • Does the headphone jack work;
  • How hard is it to play "evil" (mp3, etc) multimedia files;
  • Hardware graphics acceleration;
Naturally I want all of this "out of the box" (or at least with a couple of clicks of a button), without having to google stuff and type alien mumbojumbo in the console.
And it just so happens that this checklist is nearly impossible to pass (at least on my laptop)!

Old(7.10) ubuntu/kubuntu versions used to fail miserably, the only thing that worked was reading NTFS and sometimes- wireless. Yes, I couldn't even change the screen resolution to 1280x800!
Mandriva One 2008 and Linux Mint 4.0 looked half decent- headphone jack and hardware acceleration were the only things that didn't work, the default resolution was messed up, but it was quite simple to change it.

Mandriva Linux 2008.1
The new version came out a couple of weeks ago. I boot up the live CD and as it is loading, I sense that something is different: zomg! The resolution is 1280x800! I couldn't believe my eyes, and then the most incredible thing happened: a window popped up and asked if I wanted to enable Compiz! Whoa, it supports hardware acceleration for my cutting edge, super new HD2600 card! And the magic didn't end there- sound was coming out of the headphones, and no sound was coming out of the built-in speakers while the headphones were plugged-in.
The only problem was "glsl shaders not supported". But at least I can run Tux Racer at 50fps...

That was a historic day- not only a Linux distribution passed my entire checklist but it did it straight "out of the box".
Mandriva Linux 2008.1- certified by me.

I expect the next version to support multiple displays and maybe even the volume control thingy on the side of my laptop.

[rant]

Ubuntu 8.04 (<adjective> <noun>)
Yes, this is the one that came out today. The most beloved and popular linux distribution. It should give Mandriva a run for it's money!
No, not really.
No hardware graphics acceleration, no compiz, no sound from the headphones (uses the built-in speaker even when the headphones are plugged-in), half of teh internets is broken because "requires additional plugin" or "your Flash version is out of date", no mp3 playback without doing "stuff". And the fun thing: "your (graphics) hardware doesn't require proprietary drivers". OH RLY? Then how come it doesn't work?

I can understand not playing mp3 files, not including Flash and other hippie "free" software nonsense. I can understand when they don't support shaders or a webcam or an sd card reader, because, hey, writing drivers is hard.
But the thing that gets me, is when the dirty, tree loving hippies behind Ubuntu and other "free" software choose not to support my hardware just because they have personal issues with ATI or some other hardware vendor, I take that as a personal "fuck you".
"Humanity towards others" my ass.

And this bring me to my main point: the way I see it, there are two types of linux:
  1. Corporate Linux: Mandriva, SuSe, Fedora. This is the good kind, because they have a corporation behind them and that means that they actually care about quality (and money);
  2. Everything else: it sucks. An exception is Linux Mint. I have no idea how did this happen. Will have to investigate more.

[/rant]

Geomipmapping

The basic idea is that you split your terrain into smaller patches and render each patch in lower detail as it gets further away from the camera. Pretty much the same as texture mipmapping, hence the name- geo mipmapping. More info.

The annoying thing is solving the gaps between patches of different LOD (T-junctions). I've already done this a couple of years ago, back then, I used a static index buffer for the center of the patch, and a dynamic one for the edges.

That worked quite ok, the best part was, that one patch could have been in highest detail, its neighbor- in lowest detail and both of them would connect perfectly.

Instead of choosing witch LOD to use based on distance, I used to test how big of a "pop" a lower detail patch would cause, if it was acceptable (just a couple of pixel)- use the lower LOD.
Determining which LOD to use this way had two great effects:
Patches that were further away used lower LOD (just like determining based on distance).
Patches that were flat or very smooth, used lower LOD even if they were close to the camera. For example, if a camera is in the middle of a patch that is just a flat plane, it would be rendered in lowest detail because a plane never causes any popping. On the other hand, if you use distance based LOD, the same patch would be rendered in highest detail because it is very close to the camera.

Ok, back to the present.
Currently I'm using simple distance based LOD, limiting to only one LOD difference between neighboring patches and precomputing every possible variation of LOD/edge. So every LOD has 9 permutation of different edges (I guess 16 if you're not doing any culling, 12 if you're not doing a certain hack).
I'm going to use geomorphing to solve the popping problem.

Terrain with the height map as the texture:

Wireframe (LOD+ culling)
Size: 513x513; Patch size: 33;
720fps
(click)

Wireframe (no LOD, no culling)
300fps
(click)
(click)

(click)

Depth of Field is Fun



July 2009
M T W T F S S
June 2009August 2009
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31