Git Product home page Git Product logo

graphicsgems's People

Contributors

a-wendleder avatar andyli avatar aoles avatar erich666 avatar gonsolo avatar luigidifraia avatar lygstate avatar lysandergg avatar martinbis11 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

graphicsgems's Issues

AAPolyScan.c incorrectly draws top scanline of some polygons

Imagine that you are trying to render a square that is, say 10x10 pixels, like this:

       8,8        168,8
         ___________
         |         |
         |         |
         |         |
         |         |
         |_________|
       8,168      168,168

These are subpixel coordinates, 16 times finer resolution than pixels. The the top scanline we draw will be half covered by the square, because the top of the square has a y value of 8, half way through a full pixel.

Line 99 initializes xLmax=-1 and xRmin=MAX_X.

During the main loop for the first scanline, xLmax is dilligently updated to 8 and xRmin to 168.

Then when we come to draw this scanline, consider a pixel in the middle of the section we need to fill. We will end up calling Coverage() passing in an x value of, say, 80. We then do:

int xr = x + 16 - 1; // equals 95
if (x>xLmax && xr<xRmin)
    return MAX_AREA;

The condition will be met and we will return MAX_AREA for this pixel. But we should not have done because it is only half covered by the square.

The problem is that we only consider the x coverage and assume that the y coverage is always full. This isn't a valid assumption for the first and last scanlines of the polygon.

This only a problem if the top edge of the polygon is exactly horizontal. If it isn't, xLmax and xRmin will end up set such that the conditional above does not evaluate to true.

I think this can be fixed by removing the if (...) return MAX_AREA; As a result, the slow path will be taken which will generate the correct result. A faster solution is more complicated and would require treating the first and last scanlines as special cases (I think).

Unreachable code

GraphicsGems-master\gemsiv\interp_fast.c line 71
do statement after return cannot reached

gemsII compilation issue

quantizer.c:25:10: fatal error: 'malloc.h' file not found in GraphicsGems/gemsii/quantizer.c
commenting out #include <malloc.h> (#include <stdlib.h> is already there)
triggers a linking error ld: symbol(s) not found for architecture x86_64

gcc version 4.8.2 (MacPorts gcc48 4.8.2_0)

gems I compilation issue

'rle.h' is missing from GraphicsGems/gems/AALines/utah.h
on gcc version 4.8.2 (MacPorts gcc48 4.8.2_0)

missing free

gemsv\ch6-4\vectorize.C line 204
missing free(fatmap);

Possible Planar Cubic Curves errata, first volume

I may have found some errors in the article "Planar Cubic Curves" in the first Graphics Gems book that are not listed in the errata at http://www.realtimerendering.com/resources/GraphicsGems/Errata.GraphicsGems

Page 576:

  • The equation g'(0) = mL*(dx/dy) = m0 should be g'(0) = mL*dx = m0
  • The equation g'(1) = mH*(dx/dy) = m1 should be g'(1) = mH*dx = m1
  • After the dy has been removed from the g'(0) and g'(1) equations, dy is no longer referenced anywhere in the article and its definition dy = yH - yL can be removed

Page 577:

  • In the first group of equations, the equation d = m1 should be d = y0 like it was written on page 576
  • In the second group of equations, the equation d = y0 should be d = 0 since y0 was defined to be 0 in the preceding paragraph

In addition, on page 578, there is this equation:

f(x) = g(clamp(xL, xH, (x - xL)/(xH - xL)))

Since the (x - xL)/(xH - xL) part is remapping x from [xL, xH] to [0, 1], and g(x) seems to be expecting input values between [0, 1], why is the remapped value clamped between [xL, xH]? Shouldn't the remapped value be clamped between [0, 1] instead? I believe that would match the situation in Figure 4, and the equation would be:

f(x) = g(clamp(0, 1, (x - xL)/(xH - xL)))

Sincerely,

Mika Haarahiltunen

