The Stack Overflow podcast is back! Listen to an interview with our new CEO.
23

Tesselation is a technique that allows you to generate primitives (triangles, lines, points and such) on the graphics-card. Specifically, it lets you repeatedly subdivide the current geometry into a finer mesh. This allows you to load a relatively coarse mesh on your graphics card, generate more vertices and triangles dynamically and then have a mesh on the ...


10

Because your monitor is not properly calibrated. On my screen at home the top and bottom parts have the same hue. At my office though, the top part tends to looks a bit yellow compared to the bottom part that looks more red. The difference: my screen at home was from a series that was decently calibrated out of the factory, and on top of that I did ...


9

Is there a similarly fast way to draw antialiased lines? No, because by definition an anti-aliased line touches more pixels. Such algorithms will be slower. In a software rasterizer, the ubiquitous way to draw anti-aliased lines is Xiaolin Wu's line algorithm. It's not hard to implement, and anyway there's unusually high-quality pseudocode at that link. ...


8

In essence a image is a group of point samples (read A pixel is not a little square3). When you transform or scale the image you need to resample it. So what you do, theoretically, is take the point samples and convert them into a continuous function. Then you sample that continuous function and reconstruct a signal. So, there are two or three different ...


6

It activate 3 stages in the pipeline. The first is the tessellation control shader (hull shader in D3D) which looks at a set of vertices and then outputs how it should be divided up in separate triangles. The second is a fixed function stage that will generate the requested triangles. The third stage the tessellation evalutation shader (domain shader in ...


5

The common way to render transparent polygons in a rasterizer is by use of Alpha Blending, which basically combines the colour of the supposedly transparent pixel with the colour of the background at that pixel's position, this way rendering the pixel transparently onto what was already rendered before. This technique, however, requires your polygons (or at ...


5

There are numerous upscaling and downscaling algorithms available to scale images from any resolution to any other arbitrary resolution. Each algorithm typically involves a trade-off between efficiency, smoothness and sharpness, with varying degrees of each trade-off for different algorithms. Check out this Wikipedia article for such algorithms and examples ...


5

GPUs can efficiently scale an image by an arbitrary amount (within limits - display options fall within those limits by design) either using a 3D rendering operation or as the signal is sent from GPU to the display. Both of these paths have fully dedicated hardware for the arbitrary resizing and are not likely to be optimized for doubling or halving. Both ...


4

The answer to both your questions is the same: the physical size of the monitor makes no difference at all. If your screen is 1920x1080 pixels, and you display a 960x540 image without any scaling, the image will stake up a quarter of the screen, and it won't take any more GPU time to display on a larger monitor. The only caveat is that most OSes have some ...


4

If you're completely new to graphics programming I would start with Processing. It's based on Java and JOGL but comes with a whole bunch of drawing commands built in, and its own basic IDE. It's very good for prototyping algorithms and getting quick visual feedback without having to write a ton of boilerplate code, and it insulates you from the underlying ...


4

It is not generally useful to try to optimise small parts of a program before you have profiled the program to see where the most benefit can be gained by optimisation. Make sure everything is correct and working first, and then profile to decide where to optimise (if optimisation turns out to be necessary). Mathematically, your approach is already correct ...


4

The OS does not, in many or most cases, know the physical screen size! Often the only thing you can glean is the make and model, sometimes not even that. So if you do not want to have a database then the best you can do is ask your user. There are also some interesting corner cases. What do you do if the monitor is in fact a projector? What do you do in ...


3

According to a review by Legge & Bigelow the arc or degrees of visual angle ($\alpha$) is, $$ \alpha = 57.3 \times S/D, $$ where S is height of object and D is distance to object. [1] $S/D$ is the small angles approximation of $2 \times arctan(S/2D)$ which follows form geometry. Image 1: the equation comes straight from trigonometric definitions. ...


2

I've done something similar. The way I did it was by using a height map image to change the positions of vertices in a grid in a vertex shader. I generated a 2D grid of vertices that were evenly spaced on the CPU. I uploaded the vertices and a texture and in the vertex shader, I sampled the texture and used the resulting brightness as the height. So I'd keep ...


2

I would say it’s a weighted set covering problem. In specific, the cost for a set of points is the number of extra pixels in the bounding rectangle of this set. If the number of diff points is small, you can solve this by linear programming. Otherwise, try some approximated algorithms e.g. greedy.


2

The main part of it is simply Pythagoras's Theorem. The square root gives the length of the central line segment (which is the hypotenuse of a triangle formed by the change in x and change in y). The ratio between the hypotenuse and the change in x is the same as the ratio between the line width and the line width in y (they are similar triangles). Dividing ...


2

Back in the days, MSDN defined a couple of values which in most cases are useless (total crap): https://msdn.microsoft.com/en-us/library/windows/desktop/dd144877%28v=vs.85%29.aspx int width_mm = GetDeviceCaps(hdx, HORZSIZE); int height_mm = GetDeviceCaps(hdx, VERTSIZE); However, there is a way to retrieve the information through VESA. Any modern monitor ...


2

Usually modern game engines use Screen Space Reflections which is some kind of screen space raymarching. Basically, a simple way to achieve this is to shoot rays from the G-buffer. This means you use your depth buffer as a height field by raymarching any ray you cast. Then sample the normal at this position and take the final composed lighting from you ...


2

e = (float)(delta_x / delta_y) - 1.0; e += (float)delta_x / delta_y; Either of these lines will cause a divide-by-zero error when delta_y is zero, which is when the line is horizontal (or zero-length). You need to check for this condition and have some special-case code. As an aside, I don't know why people still teach Bresenham's algorithm to new CG ...


2

This would be considered isometric. Isometric graphics were originally used to give a 3D look, when computers could not handle actual 3D graphics. The creation of this image, however, is different than described in the Wikipedia article. The creator started by making the scene in 3D. This means, doing normal three dimensional modeling. After the scene is ...


1

The problem here is that you're not storing the YUV values of a pixel at the same place in the result image. What you seem to be doing is first storing the full size Y image and after that the quarter-sized U image and then the quarter-sized V image after that (also with a strange gap of half the image size between the Y and the UV data). This doesn't work ...


1

Wow I'm stupid, the whole problem was I thought it was 1/t and it is actually 1-t in parametric form. Hope this helps someone anyway.


1

Ad 1) Yes, if both monitors have the same resolution but different screen sizes, this means the pixels of the larger monitor are bigger. It could also mean the space between the pixels is different. Ad 2) No, the physical size of a monitor makes no difference for the GPU. It only cares about the resolution, for example 1920x1080 vs 3840x2160. The latter ...


1

To get a proper circle, you can use a transformation matrix to transform your cell coordinates into equally spaced cartesian coordinates. In the case of your 50 x 100 pixel cells, your transformation matrix would probably either double the width or halve the height. So something like this: | 0.5 0.0 | | 0.0 1.0 | If you want to draw a circle of radius r at ...


1

You have a background color and the color of your line, an antialiased line has additional lines drawn on either side of the first that are simply part way between the color and brightness of your origonal line and the background. If the line you are drawing is horizontal or vertical the additional antialiasing lines (however many, depending upon the ...


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