26

First of all, for every 3D vertex there is infinite tangent and bi-tangent vectors. The below image explains why there is an infinite number of tangent spaces for each vertex, the tangent and bitangent can have any direction in the shown plane. So inorder to properly calculate the most useful1 tangent space, we want our tangent space to be aligned such that ...


14

You can't. All right, that was a bit harsh. Let me illustrate this with two examples. Let's get outside of the computer graphics world. Suppose you are given a piece of paper with the texture you gave us printed on it. There's a faintly printed millimeter grid in the paper as well. Now you get some scissors and some paste, and your task is to make a ...


13

Typical UV mapping is what's called an affine transformation. That means the mapping of each triangle between 3D space and texture space can include rotation, translation, scaling/squash, and skew (ie. anything we can do with a homogeneous matrix multiplication) The thing about affine transformations is that they're uniform across their whole domain - the ...


10

This is where I will use a 3D painting program. I primarily use Blender for my modeling, and it has a 3D painter built in. Being able to paint directly on the model in a 3D environment, makes the strokes continue across seams. I don't find the paint tools in Blender to be great, so I'll usually switch to something like GIMP once I've got a rough idea. Then ...


9

With full source (or even just a thorough explanation) of a perspective correct textured triangle rasterizer being too long for an answer, I'll gladly refer you to Chris Hecker's classic series of articles on the topic, including source: http://chrishecker.com/Miscellaneous_Technical_Articles From your link I assume you are using Flash as a platform, so I ...


8

Texture mapping is a hard problem. For some primitives there is a mathematically sound way of finding the UV coordinates. This is only possible if we can think of a function F(u,v)->(x,y,z). An example of a figure where this is possible is the a cube. Here we can easily cut out a square for each of the surfaces. For a sphere this is also possible, here ...


8

Assuming atan2 returns an angle in radian between -pi and pi (π) you do something like: n = Normalize(sphere_surface_point - sphere_center); u = atan2(n.x, n.z) / (2*pi) + 0.5; v = n.y * 0.5 + 0.5; Where sphere_surface_point is the point on the sphere surface. / (2*pi) is there to convert the returned angle to a value between -0.5 and 0.5 Add 0.5 to ...


7

Think origami. A UV map is like a flattened (unwrapped) 2D skin of your 3D mesh (shell). If you were to cut out the map and fold it along the mesh lines, the result would be your 3d model. The (U,V) floating point values range from (0,0) to (1,1) The upper left corner of the UV map is (0,0) The lower right corner is (1,1) Each vertex in a mesh of ...


7

This may be a winding issue. Are you sure that the texture coordinates are parsed in the right sense of rotation? However, this how you should debug you program. Draw in wire frame mode to find out how the rectangle is composed out of two triangles. The OpenGL command for this is glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);. Use a texture with a gradient ...


7

UV interpolation needs to take into account the depth of the vertices. You need to perform perspective-correct interpolation, which involves dividing by the w coordinate of the interpolated homogeneous vector. The "folded plane" effect of affine interpolation becomes more pronounced at wide FOV or when the camera is close to an object, but it's not caused ...


7

I am one of the developers of the itSeez3D application you linked in your post. Accidentally stumbled upon your question. @Kevin van der Velden provided an entirely relevant reference here, I would not say it took us five years, but definitely not less than a year :) There are several problems with the simplistic approach you're describing. First of all, ...


5

Another way would be to procedurally generate your textures. This approach comes with its advantages and disadvantages. Most important tradeoff is that you can't draw your textures in an editor but have to code them using noise functions. The huge gain in your situation is that you can texture your terrain completely orientation independent. This is done by ...


5

Alright, found my issue. Not sure if this applies to OpenGL but for my DirectX application I needed to invert the v coordinate for sampling the texture. u = u v = 1 - v;


5

One example is for light maps. Usually texture space is maximized by overlapping faces which have the same diffuse texture, like the six sides of a crate. With light mapping this would mean that all six sides get the same light and shadow, not to mention it would almost assuredly confuse the light mapper because it can't tell which point in space it should ...


5

