Hot answers tagged

69

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 distance fields to achieve this, which works as long as you only have one convex corner. For concave corners, you also need the OR operation. This guy actually ...


43

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 open source program with my new multi-channel distance field construction algorithm, msdfgen, which you can try out right now. It is available on GitHub: https:...


29

"How (hardware) texture compression works" is a large topic. Hopefully I can provide some insights without duplicating the content of Nathan's answer. Requirements Texture compression typically differs from 'standard' image compression techniques e.g. JPEG/PNG in four main ways, as outlined in Beers et al's Rendering from Compressed Textures: Decoding ...


24

As Simon's comment alluded to, one major difference between hardware texture compression and other commonly used image compression is that the former does not use entropy coding. Entropy coding is the use of shorter bit-strings to represent commonly-occurring or repeating patterns in the source data—as seen in container formats like ZIP, many common ...


20

Overview The main reason for Virtual Texturing (VT), or Sparse Virtual Textures, as it is sometimes called, is as a memory optimization. The gist of the thing is to only move into video memory the actual texels (generalized as pages/tiles) that you might need for a rendered frame. So it will allow you to have much more texture data in offline or slow ...


19

Whether it's a tile based GPU or not doesn't really affect the texture cache architecture. The memory layout of texture will look like some flavor of Morton order or Hilbert curve in all GPUs. As a result, it's more efficient to render triangles that are close to equilateral triangles because GPU memory system fetches cache lines of texels. So obviously on ...


17

Yes, lookup textures are still used. For example, pre-integrated BRDFs (for ambient lighting, say), or arbitrarily complicated curves baked down to a 1D texture, or a 3D lookup texture for color grading, or a noise texture instead of a PRNG in the shader. ALU is generally cheaper than a texture sample, true, but you still have a limited amount of ALU per ...


16

Just adding to imallett's answer, it is true that increasing the number of accesses to different texture data in a shader will increase pressure on the GPU cache(s), but there are several other factors that can significantly influence the effect. It's also possibly complicated by the fact that, like CPU caches, there may be several layers of cache in a GPU, ...


16

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 define (and its precise details are generally not publicly documented). A good place to read about mip selection in detail is in the OpenGL spec, section 8....


15

As TheBuzzSaw said, it does depend on lots of things, including implementations of the rasterized graphics vs the vector graphics. Here are some high performance vector graphics methods that are rendered using traditionally rasterization methods. Loop and Blinn show how to render a vector graphics quadratic bezier curve by rendering a single triangle, and ...


14

At the top level, a GPU is subdivided into a number of shader cores. A small GPU in a notebook or tablet may have only a few cores while a high-end desktop GPU may have dozens. In addition to the shader cores there are also texture units. They may be grouped together with one texture unit per shader core, or one texture unit shared among two or three ...


14

The texture filtering hardware takes several samples of the various mipmap levels (the maximum amount of samples is indicated by the anisotropic filtering level, though the exact amount of samples taken in a given filtering operation will depend on the proportion between the derivatives on the fragment.) If you project the cone viewing a surface at an ...


13

(XYZ) can be the RGB colour you want to tint your scene by. For the above scene it can be a red colour (1.0, 0.0, 0.0) or something similar with a strong red component. Bear in mind that since you are applying the colour in a multiplicative way it will act as a filter suppressing original colour components. So if your scene is mostly green but you apply (i....


12

The rule is that to compute the next mipmap size, you divide by two and round down to the nearest integer (unless it rounds down to 0, in which case, it's 1 instead). For example, a 57x43 image would have mipmaps like: level 0: 57x43 level 1: 28x21 level 2: 14x10 level 3: 7x5 level 4: 3x2 level 5: 1x1 UV mapping, LOD selection, and filtering work just the ...


11

When Sean and I wrote stb_image_resize we chose Mitchell for downsizing. Mitchell is similar to Cubic, you can read about the cubic class of sampling filters in Mitchell Netravali 1988. They are all pretty similar and will get you very similar results. I can't find any written record between Sean and I of why we decided to go with Mitchell, but if memory ...


11

Modern hardware doesn't really have the concept of texture binding points as exposed by OpenGL. Rather, the shader unit uses a descriptor (which is just some kind of fat pointer) which can potentially address any texture as long as it's resident in video memory. This is what makes things like bindless textures possible. So the large amount of "texture units" ...


11

Updating an area of memory in the graphics device (a texture, buffer, and the like) is not quite the same as changing a rendering state. What makes a render state change expensive is the amount of work the driver has to do to validate the new state(s) and reorder the pipeline. This will most likely also incur some synchronization between CPU and graphics ...


11

Virtual Texturing is the logical extreme of texture atlases. A texture atlas is a single giant texture that contains textures for individual meshes inside it: Texture atlases became popular due to the fact that changing textures causes a full pipeline flush on the GPU. When creating the meshes, the UVs are compressed/shifted so that they represent the ...


11

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 the sides of the texture to achieve a seamless effect. This answer may not be complete because it's a large field, and different approaches will have various ...


10

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 locations in a texture. This permits the rasterizer/shader to, for each position on the object, fetch the corresponding data from the texture. The traditional ...


9

The API requirements can be found in any of the specs or extensions. Here is one: https://www.opengl.org/registry/specs/EXT/texture_filter_anisotropic.txt All GPU vendors likely deviate from the spec because AF-quality used to be a part of many benchmarks. And current implementations will continue to keep on evolving as new workloads stress the existing ...


9

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 which one you want to use and is defaulting to "no texture". There are a few ways to bind a texture. You can keep using glActiveTexture+glBindTexture as in your ...


8

What you see in the image called a UV map. That is, it is simply texture coordinates to be looked up encoded in a image. Same thing happens in all texture lookup in 3D there is a underlying sampler that picks where to pick texture color from. Image 1: Image showing UV map of two overlapped triangles and sampled texture with same UV coords Here are the ...


8

The answer depends on what you mean. Modern hardware (e.g. with bindless textures) really doesn't care too much how many textures are "bound". The real question is how many you use. Textures generally store data in a cache-friendly way (a Morton curve, I believe). If you use more textures, you'll get more cache misses, since now the textures compete with ...


8

There might be. Less technical answer: If you're building a website or another application where you have nothing to do with the graphics programming then the answer is probably yes. The underlying APIs will try to guess how to render them and cache them efficiently. However, as your application runs and the API sometimes guesses incorrectly it may have to ...


8

It turns out that no, while you can use bicubic Lagrange interpolation for bicubic texture sampling, it isn't the highest quality option, and probably not actually likely to be used. Cubic hermite splines are a better tool for the job. Lagrange interpolation will make a curve that passes through the data points, thus preserving C0 continuity, but hermite ...


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


8

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 resulting in colour, with everywhere else remaining black. If whatever you are using to display the result can only handle positive values, then you will need to ...


8

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. However, in my experience the majority of materials and ordinary lighting situations don't exhibit this problem, and most textures in a typical game are fine in 8-bit ...


8

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 'half' (16 bit float) or 16-bit unsigned integer values for color/albedo textures.


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