Jump to content
  • Advertisement
Sign in to follow this  
Hiyar

Compressed tangent space vectors

This topic is 3486 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
What exactly do you need the tangent space vectors for? If just for bumpmapping terrain, then maybe you can get away without computing these.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!