A simple method using only Photoshop: Crop the image vertically to remove anything that should be below the horizon (ie. not part of the sky dome) Scale up the height of the image to make it square Filter -> Distort -> Polar Coordinates


5

Going by WebGL Caps it looks like 4k textures are a very safe bet (which is why everyone is using them) but 8k textures still have a ways to go. Ideally you'll want to have a 4k fallback option if your users don't support 8k textures. That being said, your car shouldn't need an 8k texture, it's likely that your UV mapping could use some optimization. Make ...


4

A quad with the texture coordinates 0,0 on the one corner and 2,2 on the other corner, means the texture is tiled 4 times, 2 times in each direction. Now if you have the same quad with 4,4 on the other corner instead you have the texture tiled 16 times, 4 times in each direction. If you increase the texture coordinates without increasing the size of the ...


4

I took a quick look at your example and your code. You're extremely close to solving this, so I don't mind helping with a question that looks suspiciously like homework ;). In data.js, you are assigning the same UV coordinates to the front and rear faces of the cube. The coordinates seem to be ([0,0], [0,0.5], [0.5,0.5], [0.5,0]). This means that you can ...


4

A line is a list of connected points. For each point you'll need to calculate the X-Texture coordinate of that point, the Y coordinate will always be 0 for the upper point and 1 for the lower point. After you have defined how long one texture segment is you can do so by stepping through all the segments you have generated and noting how much distance you ...


4

Actually every face of your mesh has UV coordinates through which UV mapping works. Let take an example of cube. Cube has 6 faces and every face has 4 coordinates. That means a Cube must have 24 coordinates for UV mapping. Now second part is to map coordinates with texture. Let's take an example of a square texture image having 6 different color boxes ( ...


4

It looks like you're trying to use (rotated) vertex positions as UV coordinates. When you're using this to look up into a 2D texture, only the x & y values are used and the z is ignored, giving you a planar projection: The effect is like shining your texture onto the object using an orthographic projector, along one directional axis. Portions of your ...


3

So this doesn't provide details to every problem you'll encounter with your approach, but, if you want to map each vertex to the closest non-air voxel in order to scrape information from it (such as which texture to sample), here's a proof for the efficient method I came up with: For any given marching cubes vertex, we wish to select a voxel with which ...


3

First off, make sure you're adding a material on your mesh, then add the texture, set it as "image or movie", and chose "Coordinates: UV":


3

For simple shapes, you can usually find sensible unwrapping approaches by looking to papercraft (those guys are experts at unfolding shapes. Albeit backwards.) For an octohedron, you might consider the model here: http://psmay.com/wp-content/uploads/2012/01/logihedron.pdf This sort of approach doesn't entirely cover your texture the way that your ...


3

In the past I've fixed this sort of problem using a dilation filter. Basically, the idea is to go over the lightmap after it's rendered and expand the borders of all the pieces by a few pixels, by copying the values of filled pixels into adjacent empty pixels. This can be done with a pixel shader in a full-screen pass or two over the lightmap.


3

Either use a geometry shader (or possibly some vertex/fragment shader magic) to generate the border from each vertex of the cube, or write a function that generates a new box with a fixed border size. By scaling a box, you scale the whole box. There's no magical way of scaling the border separately. And it's a box, which should be simple enough to generate. ...


3

It sounds like you just need plain rectangular UV coordinates. The inner radius is V = 1, and the outer radius is V = 0. That angular procession from the bottom up is from U = 1 to U = 0 (or the opposite depending on tech). The vertex locations can be arranged in a curve, but the texture coordinates don't have to be.


3

First of all, the process of finding the pixels that fall in a triangle is called rasterization. You might want to look up some articles on fast software rasterization, or better yet move the lightmap build process (or at least the rasterization part of it) to the GPU, as it'll be much, much faster. There are two possible solutions to the problem of cracks ...


3

You could define a set of textures (grass, dirt, rock) and use those. Let's say using these three layers (rock at the bottom, dirt on top and grass topmost), you can define three alpha channels to define how much of each texture is visible. Start with a simple noise map for your alpha channels and maybe take the slope of terrain into account. The more slope, ...


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