Page 1 of 1

Vertex Normals [Somewhat SOLVED]

Posted: Tue Dec 24, 2013 4:26 pm
by Benjamin100
What is the best way to calculate vertex normals?
I need them to pass to the vertex shader for lighting calculation. I have an idea of what to do, but it seems extremely long; taking 3 points at a time for the array of coordinates (9 values total), breaking them into vertices, calculating the face normals, and then averaging for the vertex normals. Is there an simpler way to find vertex normals?

Thanks

Re: Vertex Normals

Posted: Thu Dec 26, 2013 1:16 pm
by qpHalcy0n
No, there isn't really an easier way. You have to sum the connected face normals up for every face the vertex shares. That said, you should only have to do this one time.

Re: Vertex Normals

Posted: Thu Dec 26, 2013 3:22 pm
by K-Bal
I don't know what your situation is so this might not help you, but if you're creating models with 3D modelling software you can usually export the model file with vertex normals included.

Re: Vertex Normals

Posted: Fri Dec 27, 2013 2:47 am
by Benjamin100
Thanks guys.

Still not sure how 3d files are set up.
Apparently I can write a script that saves the information however I want to. I'm just not sure how that works.

Re: Vertex Normals

Posted: Thu Jan 02, 2014 8:44 pm
by Benjamin100
I'm trying to read these Wavefront 3d files. I'm not sure how to find the vertex Normals. I think I see the vertices, and I see some other file that appears to be related. Are those the normals? It looks like a completely different file. Not sure if you use these file types.
EDIT: Just found out I was missing a little box in Blender for "Include Normals."

Re: Vertex Normals [Somewhat SOLVED]

Posted: Fri Jan 03, 2014 4:15 pm
by Benjamin100
OK, just one more thing...
Do most of you use a particular library for reading the Wavefront files? I'm having trouble figuring out how to parse this file. Perhaps it would be easier if I knew how to create my own type of file where I would have it split up by lines. It just gets messy trying to create a function to read the vertices. First I have to find out where the vertices start, then I have to separate them by the Vs, then I have to separate them which differs in size according to whether there is a negative sign or not. It is really a pain. Should I just stick with it? I'd rather focus on the lighting and other issues than parsing these frustrating files/ I'd like it if there was a library available to take a file and return the vertices or vertex normals. Maybe this is something I should do myself just for the experience.

What do you recommend?

Re: Vertex Normals [Somewhat SOLVED]

Posted: Sat Jan 04, 2014 3:13 am
by Benjamin100
It appears this wasn't as difficult as a I thought. I was unaware of these scanning format functions.
But I don't understand the format strings. What do the strange characters in the format strings represent?