"I do not feel obliged to believe that the same God who has endowed us with sense, reason, and intellect has intended us to forgo their use."
- Galileo Galilei
More pages: 1 ... 7 8 9 10 11 12 13 14 15 16 17 ... 21 ... 31 ... 41 ... 48
Framework4 update
Thursday, November 5, 2009 | Permalink

I haven't mentioned the new framework I'm working on in a while, mostly because progress has been slow and I've been occupied with other things. Just wanted to give a brief mention of a neat trick I've implemented recently. In my framework I try to strike some kind of balance between ease of use and readability versus performance. Most of the time my demos are not very CPU heavy at all, so the CPU-side performance part isn't all that relevant, but it's always nice to have low overhead, just because it feels good. In Framework4 I've taken some steps to keep the overhead down. Something I usually do for readability is to set textures and other resources by name using strings, like so:

context->SetTexture("Tex", m_Texture);

This makes the code very readable and it's easy to see the mapping from the code to the shader. Unfortunately, lookups by a bunch of strcmp() is not the fastest way to find the corresponding texture unit index, even though it doesn't have to be terribly slow. A faster way is to use a precomputed hash value and do a lookup with that instead. I still want to use the same syntax though. What I ended up doing was changing const char * to StringHash, which is a class containing only a uint32 value, so for all practical purposes, it's a uint32 when compiled with optimizations. StringHash has loads of constructors. One for each length of the string I need, like so:

StringHash(const char (&str)[2]);
StringHash(const char (&str)[3]);
StringHash(const char (&str)[4]);
StringHash(const char (&str)[5]);
...
StringHash(const char (&str)[21]);

This covers all strings up to 20 characters, which should be enough for resource names. Each constructor contains the unrolled code for generating the hash, for instance:

StringHash(const char (&str)[4])
{
    m_Hash = 0;
    m_Hash = m_Hash * 65599 + str[0];
    m_Hash = m_Hash * 65599 + str[1];
    m_Hash = m_Hash * 65599 + str[2];
}

The hash function itself is not very important, I chose this one because it came up early on a google search. So when I make a SetTexture() call, I can call it with a constant string directly, which in C++ means it'll look for a way to convert the const char array to a StringHash, and finding a matching constructor it will use that to construct the StringHash object for me. Given the compile-time constant string and the simple unrolled code, any decent compiler will boil all this down to the resulting hash code when compiled with optimizations, and the runtime cost is essentially the same as if I would have written it like this:

context->SetTexture(0x29C22FA7, m_Texture);

A sneak peek at the assembly code we find the resulting hash inlined as an intermediate constant:

mov dword ptr [eax], 29C22FA7h
call Context::SetTexture

It will of course still be faster to just call SetTexture() with an index directly instead of the name, but this should narrow the gap somewhat.

[ 27 comments | Last comment by Aslan Dzodzikov (2011-05-20 14:31:13) ]

Real-life low-polygon head
Tuesday, November 3, 2009 | Permalink

This has got to be the coolest Halloween costume ever!

[ 1 comments | Last comment by FMoreira (2009-11-04 00:08:16) ]

Exclusive No Ordinary Mission Trailer HD
Friday, October 30, 2009 | Permalink

Sorry for the lack of updates here lately, I haven't had much time to work on any of my personal projects or comment on the news flow. But another trailer from the game I'm working on has hit the web, so check it out.

[ 8 comments | Last comment by Humus (2009-11-13 18:40:44) ]

The Island of Panau Developer Diary HD
Friday, October 9, 2009 | Permalink

Another Just Cause 2 video has found its way onto the intertubes.

[ 8 comments | Last comment by mark (2009-11-26 21:43:41) ]

New demo
Sunday, October 4, 2009 | Permalink

There's a new demo available that illustrates a technique for seamless decals on arbitrary geometry. Shoot a paint splash in front of you by clicking the mouse. Select colors on the F1 dialog. It's hours of fun!

This technique will be featured in the upcoming GPU Pro book I mentioned in the previous post. In the "Volume Decals" article I cover all the dirty details of the inner workings as well as suggestions for alternative implementations and extensions.

[ 6 comments | Last comment by Black Knight (2009-11-03 02:20:38) ]

GPU Pro - Advanced Rendering Techniques
Sunday, October 4, 2009 | Permalink

In the not too distant future the book GPU Pro - Advanced Rendering Techniques will be published. If you haven't heard of it, it's basically what was formerly known as ShaderX 8, with the distinct difference that it'll be in full color, which is great. The book has a blog over here where additional information will be posted soon.

A few days ago I finished the last stuff for my contribution. I'm writing two articles in it, with these titles:

[ 3 comments | Last comment by GianT (2009-10-06 00:32:30) ]

Weekend reading
Sunday, October 4, 2009 | Permalink

The slides from the Siggraph 2009 course Advances in Real-Time Rendering in 3D Graphics and Games are available. Plenty of interesting stuff.

Thanks for Natasha Tatarchuk for the heads up.

[ 0 comments ]

HDR photography
Sunday, September 20, 2009 | Permalink

Back in February I made a blog post about HDR cameras. Since then a few things have happened. Pentax released their K-7, which is the first SLR with built-in HDR. It's taking the traditional approach of multiple exposure and consequently needs a lot of processing after shooting (12 seconds according to some sites). Recently Sony released the a500/550, which is both faster (2 seconds) and unlike K-7 has built-in image alignment which should allow for handheld HDR photography. Fujifilm also released the F70EXR, which is a cheaper variant of the F200EXR. Fujifilm is still the only vendor to use an actual HDR sensor and thus need no particular processing at all. All manufacturers are still only producing a final jpeg image unfortunately. Fujifilm would be in a position to offer a RAW format with HDR since they have it built into the sensor, whereas the other manufacturers could opt to use the EXR format. Anything that allows you to post-process the tonemapping would be great. But this is still early and I'm sure better solutions are around the corner and this is all a very exciting development.

After having been tempted for a while I finally pushed the order button and got myself an F200EXR. After having played with it for a while and learned how to best take advantage of the HDR feature I'm really loving it. And here's why:



The picture on the right has HDR enabled. The picture on the left is about what every other camera would produce. The pictures are taken at the same time with the same settings and no other post-processing was done other than resizing for the web.

I'm convinced that HDR will be the next big thing in photography.

[ 18 comments | Last comment by Humus (2009-10-06 23:14:17) ]

More pages: 1 ... 7 8 9 10 11 12 13 14 15 16 17 ... 21 ... 31 ... 41 ... 48