Skip to main content
Share Your Experience: Take the 2024 Developer Survey
12 votes
Accepted

How does UV unwrapping work?

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 ...
user8469759's user avatar
10 votes
Accepted

Perspective Correct Texture Mapping

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 ...
JarkkoL's user avatar
  • 3,636
6 votes
Accepted

How do I convert a hit on an infinite plane to UV coordinates for texturing in a Raytracer?

If your plane has a normal of $\begin{pmatrix}0 & 0 & z\end{pmatrix}^T$, then your computation ...
Michael Kenzel's user avatar
6 votes
Accepted

The Process of Spherical Harmonics

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 \...
Julien Guertault's user avatar
5 votes
Accepted

Jagged texture's edge on perfectly straight UV of sphere mesh

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 ...
Olivier's user avatar
  • 1,585
3 votes
Accepted

Fast approximation of spherical texture coordinates

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 ...
JarkkoL's user avatar
  • 3,636
3 votes

Why does lv = fract(uv*2) result in grid like pattern?

Multiplying uv by K scales it from a 0–1 range to a 0–K one. As you’re noting, the fract ...
Noah Witherspoon's user avatar
2 votes

UV Coordinate Interpolation in Compute Shader

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 ...
Christian Rau's user avatar
2 votes
Accepted

Special Texture Stretching without deformation

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. ...
MaT's user avatar
  • 1,229
2 votes

Extract 3D seam coordinates from

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 ...
ratchet freak's user avatar
2 votes
Accepted

Transfer the texture between two different sets of uv

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 ...
pmw1234's user avatar
  • 3,219
2 votes
Accepted

UV partial derivatives of a cylinder shape primitive

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{...
Nathan Reed's user avatar
  • 25.1k
2 votes

How to map texture pixels to the corresponding 3D positions?

Well, there is no 1:1 correspondence the pixel might be in many locations at once. What your asking is relatively easy. Just iterate through each triangle (f). Then get the texture coordinate of each ...
joojaa's user avatar
  • 8,437
1 vote
Accepted

Does automatic UV unwrapping work with an indexed face set model?

Does the process of UV unwrapping add more vertices and modify the model? Yes, in general. The final model that is rendered, i.e. what the GPU sees, will have vertices with the same position but ...
Nathan Reed's user avatar
  • 25.1k
1 vote
Accepted

Calculating UV coordinates for sampling texture atlas

Assuming normalized texture coordinates and a grid of 8x8 (which is 64 tiles not 16 like I said in the comments) then tileOffset will need to be a vec2 for the x and y offsets. Also, assuming texture ...
pmw1234's user avatar
  • 3,219
1 vote
Accepted

How to paint onto 3d models

I can't give you a "better" approach here, but I think that the approach to project each individual brush image onto the surface of the object is not really a performance issue if you ...
wychmaster's user avatar
  • 1,251
1 vote

How to paint onto 3d models

As long as no pixel on the texture is used twice, you can render the geometry and display the uv-coordinates (texture coordinates). Usually they are a combination of red and green (2d). When using a ...
Thomas's user avatar
  • 1,265
1 vote

Projective texturing from many images

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 ...
Simon F's user avatar
  • 4,261
1 vote
Accepted

Is there any free software to visualize a texture mapped to a sphere?

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 ...
Simon F's user avatar
  • 4,261
1 vote

Help with wireframe artifacts on mesh procedural UV texturing

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 ...
PaulHK's user avatar
  • 2,322
1 vote

Sphere Texture Mapping Algorithm

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 ...
ratchet freak's user avatar
1 vote
Accepted

How to get the 3D position for the point with (0,0) UV coordinates?

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 ...
Michael Kenzel's user avatar
1 vote

How does a GLSL Sampler2D read a Vec2 UV coordinate to determine UV range

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 ...
bernie's user avatar
  • 830
1 vote

Export Model Textures Per Face

Since UV coordinates are per a vertex this can be done by simply displaying the 2D UV coords in screen space and texture the resulting triangles using the same texture coords. Since UV coords are ...
pmw1234's user avatar
  • 3,219
1 vote
Accepted

In texture mapping, should we set texture coordinate to every vertex or can I skip vertices in between?

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 ...
Reynolds's user avatar
  • 1,283
1 vote

Full screen quad texture coordinates mapping

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 ...
Intrins's user avatar
  • 59
1 vote
Accepted

Full screen quad texture coordinates mapping

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 ...
Nathan Reed's user avatar
  • 25.1k
1 vote
Accepted

How do you scale an image across planes while retaining perfect tiling?

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 ...
user1118321's user avatar
  • 3,421
1 vote
Accepted

How do you interpolate UV mapping coords in a quad tessellation evaluation shader?

The problem was else-where, the same interpolation works for UV coords. ...
scx's user avatar
  • 169

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