Skip to main content
23 votes
Accepted

How are mipmap levels computed in Metal?

Mip selection is pretty well standardized across devices today—with the exception of some of the nitty-gritty details of anisotropic filtering, which is still up to the individual GPU manufacturers to ...
Nathan Reed's user avatar
  • 25.3k
13 votes
Accepted

Help me grasp Anisotropic Filtering (AF)

To understand the nature of anisotropic filtering, you need to have a firm understanding of what texture mapping really means. The term "texture mapping" means to assign positions on an object to ...
Nicol Bolas's user avatar
  • 9,997
12 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,686
12 votes
Accepted

How to do texturing with OpenGL direct state access?

You still have to bind the desired texture to the texture unit to use it for rendering. In your current code, you're not specifying which texture to use for rendering, so the GL driver doesn't know ...
Nathan Reed's user avatar
  • 25.3k
10 votes
Accepted

Seamless Textures

For these types of algorithms, you usually have to rely on multiple forms of texture synthesis. That doesn't mean you have to generate the whole texture from scratch. For example, you could regenerate ...
aces's user avatar
  • 1,383
9 votes
Accepted

Using RGB texture format for image load/store

RGB8 format and similar are often not supported by GPUs (or only supported for a subset of GPU operations) because they don't have a power-of-two number of bytes per pixel. RGB8 would be 24 bits or 3 ...
Nathan Reed's user avatar
  • 25.3k
8 votes

How to do texturing with OpenGL direct state access?

I have now replaced it with the following, which works: ...
LinAGKar's user avatar
  • 183
8 votes

The mathematics of two dimensional interpolation on a quad

(It actually is easier to think (and compute) about this with triangles, but for the sake of the answer, let's first stick to your quad example.) For this you just have to define the point you're ...
Christian Rau's user avatar
7 votes
Accepted

What's the difference between Sample and tex2D

They represent the same operation, but Sample is what it's called in D3D10 and newer versions of HLSL, while tex2D is what it's ...
Nathan Reed's user avatar
  • 25.3k
7 votes

Gaussian blur with transparency

I apologise for only skimming through your question/answer and the links you gave but I thought it would be a good idea to post what needs to be done to correctly do any blending and/or filtering on ...
Simon F's user avatar
  • 4,336
7 votes

Are textures automatically Morton-coded when loaded to VRAM?

In vulkan, like a lot of other implicit operations, this transition is made explicit. Images can be in one of 2 tiling layouts: optimal and linear. Linear images have a fixed layout while optimal is ...
ratchet freak's user avatar
7 votes

Why are texture coordinates often called UVs?

In math, geometry and physics it is common practice to use the coordinates $(u,v)$ to represent an arbitrary parameterization, including those of a surface in a 3d Euclidean space. Since the ...
Jessica Hansen's user avatar
6 votes

What is missing in this image that stops it from looking like a photograph?

The hair seems to have sampling noise or aliasing in it. This might be poor jpeg compression but it does not look like it. I've never seen hair part that way (could just be me). The neck looks a ...
Olivier's user avatar
  • 1,585
6 votes

Making low discrepancy sequence noise textures, not LDS sample positions

In theory, it is possible to stuff every sample distribution into a texture to "pre-bake" it for fast access. The question is whether any of the results might be useful. For blue noise, this makes a ...
DrivenByNostalgia's user avatar
6 votes

How to access several textures from huge amount of textures in a shader?

Well, it's unlikely that 10,000 cubemaps could fit into memory at all (at 128x128x4-bytes-per-pixel, 10,000 cubemaps would require upwards of 4GB of RAM). But as far as the mechanism to use a large ...
Nicol Bolas's user avatar
  • 9,997
6 votes
Accepted

Is a single shader and 1x1 pixel white sampler more efficient than frequent switching between shaders with and without samplers?

This is a really hardware-dependent question. But in general the best way to think about this is bottlenecks. You mentioned: one set of shaders, one slightly larger vertex struct and just uniform, ...
Calvin's user avatar
  • 506
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

Why are texture coordinates often called UVs?

This is not a definitive answer, but it is generally accepted that Ed Catmull introduced Texture Mapping in his 1974 thesis, "A SUBDIVISION ALGORITHM FOR COMPUTER DISPLAY OF CURVED SURFACES" ...
Simon F's user avatar
  • 4,336
5 votes

What happened to my texture mapping?

You aren't doing perspective correct texturing. At each pixel, $(X,Y)$, you need to be computing U and V with the equivalent of: $U=\frac{aX+bY+c}{pX+qY+r}$ $V=\frac{dX+eY+f}{pX+qY+r}$ The ...
Simon F's user avatar
  • 4,336
5 votes
Accepted

Derivative maps vs. Tangent Space Normal maps

After some researches and some answers from professionals here is my conclusion. Pros Don’t require tangents or binormals. Less interpolators. Only need two channels. less texture memory. Don’t ...
MaT's user avatar
  • 1,229
5 votes

Performance impact during texture layer loading

From the way the problem only manifests when you start overwriting previously used texture tiles, I suspect you're running afoul of some driver heuristic that's attempting to manage the lifetime of ...
Nathan Reed's user avatar
  • 25.3k
5 votes

Help me grasp Anisotropic Filtering (AF)

A few points that you probably already know, but that I just want to put out there for others reading this. Filtering in this case refers to low-pass filtering like you might get from a Gaussian Blur ...
user1118321's user avatar
  • 3,441
5 votes
Accepted

How are Normal Maps created?

"decent" is quite subjective and if you are restricting the capture to certain types of surfaces and controlled lighting conditions. For example normals and other SVBRDF parameters for shiny metallic ...
JarkkoL's user avatar
  • 3,686
5 votes

How to use multithreading in 3D software renderer to speed up fetching texture values

It could be that you have to overcome a different bottleneck first. Have you ever read Jim Blinn's "The Truth About Texture Mapping"? (I had a quick search to see if I could find a non-paywalled ...
Simon F's user avatar
  • 4,336
5 votes

Are textures automatically Morton-coded when loaded to VRAM?

Possibly "all of the above". I've worked with different generations of the same vendor's hardware which have, variously, required software (either the API/driver or the texture tool) to preorder the ...
Simon F's user avatar
  • 4,336
5 votes

OpenGL: Why glTextureSubImage2D crashes?

Pixel transfer operations are governed by more than just your parameters to a pixel transfer function. They are also governed by parameters passed to the ...
Nicol Bolas's user avatar
  • 9,997
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
5 votes

How do I efficiently calculate the distance to the edge of a shape?

A texture that stores distance from the edge of the shape, like you described, is called a "distance field" (you'll find lots of results if you google that phrase). Distance fields can be ...
Nathan Reed's user avatar
  • 25.3k
4 votes

Transforming fragment-to-camera to tangent space for parallax occlusion mapping

Without looking at the code, from the look of the pictures, my intuition would be that somewhere the code is using the inverse of the matrix it should. Looking at the code seems to confirm so, but ...
Julien Guertault's user avatar

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