TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Scratchapixel: Computer Graphics Programming from Scratch

239 pointsby MrHamdulayabout 9 years ago

8 comments

clarryabout 9 years ago
What I don&#x27;t get is why nearly all resources on 3D graphics assume the reader is familiar with matrices and linear algebra. For those who don&#x27;t speak that language, what you&#x27;re doing is plotting numbers into a magic box, doing a magic multiply, and hey presto, we got 3D! Magic.<p>Meanwhile a teenager could easily get an intuitive grasp of 3D graphics if you just explained how translation is nothing besides addition, and that to rotate, you just use good old trig functions to generate rotated basis vectors along which to plot your vertices (really easy to show with images and animations too). And that magic perspective, to make things get smaller as they get further from the camera, is just one divide by the depth away... yes, all very basic arithmetic. And no need for magic such as homogeneous coordinates. They&#x27;re just a convenience for when you do things a certain way.<p>You don&#x27;t need to go to college or even high school for 3D rasterization. But most if not all texts pretty much want to assume such a background?<p>Actually, I&#x27;m quite tempted to try write such a tutorial for the 12-year-old me. Too bad I can&#x27;t travel back in time to see if I&#x27;d actually understand it (but I have a strong feeling I could come up with something good enough). Yeah, the lack of approachable material was very frustrating for me back then. In the end I wrote a very primitive renderer (with plenty of trigonometry per vertex) which was way too slow and complicated to be useful. Because I didn&#x27;t realize how simple the problem actually is.
评论 #11746902 未加载
评论 #11745686 未加载
评论 #11745453 未加载
评论 #11745322 未加载
评论 #11745789 未加载
评论 #11745818 未加载
评论 #11745934 未加载
评论 #11745770 未加载
评论 #11745670 未加载
评论 #11822250 未加载
评论 #11746614 未加载
评论 #11745916 未加载
评论 #11745279 未加载
dahartabout 9 years ago
This is a great resource! For those interested in a very quick and direct intro to writing code for ray tracing, something I think supplements Scratchapixel nicely, you might want to also check out &quot;Ray Tracing in One Weekend&quot;. <a href="http:&#x2F;&#x2F;in1weekend.blogspot.com&#x2F;2016&#x2F;01&#x2F;ray-tracing-in-one-weekend.html" rel="nofollow">http:&#x2F;&#x2F;in1weekend.blogspot.com&#x2F;2016&#x2F;01&#x2F;ray-tracing-in-one-we...</a>. It&#x27;s a $3 ebook on Amazon, but the blog post has lots of free resources including the complete code for the small ray tracer developed in the book. Written Peter Shirley, by a graphics prof. friend of mine, well known in graphics &#x2F; ray tracing &#x2F; global illumination circles.
评论 #11746618 未加载
TACIXATabout 9 years ago
These are the other graphics related tutorials I have found.<p>Ray Tracing in a Weekend Series. Most the way through the first book and I plan on continuing it. [1][2][3]<p>Tiny Renderer - How OpenGL Works. A software renderer in 500 lines of code. Wiki has a full tutorial. [4]<p>The Book of Shaders. A step by step introduction into fragment shaders. [5]<p>[1] <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;_&#x2F;dp&#x2F;B01B5AODD8" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;_&#x2F;dp&#x2F;B01B5AODD8</a><p>[2] <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;_&#x2F;dp&#x2F;B01CO7PQ8C" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;_&#x2F;dp&#x2F;B01CO7PQ8C</a><p>[3] <a href="https:&#x2F;&#x2F;www.amazon.com&#x2F;_&#x2F;dp&#x2F;B01DN58P8C" rel="nofollow">https:&#x2F;&#x2F;www.amazon.com&#x2F;_&#x2F;dp&#x2F;B01DN58P8C</a><p>[4] <a href="https:&#x2F;&#x2F;github.com&#x2F;ssloy&#x2F;tinyrenderer&#x2F;wiki" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;ssloy&#x2F;tinyrenderer&#x2F;wiki</a><p>[5] <a href="https:&#x2F;&#x2F;thebookofshaders.com&#x2F;" rel="nofollow">https:&#x2F;&#x2F;thebookofshaders.com&#x2F;</a>
dreamcompilerabout 9 years ago
Maybe I missed it, but I didn&#x27;t see any discussion of the Bresenham family of algorithms. I realize this is always done for you nowadays, but if you&#x27;re really teaching pixels from scratch, it seems like drawing lines and circles from raw pixels needs to be covered.
评论 #11745797 未加载
评论 #11745144 未加载
评论 #11745633 未加载
ameliusabout 9 years ago
I was surprised this starts at 3D graphics, and completely skips important 2D techniques, such as drawing&#x2F;shading lines and polygons (which are also useful for doing 3D stuff).
kowdermeisterabout 9 years ago
I give them a big kudos for adding lots of illustrations, it&#x27;s vital to have good visual representation for math concepts.<p>&gt; Evaluating the curve&#x27;s equation for values of tt going from 0 to 1, is sort of the same as walking along the curve. It is important to understand that tt is a scalar but that the result of the equation for any tt contained in the range [0:1] is a position in 3D space (for 3D curves, and obviously a 2D point for 2D curves). In other words, if we need to visualise a parametric curve, all we have to do is to evaluate the curve&#x27;s equation for increasing values of tt at some regular positions (it doesn&#x27;t have to be though), and connecting the resulting positions in space to create a polygonal path (as illustrated in figure 5).<p>Unfortunately this is the language that you should avoid if you want to explain these concepts for beginners. Too technical, too rigid, too dry. I sort of understand what it says, but it could be done in much simpler way. I&#x27;d put it this way:<p>&quot;We have a function that describes the bezier curve. If you call that function with the P1-4 parameters you will receive X,Y (or Z if you do 3D) coordinates that you can easily plot and connect with straight lines. You also need to specify how many segments you want to receive, this will be resolution of the curve.&quot;<p>Or something like this. Better explained ( betterexplained.com&#x2F;calculus&#x2F; ) does a good job at this and I recently recently rediscovered Kirupa, I love his tutorials: <a href="https:&#x2F;&#x2F;www.kirupa.com&#x2F;html5&#x2F;animating_with_easing_functions_in_javascript.htm" rel="nofollow">https:&#x2F;&#x2F;www.kirupa.com&#x2F;html5&#x2F;animating_with_easing_functions...</a>
ivan_ahabout 9 years ago
Wow this is an awesome online book. Goes into a lot of details, and uses words to convey the important things + supports it with code.<p>Another good tutorial, more specific to OpenGL, is this one: <a href="http:&#x2F;&#x2F;www.songho.ca&#x2F;opengl&#x2F;index.html" rel="nofollow">http:&#x2F;&#x2F;www.songho.ca&#x2F;opengl&#x2F;index.html</a> I liked this one because each lesson has a binary you can download and run on your computer (only tested on Mac).
评论 #11745754 未加载
dahartabout 9 years ago
Anyone know who&#x27;s behind the site? I looked around, but all I found was a FAQ on the older version of the site that asks the question and doesn&#x27;t answer, aside from &quot;VFX professionals&quot;.