854 points · by haqreu · 7y ago · 63 comments
For example: https://en.wikipedia.org/wiki/Monte_Carlo_N-Particle_Transpo...
Example:
https://www.friendlyskies.net/images/266.jpg
So much of 3D graphics is "hmm, this random thing I just made slightly resembles an $X". "OK, so let's say I just created a method for modeling $X." :-) Really fun stuff.
Despite the apparent variety, most 4k intros rely on a single effect, maybe two. There isn't enough space for more. The only things that change are the parameters.
Interestingly, the technique used here is signed distance field raymarching. A technique that is used by maybe 90% of all 4k intros today.
So basically, write the code in GLSL instead of C, add music, play a bit with the parameters, use a good exe packer like crinkler and you have a nice 4k intro.
The effects make the difference, besides artistic direction, so materials, blur (bokeh), the sdf geometries (often just mere balls and cubes, but perhaps a twister or a nice water surface or a fractal) just for starters. Just from my outside perspective.
Off-topic: May I suggest that you switch to using imgur instead of the image host you chose? The ads on imgur are much less intrusive.
Edit: Found the image link on my own site:
Start here: https://github.com/ssloy/tinyrenderer/wiki/Lesson-1:-Bresenh...
Little off-topic, but that's one of the reasons I like to use Magit on Emacs, you can see the diff of each commit interactively and intuitively.
Anyhow, with just git.
Diff of most recent commit:
git show HEAD
Diff of preceding commit: git show HEAD^
Diff of commit before that again git show HEAD^^
Of course you don’t want to type ^ 200 times. Fortunately you don’t have to. Diff of commit three steps back before most recent: git show HEAD~3
Or you can look at the log first git log
And find a specific commit and then use the first few characters of the id of that commit, e.g. git show af4c
And of course I would be remiss to not mention git diff
And git diff --cached
These two show you unstaged and staged changes before you commit. I use these commands all the time. So much that they are two of the commands I have created very short two-letter aliases for in my .bashrc alias di="git diff --cached"
alias dp="git diff"https://www.iquilezles.org/www/articles/distfunctions/distfu...
https://iquilezles.org/www/articles/raymarchingdf/raymarchin...
He also has videos on YouTube, some of which show the creation of a scene starting from the basics.
I wanted to say he's an excellent introduction to graphics. As a sysadmin, I had never drawn more than simple lines and the whole thing seemed daunting. Now I see how fun it can be, and I'm waiting for next weekend to pick up some more!
https://physics.stackexchange.com/questions/372117/shadow-of...
Still, it's hard for me to not want to create a series of blog posts under the title "All those cool graphics tutorials in <language I like better>".
I didn't realize openmp was so easy to use. It isn't realtime but you could bake up some cool effects with this.
AMD FX8320 3.5GHz
$ time ./tinykaboom
real 0m4.176s user 0m28.631 sys 0m0.012s
This technique is used a lot in demoscene demos, which certainly do run in realtime.
$ time ./tinykaboom
./tinykaboom 78.08s user 0.02s system 369% cpu 21.159 total
Then I wondered how it would fare if I were to port it to Go and went ahead and hastily did port to Go and thought that, "hmmm this should run a bit slower than the c++ version" but surprisingly it ran more than twice faster: $ go build ./tinykaboom.go
$ time ./tinykaboom
./tinykaboom 34.32s user 0.03s system 368% cpu 9.315 total
https://github.com/holygeek/tinykaboom/blob/master/tinykaboo...Here's the corresponding perf report:
Go:
Samples: 103K of event 'cycles:pp', Event count (approx.): 37252033995665
Overhead Command Shared Object Symbol
32.17% tinykaboom tinykaboom [.] math.sin
28.80% tinykaboom tinykaboom [.] main.hash
11.81% tinykaboom tinykaboom [.] main.rotate
7.76% tinykaboom tinykaboom [.] math.Min
5.18% tinykaboom tinykaboom [.] main.lerpFloat64
4.25% tinykaboom tinykaboom [.] main.noise
2.59% tinykaboom tinykaboom [.] runtime.mallocgc
2.59% tinykaboom tinykaboom [.] main.fractal_brownian_motion
2.58% tinykaboom tinykaboom [.] main.signed_distance
c++: Samples: 234K of event 'cycles:pp', Event count (approx.): 86721459552303
Overhead Command Shared Object Symbol
67.93% tinykaboom libm-2.23.so [.] __sin_avx
30.80% tinykaboom tinykaboom [.] _Z5noiseRK3vecILm3EfE
1.27% tinykaboom libm-2.23.so [.] __floorf_sse41
0.00% tinykaboom tinykaboom [.] _Z23fractal_brownian_motionRK3vecILm3EfE
0.00% tinykaboom tinykaboom [.] floorf@plt
If anyone can give suggestions on how to make the tinykaboom.cpp faster that would be neat!I ran the comparison again on another machine that I have and this time their performances are about the same:
c++:
$ time ./tinykaboom
./tinykaboom 46.72s user 0.01s system 364% cpu 12.804 total
go: $ time ./tinykaboom
./tinykaboom 42.50s user 0.07s system 350% cpu 12.161 total2x e5-2667 v2: real 0m2.217s user 0m56.088s sys 0m0.016s
Seems like it's pretty inefficient with the dual CPU setup.
I wonder how many shaders this would keep busy. There is probably a class of GPUs and above that this could work on rather well alongside an already large workload.
I was willing to criticize the line count if it had a bunch of dependencies, but 180 lines seems accurate and I'll give a pass to the obligatory core C++ include statements
Way to go!
Especially for graphics-related stuff.
Yet HN community seems to ignore GPUs.
When I recently published my hobby project that renders much more advanced procedurally-generated stuff, I only got a single upvote: https://news.ycombinator.com/item?id=18921046
Indeed, I don't see why people like this. In modern world, doing graphics on CPU is very inefficient.