r/GraphicsProgramming • u/Missing_Back • Sep 07 '23
Is graphics just one big illusion?
Working on learning OpenGL and finally got past the hump of understanding how to draw a triangle (somewhat), and I used that knowledge to draw a cube, and it was kind of cool, because my brain KNOWS that it’s really just 6 triangles of slightly different shades of white, but my eyes can’t help but see a 3D cube.
It’s a big old sham. There ARE no cubes. Everything is a triangle.
Do I understand graphics now?
49
u/chillaxinbball Sep 07 '23
Everything is an illusion. You define three float3s. Do some matrix transformations that are controlled with user input which illuminates pixels layed out a 2d array which looks like a triangle to the primeape staring at it. There never was a real triangle though. It's all math done by a special rock with electricity.
19
u/anime_or_suicide Sep 07 '23
and we tricked that rock into showing us pretty things. cool if you ask me
23
15
u/HaskellHystericMonad Sep 07 '23
Bro. I don't even have triangles. I only have quads, i just send them to the GPU with some strange 6 index sequences that some might say are triangles ... that are going to write out a quad-id and never be seen again - bahaha.
But seriously, quad-centric triangle-free pipeline has been fun.
10
u/geon Sep 07 '23
Why though? Developing for the sega saturn?
1
u/HaskellHystericMonad Sep 08 '23
Took the Low -> High route instead of the High -> Low route that photogrammetry really pumped about a decade ago.
Initial workflow is quad exclusive as that better facilitates things like geometric textures. Could support tris, but that's more permutations of edges meeting other edges to handle, easier to just go quad exclusive.
---
If your hair wasn't starting to gray 10 years ago, you're not going to understand the decision making process. I chose to go balls deep on techniques from 2003 and 2001 that you've never heard of.
1
u/geon Sep 08 '23
My hair started to gray about 8 years ago. I used to read every graphics article I could find in 2003.
4
3
u/makian123 Sep 07 '23
Arent quads triangulized on the cpu before being sent to gpu?
2
u/HaskellHystericMonad Sep 08 '23
It's in compute. The stuff fed to the rasterizer is triangle indices that will emit quad indices ... because yeah, primitive indexed we go?
Been doing it for many fucking years.
13
u/Passname357 Sep 07 '23
I never bought into that mindset. I mean, it’s as much a cube as a picture of a cube is a cube. Both are projections of a 3D thing onto a 2D surface. If you really get into rendering algorithms sure everything is an approximation, but they’re fantastically accurate approximations. PBR is literally just trying to cut corners on real light behavior simulations. And when people call things like normal mapping “faking it” it’s like, okay sure we don’t have any geometry there, but at most viewing angles it’s indistinguishable to if we did have real bumps. With sufficiently dense geometry, there really is no difference. Etc etc.
9
u/corysama Sep 07 '23
Ah, The Treachery of Images! Ceci n'est pas une cube!
2
u/Qaziquza1 Sep 08 '23
Oui, but it was never supposed to be, either. It was only ever supposed to be a representation of one.
12
9
u/Blissextus Sep 07 '23
Welcome to graphics programming. Mathematics is the only truth. Everything else in an optical illusion.
Computers are dumb! They only do what you tell it to do. And they only see 0's & 1's.
"You think that UI you see is real?" (Matrix referrence)
7
u/AntiProtonBoy Sep 07 '23
"Computer graphics is about not drawing what is not seen."
I can't remember who wrote that, might have been Alan Watts.
5
u/hobojimmy Sep 07 '23
Other big illusions for me:
Everything ever put on a screen is an empty balloon in truth. Infinitely thin shells with nothing but cheap tricks to keep them all from intersecting each other.
Just outside the camera’s frustum is an awkward, stupid-looking empty void (at least with basic pruning). Unlike a real camera, nothing exists beyond its view. Everything is made to pretend a whole world is out there, but it’s not.
1
4
Sep 07 '23
Kind of. Why not both? Reality AND illusion. Illusion cant exist without reality, same way night cant exist without day, and evil without good.
2
u/Mysterious_Alarm_160 Sep 07 '23
Its like growing up and realizing you dont have to listen to your parents or your eyes wont be stuck that way if you make a funny face
2
u/Kawaiithulhu Sep 07 '23
Wait 'til you get to tessellation: that one triangle is really two triangles, and each of those is two, so now four, then each of those four is two triangles, so eight... Eventually a triangle is the size of a pixel, so 8,294,400 triangles...
On the opposite side of that, some setups just use one *big* triangle and bloat it out to cover the monitor size and just let it clip all four edges so they don't have to use two triangles to make the rectangle >mind blown<
2
2
u/the_Demongod Sep 07 '23
What do you mean "illusion," did you think there were actually people running around in the monitor?
2
u/SpookyLoop Sep 07 '23
You'll hit another red-pill moment when you realize there's not even triangles, it's all just floating point vectors.
2
u/mysticreddit Sep 07 '23
Wait till you discover one can re-create the Mona Lisa with just 50 semi-transparent polygons. /s =P
Károly Zsolnai-Fehér, of Two Minute Papers fame, wrote his own multi-threaded version.
2
u/Todegal Sep 07 '23
You know when you see a portrait painting there isn't actually a person sitting in a booth behind the frame. All 2d images are a trick on our brain to make us think we're seeing something 3d.
1
u/anime_or_suicide Sep 07 '23
This field thaught me that i am not as smart as i thought i was and it was an amazing ride so far with many ups and downs. Shaky but intriguing relationship this is.
1
1
Sep 07 '23
Yes and no?
There are more ... mathematically pure ... and/or physically-based means of representing things.
But if you use them, in, like, a way that's accurate to the point of absurdity, you are never going to see the final image.
So we come up with really a lot of hacks. Some are approximations of the real world, and others are "if you squint, it looks real enough, and runs 10x faster". And sometimes, you go even more old-school than that.
1
Sep 07 '23
Most objects are "generally" made of triangles, so it's an approximation. However in the case of a cube, you can make an exact cube with 12 triangles so it's basically perfect. In general that goes for objects with all flat faces.
1
u/fourrier01 Sep 07 '23
Some graphics subjects are true to its mathematics. Your example is just one of the many. You define vertices, triangle faces, face culling, and finally do final projection onto your screen.
But I'd say lots of the advanced subjects involves lots of hacks. An easy example would be Raytracing vs conventional rasterization. Raytracing is closer to physical reality, but often times we have hard times differentiating the visual fidelity with rasterization technique.
1
u/ds604 Sep 07 '23
you're stuck in the matrix, man... go look at an old asteroids game, or tempest or a vectrex, and see how awesomely amazing non-pixel based vector graphics look
the timeless look of resolution-independent, mathematically correct stuff, that's the real deal. it's a beam of light drawing some lines on the surface that you're looking at, but it just *feels real*. it's like the difference between seeing a picture of the sun on a screen, and then going outside and seeing and experiencing the actual sun
1
u/msqrt Sep 07 '23
Part 2 to this will come whenever you try writing a ray tracer, where you can directly intersect geometric objects like cubes and spheres :) But yeah, GPUs really like triangles.
1
1
u/pedersenk Sep 07 '23
To coolest bit is when the concept of a "camera" clicks.
You just inverse(camera_model_matrix) because you really want to move everything *to the opposite* of where your camera is conceptually positioned, direction (and to a lesser extent, scaled).
They call this a view matrix and it really does just provide the same functionality of when in 2D games you draw sprites negating the offset of where your fake screen bounds are to simulate an i.e scrolling window.
There was never a camera, for 2D or 3D; you just draw everything in different places to make it look like there is.
1
u/tylercamp Sep 07 '23
And when you “move the camera around”, the camera isn’t actually moving (it’s fixed), you’re “just” moving and rotating the entire game world around it
1
u/FredTargaryen Sep 07 '23
If you hate the triangles so much you could investigate Projective Geometric Algebra for rendering - I only needed a few minutes of a YouTube video about this to gain a whole new appreciation for the triangles
1
u/EVJoe Sep 07 '23
I mean, if you want to get really galaxy-brained about it, technically all of your sensory experiences are just neurotransmitters firing in your brain.
Phenomenologically speaking, to use your phrasing, it's ALL "just triangles"
1
1
u/ifjarc Sep 07 '23
as for impressionism in art of XVIII, shapes is just an illision comming from light colors shades...
1
1
u/r_transpose_p Sep 07 '23
Welcome to the first steps of a magical, and potentially life-long, journey!
(there are cases where the triangles aren't the informative thing -- like, most of what you see on https://shadertoy.com is all one triangle, or maybe two, depending on how they wrote it, but knowing where those triangles are usually doesn't fully explain what you see on the screen. But yeah, a lot of stuff really is just triangles. Triangles are pretty amazing.)
1
1
1
1
u/aqjo Sep 08 '23
There are no triangles either. It’s just photons hitting your retinae. Based on your experience, your brain separates things into objects, including figuring out foreground, background, that deer standing behind the deer is a single deer, not two deer, one on each side of the tree, (amodal completion), etc. It’s an amazing process.
1
1
u/starfishinguniverse Sep 09 '23
Welcome to Geometry class back in high-school, where we were taught the basic shapes and their mathematical equivalents.
The Triangle is the basic shape of the universe. So basic in fact, that multiple triangles fit inside of itself.
1
1
u/noselfinterest Sep 10 '23
"The scientific principles that man employs to obtain the foreknowledge of an eclipse, or of any thing else relating to the motion of the heavenly bodies, are contained chiefly in that part of science that is called trigonometry, or the properties of a triangle, which, when applied to the study of the heavenly bodies, is called astronomy; when applied to direct the course of a ship on the ocean, it is called navigation; when applied to the construction of figures drawn by a rule and compass, it is called geometry; when applied to the construction of plans of edifices, it is called architecture; when applied to the measurement of any portion of the surface of the earth, it is called land-surveying. In fine, it is the soul of science. It is an eternal truth: it contains the mathematical demonstration of which man speaks, and the extent of its uses are unknown."
1
u/devmerlin Sep 10 '23
There's an even bigger secret to game design and graphics in general: It's all stage theatrics.
1
1
1
1
u/Same-Artichoke-6267 Sep 27 '23
This is how I felt once I understood matrices and matrice rotations, a little after triangles. It's all... fake. ... realy fake
1
u/Belfer4 Sep 28 '23
Triangles are the atoms of typical graphics programming. Is it an illusion? Yeah, duh. One could argue that our reality is also an illusion tho, in the end it's not really whether it's an illusion or not, it's more about using the tools to make the virtual reality you want to immerse players in, it's all smoke and mirrors baby, and as long as you believe it we've done our job.
0
u/Eindacor_DS Sep 07 '23
Not only are there no cubes, there are no triangles either. No edges, no vertices, no actual decimals. It's all 1's and 0's, it's practically magic
121
u/Badwrong_ Sep 07 '23
It is all smoke and mirrors with approximations.
I'm a graphics engineer and one of the more exciting moments at work is when someone can say, "We can remove all these expensive calculations, because I found a way to approximate it that is good enough."