# Tag Info

21

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

In short, performance reasons are why they aren't programmable. History and Market In the past, there used to be separate cores for vertex and fragment processors to avoid bloated FPU designs. There were some mathematical operations you could only do in fragment shader code for instance (because they were mostly only relevant for fragment shaders). This ...

10

There are a couple of special cases where mirror-like reflections can be rendered efficiently using rasterization techniques, and these are commonly used in games, although they don't work for the general case. Planar reflections If the reflecting surface is flat or reasonably close to flat, the reflected image can be rasterized in an separate rendering ...

10

Any techniques that involve raytracing in the fragment shader might want to write Z in order that the depth buffer contain an accurate representation of the raytraced surface. For example: Distance-field ray marching, as seen in many shadertoys and demoscene productions. Here, only a full-screen quad gets rasterized, and all the geometry is generated by the ...

10

This is the same problem as discussed in What are sample gaps during scan conversion? Briefly, rasterisation - at least with the majority of hardware systems - tests at a single 'infinitesimal' point for each pixel to determine if that pixel is inside a given triangle. If the sample point lies exactly on an edge, then additional tie-breaking rules, often ...

8

Sample gaps will occur if you don't do things "properly". In OpenGL or D3D, assuming a consistent winding order, if you have triangles ABC and CBD, then when a sample point - that is a test during scan conversion to determine if a point (read pixel) is inside a triangle - lies exactly on the shared edge BC, then that sample will belong to exactly one of ...

8

There are lots of ways to fake SSS with greater or lesser fidelity. A few recent-ish methods: Screen-space blurring of object lighting (described in detail here) Using “interior” ambient-occlusion maps generated from a normal-flipped version of the geometry to approximate local thickness, providing an easy way to fake light transmission (more information ...

7

The scan-line algorithm (as described on Wikipedia for instance) is concerned with generating the pixels in order, left-to-right and top-to-bottom, with each pixel needing to be touched only once. It was developed in the late 1960s, for devices with no framebuffer memory—so it has to generate each pixel just-in-time as it scans out to the display. The ...

5

It's not 100% clear what the author means here, but I'll choose to interpret "screen coordinates" as "pixel coordinates". These would be related to the projected points by a 2D coordinate transformation. You're correct that projection is done by dividing each component of a point by its $z$ component. (That's not quite true—actually, we usually use ...

5

I'm not sure what exactly you mean by how to visualize a plane that use w value as one of this coordinates but here's a sketch that will, hopefully, clarify this sentence: a line through each edge of the input triangle as a plane in homogeneous (x c , y c , w c )-space I've used uppercase letters for clip-space, and lowercase letters for window ...

5

It's an interesting question, because the advice changes over time. Having said that: On a GPU, by far the most efficient way, as Nathan Reed said in the comment, is to use the rasterisation hardware because that is that it is designed for. On a CPU, one of the most efficient ways is to more-or-less mimic what rasterisation hardware does. GPU vendors are ...

4

When depth testing is enabled, the testing occurs after the fragment shader executes. The procedure is relatively simple (and spelled out pretty well here): Get depth of fragment Test against depth buffer Discard if it fails Early-z discard is when a rasterizer discards a fragment before a fragment shader runs because it's clear early on that it won't pass ...

4

The problem, I think, is that you are comparing two different kinds of depth values. For want of better terms, the rasterizer's depth buffer stores 'parallel' depth, whereas raymarching calculates 'true' depth - that is, the rasterizer stores the distance to the plane parallel to the view plane which contains the point, but the raymarcher calculates the ...

4

Projective transformations (represented by 4×4 projection matrices) are invertible. You can go from NDC coordinates back to view space using the inverse of the projection matrix, in the same way that you go from view space to NDC. That is: take your NDC $x, y, z$ coordinates, append $w = 1$ to make a 4D vector, transform by the inverse projection matrix, ...

4

That's why the seam between two triangles can be rasterized twice. The seam won't be rasterized twice because of the OpenGL or D3D fill/rasterisation rules. What I think Humus is alluding to is that a fragment shader may be executed multiple times on pixels spanning the shared edge, which just implies wasted effort. The moral of the story is "avoid small ...

4

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 version but you may have better luck than me. Alternatively you might find a dead tree version of "Jim Blinn's Corner" in a library). Though this article is old and ...

