RSS
 

Back… I think…

26 Apr

Well, there go my good intentions… work and laziness have won, and I’ve not been updating… But I’m going to try to change that again, starting this weekend: another Ludum Dare competition!

I’ll probably participate in it, using my usual framework, that needs some more work on it, since I want to add support for skeletal animation (through my own Reality format)… I want to try my hand in designing some 3d characters and animating them…

On the game playing front, not much going on… Played through "Dragon Age 2" and I’m playing "Metal Gear Solid IV" (which I probably won’t be finishing), besides loads of "Band Hero" and some "World of Warcraft".

dragon-age-2-capa1-550x463

"Dragon Age 2" was nice, but it’s nowhere as good as Mass Effect… the CRPG component (the stats and skills part) is almost absent (it’s a very basic system, in which you really don’t really feel any impact on the decisions you make), but the RPG part was actually very good, since I felt my decisions impacted the game world and the distinction between "good" and "bad" decisions was very blurred in some instances, which made it more "real". The gay thing everybody’s talking about was taken a bit too far, in my opinion… I almost felt raped (and I think this runs a bit against the whole "gay is a choice, not a disease" vibe the developers wanted)… Another bad decision (in my humble view, of course) was the fact that the "troubles" were too local… although it ends up being more "real" and different from the usual "thou must taketh the artifact to somewhereth elseth", it takes a lot of the "epic" from it…
In other perspective, the graphics were sometimes appallingly bad (except for the facial rendering, which was very good, although a bit wooden in terms of expressions, but that’s to be expected in this kind of massive games), but it was a competent affair most of the time.
All in all, the game is interesting, and I had a good time playing it, but I think the series is going in a direction I don’t care much for (but again, this is a matter of taste)… 7/10

On the other hand, "Metal Gear Solid IV" is terrible…. I fail to understand why people loved this so much… the story is convoluted and makes little sense (and the sense it does seems like a soap-opera), the graphics are average, the storytelling is erratic, the missions are dreary and punishing (checkpoints at the beginning of the level only?! What is this, 1985?!), terrible controls…
Don’t get me wrong, I don’t have anything against the series as a whole, I loved the first 2 MGS, they had proper pacing (even if the story was already terrible), but this one is just a grind to get to the next (idiotic) cutscene… Maybe the problem is me, but I think that a stealth game should give us enough stealth opportunities, with loads of different paths, etc, and not make us wait behind a car for 1 minute for the patrol to go away, for lack of other paths… this hurts when you’re doing the scene for the n-th time, always getting a bit further using stealth… I end up finishing the levels by shooting everything, which kind of defeats the whole "tactical espionage" thing, in my opinion… 4/10…

Since I’m just bitching about stuff… I’ve been working on an iPad application for work… and I hate Macs more and more each day… 🙂 The fact that I connect my nice keyboard to it and it still doesn’t map all keys correctly (not even using Ukalele and other such applications) pisses me off to no end… And don’t get me started with XCode! I’ve ended up mapping a directory of the iMac to my harddrive and just using Visual Studio to develop, just using the iMac as a compiler (BTW, if you want to share a keyboard and a mouse only, without need for video, take a look at Synergy, which is a software-only solution for multiple systems, which is pretty cool if you want to do stuff like I’m doing)…
Even so, I’m still stuck with debugging with XCode, which is terrible for a person that’s used to Visual Studio’s debugger… I know half the problems I have with it might be solved with some web-searches, etc, but how hard would it be for me to be able to see the contents of an STL vector right in the debugger window out of the box?!
The iPad itself is not a bad piece of hardware, my application runs lots of triangles (even a bitmap based font renderer, which is pretty triangle heavy) without any big problems… I can definitely see the potential for gaming in that platform, although I don’t think most games play well there (the ones that use a "virtual d-pad" and stuff don’t work too well for me); but it’s easy to see the appeal for independent game developers… I’m more of a PC-dev guy, since most my game ideas are of a different focus that doesn’t translate well for iOS devices.

So, that’s it for now… Hopefully I’ll be more regular again from now on… want to get my hands on that "Portal 2" thingy, and Pixel Junk’s "Shooter 2", besides improving on my artist skills, so I can do better on competitions…

 
 