Missing free

\gemsv\ch6-2\halfadap.c line 189: missing free(cluster);

Find a bug in gemsiv/clahe.c

In gemsiv/clahe.c, lin 226, pImage = &pImagePointer[uiSizeX]; should be pImage = &pImagePointer[-uiSizeX];. At the original version, it is pImage = &pImagePointer[-uiSizeX];.

drawPolygon() from AAPolyScan.c doesn't render the last scanline of most polygons

There was previous discussion of this bug in #32

The reprocase is almost any polygon. I'll illustrate with a diamond shape.

The wrong logic hits when we're processing the final subpixel row in the main loop of drawPolygon(). Here's a picture showing which vertices vLeft, vNextLeft, vRight and vNextRight point to when we start the final iteration of the loop. The current subpixel row is highlighted in red.
image

The first code in the loop is while (y == VnextLeft->y). The condition is true, so we move vNextLeft on to vertex 3 - ie the left side we're walking is about to start going backwards up the right side of the poly. The next statements are, if (VnextLeft == Vright) return. The condition is true, so we exit the function. We should not exit because this scanline has a bunch of partially covered pixels in it that we haven't rendered yet. Instead we should break from this while loop and then do the "done, mark uncovered part of last scanline" code below, which already includes a return.

In all my testing, that "done, mark uncovered part of last scanline" code block is never executed. I think I've convinced myself the code is unreachable because of the if (VnextLeft == Vright) return above. Once I replaced the return with a break it is called but renders the last scanline one pixel too low. That is because the for-loop setting all the sub-pixel extents to -1 had the side-effect of incrementing y. So we need to add a -1 in the renderScanline() call. Because of the off-by-one bug here, I'm even more confident this code was unreachable in the original GG version.

One more change is needed. The if (VnextLeft == Vright) return that I removed had a comments saying all y's same? and (null) polygon. With it removed, if we pass in a poly with the same y value for all vertices, the function no longer terminates. The simplest fix for this I can see is to store y before the main loop (ie the minimum y of the poly), and change if (VnextLeft == Vright) return to:

if (VnextLeft == Vright) {
    if (y == minY) /* all y's same?  */
        return; /* (null polygon) */
    break;
}

Here's AAPolyScan.c with my fixes:
AAPolyScan.zip

gemsiii comp issue

erased #include <malloc.h> in GraphicsGems/gemsiii/contour.c and GraphicsGems/gemsiii/filter.c
I get
bsp.c:337:34: error: passing 'double *' to parameter of incompatible type 'double'; dereference with *PointAtDistance(ray, distance, &p);

gcc version 4.8.2 (MacPorts gcc48 4.8.2_0)

name mismatch

gems\AAPolyScan.c line 64
Declaration:
void renderScanline(Vertex* left, Vertex* right, int y, Surface* object);

Definition:
void renderScanline(Vl, Vr, y, object)
Vertex *Vl, Vr; / polygon vertices interpolated /
/
at scanline /
int y; /
scanline coordinate */
Surface object; / shading parms for this object */

Rank 1 matrices are not polar-decomposed properly

When using polar_decomp from GraphicsGems/gemsiv/polar_decomp/Decompose.c, matrices of rank 1 are not handled properly.

The problem is that polar_decomp calls do_rank2 with the same matrix Mk as the M and the Q parameter. This is not a problem (yet), because do_rank2 does not change Q before being done with reading from M, with the exception of the call to do_rank1.

In do_rank1, again the same matrix ends up being represented by both parameters M and Q. However, the function starts by assigning the identity matrix to Q (which at the same time overwrites M). Therefore, do_rank1 will always return the same matrix when M and Q are the same object.

The fix is trivial: we simple have to move the assignment of identity to matrix Q. It just has to move from the beginning of the function to after the computation of the s factor (last line reading from M). In order to also work with matrices of rank 0, it must also be put in the early return case if there is no maximum column.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.