Issue 1:
I have an indexed BufferGeometry and indexed set of uvs. I have been unsuccessfully trying to pass uv coordinates per face per vertex to the vertex shader as it seems that BufferGeometry expects exactly one uv vertex per geometry vertex.

I resorted to using Geometry.fromBufferGeometry and then populating the faceVertexUvs array but there's a lot of overhead involved.

Judging by http://stackoverflow.com/questions/25874926/buffergeometry-always-creates-flatshading-normals-i-need-smoothshading, it seems this is not supported yet, is that right?

A vertex is basically just a set of attributes, so it doesn't seem that easy to implement (you probably need to duplicate vertices where necessary), do you have ideas in this direction?

Issue 2:
Hi guys,

I wanted to try and contribute to Three.js and this thread is for discussing about the stuff i wrote.

The questions that are open:

Do you want to use this functionality or do you think three.js needs it?

What do you think of my algorithm. I was hoping for some guys to check the functions and maybe try to optimize the functionalty in case question 1) is "yes" ;)

What i caught missing in THree.js is the functionality to smooth dynamically generated geometries based on an angle. (like in 3dsMax for example)

If the angle between two face normals is smaller than 'angle' the faces get smothed and the vertex normal accounts for that smoothing.

I forked the three.js repository and created a new branch.

I provide an example in my github fork:

https://github.com/GuyGood/three.js/blob/AngleBasedSmoothing/examples/webgl_geometry_smoothing.html

The example compares an extruded geometry with bevel applied.

left: unsmoothed as is, middle: my angle based smoothing, 25°, right: computeVertexNormals(true)

http://img109.imageshack.us/img109/3081/v0jc.png

As I put all my code into Three.GeometryUtils without rebuilding, my example directly uses GeometryUtils.js script.

New stuff to GeometryUtils briefly explained:

So, i added the function "calculateVertexNormals" (should then be renamed to sth else).

It firsts creates new vector3 objects for every vertexNormal for every face of the mesh. (just for having everything at zero).

It then fills an array 'adjacentNormals' with objects so that it contains a face and the vertexNormal, and an empty array for the smoothingGroup stuffs for later on.

then there is the helper method _sortAdjacentFaces. This is because what i am going to do is iterate over all vertices and check all faces connected to one vertex , so to say in a circular manner. And if i don't sort the array beforehand, i would compare faces, connected to the vertex that do NOT share one edge, which would be no good. As a side note, the last iteration compares the last and first face of the vertex in question.

After sorting, the algorithm gets the angle between the faces and checks if it is <= the user defined angle. if it is, it will generate 'smoothing groups' . These groups are local to each vertex and do not work like in 3dsMax for example. They are just for knowing which facenormal from which face to take into account for the vertex normal calculation.

After having calculated the groups and based on them, the vertexNormal is calculated using the helper function: '_calculateVectorSumsForSmoothingGroups'

This function is much like the "computeVertexNormal" from geometries but is always area weighted, so normals are accumulated but not normalized within there.

Finally, normalize the vertex normals and we are done.

I hope i could explain some of the stuff and maybe you like the general idea. I am just proposing some code for review because although it works, there are for sure 2-3 small issues and maybe it can be greatly optimized.

p.s. i know the code is for sure not nice to read but i hope you like the feature anyway and want to have a discussion about it.

Thanks in Advance