Motivation…

01 Apr

According to Wikipedia, Motivation is the driving force which helps us to achieve goals… Yet, my motivation lately has been a bit lacking; not only I haven’t updated this blog as often as I set myself to do when I started it, I haven’t worked in any of my game ideas for ages, even been lacking in my game-playing!

So, why’s that? Well, the first thing that pops to mind is that I’m lazy… but that’s only part of the truth, considering I don’t think making games is work, but a pleasure; yeah, of course it has its frustrating times, but no more than playing a game and being stuck in a boss fight (exhilarating when you finally kill it!), or when you watch a TV-series that ends on a cliffhanger (just makes the next week sweeter)…

So, what’s the source of my lack of motivation lately?

After some soul-searching, I’ve found 2 things that my games and my blog-writing have in common, and how that relates to my inertia:

Thinking too big

I think too big most of the time… My game concepts start simple enough, but they soon balloon in my mind until they reach the point that I can’t do them by myself (specially considering my graphic skills); most of my ideas are story-based, which don’t work without decent graphics for the exposition (even retro graphics with loads of text, etc, are beyond my grasp).

Some of my ideas are even doable with graphics made by me, without losing its core identity, but then I feel that I wouldn’t do that "great idea" any justice like that… A good example is a story I have in my mind (project codename is "Thanus Gray")… It started with a crossover idea between the game I did for the last Ludum Dare compo I’ve participated (Conquest) and a story I’ve been munching around for some months now… but I like the story so much, I don’t want to "waste" it on my graphics…

Same principle applies to this blog… I have a list of posts I want to make, with some development stuff, tutorials, pseudo-reviews, etc, but I don’t like to do stuff half-assed… so they sit there, and I continuously think "tomorrow I’ll definitely write this, so no point in writing anything today…"; and this has been my mindset for ages now…

Lack of awareness

Even as I write this, I know my blog is read by very few people in the world (not that I do that much effort in advertising it, but then again I think "why should people care, it’s not like this is very interesting"). This lack of exposure makes me cave in to the demotivation that’s the cornerstone of this blog post… After all, it’s not like many people will care if I write or not… 🙂

On the same page, my solo game development efforts will probably also pass under the radar, apart for some friends that will try it out (and not enjoy it much also!). That also doesn’t lead to motivation in creating a game (which is a medium that can’t serve just for itself for oneself, in my opinion).

So, what now?

I have to fight these two conditions, to be honest… I feel the need of expressing myself through the creation of a game, and being to demanding/megalomaniac isn’t helping my cause…

This will probably require some thought on how I can approach these two problems (although number 1 is way more important, in my opinion), but hopefully I’ll be able to start tackling solo game development in a different way, and I have material for some blog entries…

I really love the Wolfire blog in the way they have normally 2 weekly updates (one technical, one art), and that can also be a good idea for me: isolate the technical me from the artist me from the game designer me… Might help me reach my objective of actually finishing a good game that 3 people in the world might enjoy playing! 🙂

So stay tuned for more developments on this blog, I intend to really start working on it in the near future!

 
No Comments

Posted in General

 

Blizzard turns 20…

11 Mar

Didn’t had the time to write anything decent this week, but didn’t want it to go by without sharing this video with you:

http://eu.blizzard.com/en-gb/company/about/b20/videos.html#blizzard-retrospective

It’s a nice retrospective of one of the most influential game development companies in the world, and it has some nice trivia and behind the scene looks… It’s really something, thinking that a small group of dedicated people could create something like that!

Another good link to share was written by David Amador on his blog, and he talks about motivation and game development, check it out at http://www.david-amador.com/2011/03/so-where-is-that-motivation/

And that’s it for this week… Work has been hectic, but I’m almost reaching the first deadline of an important project, and most stuff should be simple and neat from here on, so I expect to have more time for game dev stuff in the near future!

 

Sick as a dog…

07 Mar

Sorry about the lack of updates lately, but last week I’ve been sick as a dog with a nasty flu.

Other than that, work has been keeping me busy and exhausted (currently trying to optimize my current server system memory-wise, without loosing too much performance)…