3

Most software rendering engines dice the parametric primitives to micropolygons, usually on the fly as needed. In essence this reduces the needed complexity to determine intersections. The surface will still look smooth, since each polygon is smaller than a pixel. This allows for Data caching. Discrete geometric derivates. Displacement is easy to ...

3

You can use a threshold set through a constant buffer to clip pixels (ie an alpha test): float threshold; // in constant buffer float4 color = myTexture.Sample(...); if (color.a < threshold) discard; Set threshold to 1.0 to discard all transparent fragments; set it to 0.0 to discard nothing. There will be some minor inefficency in the latter case ...

3

You can mimic a mirror by masking out the visible reflective surface when you first render and then mirror the world around the reflective plane and render again while only drawing where the reflective surface was. There are some other details to worry about like not drawing stuff on the far side of the mirror when drawing the mirrored world which can be ...

3

This is one of the most common "misconceptions" on rendering, rasterisation and ray-tracing. Don't get me wrong. This is a good question, but one that should be answered once and for all. So to answer your question: 1) it is much easier to simulate reflection and refraction with ray-tracing than with rasterisation, which is often why when you see an image ...

3

It is true to on today's GPUs, unless one or more vendors has implemented a technique such as this: http://graphics.stanford.edu/papers/fragmerging/shade_sig10.pdf To clarify, rasterization is not being done multiple times, or redundantly - rather it is the shading work that is done redundantly. Each 2x2 quad will be shaded once for every triangle that ...

3

Since the cube is a convex object, you could first find the silhouette edges of the cube, by using dot product between cube face normals & view vectors. Then you can sort the edges by the smallest screen y-coordinate for each edge and rasterize the cube a scanline at the time by filling the span between two active edges for each scanline. For each ...

3

I'm guessing Rasterization based pipelines use the same procedure for shading i.e. A ray is shot from the pixel and then from the triangle that got projected on that pixel to the light source? Close, but not quite. There's no actual tracing of rays but the underlying linear algebra is the same. It sounds like you already understand the first part of ...

3

Unfortunately, the iridescence model is not made to be applied to a diffuse term. Pascal and I made it for microfacet models only (that is the specular term). One way to understand how to include it to a game engine might be to look at Unity's HDRP implementation. In the Lit.hlsl to see how to incorporate the iridescence Fresnel into a specular + diffuse ...

3

For culling faraway particles: as lightxbulb said, the keyword to search for is "acceleration structure". There are a variety of options: BVH, octree, kd-tree, uniform grid, or some combination of these. Which one will be most suitable is going to depend on the details of your situation—how large/dense is the simulation, how much you care about ...

2

For PCs with discrete displays, the resampling to the screen resolution may happen either on the computer prior to the signal being sent to the display, as part of window compositing, or on the display side. I don't think it's anything to worry about in terms of FPS, in either case, but it possibly could affect latency. It depends whether you're in "true" ...

2

It sounds like you're rasterizing a line segment between two endpoints. The points on the line are obtained by linearly interpolating between the endpoints (whether in world space, screen space, or any other coordinate system). The barycentric coordinates identify points on the line segment. It's defined this way to make range of $\lambda$ be [0, 1]. (When \$\...

2

When drawing objects that exist in 3D space to a 2D plane (like your monitor or an image), there are a number of spaces that are useful to work in: Global Coordinates - Somewhere in your 3D world there is an origin, and objects will be placed relative to that origin. The camera will also be placed somewhere relative to that origin and will point in some ...

2

This is rather general programming question but parallelizing for loop (most common usage) in c++ is easy with openMP library. Basic example for parallelizing outer loop: #pragma omp parallel for schedule(static, 1) num_threads(omp_get_num_procs()) for (int i = 0; i < size1; ++i) { for (int j = 0; j < size2; ++j) { buffer[i*size1 + j] =...

2

3D clipping is usually done in clipspace coordinates, that means the perspective matrix is used for sending the primitives to clipspace before doing the actual perspective projection. You can visualize the clipspace as a view frustum but with the shape of a box. So it is very fast to clip primitives against a AABB. The math is a little involved, but is all ...

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