8 ms·
A long time ago, due to an improbable sequence of events, I found myself teaching Computer Graphics at my alma mater, a year after I took the class myself. Over
by ggambetta 6y ago
A long time ago, due to an improbable sequence of events, I found myself teaching Computer Graphics at my alma mater, a year after I took the class myself. Over the following five years or so, my approach to the subject evolved, and I really got the hang of it.
After I stopped teaching, I took my notes, handouts and slides, and made them into a series of articles that I put on my website, where they remained in relative obscurity. Hacker News managed to find it every once in a while, and it was generally well received, but nothing came out of this. Until April 2019. It made the HN front page again [0], except this time it caught the attention of an editor in No Starch Press [1].
Long story short, today I’m incredibly grateful and excited to tell you that CGFS is coming out as a real book, with pages and all [2]. The folks at NSP graciously agreed to let me publish the updated contents, the product of almost two years of hard editing and proofreading work, for free on my website [3]. But if you’d like to preorder the printed or ebook version, you can use the coupon code MAKE3DMAGIC to get a 35% discount at https://nostarch.com/computer-graphics-scratch https://nostarch.com/computer-graphics-scratch.
I’m still somewhat in disbelief that my work is getting published as a book, and this genuinely wouldn’t have happened without your support. So once again, THANK YOU :)
[0] https://news.ycombinator.com/item?id=19584921 https://news.ycombinator.com/item?id=19584921
[1] http://nostarch.com http://nostarch.com
[2] https://nostarch.com/computer-graphics-scratch https://nostarch.com/computer-graphics-scratch
[3] http://gabrielgambetta.com/computer-graphics-from-scratch http://gabrielgambetta.com/computer-graphics-from-scratch
- sriram_sun 6y agoAwesome! Thanks for sharing!
- gauku 6y agoThis looks great. I have been developing interest in CG recently and this looks like a great way to start. Thank you. And finding your Imdb profile was a nice addition on top ;) All the best.
- ggambetta 6y agoThanks! For better or worse, I'm interested in a lot of different things
- breck 6y agoI'm always in the market for great graphics books, and NSP is my favorite publisher, so excited to get this. Thanks for the coupon!
- ggambetta 6y agoYou're welcome! I have to say they're also amazing to work with :) Special thanks to Alex and Kassie <3
- billpollock 6y agoThat's great to hear!
- aperrien 6y agoThis is awesome, but as a kid back in the Pong era, I always wondered how the basic squares of pixels worked. In your travels writing this book, did you ever come across one that explained that in a way friendly to 12 year olds?
- kevin_thibedeau 6y agoPong uses discrete logic gates and no microprocessor for its game logic and graphics. It isn't comparable to much else.
- foobarian 6y agoI was dismayed to learn that pixels are not square at all. It got worse with the switch to LCD.
- vram22 6y agoInteresting, didn't know that. What shape are they, then? Round? Or other?
- corysama 6y agoCan you be specific of the context you are interested in? On modern machines, a pixel is just a set of three numbers indicating how much red, blue and green light should be shown at a particular point. Ex: {0.75 red, 0.0 blue, 0.5 green} for a kinda-dark, orange pixel. The GPU keeps a big 2D grid of these number-triples in memory and on a regular schedule sends out a copy over the DVI cable to your monitor. The monitor has a bit of memory to hold it's copy. And, it has hardware to scan over the grid of numbers to produce a sequence of voltage levels that are used to change the color of the points on the LCD. There's a bit of math involved in how to do a good job representing colors with numbers and how to convert those numbers to voltages. But, at the most basic level, an image is just a big 2D grid of numbers. If you want to change the image, poke the grid. People want to change images a whole lot. So, we've developed pretty sophisticated hardware and software around poking 2D grid... But, that's a whole other topic.
- gamacodre 6y ago
- kayoone 6y ago> due to an improbable sequence of events is that why you ended up working for improbable? ;)
- ggambetta 6y agoThat was a semi-intentional pun, good catch ;) You're not far off the mark, though! It was my other series of articles about client-side prediction [0] that brought me to Improbable's attention :) [0] https://gabrielgambetta.com/client-server-game-architecture.html https://gabrielgambetta.com/client-server-game-architecture....
- kayoone 6y agoexcellent articles, i quoted them in my bachelor thesis some time ago :)
- adamnemecek 6y agoHow has your approach changed?
- ggambetta 6y agoAt first I mostly followed the lecture structure of the previous professor, but over the years I streamlined it a lot, emphasized a "motivated" approach to each topic (e.g. "last chapter we did this, now we try to do this thing, it doesn't quite work, how can we fix it?"), and generally refined and simplified the explanations of everything. Teaching the same material year after year was a fantastic opportunity to identify the recurring sticking points and finding ways around them.
- mstade 6y agoHey Gabe – great work and huge congrats! I'm sure you don't remember me, but we used to work together at Improbable – you sent me such a wonderful email when I left to go back to Sweden, thank you! Anyway, just wanted to say congrats and hope you're doing great buddy. All the best! :o)
- ggambetta 6y agoOf course I remember you! Could never forget such an impeccably dressed coworker :) I think we were super close to meeting in Miami that one time I had a long layover?
- mstade 6y agoAww – thank you! <3 That's right, I was in Florida visiting family. Would love to reconnect, don't hesitate to ping me an email at marcus@madebystade.com if the feeling is mutual! :o)
- mcdevilkiller 6y agoIf I were you, I'd edit that email, there are spambots crawling everywhere :)
- mstade 6y agoIt's ok, my spam filter seems to do its job (knock on wood!) Either way I'm past the edit time limit now anyway.. What matters is I got the opportunity to reconnect with an old pal, I'll gladly pay the spam tax if it comes to that. Worst case scenario I guess I'm getting a new email address eventually. :o) Good tip though, thanks!
- enriquto 6y agoI love this resource, thank you! My favorite chapters are those about drawing raster lines and triangles. One of my first programs was writing (in 386 16-bit asm) the routine to draw a triangle, and I love these algorithms dearly. An important and beautiful thing that is missing in the book is the drawing of anti-aliased lines (easy) and triangles (not trivial!). I find that rendering carefully shaded smooth objects with a pixelized boundary loses a big part of the magic.
- ggambetta 6y agoYep, good point. The reason is that the objective of the book is to cover as much material as possible, in the shortest time possible, and in the simplest way possible; so I had to build the shortest path between putPixel() and filtered textures, and that leaves things like antialiasing behind. I explain a bit of this in the introduction, most of the time I present not the best/fastest algorithm, but the one that it's the simplest to understand. For example, I don't even mention Bresenham's algorithm; instead I present a super simple but inefficient one, which achieves two critical things: (1) you're drawing lines in no time, (2) it motivates the linear interpolation method that is then used for shading, z-buffering and texturing.
- trilinearnz 6y agoCongratulations! It's a wonderful resource, and great to see it make it's way into library-form.
- q_andrew 6y agoThis is awesome. You should be proud!
- ggambetta 6y agoThank you! Right now it's 1:13am here and I'm proud, overwhelmed by the reaction, still in disbelief,... good luck sleeping tonight XD
- Shared404 6y agoI've wanted to learn this for a while, and never got around to it. I think this is the final kick I needed, so thanks!
- mysterydip 6y agoGreat news! Please make sure the links to demos work for a while or you have some archival/preservation in mind. I've read through older technical books whose examples went offline and depending on the subject matter it can be quite a loss.
- jzer0cool 6y agoCongrats on this book! I did a computer graphics class for my undergraduate and we used this fat OpenGL book bible to try and implement some functions. Things got very hard with ray tracing and later u,v texture mapping, etc. Making a note here so I can try your book out sometime!
- runald 6y agoWhat's the difference between the ebook and the one free one in the website?
- LegitShady 6y agoone costs money
- ggambetta 6y agoThe contents are the same; the formatting, presentation, accessibility, etc, are much better in the ebook (an ebook isn't just a printed website).
- 2pEXgD0fZ5cF 6y agoI wanted to learn about rendering and graphics for a while. Almost every modern source however uses engines or big frameworks and skips the parts I actually want to look into. Compiling a reading list or figuring things out myself of course would have been an option, but I guess others can relate to the problem of having too little time for hobby projects :) Big bonus points also for trying to remain programming language agnostic! I immediately preordered your book and find it hard to express my excitement, can't wait.
- garmaine 6y agoWay back in the day I read either the 1st or 2nd edition of this book: https://www.amazon.com/Computer-Graphics-Principles-Practice-3rd/dp/0321399528 https://www.amazon.com/Computer-Graphics-Principles-Practice... It's a classic in the computer graphics field, like Knuth is for algorithms. I'd recommend it alongside the OP's new book. EDIT: But for anyone who is reading this wanting to learn about practical computer graphics, CG:P&P is NOT the resource to use! Learning the low-level rasterization algorithms used in computer graphics is an important thing to learn at some point, just like learning assembly language provides valuable insights even if you never touch a line of assembler again. But if you actually want to write graphics code on modern hardware with GPUs, I'd highly recommend Real Time Rendering instead: https://www.amazon.com/Real-Time-Rendering-Fourth-Tomas-Akenine-Möller/dp/1138627003/ref=pd_bxgy_3/135-4503605-4938943 https://www.amazon.com/Real-Time-Rendering-Fourth-Tomas-Aken...
- 2pEXgD0fZ5cF 6y agoThanks a lot for the recommendation! What would you say are the prerequisites for this one? Also from the description it sounds as if it also goes a bit more into 2D graphics too, is that correct?
- garmaine 6y agoAgain, I read an ancient edition which predated the existence of consumer GPUs. But the edition I read was more than half on the topic of 2D graphics and what you might consider to be mundane things like font rasterization. You might think this has nothing to do with 3D graphics, but in fact there is a big overlap. The graphics driver + GPU takes a description of a 3D scene and projects it into 2D primitives whichs are rasterized onto a bitmap (the display) just as one might render a font glyph. So IIRC the book begins with the basic theory and techniques of 2D graphics, and then shows how projective geometry can be used to render 3D scenes onto 2D displays, and progressively adds various corrections which we take for granted, such as perspective-correct interpolation of texture values, which these days is done automatically by the hardware. I don't think there's any pre-requisites other than a basic understanding of beginner computer science, coding, and algorithms. If you can read Knuth, you can read CG:P&P. Also, see my edit to the grandparent comment.
- cshenton 6y agoCongrats on getting your book published! I will definitely be ordering a copy :)
- strangeattractr 6y agoCongratulations on getting published, I have been looking for a book like this.
- michaelg7x 6y agoHi Gabriel, is there a European site from which we can order? The delivery costs from the US are quite punchy, and it makes no sense to send the paper copy when a printer could do as good a job locally. Too many paper-miles? Looking forward to getting hold of it, great work! Mike
- ggambetta 6y agoHi Mike! I have nothing to do with distribution, but the book is also available from Amazon [0], B&N [1], Bookshop [2], and Penguin [3], maybe one of these has better shipping to Europe? [0] https://www.amazon.com/Computer-Graphics-Scratch-Gabriel-Gambetta/dp/1718500769 https://www.amazon.com/Computer-Graphics-Scratch-Gabriel-Gam... [1] https://www.barnesandnoble.com/w/computer-graphics-from-scratch-gabriel-gambetta/1136585778?ean=9781718500761 https://www.barnesandnoble.com/w/computer-graphics-from-scra... [2] https://bookshop.org/books/computer-graphics-from-scratch/9781718500761 https://bookshop.org/books/computer-graphics-from-scratch/97... [3] https://www.penguinrandomhouse.com/books/645952/computer-graphics-from-scratch-by-gabriel-gambetta/ https://www.penguinrandomhouse.com/books/645952/computer-gra...
- michaelg7x 6y agoHey, thanks for this. I did go on to find it on Amazon.co.uk, but of course the e-book + paper-book bundle is different. I'll check out the other sites as well. Thanks again.
- legerdemain 6y agoThanks for keeping the material free online! This is one of the few tutorials that covers raster rendering. Lots of introductory material on ray-tracing, not a lot on raster graphics. Where can students look for more stuff on rasterization after they finish this book?