Ridiculously Easy 3D in C

  Рет қаралды 60,009

Tsoding Daily

Tsoding Daily

Күн бұрын

Previous Episodes: • Data Mining in C
References:
- Source Code: github.com/tsoding/data-minin...
- Wikipedia - K-means Clustering - en.wikipedia.org/wiki/K-means...
- Wikipedia - Color Quantization - en.wikipedia.org/wiki/Color_q...
- Wikipedia - Spherical Coordinate System - en.wikipedia.org/wiki/Spheric...
- mortenhannemose.github.io/lena/
Chapters:
- 0:00:00 - Announcement
- 0:00:36 - Intro
- 0:04:52 - 3d executable
- 0:08:03 - nob ideas
- 0:09:21 - Raylib Boilerplate
- 0:11:06 - Perspective vs Orthographic
- 0:14:01 - Finishing the Raylib Boilerplate
- 0:14:30 - Creating Camera3D
- 0:17:00 - Drawing Cube
- 0:19:07 - Examples
- 0:21:18 - Camera Parameters
- 0:24:55 - Why Raylib Uses Degrees?
- 0:26:14 - Continue Camera Parameters
- 0:26:46 - Compose Key
- 0:27:57 - TBD

Пікірлер: 93
@Je3f0o
@Je3f0o 4 ай бұрын
I'm a graphics developer. I developed a Game Engine in C. I know only 200 spheres are nothing for your graphics card. Reason why your FPS dropping is, because raylib maybe 200 draw calls behind the scene. If you optimize ur draw calls u can only 1 draw call and draw more than 10000 spheres without any problem. Graphics card and CPU is actually like server client architecture. Imagine u send 200 sync requests to server for each sphere, instead 1 request for 200 spheres...
@judahmatende3769
@judahmatende3769 4 ай бұрын
makes sense
@sournois90
@sournois90 4 ай бұрын
damn makes sense
@matthias916
@matthias916 4 ай бұрын
doesnt raylib already buffer everything with the begin and end drawing methods?
@balisticemerald8512
@balisticemerald8512 4 ай бұрын
I feel the problem is also that Raylib generates a new sphere each time you do a DrawSphere() call. Like I did some messing around and you can get a lot of performance if you load a sphere model before the loop and then draw that model instead of doing DrawSphere(); You can get a simple sphere with LoadModelFromMesh(GenMeshSphere(radius,slices,rings)); so thats also pretty neat Like in the DrawSphere() case I draw 1,000 spheres at like 15fps but when drawing the pre-loaded sphere model I get like 40fps when doing 10,000 spheres. Both using -O3 as the flag if that matters for graphic stuff, and I loaded a model with 16 slices and rings which is the same number DrawSphere() uses. It's by no means a professional test, but you can notice it running better
@Je3f0o
@Je3f0o 4 ай бұрын
@@matthias916 I don't know how raylib implemented under the hood. But I'm damn sure it's not about how many triangles, vertices and fragments. Specially fragment shader doesn't compute lighting, shading etc... expensive calculations. On the screen only few fragments with simple flat colors. There is no way only 200 spheres that much lag. I'm just guessing maybe too many OpenGL calls. Copy data to GPU and draw etc... Each OpenGL calls are blocking. Maybe beginMode3D and endMode3D just switching shader programs. Not buffering for batch rendering.
@rubyciide5542
@rubyciide5542 4 ай бұрын
TSoding Turing Soding ❌ Terry daviS OverDosING ✅
@bonekazz-8441
@bonekazz-8441 3 ай бұрын
"the source code is the best documentation" this will stick in my mind forever, thanks
@aaronspeedy7780
@aaronspeedy7780 4 ай бұрын
I've been loving these streams on raylib! Raylib is such a wonderful library. By the way, raylib has an rcamera module which makes a lot of the math you did redundant with one super easy function, namely UpdateCamera, for moving the camera with usual controls under a variety of modes, and a couple of lower-level functions, namely CameraMoveForward, CameraMoveRight, CameraMoveUp, CameraYaw, and CameraPitch, for managing the camera yourself, and some even lower-level functions that I won't name.
@EricT43
@EricT43 4 ай бұрын
This was so cool to watch, starting from the algorithm and all the way to applying it to color quantization and image compression. You've inspired me to build some image processing projects of my own.
@stephaneduhamel7706
@stephaneduhamel7706 4 ай бұрын
I think using only the unique colors is a good idea for optimisation, but maybe it would make sense to keep track of the number of times each unique color appears in the image, to give more weight to these colors depending on the amount of pixels they correspond to (unless you're already doing that and I missed it). (Also default sRGB is a terrible color space to do quantization in, but it doesn't matter too much)
@ZoraAlven
@ZoraAlven 4 ай бұрын
Another amazing one stream, Merry Christmas
@SeishukuS12
@SeishukuS12 4 ай бұрын
That's pretty freaking cool, a simple dither mask pre-applied before quantizing would make an even bigger difference at the low color counts I bet. I've always wondered how to do this kind of thing, but never really looked into over the years, it's so stupid simple!
@OlivierDALET
@OlivierDALET 4 ай бұрын
It makes very much sense for an api to expose degrees as it allows the user to, most of the time, input exact values: 30, 45 or 90 are nicer to type and read than fractions of pi. It's even more true if you read your values from some config file and feed the api directly.
@unnamed1479
@unnamed1479 4 ай бұрын
degrees also have higher precision than radians which is nice when working with floats
@OlivierDALET
@OlivierDALET 4 ай бұрын
@@unnamed1479 sure, however they usually get converted into radians at some point and then you loose precision...
@unnamed1479
@unnamed1479 4 ай бұрын
@@OlivierDALET heh yeah good point
@littlecurrybread
@littlecurrybread 4 ай бұрын
God I love C, keep it up!
@shivashankar28
@shivashankar28 4 ай бұрын
same here, C is love, C is life! HAHAH
@ecosta
@ecosta 3 ай бұрын
Also, classical end-of-stream comment: after years trying complex dithering algorithms, I loved how such a simple and elegant solution exists. I'll definitely try that approach if I need it. Or try that visualisation in Vulkan (just because I can 😄).
@carvas18
@carvas18 4 ай бұрын
Degrees are usually used because it is a more intuitive unit than multiples of pi, in mathematics you rarely ever see a degree tbh.
@____r72
@____r72 4 ай бұрын
hey look man, i quick and easy mercy evaporation is in both of our best interests, i go poof and escape mad man next door, you continue reclaiming a throne that always belonged to you - its a win win
@JonnyDeRico
@JonnyDeRico 4 ай бұрын
In germany we have a "Doppelhaushälfte" 😂
@apppples
@apppples 4 ай бұрын
now use CIEDE2000 for the distance metric instead of euclidean distance
@lievenpetersen
@lievenpetersen 4 ай бұрын
36:28 check out the position name 4 lines below :D
@lMoonHawk
@lMoonHawk 4 ай бұрын
Would have been cool to see the image render in real time on screen as the means approach their local minimum
@StevenMartinGuitar
@StevenMartinGuitar 4 ай бұрын
Yeah do this!
@RandomGeometryDashStuff
@RandomGeometryDashStuff 4 ай бұрын
28:26 why changing Z sign made camera see cube? isn't that just looking at cube from different direction?
@classawarrior
@classawarrior 2 ай бұрын
Was wondering the same thing!
@desertfish74
@desertfish74 4 ай бұрын
Zozing need a new PC, on mine , Krita loads up in under 3 seconds.
@slavpetrovich32
@slavpetrovich32 4 ай бұрын
- How much watches? - Ten clocks. - Such much? - For whom how… - MFTI finished? - A-a-a-ask!..
@onaecO
@onaecO 4 ай бұрын
Bro u so smart!
@rev_krakken70
@rev_krakken70 4 ай бұрын
Can you share with me the discord link?
@luicecifer
@luicecifer 3 ай бұрын
And that is why programmers and computer scientists get paid so much. Because we're the only ones that are stubborn and stupid enough to put up with that crap every single day.
@RandomGeometryDashStuff
@RandomGeometryDashStuff 4 ай бұрын
22:23 doesn't which way z goes depend on which way camera is looking?
@unnamed1479
@unnamed1479 4 ай бұрын
pretty sure in raylib the x,y,z axes are fixed, but your unit vector for forwards and backwards would be affected by your camera direction
@RandomGeometryDashStuff
@RandomGeometryDashStuff 4 ай бұрын
​@@unnamed1479> unit vactor for forwards and backwards are you talking about `position` or `target` or `up`?
@unnamed1479
@unnamed1479 4 ай бұрын
@@RandomGeometryDashStuff (target - position) / mag(target - position)
@AeSoGakalololoolmlololoolm
@AeSoGakalololoolmlololoolm 4 ай бұрын
HOW CAN I JOIN UR DISCORD?
@slazil
@slazil 3 ай бұрын
27:30 Здорово! 😃
@apppples
@apppples 4 ай бұрын
hold all fingers together, index finger pointing towards positive x, curl your fingers into a thumbs up, they curl towards positive y, positive z is the direction of your thumb.
@2dapoint424
@2dapoint424 4 ай бұрын
2:10:22 ! Dumy dum dum!! Ofcourse!!! lol
@thatstupiddoll
@thatstupiddoll 4 ай бұрын
Twice of the half of the cube
@jjonojj
@jjonojj 4 ай бұрын
great video, but pls expand your german wortschatz
@ess4591
@ess4591 4 ай бұрын
it was so easy
@blocksrey
@blocksrey 4 ай бұрын
Is your Emacs evil?
@kunalsanjaybutiya5944
@kunalsanjaybutiya5944 4 ай бұрын
Can you please make a series on system programming with C language pls.
@Zipperheaddttl
@Zipperheaddttl 4 ай бұрын
look up handmade hero. That will give you what you need.
@neshkeev
@neshkeev 4 ай бұрын
He can't do system programming, only computer graphics
@michelalwan8410
@michelalwan8410 4 ай бұрын
​@@neshkeevhow do you know?
@SENTRY456123
@SENTRY456123 4 ай бұрын
​@@neshkeev are you trying to Dani him?
@4445hassan
@4445hassan 4 ай бұрын
@@neshkeev Huh? This implemened multiple programming languages and just A LOT of interesting stuff. Just scorll a bit through the videos and you find many many many things that don't have anything to do with any graphical thing what so ever.
@anon_y_mousse
@anon_y_mousse 4 ай бұрын
Interesting that they use degrees, because I thought radians were standard. Maybe that's just for the things I've been doing and not graphics programming? I wish I could get you a new computer because your potato is more highly starched than mine. I would just use GIMP to specify an image size, but it might be too much for your computer to handle. Of course I should probably use my image library to do such simple things more like you use STB. And your statement about spending too much time on rotation really hits hard, but not in the way you meant it. Too much time on rotation can really give you PTSD. Although I doubt anyone else watching you will understand what I'm talking about.
@switchzzz6285
@switchzzz6285 4 ай бұрын
SHAYSER
@ecosta
@ecosta 3 ай бұрын
Too bad Raylib uses raw GL vertex primitives behind the scenes. So each sphere/cube pumps one draw call per vertex. 200 spheres isn't much, but it shows how OpenGL sucks unless you use array objects, instances, etc.
@adlen01
@adlen01 4 ай бұрын
Why you dont publish your code make it easier
@fiona9891
@fiona9891 26 күн бұрын
the source is usually in the description
@matthewexline6589
@matthewexline6589 4 ай бұрын
OpenGL isn't utterly insane to learn. Why people don't just write their own OpenGL code themselves and take responsibility for their apps' performance is beyond me.
@sdrogo0364
@sdrogo0364 4 ай бұрын
1:28:33 How about that
@paca3107
@paca3107 4 ай бұрын
please show me how to do this in serious language like javascript or react.
@SomeRandomPiggo
@SomeRandomPiggo 4 ай бұрын
C isn't serious? XDDDD
@paca3107
@paca3107 4 ай бұрын
@@SomeRandomPiggo is not, in real life people use js.... xDd
@SomeRandomPiggo
@SomeRandomPiggo 4 ай бұрын
@@paca3107 On the web they do, but the browser you use is written in C or C++ and so is the OS below it. JS would be a weird choice for a desktop music player unless you want to use Electron which is really slow
@caio757
@caio757 2 ай бұрын
”0" ==- null >>true serious language moment.
@niggacockball7995
@niggacockball7995 9 күн бұрын
javascript serious ha...
@Person1873
@Person1873 4 ай бұрын
First!!!
@reinhold1616
@reinhold1616 4 ай бұрын
get real
@divingeveryday
@divingeveryday 4 ай бұрын
What? No 4D visualizations? Unsubscribe! 😂
@zizzyballuba4373
@zizzyballuba4373 4 ай бұрын
im indian sir please help im indian
@ekshalibur
@ekshalibur 4 ай бұрын
sorry, you cant be helped ... good luck
@aeonian8687
@aeonian8687 4 ай бұрын
how can ı in discord channel ?
@JkaBG
@JkaBG 4 ай бұрын
you dropped this .
@remondrk
@remondrk 4 ай бұрын
​@@JkaBGİ stole it
Can C actually do Perfect Bézier Curves?
2:17:22
Tsoding Daily
Рет қаралды 6 М.
I regret doing this...
1:20:07
Tsoding Daily
Рет қаралды 60 М.
Buy Feastables, Win Unlimited Money
00:51
MrBeast 2
Рет қаралды 91 МЛН
Каха с волосами
01:00
К-Media
Рет қаралды 6 МЛН
I MADE A CARDBOARD SWING!#asmr
00:40
HAYATAKU はやたく
Рет қаралды 31 МЛН
маленький брат прыгает в бассейн
00:15
GL Show Russian
Рет қаралды 4,1 МЛН
Will Ada Replace C/C++?
44:57
Tsoding
Рет қаралды 68 М.
An introduction to Shader Art Coding
22:40
kishimisu
Рет қаралды 891 М.
Why is Raylib becoming so popular?
9:24
Chris_PHP
Рет қаралды 11 М.
Is C++ better than C?
1:46:10
Tsoding Daily
Рет қаралды 27 М.
Is John Carmack Right about UI?!
1:52:02
Tsoding Daily
Рет қаралды 29 М.
researchers hack the PS4 with a 20 year old bug
12:21
Low Level Learning
Рет қаралды 23 М.
You don't need Generics in C
1:37:38
Tsoding Daily
Рет қаралды 55 М.
Coding Adventure: Simulating Fluids
47:52
Sebastian Lague
Рет қаралды 1,6 МЛН
Async Engine in C
3:12:16
Tsoding Daily
Рет қаралды 31 М.
Я Создал Новый Айфон!
0:59
FLV
Рет қаралды 3,2 МЛН
Рекламная уловка Apple 😏
0:59
Яблык
Рет қаралды 822 М.
Добавления ключа в домофон ДомРу
0:18
How much charging is in your phone right now? 📱➡️ 🔋VS 🪫
0:11
Airpods’un Gizli Özelliği mi var?
0:14
Safak Novruz
Рет қаралды 4,1 МЛН