normals

Generating Smooth Normals from active Vertex Array

强颜欢笑 提交于 2019-12-21 23:04:01
问题 I'm attempting to hack and modify several rendering features of an old opengl fixed pipeline game, by hooking into OpenGl calls, and my current mission is to implement shader lighting. I've already created an appropriate shader program that lights most of my objects correctly, but this game's terrain is drawn with no normal data provided. The game calls: void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid * pointer); and void glDrawElements(GLenum mode, GLsizei count,

Normals for height map data

℡╲_俬逩灬. 提交于 2019-12-21 23:03:21
问题 I want to find normals for height map data. I am using gl_triangles in my code for indices. How would I find normals for this? 回答1: Given a triangle (vert1, vert2, vert3) its normal is ((vert2 - vert1).cross(vert3 - vert1)).normalize() . For smooth, per-vertex normals: Foreach vertex, sum together the face normals for each triangle that vertex is a part of, then normalize the sum. EDIT : Example: #include <GL/glut.h> #include <vector> #include <cmath> #include <Eigen/Core> #include <Eigen

Computing face normals and winding

放肆的年华 提交于 2019-12-21 05:14:08
问题 Given a convex polyhedron with defined vertices (x, y, z) that specifies the faces of the polyhedron. How can I go about calculating the surface normal of each face of the polyhedron? I need the surface normal in order to compute the vertex normal to perform Gouraud shading. The only clue I could find about how to do this is Newell's method, but how do I make sure the normals are outward normals and not inward? Thanks for any help. 回答1: Compute the face normal You have to compute the cross

What is a normal in OpenGL?

佐手、 提交于 2019-12-20 17:39:34
问题 I heard that I should use normals instead of colors, because colors are deprecated. (Is that true?) Normals have something to do with the reflection of light, but I can't find a clear and intuitive explanation. What is a normal? 回答1: A normal in general is a unit vector whose direction is perpendicular to a surface at a specific point. Therefore it tells you in which direction a surface is facing. The main use case for normals are lighting calculations, where you have to determine the angle

Three.js: Convert face normal from local space to world space

泪湿孤枕 提交于 2019-12-19 04:06:05
问题 I have a THREE.PlaneGeometry , with ComputeFaceNormals() . I create two meshes using this geometry, with different rotations applied to them. I want to compute the two angles between the camera and the two meshes central face normal. It should be : vLocalCamera = vCamera.position - mesh1.position; mesh1.normal() . vLocalCamera = cos(angle); The problem is that I don't know how to get the mesh normal in world coordinate (from geometry and mesh rotation) with three.js API 回答1: If you want to

Calculate surface normals from depth image using neighboring pixels cross product

ぐ巨炮叔叔 提交于 2019-12-17 21:56:54
问题 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

Getting consistent normals from a 3D cubic bezier path

巧了我就是萌 提交于 2019-12-17 19:11:01
问题 I'm writing a BezierPath class that contains a list of BezierPoints. Each BezierPoint has a position, an inTangent and an outTangent: BezierPath contains functions for getting linear positions and tangents from the path. My next step is to provide functionality for getting the normals from the path. I'm aware that any given line in 3D is going to have an unlimited number of lines that are perpendicular, so there isn't going to be a set answer. My aim is for the user to be able to specify

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

冷暖自知 提交于 2019-12-17 17:31:13
问题 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. 回答1: You can actually calculate it without a cross product, by using the "finite difference method" (or at least

Flip Normals Three.JS after flipping geometry

匆匆过客 提交于 2019-12-13 14:27:56
问题 I followed this stackoverflow example: ThreeJS geometry flipping I successfully mirrored my geometry. However now my geometry is black. Can I flip my normals at the same time as the geometry to correct this? Or should I have used a different approach to mirror the geometry from the beginning? EDIT: Tried adding the updates to this code and still have inverted geometry. #transformation mS.elements[5] = -1; mesh.applyMatrix(mS); #updates mesh.geometry.verticesNeedUpdate = true; mesh.geometry

Calculating the vertex normals of a quad

好久不见. 提交于 2019-12-13 13:38:31
问题 Lets say that i have the following array : float QuadVertices[4 * 2]; float QuadNormals[4 * 2]; Which i fill this way : //Fill vertices for a 2d quad Renderer->FillVertices(QuadVertices,GL_QUADS,x,y,width,height); Now at this point everything is ok i can render a quad , texture it , stretch it and all that. But now i want to calculate the normals of the quad : for (int i = 0; i < 8;i++) { QuadNormals[i] = ?? } BUT i can't figure out how on earth i am supposed to calculate the normals of a