So this update isn’t just a "oh, sorry about the lack of updates" post, here’s the winners of the IGF: http://igf.com/2011/03/minecraft_amnesia_top_winners_.html#more

No big surprises there, but it’s good to see Amnesia taking home so many of the prizes!

Hopefully at the end of the week I’ll have some more stuff to share with you guys!

 
No Comments

Posted in General, Indy

 

Shadowmap LOD

18 Feb

ShadowmapLOD

This week I’ve been working on the LOD system for the shadowmaps…

Using the idea that I can have about 60-70 lights per area on the game, I can’t update 1024×1024 shadowmaps every frame… Well, I could, but I’d get 0.5 FPS (I tested it for fun)…

So, I decided to play with 4 variables:

  1. Multisampling: 16 samples per pixel take some time to render, even in today’s video cards, so I can’t have all lights multisampling
  2. Resolution: 1024×1024 to 64×64 shadowmaps give me quality on those that are near, but still have some quality on stuff that’s far away
  3. Update rate: Updating all shadowmaps (even the 64×64 ones) is slow, because of all the setup time, changing rendertargets, etc…
  4. Turning off shadows at a distance

Number 4 got removed from my LOD algorithm. The reason for this is that in some angles, the difference in lighting is actually pretty big… the shadows are necessary to keep the light confined to the room where the light source is.

So, what I do is that I do the nearest N1 lights with multisampling+256×256 shadowmaps+update all frames, then I do N2 lights with 128×128 shadowmaps+update every 4th frame, and so forth…

On my test case, I have 120 lights, and I defined that I could do 10 updates per frame… I defined circa 22 categories with different resolutions and update rates, and I set the category of each light per frame, based on distance.

On my video card (a NVidia GTX 465), I get about 200 FPS average with this scene (which is very simple, not many texture switches)… In a real case, this will of course not be the frame rate, with all the setup of objects, etc, but I still have some tricks up my sleeve (group up all static objects in a few DIP calls for shadowmap rendering, separating objects that might have alpha-test from the others so I don’t need to use texture swaps, change the criteria of the lights, even going back to not having shadowmapping in lights that are too far away).

Anyway, I’m very happy with the results, specially considering that the game will not feature a camera so close to the shadows as on the above screenshot. This, combined with the ambient occlusion map rendering, will probably be a good rendering solution for the game.

Now I’m going back to work on the editor I’ve been working on and off for one year… Never added 3d capabilities to it, so it will be a neat challenge, but I hope that in the next few weeks, my artist can start creating levels with decals and such stuff…

 
 

Ambient Occlusion Maps

10 Feb

I’m back to rendering pipeline for our current project… this time: Ambient Occlusion Maps.

Ambient occlusion is the small dimming of ambient light in areas where the ambient light couldn’t reach…

Basically, ambient light exists to simulate the effect of trillions of photons bouncing off the objects in an area, so in fact, simulating indirect light. Note as a room is not completely dark in areas not illuminated directly by the window… that’s due to surface reflection.

While to do this normally in realtime you’d have to resort to high-end and extremely complex techniques (i.e. CryEngine 3 has something akin to this), you have three low cost alternatives:

  1. Radiosity computed lightmaps
  2. Pre-calculated ambient occlusion maps
  3. Screen-space ambient occlusion algorithms

While (1) is out of the question at the moment (because the interaction of lightmaped environments with dynamic objects is too complicated to get right), (2) and (3) can be used.

Problem with (3) is that I really only like their effect in Crysis… I’ve tried lots of different flavors of Screen Space Ambient Occlusion (SSAO) before, but results where never to my liking:

abstract_ssao02

azenha_ssao02

Although some of the things that were wrong could probably be tweaked out, I’m very strongly against tweaking stuff (my development time is very short, since I have a job and stuff)…

So that leaves me with (2)…

So I used the lightmap calculator to create some ambient occlusion maps that will be used in the realtime render of the scene.

First, I just tried visualizing the points corresponding to the lumels:

01_lumel_point

