Spread too thin

4:54 pm hacking

I have a bad habit of doing this in the projects I’m working on. I have too many sub-projects that are open at a time. I have finished about 75% of the support for the OpenGL Shading Language now, but I’m beginning to think that I won’t finish it before I release NeoEngine 0.8.2. I added image writing to the codec interface, and finally finished implementing it in the PNG codec yesterday. I was going to do a couple other codecs as well, like JPG and BMP, but I no longer really have any interest in wasting my time on that. The main application for this is at the moment is to take screenshots or to dump images of the stencil buffer for testing. PNG works well enough for that.

I also came up with another idea the other day for doing texture blending in terrains. What we want to do is to have four RGB input textures and one RGBA input blendmap, then interpolate the RGB output by interpolating the value of each of the input textures according to the color value of a single channel in the blendmap. Since the blendmap has four channels (R,G,B,A) each channel describes how much one of the four input textures is blended at any given pixel. Okay, so this is all very normal stuff. The problem is that GeForce FX hardware only has four texture management units, and to do the above algorithm using ARB_fragment_shader as I’m doing I would need a grand total of five TMUs (one for the blendmap, and one for each of the textures). This is where my cool idea comes in. I counted up the total number of color channels we have (RGB * 4 + RGBA == 16). The total number of color channels a GeForce FX can deal with is 16 (4 TMUs * RGBA). So I took the four RGB input textures, decomposed them in GIMP, then recomposed them as three RGBA images. 4 * RGB == 3 * RGBA. Now I can pass everything to ARB_fragment_program in four TMUs. Now I need to make a program to automate this image channel compression.

Comments are closed.