Jump to content
  • Advertisement
Sign in to follow this  
terryeverlast

face normals

This topic is 919 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

Im trying to output a mesh with the face normal on each triangle. I'm doing this in the geometry shader. I have the center of every triangle. I append that point. Then I add the center with the face normal. ex.. (center + facenormal) than I add that point. So I get a line. but there not straight.

 

my code for the face normal is

 float3 faceEdgeA = input[1].PosH - input[0].PosH;
    float3 faceEdgeB = input[2].PosH - input[0].PosH;
    float3 faceNormal = normalize( cross(faceEdgeA, faceEdgeB) ) *.1;

so to find the face normal, I just add the center of the triangle with the face normal?

 

Share this post


Link to post
Share on other sites
Advertisement

This is what I'm getting

 

s5btoj.png

 

 

The face normal are going in and not straight

 

my code is ( a snippet)

 

This is done in the geometry shader

 float3 faceEdgeA = input[1].PosH - input[0].PosH;
    float3 faceEdgeB = input[2].PosH - input[0].PosH;
    float3 faceNormal = normalize( cross(faceEdgeA, faceEdgeB) ) *1;
output.PosH = float4((input[0].PosH.xyz + input[1].PosH.xyz + input[2].PosH.xyz)/3.0,1);
output.PosH = mul( output.PosH, gWorldViewProj);
TriStream.Append( output );
output.PosH = float4((input[0].PosH.xyz + input[1].PosH.xyz + input[2].PosH.xyz)/3.0,1) + float4(faceNormal,1);
output.PosH = mul( output.PosH, gWorldViewProj );

TriStream.Append( output );
Edited by terryeverlast

Share this post


Link to post
Share on other sites

( It's early here, might not be correct ):

 

When creating the end point of the normal "visualizer", you do this:

pos = float4(center, 1) + float4(normal, 1);

.

 

Leaving the w component 2, which I do not believe you want, so:

output.PosH = float4((input[0].PosH.xyz + input[1].PosH.xyz + input[2].PosH.xyz)/3.0 + faceNormal,1);

.

Back to bed, I am.

Edited by Migi0027 (????)

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!