They didn’t seem very right at the time, but I thought it was because of my UV being wacky… Then I did some experiments with simple raycasting and the results were average (no screenshot, I forgot to take one!)… I decided I needed to use multi-sampling to achieve decent results. This is where everything went wrong… I did a first iteration of the rectangle in the lumels area using the gradients of the rasterizer, and these were the results:

02_lumel_area_incorrect

While some of it seems to be more or less right, most is totally wrong… I was expecting the rectangles to encompass a whole lumel, but they weren’t… After some hours of pulling hair, I decided to rebuild my rasterizer, thinking the problem was there… it wasn’t… 🙁

Anyway, after some attempts, I decided to ask for help in the GD-Algorithms Mailing List, and as usual, people came through… Thanks to the help of several people, specially Olivier Galibert, I managed to change my rasterizer and ambient occlusion map generator to barycentric coordinates, which fixed the problems:

03_lumel_area_correct

On a triangle barycentric coordinates are a pair (U,V) such that if (U+V<=1), then P(U,V)=V0+V1*U+V2*V belongs to the triangle.

So, the triangle (and all his properties) are defined through the use of just (U,V) coordinates, which makes everything easier and more precise. Instead of just trying to find spans and filling in the insides with interpolated values, I actually just interpolated the U and V along the triangle edges, and used those values to find all the properties, achieving with this the result above.

There’s still some imperfections on the edge cases, but that’s to be expected, since the triangles edges don’t exactly match the pixel boundaries, but most of it can be taken care with a “bleeding” of the resulting ambient occlusion map.

After I got this right, was just a matter of implementing the raycasting proper…

04_base_ambient_occlusion

I like seeing the blocky ambient occlusion… In the above case, we only have about 16 rays per lumel.

04_ray_casting

Without multisampling, we only cast rays from the upper-left corner of the lumel (in this case it seems to be reversed, but that’ because the UV space is “reversed” in the U direction on that lumel)… Adding multi-sampling:

05_multisampling

We get a more uniform spread… the quality improvement doesn’t show much with this amount of rays, but with loads of them, at the “edges” of the “shadows” of objects, they definitely show.

With 1024 raycast per lumel, on a 128×128 ambient occlusion map used by the whole scene:

06_ray_casts_1024_point_sampling

Sampling is set to point, so I can see the lumels properly. Note that there are some artifacts on the top of the box on the left… that’s due to the rasterizer not going “all the way” to the edge… this is solved through bleeding of the texture.

On a larger scene (with some rooms, etc), with 256×256 ambient occlusion maps, 1024 rays per lumel, half-lumel per unit resolution, this was the result.

07_large_scene_256_half_lumel_per_unit_1024_rays

There’s no light sources in the scene, only ambient light, and still point sampling for testing purposes… it looks ugly, but there’s already some feeling of space to it… Turning on linear sampling, increasing the resolution to 1024×1024 and going to 256 rays per lumel:

08_large_scene_1024_half_lumel_per_unit_256_rays

Results are a bit noisy, but they’re already very good for the intended purposes… Adding rays to the scene would get rid of the noise (I think, haven’t tried), but with the additional “noise” of the textures, normal maps and direct lighting, I doubt it shows in a real game situation.

There’s good details on this solution:

09_large_scene_detail_door

10_large_scene_detail_ceiling

I like this one in particular… The wall doesn’t touch the ceiling (hacked scene, this is what you get), but the ambient occlusion really fleshes out the volume.

I’ve added some code to use multi-processors (since this is software only rasterization and calculation) to speed up the generation of the scene, and the raycasting isn’t as good as it should at the moment (probably will build an octree with all the geometry and use it for raycasting). This scene takes about 4 minutes to compute (resulting in 3 1024×1024 ambient occlusion maps), but hopefully I’ll be able to chop that time down…

