normals

Understanding normals indices with Wavefront Obj

别来无恙 提交于 2019-12-09 19:17:22
问题 I've written a C++ Obj file loader that I can't get to work correctly. The problem is that while parsing a simple obj file like the following: # Blender v2.62 (sub 0) OBJ File: '' # www.blender.org mtllib cube.mtl o Cube v 1.000000 -1.000000 -1.000000 v 1.000000 -1.000000 1.000000 v -1.000000 -1.000000 1.000000 v -1.000000 -1.000000 -1.000000 v 1.000000 1.000000 -0.999999 v 0.999999 1.000000 1.000001 v -1.000000 1.000000 1.000000 v -1.000000 1.000000 -1.000000 vn 0.000000 0.000000 -1.000000

Rotate Normals in Shader

社会主义新天地 提交于 2019-12-09 18:24:00
问题 I have a scene with several models with individual positions and rotations. Given normals, the shaders apply simple bidirectional lighting to each pixel. That is my vertex shader. #version 150 in vec3 position; in vec3 normal; in vec2 texcoord; out vec3 f_normal; out vec2 f_texcoord; uniform mat4 model; uniform mat4 view; uniform mat4 proj; void main() { mat4 mvp = proj * view * model; f_normal = normal; f_texcoord = texcoord; gl_Position = mvp * vec4(position, 1.0); } And here is the

LibGDX mesh heightmap normals and lights

心不动则不痛 提交于 2019-12-09 11:49:57
问题 I am trying to get mesh normals and lights working in LibGDX project. I already have textured mesh generated from heightmap texture pixels. The problem is I cannot get normals lighted up correctly. Also Im not 100% sure I have normal vertices correctly set up in TerrainChunk class. Heres the main class code: package com.me.terrain; import com.badlogic.gdx.Game; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic

Calculating Normals across a sphere with a wave-like vertex shader

泄露秘密 提交于 2019-12-08 09:31:42
问题 I've been trying to get the correct normals for a sphere I'm messing with using a vertex shader. The algorithm can be boiled down simply to vert.xyz += max(0, sin(time + 0.004*vert.x))*10*normal.xyz This causes a wave to roll across the sphere. In order to make my normals correct, I need to transform them as well. I can take the tangent vector at a given x,y,z, get a perpendicular vector (0, -vert.z, vert.y), and then cross the tangent with the perp vector. I've been having some issue with

Normal averaging of heightmap

时光毁灭记忆、已成空白 提交于 2019-12-06 15:16:21
问题 i have the following code for calculating Heightmap normals void CalcMapNormals(HeightMap * map, Vec3f normals[]) { int dst, i, j, right, bottom; Vec3f p0, p1, p2; Vec3f n0; /* Avoid writing map->rows|cols - 1 all the time */ right = map->cols - 1; bottom = map->rows - 1; dst = 0; for (i = 0; i < map->rows; i++) { for (j = 0; j < map->cols; j++) { Vec3Set(normals[dst], 0, 0, 0); /* Vertex can have 2, 3, or 4 neighbours horizontally and vertically */ if (i < bottom && j < right) { /* Right and

What is use of getNormals() method in TriangleMesh JavaFX

和自甴很熟 提交于 2019-12-06 10:55:09
问题 I am currently working of JavaFX 3D application and come across getNormals() method in TriangleMesh class. As in TriangleMesh class is used to create user defined Java FX 3D obejct and in that getPoints() is used to add Points getFaces() is used to add Faces getTexCoords() is used to manage Texture of 3D Object, but I am not sure what is use of getNormals() method in TriangleMesh class. In TriangleMesh class, we can set vertex format to VertexFormat.POINT_TEXCOORD and VertexFormat.POINT

Per-Vertex Normals from perlin noise?

谁说胖子不能爱 提交于 2019-12-05 22:13:03
问题 I'm generating terrain in Opengl geometry shader and am having trouble calculating normals for lighting. I'm generating the terrain dynamically each frame with a perlin noise function implemented in the geometry shader. Because of this, I need an efficient way to calculate normals per-vertex based on the noise function (no texture or anything). I am able to take cross product of 2 side to get face normals, but they are generated dynamically with the geometry so I cannot then go back and

Calculate if two 3D triangles are on the same plane

一世执手 提交于 2019-12-05 17:37:06
For a 3D game engine I'm working on I need to calculate if two 3D triangles are on the same plane to display it accordingly. How do I calculate the angles of a triangle in 3D space? Would calculating a surface normal and comparing those ever give me 2 equivalent normals? Why do you want to do that? What is the number of triangle you expect to test? It seems a little bit complex for a real time rendering algorithm! Anyway: Compute the normal n of the triangle. Then compute the plane equation: a.x + b.y + c.z + d = 0 with (a,b,c) being your triangle normal and d = - dot(n,P) (P is one of your

Integral Image normal estimation from kinect depth image

你离开我真会死。 提交于 2019-12-05 04:07:13
问题 I am doing the following to try and estimate surface normals from a point cloud generated from a Kinect depth image: pcl::PointCloud<pcl::PointXYZRGB>::Ptr create_point_cloud_ptr(Mat& depthImage, Mat& rgbImage){ pcl::PointCloud<pcl::PointXYZRGB>::Ptr cloud(new pcl::PointCloud<pcl::PointXYZRGB>()); cloud->width = depthImage.rows; //Dimensions must be initialized to use 2-D indexing cloud->height = depthImage.cols; cloud->resize(cloud->width*cloud->height); int min_depth = INT_MAX; int num_of

Loading an OBJ file, how to use normals (#vertices < #normals)

我怕爱的太早我们不能终老 提交于 2019-12-04 16:42:59
I have an obj file and have succesfully loaded the object to opengl without using the normals given. This is how it looks: The format of the file is: v x y z vn x y z f x//x' y//y' z//z' The displaying function of the mesh is like that: glBegin(GL_TRIANGLES); for all faces { glVertex3f(.., .., ..); glVertex3f(.., .., ..); glVertex3f(.., .., ..); } glEnd(); And the result is this: I've read that the object might look flat due to the default normal vector that OpenGL uses for lighting equations. This could be solved with normals. The normals given are 780 and the vertices 155. I've tried using