Friday, April 5, 2013

Monday, December 31, 2012

Old post by Tim Sweeny regarding Garbage Collection


So UClass/UFunction/UProperty(which still exist in Unreal) etc. appear to date to at least 1999

Tim Sweeny 1999

Tuesday, December 25, 2012

Compile time reflection in C++


  As everyone knows, C++ does not have reflection, compile time or otherwise. It might be added in C++14, but I needed it *now*.

 So I wrote a macro using the Boost Preprocessor library to generate compile time reflection data within a class.

 A Reflected object looks like this:
 After macro evaluation this generates an embedded type called "Reflection".
 The Reflection structure contains N sub types labled [Member1 - MemberN], and an enum indicating how many members are present.

 Each Member structure then contains the following data.

1. The type: (Member::type)
2. Access to member pointer (Member::GetMemberPtr())
3. Access to name of the reflected member (Member::GetName())
4. A type which indicates if the member is a function or variable, and if it is static or not(Member::member_class)
4. Optional meta data(basically user defined attributes). (Member::meta)

 The meta tags can be optionally attached like so:

 PP_Reflect(Test,
           ((_member)(Serialize)(Replicate)) //Serialize and Replicate being types you have declared 
           ((_static_member))
           ((MemberFuntion))
           ((StaticMemberFuntion)))


 You then need some compile time functionality to walk this and generate something useful out of it.

Dealing with inherited base types is not difficult, you just need to add a type list which lists any base types, and then have your evaluation functions walk the full hierarchy.

 Here is a link to the code if you are interested: reflection

 Uses decltype and auto so some C++11 conformance is required.






Monday, November 26, 2012

precision workaround

 Addition/Subtraction cause more precision to be lost with floating point values then multplication/division.  One area where I've run into floating point precision issues is the during the summation of noise octaves.  Floating point only has 23 bits of significant precision, so around the 20th octave(each being ~half the size of the previous), you basically hit a wall.

Here is a possible way to work around the inevitable precision issues without resorting to doubles(which for practical purposes don't exist on GPU right now).

Kahan Summation


function KahanSum(input)
    var sum = 0.0
    var c = 0.0          //A running compensation for lost low-order bits.
    for i = 1 to input.length do
        y = input[i] - c    //So far, so good: c is zero.
        t = sum + y         //Alas, sum is big, y small, so low-order digits of y are lost.
        c = (t - sum) - y   //(t - sum) recovers the high-order part of y; subtracting y recovers -(low part of y)
        sum = t             //Algebraically, c should always be zero. Beware eagerly optimising compilers!
        //Next time around, the lost low part will be added to y in a fresh attempt.
    return sum


 Another possibility(although likely *much* slower) is emulating 64 bit doubles.

64bit doubles on GPU

Monday, November 12, 2012

currently working on...

I've been creating a modern version of my voxel engine for a few months now, the old one was about five years old and was too limited for what I wanted to do.  Hopefully I'll have something ready to show within a few weeks..

Tuesday, April 24, 2012

Game UI options


  1. librocket : uses HTML/CSS for formatting, supports a custom C++ interface, for which they offer python bindings(I'd prefer Lua, but it is simple enough to port).  I like this option because it appears easy to use, reuses well known technology, and works on many platforms(including phones).  Has support for rendering directly on the GPU.
  2. CEF : Chromium Embedded Framework, this is a fork of chromium(chrome browser), modified to work embedded in another program.  It appears to have support for offscreen rendering, so you would have chrome software render to a A8R8G8B8 memory buffer, then you would upload to the GPU.  Downside is chrome is huge, the .exe is 35 megabytes.  Upside is you get every modern web technology at your disposal,  so you can do a whole lot more then just render a UI.   Another downside is that it likely doesn't work on anything that isn't a PC, so no phones, and probably no consoles.  The website also includes prebuilt binaries for CEF for Windows, Mac, and Linux.
  3. Berkelium This is similar to CEF, it embeds chrome and has most of the same capabilities.  One downside is that you must build it yourself, not the simplest thing since chrome source is huge, and you have to modify it.  Berkelium does not appear to be updated as often either.
  4. I hate UI anyway.. why have a UI?


Wednesday, January 25, 2012

Sun Shafts & SSAO

 Added screen space sun shafts, based on this article from GPU Gems 3.





Also added basic SSAO(screen space ambient occlusion).  Right now it is just using the depth buffer.  For performance I will switch this over to using a downsampled depth buffer at some point in the future.  There are also some alternative methods that take into account surface normals that tend to generate more accurate results, so I might add one of those methods later.
Ambient Occlusion