# Tag Info

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 ...

10

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 ...

8

UV unwrapping is a difficult topic. They can be both combinatorial algorithms or variational methods but in general they're optimization based, i.e. you setup an optimization problem and you solve it using some numerical optimization solver. I'm just going to give you some names and some libraries you can use eventually. I'll give you few names (both classic ...

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

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 coefficient ...

5

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 ...

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

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

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. ...

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 ...

2

Are the two sets well correlated? This would boil down to having a good set of vertex attributes for each set of uv's. If each set of uv's in mapping 1 has a know set of mappings in set 2 then it should be relatively straight forward to read from the first set of uv's and write to the second set. If this is as simple as vertex 1 has a mapping in uv set 1 and ...

2

I think it's easiest to get the tangent frame by writing the forward mapping from $(u,v)$ to $\mathbf{p}$: $$\mathbf{p}(u,v) = \begin{bmatrix} R \, \cos (2\pi u) \\ R \, \sin (2\pi u) \\ vL \end{bmatrix}$$ Then you can see that the derivatives are:  \frac{\partial\mathbf{p}}{\partial u} = \begin{bmatrix} -2\pi R \, \sin(2\pi u) \\ 2\pi R \, \cos(...

1

This looks like a side effect of bilinear filtering where it can sample texels neighbouring those that are at the edges of the used areas of the texture - the red/green boundary in your case. One solution for this is to perform a "colour bleed" pass on the texture where for every 'empty'(Green) texel with none-empty (Red) neighbours you can output the ...

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

It's hard to say without seeing the shader in question. My guess is that every animation frame in the atlas has the same size. This fixed size allows mapping any UV coordinates to the proper animation frame's UV extents. For example, with 16 frames in a texture: 0 0.25 0.5 0.75 1.0 \ \ | / _/ +--+--+--+--+ | 0| 1| 2| 3| +--+--+--+--+ 0.25 | 4| 5| ...

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

An alternative solution would be to avoid the vertex/geometry shader completely and draw your fullscreen quad with glRecti(-1, -1, 1, 1); then just compile a fragment shader and generate your UVs with: vec2 uv = gl_FragCoord.xy / framebufferSize.xy; I don't know what you're doing but this could be potentially a fast forward solution for what you require....

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

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 ...

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