My next step is really exporting the generated scene (I’m lazy and haven’t done that part of the code yet, the test application computes and displays the solution), and trying this with a “real” scene (which I’m waiting for my artist to finish, he’s been having some troubles getting some “walls” and “ceilings” he actually likes.

After that, next stop is trying this with direct lighting… I’ve added “soft-shadows” to my dynamic shadowmaps, and they will really help the scene, although they need loads of samples (16) to actually look good… Anyway, I’m hoping that combining the ambient occlusion, the soft-shadows, and playing around with the update times of the shadow maps, I can have a fully dynamic lighted environment that requires little tweaking and is fast enough to work with in the game…

Until next time, cya guys!

 
 

Lightmap work…

31 Jan

Well, after three days of work, I finally have a working lightmap renderer… I’m not very happy with the results, to be honest, but there’s still some places for improvement… to go further, I need a real example to work with, with some moving characters to see how enabling/disabling lights will work and the effect of having a priority queue for the light updates (so I can have stuff that only updates once every four or five frames)… more on this below…

Anyway, as I said in my previous post, I’m using the UV-unwraper that comes with D3DX, since this is just for a preprocess tool… the results are quite nice, but I had to tweak it a bit…

01_InitialScene

This was my first test scene, renderer without shadowmaps in my normal deferred renderer… There’s only diffuse color maps in the objects.

02_FirstIteration

This is the first iteration of the lightmap (rendered in 6 seconds in debug mode, a single 256×256 map).

03_EdgeArtifact

A closer look shows some edge artifacts… This got solved by simply doing a "bleed" effect on the generated lightmap.

04_BleedTexture

The black spots in the bottom of the pyramid are due to sampling artifacts (since it’s at the same height as the plane, so it intersects). This can be solved through multisampling (on my wish list).

05_Discontinuities

Here I had a big error (didn’t take a screenshot), where the orange and the yellow would fight, since that edge was shared in the lightmap. Fixing this was just a matter of tweaking the UV generation so that that edge wouldn’t be shared; so I added code that took in consideration that triangles whose normals differed more than 30 degrees wouldn’t be considered adjacent, and the results were good.

06_DynamicAndStaticLights

Mixing static and dynamic lights worked well. The red shadow cast by the red block is the result of a light circling the scene. Note that the edges are much more defined.

07_AlphaMaps

Adding the stained-window effect was pretty easy with the current system, and I love it, to be honest… 🙂

08_NormalMaps

Adding normal mapping was also pretty easy, but problems become evident when we zoom in:

08_NormalMaps_LowRes

The lack of resolution of the lightmap shows pretty obviously… I think this can be solved through multisampling, or just doing a better sampling of the normal map to consider the resolution… But it’s pretty obvious that normal maps won’t work well in lightmaps, since lightmaps are good for low-frequency lighting, and normal maps add high-frequency data to it… There’s other solutions for this, like what Valve did in the Source engine: http://www2.ati.com/developer/gdc/D3DTutorial10_Half-Life2_Shading.pdf

This considers the direction in which light is coming and applies normal mapping in runtime on top of the lightmapping, which improves quite considerably the results, besides enabling us to use specular highlights aswell. Still need to think if this is worth implementing, since I’m not sure about lightmaps anyway… Since I have my own renderer, I can change it suit me…

09_DynamicObjects

The worst problems came with the dynamic objects… Casting shadows on dynamic objects is simple enough, just use the standard shadowmap technique… Problem is that dynamic objects cast shadows on static (lightmapped) objects, and this is where things become complicated…

The way I solved it was by rendering the static lights three times… First time is the generic lightmap pass, in which all static objects are rendered, and a stencil mask is created. 0 on the stencil buffer means that pixel comes from a dynamic object, 1 means its from a static object.

Second time it’s for the dynamic objects (stencil buffer=0), and the results are as expected (both the static objects and the dynamic objects cast shadow on the dynamic objects).

Third time it’s for the static objects (stencil buffer=1), and it requires a subtractive pass… Basically, for each pixel of static objects, I compute the light that would reach that point, check if the point is being shadowed and subtract that light from what’s in the render buffer. Problem with this approach is that the lightmapped shadows will be twice as dark, since they’re already present in the shadowmap and the value will be subtracted.

To fix this, I had to find a trick, which almost does it… Basically, when rendering the shadowmap, I render the pixels in the [0..1] range if the object is static, and in the [1..2] range if the object is dynamic. Then, when I’m computing the subtraction, I only account for the dynamic objects (since the shadows cast by static objects are already accounted for in the lightmap). As I said, this almost works, with two caveats:

10_DynamicObjects_Artifact01

In this screenshot, you can see the "ragged edge" between the static-cast shadow of the block, and the dynamic-cast shadow of the skinned cylinder… This is due to the resolution of the shadow map, and it’s extremely hard to get rid of, without raising the shadowmap’s resolution to proibitive values… I think we might be able to solve this by multi-sampling the shadowmap, but that would required more cycles, and for the game we’re working on, I don’t think these small mistakes will matter…

A slightly worse problem:

11_DynamicObjects_Artifact02

The shadow from the cylinder in this case subtracts light to the block-cast shadow, which shouldn’t happen… This is due to the fact that the computed shadowmap only "sees" the cylinder, and the block behind, so the system doesn’t know that the block is also casting a shadow at that pixel… I can think of a couple of ways to solve this (two different shadowmaps for static and dynamic objects, for example), but most of them just consume more GPU/memory/etc, and for a small gain…

Finally, the biggest problem: due to the limited precision of the render buffer (8-bit per channel), if we have multiple lights illuminating a place and casting a shadow on that place, the shadows will become darker than they should… Reason for this is the following:

Imagine 2 lights, illuminating a certain pixel… Light A casts 80% light, light B casts 60% light… Summed together, this is 140% light, which gets clamped on the buffer to 100%. Then, we want a dynamic object casting a shadow on that spot (because it blocks light B). Because of the current algorithm, light B is subtracted to the frame buffer, which makes the intensity there go to 40%, instead of the 80% it should…

This could be fixed with HDR buffers (which wouldn’t be so hard to add), but by this time I’m under the feeling that I’m just fixing one problem after another, without having a complete lighting solution, or worst, having a complete lighting solution that requires too much tweaking…

So now I’m thinking that I may ditch all of this and go for a full dynamic lighted system. Of course, I can’t have 100 lights casting shadows, etc, but I think I can reduce this substantially by making lights that aren’t near the player use less resolution and updating less frequently, and go around interpolating the lights to get the correct results… Now I just need a working scenario so I can see the impact of this, with some characters moving around and some real geometry to check perfomance…

Anyway, this isn’t a complete lost… worst case scenario, I’ll be able to use this system to create ambient occlusion maps to get a bit more realistic look without having to resort to SSAO (which I only liked in Crysis)…

Unfortunately, for the next foreseeable days, I’ll be busy with hard work stuff, which means no energy in my free time to work this…

Stay tuned for more adventures with lighting pipelines! 🙂

 
 

The Quest for Lightmaps

25 Jan

Finally some of the work insanity has died down, and as so I can go back to do some cool stuff on my spare time again…

After the basis of the renderer for our next project is done, I still feel there’s loads of stuff to be done in the environment lighting… since it is unfeasible to have shadowmaps in all visible lights (still have to determine a good algorithm to select lights to be shadowmapped in real time),I’ve decided to add lightmaps to the environment, and in the process (since it’s easy to add), also add pre-rendered ambient occlusion maps.

I’ve worked on lightmap generators in the past.

First of my experiments were with direct lighting lightmaps, which only account for the light that shines directly in objects. I built my own UV-map generator, which didn’t work that badly, but it was slow and some of the results were terrible… The advantage of that renderer was that I could add stained-window effects (through alpha maps) and other nifty effects to the resulting lightmap…

Some pictures of the obtained results (over 3 years ago):

lightmap_only_direct

Two sources of light, one red and one white, no textures.

multi_light_textured

Same as above, but textured, which makes everything look infinitely better, since it disguises the imperfections of the limited resolution of the shadowmap.

lightmap_alpha1An alpha object that blocks part of the light and tints it.

lightmap_alpha4

Again an alpha object, but with a textured alpha-map… The effect is quite nice.

Although the results I obtained with this were nice enough, I was never too happy with the UV-generation and the lack of soft-shadows, so a couple of years ago, I did some experiments with hardware-accelerated radiosity.

I replaced my UV-generator with the one that DirectX 3DX library has, and used the normal HW-accelerated radiosity algorithm (render scene from the point of view of the patch, average results, rinse and repeat).

While the results weren’t terrible, it demanded too much tweaking to get good results:

radiosity02_uv_work_no_iterations

The wall is an emissive light source.

radiosity07_render_iteration_06_075

After 6 iterations, the shadows become more “real” and you can see some color blending near the green “barrels”, which is pretty neat. The window is a glowing polygon, to simulate intense outside light.

radiosity08_render_iteration_06_075

Using a light that’s not white, and a spherical light source (with volume), that’s not visible from the whole room. After 6 iterations, the scene looks warmer, but it has too many artifacts on the floor (sampling artifacts), and in the near wall (because the wall was too close to the patch, it wouldn’t get drawn in the buffer, due to the near plane. This would lead to that silly illumination).

radiosity10_colored_floor_iteration01

Using a colored floor (at a much lower resolution that the previous tests), the scene again becomes warmer and indirectly lit.

radiosity12_normal_pass01

I supported normal maps in the rendering, and the result is quite nice, disguising some artifacts behind the more complex lighting.

I even did an application that would enable me to change the reflectivity parameters:

radiosity16

But it was too much work getting this to work properly, too many small tweaks and too much time to actually see results… This is when I abandoned this project and moved on to other stuff (I know, I lack focus sometimes).

Anyway, back to the present, I decided to pick this up again… For the current game, I think radiosity is overkill, but I intend to divide the generation of lightmaps in two parts, so I can replace the direct lighting for radiosity later:

  • Preprocessor
  • Lighting engine

Basically, the preprocessor will take care of all the tasks that are common to any lightmap processor:

  1. See what meshes are present in the scene
  2. Create UV-map per mesh (using as a metric for resolution the surface area of the mesh and an adjustable parameter)
  3. Create instances of objects that share the same mesh (effectively copying the mesh with the new UVs)
  4. Create an UV-atlas that aggregates UV-maps
  5. Load into RAM the textures used (diffuse map, alpha map, normal map, emissive, etc). This data needs to be in accessible memory since we’ll need to sample it
  6. Initialize the lighting engine (give it all the meshes, etc, so he can build acceleration structures for raycasts, etc)
  7. For all lumels in all the lightmaps, call the light evaluation function on the lighting engine. This will probably be called multiple times for each lumel, taking into account the possible area of the lumel, so that we get anti-aliasing and reduce the artifacts caused by edge conditions. These samples will be averaged (either by standard average or some kind of distribution).
  8. This last step will be repeated a certain ammount of times, depending on the instructions of the lighting engine.
  9. If requested, build ambient occlusion map, by requesting the lighting engine an ambient occlusion factor. This will also take in consideration the area of the lumel, like in step 7.
  10. Save lightmaps generated

The lighting engine for now will be a simple Direct Light system. I want to take in consideration the following things:

  1. Take into account diffuse, normal and emissive maps
  2. An octree will be generated with all the world geometry for faster raycasting
  3. Raycasting will take in account the possible intersection of alpha/tinted objects and do the correct coloring to account for that
  4. Ambient occlusion will be computed by raycasting in an hemisphere around the lumel being computed, and considering what amount of rays gets intersected.

This system should also consider multi-processor usage (for direct light at least, since the HW-accelerated radiosity can’t take advantage of multiple processors, since there’s just one GPU).

Most of this stuff I already know how to do, since I have in done in previous projects… the exception is the octree generation (I usually use loose octrees, so there’s loads of code for splitting triangles, etc, that has to be done), and the part where I consider the area of the lumel for smoothing the lightmap.

Rendering the lightmaps in the deferred rendering pipeline will require an additional passage, since I don’t have any space left on the G-Buffer for three components (RGB, since I want colored lightmaps), but that’s ok, since it will enable me to do fill up the stencil buffer to avoid drawing the static lights onto the static geometry again, while I still have the possibility of using the static lights on the dynamic geometry. This will also enable me to light the environment with dynamic lights (in static and dynamic geometry) without wasting too much performance. Adding the concept of light volumes to both types of lights will also be easier this way, since I can filter out what parts of the scene shouldn’t be affected. The ambient occlusion term can be stored with the ambient component already in the G-Buffer, so that shouldn’t have a big performance hit.

All the lights and geometry that are present in the input scene will be considered static… Bad part of this is that opening doors won’t have the dramatic/cool effect I would like, unless I use dynamic lights and shadowmaps at the correct circumstance.

Anyway, I’ll hopefully have something working by next week (hopefully in time for the Screenshot Saturday thingie which I enjoy seeing every week).

Ah, just recalled… why do my own lightmap generator, instead of using an existing (free) one? Well, I never found one that produced nice results while making the trouble of writing an importer/exporter wasn’t a nightmare, to be honest… I feel that this is the kind of thing that’s kind of linked with your pipeline and your own way of doing stuff… besides, this is fun code! 🙂

So, wish me luck!

 
 

Nothing to see here, move along….

14 Jan

The main reason I haven’t been writing in my blog is that there’s nothing to talk about, without spending some time…. 🙂

Since the beginning of the year, I’ve been struggling with work; it really piled up in the holiday seasons, and I want to be able to buy some time to be able to dedicate myself to games again… specially because I’ve been having an idea brewing inside of me that’s begging to be developed… for now it’s just a story (one that I rather like) and a game mechanic (summoning/possession based), but hopefully it will grow into something really neat; problem is that I want to develop this one by myself (so there’s the “surprise” effect of the story in everyone), and I suck at art! 🙂

Anyway, I’m almost completing one project, and the next one is more or less under control, so hopefully I’ll have time for some more game development stuff (my own project and the bigger game I’m developing with some friends), and for the return of my “feature blog posts” (which take some time to write properly!)…

Damn, my blog looks more and more like one of those blogs that get abandoned after a while, and I certainly don’t want that!

So this post isn’t completely bereft of real content, a word of caution: don’t see “Skyline”… it’s sucks so badly it hurts; it’s not because of the limited scope (it all takes place in a building), or the low-budget special effects (I can live with that)… it’s because they spent 45 minutes developing characters (in the most boring way ever, I might add), to throw all that character development out the window and replace it with a slasher-cum-alien invasion movie, with no sense of purpose or direction…. and the end of the movie (while a tad lame) could have been a decent beginning to it, to be honest!

So, I’m giving this one a 3/10 (I’m being generous ‘cos the movie only cost 20 million to make, which is cheap for today’s standards)…

Can hardly wait to be able to watch Tron (it only came out yesterday here in Portugal)… from what I’ve heard, the movie is awesome! 🙂

 
No Comments

Posted in General

 

Happy new year!

07 Jan

Well, the new year has started, and my update-rate is miserable… blame it on a the holidays, plus WoW: Cataclysm and just plain laziness…

So what’s new? Nothing much… had a very big cold, had to stay home for two days (which kind of drives me crazy)… other than that, I just spent the last three weeks eating and enjoying the season…

In World of Warcraft, my small guild started raiding yesterday… we started with Blackwing Descent (wanted to go Baradin Hold first, but Horde didn’t let go of it, and we don’t do PvP, so we can’t really help), and quickly found out that most of us weren’t geared enough for Magmaw (the “first” boss)… curiously enough, we made much better attempts at the Golem Council (Omnotron Defense System, or something like that), which is a skill battle, as opposed to Magmaw, which is a gear fight. That said, Cataclysm promises some very interesting raids!

Work has been pilling up at the office, and I have currently in hands about 5 different projects, all due in the next couple of months… some of them are simple enough, but others are beasts, and the lack of communication between teams is taking its toll, time-wise… Anyway, I’m quite confident that we’ll be able to pull it off… we always do! 🙂

Game-wise, haven’t played anything but WoW and Band Hero… I still suck at Band Hero, but a little less everyday…

Finally, I’ve been thinking a lot about a story that I could turn into a game (a low budget, 48-hour competition kind of game)… if I could do that, I think this one would be awesome… It’s kind of tormeting having a good story in your head and not sharing it with anyone because you want them to experience it in its fullness, bit by bit… 🙂

Well, that’s all the time I have for today, I’ll try to be more regular now that the dust of the holidays (or snow, whatever) has settled down… hopefully… Loads of work ahead of me! 🙂

 
No Comments

Posted in General