erich666 / graphicsgems Goto Github PK
View Code? Open in Web Editor NEWCode for the "Graphics Gems" book series
License: Other
Code for the "Graphics Gems" book series
License: Other
thanks a lot
gemsv\ch5-5\voronoi.cxx line 124
should be delete [] C;
In gemsiv/clahe.c, lin 226, pImage = &pImagePointer[uiSizeX];
should be pImage = &pImagePointer[-uiSizeX];
. At the original version, it is pImage = &pImagePointer[-uiSizeX];
.
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 */
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:
Page 577:
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
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.
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
From Andrew Bainbridge:
On page 665 of volume 1 there's a line of code that looks like:
if (x>xLmax && x<xRmin)
It should read:
if (x>xLmax && xr<xRmin)
The original code leaves jaggies on the right hand edges of polygons.
Also, there's a tiny error in the errata! I'm looking at:
https://github.com/erich666/GraphicsGems/blob/master/Errata.GraphicsGems
There's an existing entry for page 665, but it is out of order. Shock horror.
gemsv\ch6-4\vectorize.C line 204
missing free(fatmap);
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)
(from a user) For ch7-4 in Graphics Gems V: when I run the provided code I always receive the following error “Assertion failed: (dstD != NULL), function complexCut, file polygon.cc. Abort Trap: 6”.
Eric here: specific line is https://github.com/erich666/GraphicsGems/blob/master/gemsv/ch7-4/polygon.cc#L169
I could not find George Vanacek Jr, the author of this gem (he was at Purdue 1991-1995, after that I do not know).
GraphicsGems-master\gemsiv\interp_fast.c line 71
do statement after return cannot reached
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.
e.g. if units are such that user's error
threshold is less than 1, the function will never try to re-parameterize. Based on the usage example (where error is 4.0), I think the intent would be preserved if you just set iterationError = error * 4.0;
bad code is here:
Line 113 in 4d1d0a0
'rle.h' is missing from GraphicsGems/gems/AALines/utah.h
on gcc version 4.8.2 (MacPorts gcc48 4.8.2_0)
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).
\gemsv\ch6-2\halfadap.c line 189: missing free(cluster);
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)
I try to run it in Xcode on Mac, but so many errors have happened!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.