14

This is achieved via Barycentric Interpolation. First, we find the barycentric coordinates of $P$. Barycentric coordinates represent how much weight each vertex contributes to the point, and can be used to interpolate any value which is known at the vertices across the face of a triangle. Consider the 3 inner triangles $ABP$, $PBC$ and $PCA$. We can say ...


10

The way it is usually defined, every vertex in a mesh corresponds to a UV-coordinate, and there must be exactly one such coordinate per vertex, because that is how a renderer would fetch texels. So it is impossible to have multiple UV coordinates for a single vertex unless you have multiple parameterizations for your mesh. However, meshes often get split up ...


8

My guess is that to get the texture to look right, you'll have to subdivide the interior of the triangle as well, and approximate the non-linear UV mapping within it. Currently, it looks like you're subdividing around the edges of the triangle, and forming a fan of smaller triangles between the edge and the incenter. This would be fine if you were just ...


7

Short answer: Yes, but it won't be pretty. Explaination: While there are algorithms to automagically UV map polygon soup, the mapping probably wont be ideal. UV mapping is an art really. Choosing where to hide the seams and where to put them to limit stretching and optimize texture space. That said, there are lots of tools that can make manual UV mapping a ...


6

You are on the right track but what you need to do is to calculate u/w and v/w, and also 1/w for each vertex, which you interpolate linearly in screen space in your rasterizer. Then for every pixel you divide the interpolated u/w and v/w coordinates with the interpolated 1/w to get perspective correct uv-coordinates for the pixel. The same applies to all ...


6

1 For each texel of the generated diffuse cube map (which has $6$ faces times $32 \times 32$ texels), the diffuse equation combines all texels of the environment map (which has $6$ faces times $64 \times 64$ texels). Thus $32 \times 32 \times 6 \times 64 \times 64 \times 6$ as stated. Since the article considers SH with $9$ coefficients, and each ...


5

It looks like distortion because the trapezoids are rendered as two triangles by the GPU. This leads to incorrect UV interpolation. Try this: draw a horizontally symmetrical trapezoid with the top being much shorter than the bottom. Then draw one of its diagonals to split it into two triangles. Place a mark at the midpoint of that diagonal. It should be ...


5

Texture baking can be accomplished by simply rendering the mesh in texture space. In other words, you set up a render target matching the size of your texture, and draw the mesh with a vertex shader that sets the output position to the vertex's UV coordinate (appropriately remapped from [0, 1] UV space to [−1, 1] post-projective space). The vertex ...


4

If your plane has a normal of $\begin{pmatrix}0 & 0 & z\end{pmatrix}^T$, then your computation vec3 u = vec3( normal.y, -normal.x, 0 ).normalized(); vec3 v = normal.cross( u ); will result in u and v both being $\begin{pmatrix}0 & 0 & 0\end{pmatrix}^T$. A more general approach would be, for example, to compute the cross product of your ...


4

I just need to add a bit to ap_'s answer. Of course you can have multiple UV for one vertex, this is called UV layers. This is how engines have displayed lightmaps and albedo maps on the same time, since the advent of lightmaps. (quake engine in 1996 maybe ?) You can have more UV layers, if you want to do multitexturing like for terrains, lightmap, albedo ...


3

