Sunday, October 18, 2009

Tangent Basis as a Quaternion

Have not done perf testing on this much yet, but if you want to save some memory and bandwidth at the cost of a bit of maths try packing your normal+tangent basis into a quaternion instead. It might be a good option vs 8-bit normals. Can even compress the quat into 3 components too if you assume dot(q,q)=1 by negating the quaternion if w is negative which should work fine if its normalized. I suspect this could be a win for static geometry.

Thursday, October 08, 2009

Color Coding Makefile Output

Quick useful tidbit... color coding makefile output...








You can then echo out $(OK_STRING), $(ERROR_STRING) or $(WARN_STRING) depending on if errors were encountered. Errors are Red, Warnings are Yellow, Success is Green. If you want to know what the goofy strings like "\x1b[32;01m" actually mean, well it really should be obvious, duh! But in case you can't decode that enigma of a color coding scheme you can read about it here.

The only tricky bit then is just conditionally echoing the right string. Personaly I found the easiest way is to use temporary files to determine if the build was a success or had errors/warnings . But maybe there is a cleaner solution that doesn't require temp files?

@$(ECHO) -n compiling debug foo.cpp...

@$(CXX) $(CFLAGS) -c foo.cpp -o $@ 2> temp.log || touch temp.errors

@if test -e temp.errors; then $(ECHO) "$(ERROR_STRING)" && $(CAT) temp.log; elif test -s temp.log; then $(ECHO) "$(WARN_STRING)" && $(CAT) temp.log; else $(ECHO) "$(OK_STRING)"; fi;

@$(RM) -f temp.errors temp.log

For those that don't like writing makefiles explicitly, XPJ currently supports this color coding mechanism and leaves the OK/ERROR/WARN strings defined in the user specified platform file so you can alter the colors or disable them entirely.

Friday, October 02, 2009

Eye Candy: GTC Demos

Here are some videos of the tech demos used during the GPU Technology Conference Keynote this year which were all simulated and rendered live in real-time. Our goal was to take the bits of tech we were each working on and produce a small demo of it to give the audience a taste. All the demos were presented in 3D Stereo and looked amazing. So, in order of appearance...

- Sarah Tariq made a pretty kick ass demo showing off the turbulence (sorry for the really poor video, a better one will be posted soon I am sure).

Photoshop PSD Loading

A year or so ago I went about improving my tools chain for textures. Previously an artist would have to export their texture from Photoshop to PNG and then import into a custom engine format. This was problematic because it meant there was this useless intermediate file always laying around (the artist's .psd, the intermediate .png and the engine formatted .xbin). It was yet another piece of the pipeline that could get out of sync and cause problems.

There were two solutions I saw, either write a plugin for Photoshop, or import the PSD files directly in my tools chain and convert to engine format there. Now because I have sort of this automagical serialization tech writing plugins for other tools makes me a bit nervous because everything has to stay in sync and I also didn't want to have to support 50 versions of Photoshop and other imaging tools so the latter choice was selected.

After a wee bit of research I found that the PSD format was actually fairly well documented. Along with the exact run length encoding algorithm used internally for compression. The format is incredibly stable too, appears to not have changed much since version 2.5 and works fine with Elements (the $99 version of Photoshop).

One big concern I had was that I would have to replicate all of Photoshop layering options and composite the image myself, but luckily enough PSD actually stores a "preview" image in the file which is an already baked single layer version of the image including alpha channel so I didn't need to bother with compositing. Basically all the pieces were there... and it looks incredibly easy to do, so I just did it one lazy Sunday afternoon last year and thus far its worked fairly well for me. I still support PNG importing to make it friendly for non-Photoshop tools still, but the majority of my textures now come straight from Photoshop into my own format.

Anyways, below is a download link to some simple source for loading PSD images. It includes some test source for then saving back out in PNG to confirm it works.