Compressed tangent space vectors

Started by
12 comments, last by realkiran 15 years, 3 months ago
Hi, Is it possible to store tangent space vectors in textures instead of vertexbuffer. Normalized vectors are always in interval [-1,1]. So this interval can be transformed in range [0,255]?
Advertisement
In theory you can *always* store per vertex data into a texture map.

This is expecially true nowadays since you are not forced to store data in classic rgba format.

In practice I wonder why you would like to have a "tangent map", since compared to interpolation it has some weaknesses:

- higher bandwidth needed
- higher video memory usage
- less precision
- needs mipmapping
you could as well store the whole tangentspace + normal with one quaterion (x,y,z,w) and then regenerate the normal, tangent, bitangent from this. a bit more computational work, a bit less storage.

always those trade-offs.

i wouldn't suggest storing it in a texture in general, too.
If that's not the help you're after then you're going to have to explain the problem better than what you have. - joanusdmentia

My Page davepermen.net | My Music on Bandcamp and on Soundcloud

I'm rendering my terrain with a single shared vertexbuffer. (This is possible if using vertex texture for heightvalues)

So, if I need additional vertex data (like tangents), I need to use multistreaming (Because the vertex position is calculated in the shader)

I'm trying to avoid vertex streams

@davepermen
How do I generate tangent space vectors from quaternion?
What exactly do you need the tangent space vectors for? If just for bumpmapping terrain, then maybe you can get away without computing these.
Do you have a normal vector? I would start from that, because you will need it for simple shading anyway.

If not, you could compute it from the heightmap in the VS or you can use a vertex normalmap, like you are already using the heightmap.

With the normal you can easily compute the tangent vector as long as the terrain is a regular grid. I guess you are computing the texture coordinates via the vertex position too.
Yes, I need tangents just for normalmapping. I've tried to do normalmapping without computing tangents, but I'm getting weird results.(I need more details how to do this correctly)

I'm computing vertex normals in the vertex shader, I think this is very easy and saves memory.(So I'm not using vertex normalmap)
Yes, texture coordinates are computed via vertex position.

[Edited by - Hiyar on December 21, 2008 12:00:29 PM]
You only need to use tangent space when you are working with deformable models (skinned characters generally), otherwise use object space. No need for storing the binormal and tangent, so you save space, and no need for doing the extra transform from tangent space to object space.
Thanks for reply,
The normals in a normalmap are relative to the texture space. And the light vector is relative to the worldspace. For correct lighting I need to transform light vector to the tangentspace. I'm not using a global normalmap for the entire terrain. Normalmaps I'm using are for detail textures. So how do I use objectspace for detail normalmapping?

(For distant lighting I'm using normals that are computed in the vertex shader)
Have you solved it already?

The tangent and binormal can be caluculated like this:
Tangent = cross(float3(0, 1, 0), Normal);Binormal = cross(Normal, Tangent);
Maybe you will need to invert a vector, but that should be it.

This topic is closed to new replies.

Advertisement