normals

Can I specify per face normal in OpenGL ES and achieve non-smooth/flat shading?

青春壹個敷衍的年華 提交于 2019-11-30 03:41:19
问题 I want to display mesh models in OpenGL ES 2.0, where it clearly shows the actual mesh, so I don't want smooth shading across each primitive/triangle. The only two options I can think about are Each triangle has its own set of normals, all perpendicular to the triangles surface (but then I guess I can't share vertices among the triangles with this option) Indicate triangle/primitive edges using black lines and stick to the normal way with shared vertices and one normal for each vertex Does it

Calculating normals between 2 meshes ending up in seams

我的梦境 提交于 2019-11-29 17:38:32
问题 My Task I currently creating a terrain for Unity3D which is specialized for mobile-devices with low memory for a running app. Allowing a terrain with a size of 15.000 x 15.000 kilometers and a height from -1.000 meters to 10.000 meters and it's only limits are the space on the hard disk. Situation Everything is running fine right now except that the normals between different meshes ( each mesh has a subdivision level ) are not calculated correctly. Here are two pictures which visualize the

Most efficient algorithm to calculate vertex normals from set of triangles for Gouraud shading

拜拜、爱过 提交于 2019-11-29 11:09:37
We are given a set of triangles. Each triangle is a triplet of points. Each point is a triplet of real numbers. We can calculate surface normal for each triangle. For Gouraud shading however, we need vertex normals. Therefore we have to visit each vertex and look at the triangles that share that vertex, average their surface normals and we get vertex normal. What is the most efficient algorithm and data structure to achieve this? A naive approach is this (pseudo python code): MAP = dict() for T in triangles: for V in T.vertices: key = hash(V) if MAP.has(key): MAP[key].append(T) else: MAP[key]

Calculate surface normals from depth image using neighboring pixels cross product

会有一股神秘感。 提交于 2019-11-28 17:35:19
As the title says I want to calculate the surface normals of a given depth image by using the cross product of neighboring pixels. I would like to use Opencv for that and avoid using PCL however, I do not really understand the procedure, since my knowledge is quite limited in the subject. Therefore, I would be grateful is someone could provide some hints. To mention here that I do not have any other information except the depth image and the corresponding rgb image, so no K camera matrix information. Thus, lets say that we have the following depth image: and I want to find the normal vector at

Most efficient algorithm to calculate vertex normals from set of triangles for Gouraud shading

故事扮演 提交于 2019-11-28 04:53:50
问题 We are given a set of triangles. Each triangle is a triplet of points. Each point is a triplet of real numbers. We can calculate surface normal for each triangle. For Gouraud shading however, we need vertex normals. Therefore we have to visit each vertex and look at the triangles that share that vertex, average their surface normals and we get vertex normal. What is the most efficient algorithm and data structure to achieve this? A naive approach is this (pseudo python code): MAP = dict() for

OpenGL - How to calculate normals in a terrain height grid?

吃可爱长大的小学妹 提交于 2019-11-28 03:43:05
My approach is to calculate two tangent vectors parallel to axis X and Y respectively. Then calculate the cross product to find the normal vector. The tangent vector is given by the line that crosses the middle point on the two nearest segments as is shown in the following picture. I was wondering whether there is a more direct calculation, or less expensive in terms of CPU cycles. You can actually calculate it without a cross product, by using the "finite difference method" (or at least I think it is called in this way). Actually it is fast enough that I use it to calculate the normals on the

Three.js: How to flip normals after negative scale

爷,独闯天下 提交于 2019-11-28 01:18:07
I have cloned and than flipped an object using negative scale, which causes my single sided faces to inverse. My question is, how can i flip the normals too? I don't want to use material.side = THREE.DoubleSide, for reasons: 1) didn't work properly (some shades are drawn from inside) and 2) wanna keep as much performance as possible. So DoubleSide isn't an option for me. Thats how my object if flipped. mesh.scale.x = - scale_width; Thanks in advance! WestLangley I would advise against negative scale for a whole host of reasons, as explained in this link: Transforming vertex normals in three.js

Three.js: How to flip normals after negative scale

只谈情不闲聊 提交于 2019-11-26 21:52:40
问题 I have cloned and than flipped an object using negative scale, which causes my single sided faces to inverse. My question is, how can i flip the normals too? I don't want to use material.side = THREE.DoubleSide, for reasons: 1) didn't work properly (some shades are drawn from inside) and 2) wanna keep as much performance as possible. So DoubleSide isn't an option for me. Thats how my object if flipped. mesh.scale.x = - scale_width; Thanks in advance! 回答1: I would advise against negative scale

Calculating normals in a triangle mesh

倾然丶 夕夏残阳落幕 提交于 2019-11-26 14:10:00
I have drawn a triangle mesh with 10000 vertices(100x100) and it will be a grass ground. I used gldrawelements() for it. I have looked all day and still can't understand how to calculate the normals for this. Does each vertex have its own normals or does each triangle have its own normals? Can someone point me in the right direction on how to edit my code to incorporate normals? struct vertices { GLfloat x; GLfloat y; GLfloat z; }vertices[10000]; GLuint indices[60000]; /* 99..9999 98..9998 ........ 01..9901 00..9900 */ void CreateEnvironment() { int count=0; for (float x=0;x<10.0;x+=.1) { for