Incidentally I implemented something similar for similar hardware some 20 years ago (: IIRC, I calculated 1D look-up-table using acos for parallel projection of a cylinder and just scaled it for each scanline to reduce computation cost. The LUT just gives you x-coordinate offset to the texture and you add constant offset for each scanline for the rotation. ...


2

The Nine Patches algorithm is a really nice and powerful solution if you are using textures but I ended up by using a fully procedural solution. I am just drawing a round box like this. float udRoundBox( vec3 p, vec3 b, float r ) { return length(max(abs(p)-b,0.0))-r; } You can simply avoid the 3rd dimension if you don't need it. This method comes from ...


2

A seam can be defined as a line along the mesh where the vertices are doubled each with different texture coordinates. So that's what you should look for. The set of vertices where there is a twin in the same position with different texture coordinates. Depending on how the obj file was built that will be simple if they didn't duplicate the position when a ...


1

A few options: Make the 0-1 discontinuity explicit in the mesh. That is create a 2 sets of vertices that lie exactly on the line where the value would be 1 or 0 (one set gets 1 and one gets 0) then connect the vertices up like they would makes sense. Switch to a different texture mapping projection, I prefer a cubemap because it minimizes distortion at the ...


1

I realize that the solution I'm giving further below is basically the one you mentioned in your question. So let's begin by addressing this: The solution in question assumes that M° is linear.. if that was the case you can have: M°(P) = alpha*M°(A) + beta * M°(B) + gamma*M°(C) But that is not the case (correct me if I'm wrong). The solution in ...


1

Typically, texture coordinates are interpolated from the vertices of a triangle during rendering. This can be seen in two ways. evaluating your texture at vertices and the interpolating the result or interpolating the texture coordinates and evaluating your texture at the fragment level. If you do not supply vertices with corresponding texture coordinates ...


1

I may have misunderstood, but it sounds like the frame buffer you're rendering to is only 2×2 pixels? In that case, the fragment shader will be evaluated at each pixel center, which will be at 0.25 and 0.75 in UV space. So with a threshold of 0.95 you will indeed not get any pixels green. If you use a larger framebuffer, say 100×100, then the last 5 pixels ...


1

Apologies in advance for the poor quality of this answer, but this sounds a little like what an ex-colleague was doing as part of his PhD. The "Free-Viewpoint video" papers listed at the bottom of https://www.researchgate.net/profile/James_Imber might be useful, or at least a starting point to find related work.


1

Although this is borderline "off-topic" for the site, there is perhaps a simple answer: Why not use a webgl approach such as this one? http://learningwebgl.com/lessons/lesson11/index.html (parent page here: http://learningwebgl.com/blog/?p=1253) Just rotate the image of the moon around until you have one of the poles visible and you'll see the typical ...


1

One solution would be to use repeating texture wrapping, and then use a texture transformation matrix. So let's say you normally set the texture coordinates of your GL_TEXTURE_2D to be 0-1 in u and v. Instead, ensure that your GL_TEXTURE_WRAP_S and GL_TEXTURE_WRAP_T are set to GL_REPEAT or GL_MIRRORED_REPEAT and set the texture coordinates to be the tile ...


1

The problem was else-where, the same interpolation works for UV coords. vec2 uv1 = mix(teUv[0], teUv[1], gl_TessCoord.x); vec2 uv2 = mix(teUv[2], teUv[3], gl_TessCoord.x); fUv = mix(uv2, uv1, gl_TessCoord.y);


1

You seem to do things more complicatedly than you need to, as adressed in the comments. What you actually want to do is simple the opposite of the normal render flow. Rather than drawing your mesh in world space and mapping the texture into it, you draw it in texture space and map its vertices onto it and let your graphics hardware worry about interpolation. ...


1

A static occlusion map won't generally work accurately with a dynamic mesh, as you can see. In your case you can separate the occlusion map and instead put it on a static object that wraps around the eye. You can render that object with multiplicative blending and get the effect you want.


1

GLSL has built-in fragment shader inputs, and one of them is gl_FragCoord. You can get the $x$ and $y$ value from this and use that as the lookup coordinate of the texture map in a sequence of two passes, but that could be a good or bad thing depending on the application (such as caching the result). This would both be rotation invariant while allowing you ...


1

The inverse coordinate is not entirely trivial in all cases. But basically, for a basic triangle mesh with nothing exotic and has non overlapping UV's, you need something like this: For the UV coordinate you need to find the corresponding UV triangle. (step can be eliminated see below) Then calculate the barycentric triangle coordinate. Most raytracers ...


Only top voted, non community-wiki answers of a minimum length are eligible