Hot answers tagged

79 votes

Sharp Corners with Signed Distance Fields Fonts

EDIT: Please see my other answer with a concrete solution. I have actually solved this exact problem over a year ago for my master's thesis. In the Valve paper, they show that you can AND two ...
Detheroc's user avatar
  • 1,436
50 votes

Sharp Corners with Signed Distance Fields Fonts

Sorry about the long wait, but it has become obvious that although the article I have promised is basically complete, the publishing process will take some time. Therefore, I have instead prepared an ...
Detheroc's user avatar
  • 1,436
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
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
12 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,752
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,626
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,353
9 votes
Accepted

16bit half-float linear HDR images as (diffuse/albedo) textures?

In film production, we almost never use 8-bit textures for color/albedo, because of banding, etc. (JPEG is especially problematic since by spec, it's sRGB rather than linear values.) We either use '...
Larry Gritz's user avatar
8 votes
Accepted

Sine-based Tiled Procedural Bump

As you are taking the mean of a number of sine waves, your colour values will range from -1 to 1. From your example image, it looks like only the top half of this range of values (from 0 to 1) is ...
trichoplax is on Codidact now's user avatar
8 votes

16bit half-float linear HDR images as (diffuse/albedo) textures?

Yes, it's possible in some extreme cases for HDR lighting and tonemapping to expose banding issues in color textures. In those cases, having a higher bit depth for the textures could be useful. ...
Nathan Reed's user avatar
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
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
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

Texture rendering in OpenGL

This type of artifact is a tell-tale sign that you've messed up your texture image format at the byte level. It's hard to tell what exactly is wrong, but it's something along the lines of bad pitch or ...
IneQuation's user avatar
7 votes
Accepted

Why does substracting -1 in shader fail for a float data type?

Without seeing the error message I can't be sure but I think it's failing on the 1 being int instead of a float. float inv_coord = v_coord - 1.0; There is a ...
ratchet freak's user avatar
7 votes

Sharp Corners with Signed Distance Fields Fonts

Quite interesting! I'm the author of the valve signed distance paper. Sorry that it's a little sparse on implementation details. I only included the two channel example as future work - I didn't have ...
chris green's user avatar
7 votes
Accepted

Map a texture onto a hyperbolic triangle

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 ...
Nathan Reed'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
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,231
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
6 votes

How to create a patterned object with variable pattern density in real-time?

In order to ensure that the pattern shapes are always either wholly present or absent, never cut off, it's necessary to ensure that the same p value is used for all ...
Nathan Reed'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,752
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
5 votes

16bit half-float linear HDR images as (diffuse/albedo) textures?

I'd like to invite readers to read this article about Quake 2 engine rasterization technology explained in details, if they have the time. If TLDR, please pay attention to this image: What we see is ...
v.oddou's user avatar
  • 623
5 votes
Accepted

Jitter texture generation

The texture is probably generated by picking a random angle per pixel, and populating the image with its sine and cosine, remapped into [0, 1]: $$\theta \sim [0, 2\pi] \quad \to \quad \begin{bmatrix} ...
Nathan Reed's user avatar
5 votes
Accepted

Background behind 3D model

Normally if you paint a background image you simply draw a textured full-screen square while depth testing and writing is disabled before drawing the actual scene (where you re-enable depth) In the ...
ratchet freak's user avatar
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,231

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