14 votes

Why do GPUs divide clip space Z by W, for position?

If you are doing a perspective image and your model has implicit intersections then, if you use "linear Z", those intersections will appear in the wrong places. For example, consider a simple ground ...
Simon F's user avatar
  • 4,161
10 votes
Accepted

How can I check if a polygon can completely contain a circle of a certain radius?

This is likely more complicated than you would prefer, but: Compute the medial axis, which immediately yields the largest disks that fit inside the polygon: their centers are vertices (degree $\ge 3$) ...
Joseph O'Rourke's user avatar
9 votes
Accepted

Maximum number of vertices after clipping a triangle against an AABB

Funnily enough, I asked this exact question on Math.SE a couple years ago: Maximum number of vertices in intersection of triangle with box. The answer is 9 vertices, because each of the 6 planes of ...
Nathan Reed's user avatar
  • 24.7k
9 votes
Accepted

Why does opengl perform clipping in clip coordinates?

The space after clip space is normalized device coordinate space, which is obtained by dividing clip.xyz by clip.w. If W is zero....
Nicol Bolas's user avatar
  • 9,577
7 votes

Why do GPUs divide clip space Z by W, for position?

Using Z/W for the depth buffer goes deeper than just clipping against the near and far planes. As Simon alluded to, this has to do with interpolation between the vertices of a triangle, during ...
Nathan Reed's user avatar
  • 24.7k
5 votes

Could we dispense the near clipping plane?

The near clipping plane in rasterizing setups with perspective projection is there to avoid a divide by 0 and bound the possible depths for orthogonal projection. With a bit of extra math you can ...
ratchet freak's user avatar
4 votes

Alternatives to Clipping in avoiding display problem

"Go not to the CG Elves for counsel for they will say both no and yes". Yes and No. As noted in another post, these issues don't exist with ray tracing but I'll assume you are interested in ...
Simon F's user avatar
  • 4,161
4 votes

Parametric line intersection test

Hint: The three coordinates can be handled independently. For instance in $x$, you need to solve $$x_0 + t (x_1-x_0) = 0$$ and $$x_0 + t (x_1-x_0) = x_{max}$$
Yves Daoust's user avatar
4 votes
Accepted

Could we dispense the near clipping plane?

The near clipping plane is a fundamental feature of projective rasterization. To borrow a diagram from Eric Lengyel's Projection Matrix Tricks presentation: The displayed region of clip space (that ...
John Calsbeek's user avatar
3 votes
Accepted

OpenGL layered rendering with multiple additional clip planes per view

The GS is responsible for assigning a particular primitive to a particular layer. The GS is also responsible for writing values for gl_ClipDistance for a particular ...
Nicol Bolas's user avatar
  • 9,577
3 votes

Worst Case Scenario for Cohen-Sutherland Line Clipping Algorithm

Maybe it helps to draw out the steps of the algorithm. Here is an example for TBLR The red is the worst case: clip top, clip bottom, clip left, clip right. Four steps! The green is the best case: ...
user81327's user avatar
  • 131
3 votes
Accepted

Why should you do homogenization after clipping?

One good reason to do clipping in homogeneous space is that the perspective division loses the distinction between regions behind the camera and in front of the camera. Points in front of the camera ...
Nathan Reed's user avatar
  • 24.7k
3 votes

Outcodes in Cohen-Sutherland Clipping Algorithm

The outcodes just represent four boolean flags as a bitfield. Codewise it is easier to move a bitfield around than four booleans. Functionality-wise it becomes very easy to check if any bits are set (...
Mikkel Gjoel's user avatar
3 votes
Accepted

Maximal and minimal no. of angles obtained from clipping a convex polygon with n angles

Since this is a homework question, I'll give hints rather than a numerical answer. Clipping a convex polygon Think about how many times the polygon can cross each edge of the rectangle. In general, ...
trichoplax is on Codidact now's user avatar
2 votes
Accepted

Meaning of the parameter in a line-plane intersection in the space

The $t$ parameter represents the distance from the ray's origin point to the intersection point, as a multiple of the ray's direction vector. It is positive for intersections "in front" of the origin, ...
Nathan Reed's user avatar
  • 24.7k
2 votes

Clipping for perspective projection

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 ...
Mauricio Cele Lopez Belon's user avatar
2 votes

3D coordinates of intersection point in clipping for a rasterizer

I think it depends on what your goal is and what kind of initial data you are provided with. I don't think that dividing by the forth coordinate solves a clipping task. What it does is switching of ...
Futurologist's user avatar
2 votes
Accepted

What are the outcodes that would be assigned to these points?

The diagram on the Wikipedia entry for Cohen-Sutherland Clipping explains it pretty well: ...
user1118321's user avatar
  • 3,401
2 votes

How to interpolate vertices when clipping?

Points in front of the camera have $w > 0$ strictly, by definition. I would say that if clipping is giving you points with $w = 0$ then something is going wrong. Consider the left/right/top/bottom ...
Nathan Reed's user avatar
  • 24.7k
1 vote
Accepted

Rendering a volume that might be completely clipped in OpenGL

First, regarding the specific problem of bits of the geometry being lost to the near and far planes, this can be solved by using depth clamping instead of depth clipping. This disables clipping ...
Nathan Reed's user avatar
  • 24.7k
1 vote

Using original vertices coordinates after clipping

A vertex consists of not just the position, but all of the values passed from the vertex processing stage to the rasterizer. So if a vertex gets clipped, the new vertices generated in that process ...
Nicol Bolas's user avatar
  • 9,577
1 vote

Why does opengl perform clipping in clip coordinates?

Clipping could be done in normalised device coordinates as all primitives with z-coordinates outside -1 to 1 are outside the clipping planes. However, there is no reason not to do it in clip ...
Reynolds's user avatar
  • 1,089
1 vote
Accepted

Fast clipping without clearing stencil buffer

It sounds like what you need is a scissor test. It's specifically designed for clipping against an unrotated rectangle, and should be faster than messing about with the stencil buffer.
russ's user avatar
  • 2,342
1 vote

Clipping circle and polygon and generate a CAD drawing

If Clipper has the capability of working with tagged edges (i.e. such that you can associate some label to every edge of the input polygons and retrieve these labels after clipping), then you can tag ...
Yves Daoust's user avatar
1 vote

Clipping circle and polygon and generate a CAD drawing

I don't know how the clipping library you are using returns the clipped objects, but if I understand your question, you want a way to represent your circles that does not use much memory? If you are ...
Chuck's user avatar
  • 296
1 vote
Accepted

Finding vertices of the outer contour of intersecting polygons

Sounds like you’re looking for a way to do a Boolean union operation. There’s a couple of algorithms linked from that article that should do the trick.
Noah Witherspoon's user avatar
1 vote

How to clip multiple tiled textures to polygon in Webgl / opengl

Quick idea: render platforms color to screen quad render mesh and platforms to screen quad, but as a mask. For example mesh is white, rest is black. in another pass sample these textures and if mask ...
mdkdy's user avatar
  • 2,089
1 vote

Cohen-Sutherland Clipping

Taken from Wikipedia's article on Cohen-Sutherland: Both endpoints are in different regions: in case of this nontrivial situation the algorithm finds one of the two points that is outside the ...
Tare's user avatar
  • 1,501
1 vote

Data structure and algorithm for clipping triangulation with leaf nodes of an octree

Rather than making one spatial subdivision structure do double duty in representing both the voxels and the triangles, I would suggest creating a separate BVH for the mesh. You can find many articles ...
Nathan Reed's user avatar
  • 24.7k

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