• Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at \$59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.

Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!

# Wrong vertex displacement direction

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

6 replies to this topic

### #1Juan Camilo Acosta Arango  Members   -  Reputation: 152

Like
0Likes
Like

Posted 27 June 2013 - 06:10 PM

Hi

I am implementing displacement over a tessellated surface, but the result is strange because the position of the vectors is tending to go up. Is that normal? i think the new position must follow the normal map.

THis is my code:

float offset = g_DisplacementTxt.SampleLevel(g_samLinear, Out.texCoord, 0).x;

float4 txtNormal = g_NormalTxt.SampleLevel( g_samLinear, Out.texCoord, 0 ) * 2 -1;

position = position + (txtNormal * offset);

Juan Camilo Acosta Arango

Bogotá, Colombia

### #2TiagoCosta  Crossbones+   -  Reputation: 2462

Like
1Likes
Like

Posted 27 June 2013 - 06:20 PM

The vertices should be displaced in the normal direction.

Are you transforming the normal to world-space?

### #3Juan Camilo Acosta Arango  Members   -  Reputation: 152

Like
0Likes
Like

Posted 27 June 2013 - 08:52 PM

I am only sampling the normal texture and then 2 * -1 to get the world normal

float4 txtNormal = g_NormalTxt.SampleLevel( g_samLinear, Out.texCoord, 0 ) * 2 -1;

Juan Camilo Acosta Arango

Bogotá, Colombia

### #4MJP  Moderators   -  Reputation: 11786

Like
0Likes
Like

Posted 27 June 2013 - 11:30 PM

Tiago is asking if your normal map contains world-space normals, since typically they contain tangent-space normals that have to be transformed to world-space before you can use them.

### #5Juan Camilo Acosta Arango  Members   -  Reputation: 152

Like
0Likes
Like

Posted 28 June 2013 - 07:16 AM

Yes, when i made the map i set it to be world space normals

Juan Camilo Acosta Arango

Bogotá, Colombia

### #6TiagoCosta  Crossbones+   -  Reputation: 2462

Like
0Likes
Like

Posted 28 June 2013 - 08:04 AM

Yes, when i made the map i set it to be world space normals

Don't you mean object space normals?

If they're indeed object space normals, and position is in world space you have to transform the normals to world space using the world space matrix.

### #7Juan Camilo Acosta Arango  Members   -  Reputation: 152

Like
0Likes
Like

Posted 05 July 2013 - 02:13 PM

I have found another clue, i duplicated the geometry and place in positions different from the origin and these is the result i get....

I think is some one related to the vertex position space but not sure.

Juan Camilo Acosta Arango

Bogotá, Colombia

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS