Mar 31, 2011

Added Generic Convolution Filter to NVidia Texture Tools

I've recently added generic convolution filter to the NVidia Textures Tools version I'm using at work. (This is based upon unreleased version that I grabbed from NVTT Google Code page.  I wanted to contribute it back to the code base or share with the public, so I asked for the permission from the work, which I'm still waiting for.

At the end it's not hard.  If you just dig around the source code, you will find a way to implement it in less than an hour.  Or, just wait until I get the OK sign from my work :)

Mar 2, 2011

Missing Documentation: tex2Dlod()

Today, I tried to use tex2Dlod() to generate the full mip chain of a texture. HLSL function, tex2Dlod() takes float4 as texture coordinate and the 4th component is supposed to specify which mip level it should sample.

So my question was "what value should I pass if i want the 2nd highest mip." I had two educated guesses:

  1. texcoord = float4(u, v, 0, 1);


  2. texccord = float4(u, v, 0, 1 / number of total mip levels)

Unfortunately, I was not able to find any documentation on this: MSDN doesn't explain it and I couldn't find it on Google either.  (my Google God status is being challenged here. :-) OMG! )

My co-worker Doctor Barrero did a quick test on Render Monkey, and the answer is 1. (the first choice, or passing simply 1 as the 4th component).  Also you can deduce the same answer from D3D Sampler State, D3DSAMP_MAXMIPLEVEL, which is documented as:
D3DSAMP_MAXMIPLEVEL: level-of-detail index of largest map to use. Values range from 0 to (n - 1) where 0 is the largest. The default value is zero.
By the way, this works same both on DirectX and OpenGL.