PDA

View Full Version : Is it possible to access the surface normal (not vertex)?



dugla
03-25-2010, 11:35 AM
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
twitter: @dugla

MegaJiXiang
09-14-2010, 08:45 PM
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.

dugla
09-14-2010, 09:01 PM
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.

MegaJiXiang
09-14-2010, 09:05 PM
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.

dugla
09-15-2010, 05:23 AM
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...

MegaJiXiang
09-15-2010, 09:17 AM
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.