Is it possible to access the surface normal (not vertex)?

• 03-25-2010, 12:35 PM
dugla
Is it possible to access the surface normal (not vertex)?
I would like to write a fragment shader that uses the surface normal rather then the interpolated vertex normal. Is there a way to access that information?

Thanks,
Doug
• 09-14-2010, 09:45 PM
MegaJiXiang
Re: Is it possible to access the surface normal (not vertex)
What kind of shape is it? The common way to get smooth normals is to use point normals on the model and normalize the interpolated point normals in the pixel shader. I'm not sure what you're looking for when you say surface normal because you'd have to evaluate the equation of a surface like a sphere or something to get that.
• 09-14-2010, 10:01 PM
dugla
Re: Is it possible to access the surface normal (not vertex)
Quote:

Originally Posted by MegaJiXiang
What kind of shape is it? The common way to get smooth normals is to use point normals on the model and normalize the interpolated point normals in the pixel shader. I'm not sure what you're looking for when you say surface normal because you'd have to evaluate the equation of a surface like a sphere or something to get that.

I want the normal to the plane of the triangle rather then the interpolated normal.
• 09-14-2010, 10:05 PM
MegaJiXiang
Re: Is it possible to access the surface normal (not vertex)
Ok it sounds like you want flat shading, correct? If that's the case make sure your triangles are all separate, no indexed triangles. Then make sure your normals for all 3 points in each triangle are all the same.
• 09-15-2010, 06:23 AM
dugla
Re: Is it possible to access the surface normal (not vertex)
Quote:

Originally Posted by MegaJiXiang
Ok it sounds like you want flat shading, correct? If that's the case make sure your triangles are all separate, no indexed triangles. Then make sure your normals for all 3 points in each triangle are all the same.

Unfortunately that is not a viable solution. Non-indexed triangles datas would be unthinkable for the datasets I am working with. I simply want the control - at the shader level - to create a faceted look as one of many different looks. I thought to attach the plane normals as vertex attributes but the won't work with a shared verted model. Sigh...
• 09-15-2010, 10:17 AM
MegaJiXiang
Re: Is it possible to access the surface normal (not vertex)
I'm pretty sure it's the only way though. I have a lot of graphics experience. I would love for someone to prove me wrong though and show a novel way to do it.