New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Index not considered for FloatVertexAttribute in IndexedFaceSet #596
Comments
Could you try creaseAngle='3.14' as an IndexedFaceSet attribute ? I believe the default creaseAngle='0' leads to duplication of shared vertices to be able to have segmented shading with the default shading. Unfortunately, the default is required by the spec. to be 0. |
It worked, It indeed removed the duplicated points, and no out of range error! in the shaders the data would be associated like that : 0.1 for point 0, 0.2 for point 2, 0.3 for point 1 |
My mistake, it works well! |
Ok ! But the mapping of the FloatVertexAttributes uses the coordIndex indices as you explained ? |
Without duplication, there is no problem the first data is associated to the first color and position... But the problem is when someone need duplicate points for each faces (it is the case for some scientific data mesh). |
But it does here in the third paragraph: So it should be like you had expected in the first place. |
If you need duplicate points for each faces, could you just specify duplicate points in the coords ? |
Yes that a solution. I can try to fix the parsing of the FloatVertexAttribute. I encountered another problem: It seems that creaseAngle='3.14' disable normalPerVertex='false' <IndexedFaceSet id="faceSet" solid="false"
coordIndex='0 1 2 -1 0 1 3 -1 '
creaseAngle='3.14'
normalPerVertex='false'>
<Coordinate point="0 0 0, 0 1 0, 1 0 0, 0 0 1,"></Coordinate>
<Normal vector="1 0 0, 0 0 1, 0 0 1, 0 0 1" ></Normal>
<!-- Expected but did not work :
<Normal vector="1 0 0, 0 0 1," ></Normal>
--> Should I open a new issue? |
Yes, I would suggest to open a new issue. |
Thinking a bit more about what the goal was, a solution is often to use a 1d texture map to visualize data on geometry. The data then become the texture coordinates for each vertex. |
I already have a function code using textureCooridinate (the texCoord are computed from the data, so I computed the data from the texCoord), but in order to have a simpler and more direct code I would like to use FloatVertexAttribute. |
OK. |
The issue can be solved by redefining the handleAttribs function in handle attribut. (inherited from X3DComposedGeometry ). |
This brings up if you could just use IndexedTriangleSet or TriangleSet since they do not have creaseAngle ? |
http://stackoverflow.com/questions/4580690/normals-per-index Explain how normals per face are really multiple normals per vertex for the GPU which means duplication of vertices. So it is best to supply normals per vertex in the first place. |
In this issue I think that duplication isn't the problem. The problem is to have a natural input for the FloatVertexAttribute for the Indexed elements. (IndexedFaceSet , IndexedTriangleSet... ) |
I thought duplication in the creaseAngle=0 case was the problem, since without duplication the FloatVertexAttributes are actually associated with correct vertices ? |
well, for my project I can duplicate the normals in order to have the normal per vertex. |
Sounds good to me. |
Thanks to you two for the analysis! With the new open issue, would it be fine to close this one? |
I think a fix which treats FloatVertexAttributes the same way as colors and normals would be good. Could it go into X3DComposedGeometry.js ? |
Well I have two solution, The second solution change the handleAttritut function in X3DComposedGeometry, and I can change the data before saving them into _cf._attrib. The problem with the first solution is that I sould copy/past the modification for each Indexed Geometry like : IndexedTriangleSet, IndexedLineSet ... |
Hello,
In my project, I have a mesh with data associated to each vertices and I wanted to hide part of the mesh if the data are to lower than a chosen value.
To do that, I used an IndexedFaceSet for the geometry and add the attribute to the shaders with FloatVertexAttribute.
In the example below I created 2 triangles with 4 points, so I can set normal, texture coordinate, for the 4 points: 3* 4 values for coordinate, 2*4 for texture coordinate...
The problem is when I tired to set only 4 values I got the webgl warning :
[GroupMarkerNotSet(crbug.com/242999)!:D0DAD8CDB47F0000]GL ERROR :GL_INVALID_OPERATION : glDrawArrays: attempt to access out of range vertices in attribute 3
For x3dom there is 6 points (some points are duplicated during the creation of the faces). When I tried to set the FloatVertexAttribute, it asked for 6 values not 4. After reading a parts of x3dom code I believe that FloatVertexAttribute should be parsed with the other attributes (normal, positions...)
Franck
[EDIT] : I changed the exemple to make it simpler
The text was updated successfully, but these errors were encountered: