Improving Learn OpenGL's Text Rendering Example | Adventures in Coding

  Рет қаралды 4,969

Whatever's Right Studios

Whatever's Right Studios

Жыл бұрын

Learn OpenGL is a massive resource for anyone starting or growing their knowledge of OpenGL. It's been instrumental for me. In this video, we go through and take Learn OpenGL's text rendering example as a starting point and improve its performance by over ten times!
Huge credit to learnopengl.com/ without that website my game wouldn't exist.
If you'd like access to my finished example head to:
github.com/johnWRS/LearnOpenG...
And as always check out Redeemart on Steam.
store.steampowered.com/app/21...

Пікірлер: 31
@seacabouse
@seacabouse 9 ай бұрын
Thanks for sharing your implementation, i will definitely be adopting it. The improvements you've made were things that were bothering me for days but i didn't have myself the knowledge to solve. Looking foward to your other videos, cheers.
@realishak
@realishak Ай бұрын
Thanks a lot for this video. Gonna yoink the code for my little engine if you don't mind :)
@WhateversRightStudios
@WhateversRightStudios Ай бұрын
Absolutely, it's what it's there for! As some people mentioned in the comments switching to SSBOs for the text would be a big performance improvement for an engine.
@slowbro13215
@slowbro13215 2 ай бұрын
Thanks so much for the tutorial, it was really nice to be able to get those big improvements in my own project! I am writing my engine in C & trying to keep it compatible with Emscripten by using GLES 3.0, so there was a good bit of translation I had to do, but I got all of the improvements working in the end. Awesome stuff, I'll definitely be checking out your other tutorials. The new ones on particles should be really helpful too.
@WhateversRightStudios
@WhateversRightStudios 2 ай бұрын
That's great! You must have put a lot of work into that engine!
@gennitter4
@gennitter4 11 ай бұрын
Programming with John! Very cool. I now know what I'm going to be doing for the next hour lol
@WhateversRightStudios
@WhateversRightStudios 11 ай бұрын
Haha just when you thought you'd never have to experience this again!
@Faby__
@Faby__ 7 ай бұрын
great video
@frostpitt
@frostpitt 3 ай бұрын
Great video. There is one issue with the code and its also visible at the end of the video when you have used texture arrays. I always found texture arrays tricky and this video helped simplify them. I have a modified version of your code using SSBO's and the "newer" OpenGL MultiDrawArraysIndirect so I have only one draw call to render the whole text. Added a timer as well to show the letters sequentially appearing as they do in game dialog boxes. However I've been trying to figure out why the 'j' character's texture is black. I first thought it was a bug in my code until renderdoc showed me that the texture array at index 106 (j) was black. I paused your video where a j is supposed to appear in the text and also saw that it is missing. I havent found the fix yet but just thought I'd let you know. Awesome video regardless.
@frostpitt
@frostpitt 3 ай бұрын
Update: Its likely an issue with the Antonio-Bold font. I dont see the issue when using the regular or the light version of the font. Guess fonts have to be compatible with this library.
@WhateversRightStudios
@WhateversRightStudios 3 ай бұрын
You are 100% right about the texture arrays! Haha I burned like 6 hours trying to figure out some issues with them. That's awesome about the texture rendering! I really need to learn more about SSBO's sounds like you added a nice improvement. Thanks for the feedback and positivity, I really appreciate it!
@NyanCoder
@NyanCoder 8 ай бұрын
Wont it be faster if you push that string into a single vertex buffer and prepare character atlas and draw all of the text with single draw call? But your approach is definitely would be faster in dynamic text rendering P.S. Also I'd recommend you to check out SDF (Signed Distant Field) it looks amazing
@WhateversRightStudios
@WhateversRightStudios 8 ай бұрын
Yeah, you're correct that if the text is guaranteed to be static then you could send data in the VBO to be faster. It's just when you start having to modify the text that that becomes efficient. We saw that with the initial implementation. Modifying the often VBO can be expensive. Additionally, if you knew strings wouldn't change frequently then you could implement a two step system. Where the first step is the text rendering we're dicussing but at the end you save the resulting image to a texture. And the second step just draws that prerendered texture. That way if the text doesn't change you can skip the first step each frame. I've been meaning to implement them for a while! My game needs smoother text so I looked into them. I'm hoping to implement them in the near future then do a programming video on it.
@NyanCoder
@NyanCoder 7 ай бұрын
@@WhateversRightStudios for even more smoother text check out the msdfgen (it generates multichanneled SDFs, or MSDF for short) If you have read something about SDF, it would be very simple to explain how MSDF works: So, basically, MSDF is just multiple SDFs, and by picking the median one (the middle value of 3 of them) you can achieve very sharp edges About text itself: I prefer the atlas approach, where you generate the atlas and use it in multiple text objects in the scene, so you'll have a single shared texture to generate next texts significantly faster than regenerating textures, so you can collect the whole translation characters into the one collection, generate the atlas and then you'll have to generate only VBOs in a further texts P.S. SDF and MSDF are not only for text rendering, you can utilize them as rasterizer for vector graphics and achieve vector-look-a-like from raster info (tbh, you should treat them as fields as the name says, rather than rasters)
@midnightdavy5784
@midnightdavy5784 6 ай бұрын
Hi, i get the above error when I run the code on github, is there a reasoon for that? ERROR::PROGRAM_LINKING_ERROR of type: PROGRAM Vertex info ----------- Internal error: assembly compile error for vertex shader at offset 669: -- error message -- line 19, column 9: error: invalid parameter array size line 26, column 43: error: offset for relative array access outside supported range line 28, column 27: error: offset for relative array access outside supported range line 30, column 21: error: out of bounds array access line 31, column 21: error: out of bounds array access line 32, column 21: error: out of bounds array access line 33, column 34: error: out of bounds array access
@WhateversRightStudios
@WhateversRightStudios 5 ай бұрын
Odd errors as none of the shaders on GitHub have that many lines. But based on that error your array size is too large for your GPU. Also double check your GPU supports OpenGL 3.1 and up
@realishak
@realishak Ай бұрын
For who happens to have this error, just lower the transforms array size to 200 and all good
@stephenkamenar
@stephenkamenar 8 ай бұрын
isn't opengl a piece of trash? it can't even render a blank scene without stuttering. i'm pretty sure even directx would run better on linux
@NyanCoder
@NyanCoder 8 ай бұрын
I wouldn't say so, it's true that ogl and d3d11 and below are pretty strict to perform a lot of micro-optimization (multi-threaded filling command lists, for example). But in linux ogl is definitely better than d3d simply because it wont carry with him bloat called wine (wine is for not ported stuff, native is almost always better) P.S. I'm choosing opengl only because emscripten has gles3 emulation on webgl2 so I can write almost the same code for multiple platforms. In win-only projects d3d11 is my favorite, btw, but only because I'm just more familiar with it
@stephenkamenar
@stephenkamenar 8 ай бұрын
@@NyanCoder wine? maybe that was true a long time ago. now we have steam proton stuff which I think runs very well
@NyanCoder
@NyanCoder 8 ай бұрын
​ @stephenkamenar sorry, I don't use steam on my linux, for games I have Windows install, so maybe I'm a little bit out of context. Btw, doesn't it use wine for os imitation and providing libraries that used by exe's? Basically my point is the compatibility layers have a bunch doubling stuff for basic things (memory allocation, work with files, console output, access to hardware, creating threads/processes, memory protection like mutex, application window api, e.g. winapi), for example a lot of dll's should be provided (such as kernel32.dll, user32.dll, d3d11.dll and more), and memory and process management should be doubled for Windows executables in other way (the exe is structured different, also the things in windows and linux done in different way, for example to output to console in linux you need to int something, and in windows the kernel32.dll provides functions to work with files and the file-handlers that are bound to console window), also they have their own set of libraries (ogl+vk vs ogl+d3d+vk, cpp runtime, x11+wayland vs winapi, etc.) And that makes you basically have multiple things that do the same thing (ofc some things are just wrappings, but a lot of thing are dupes). That what I call bloatware. It's better to have multiple native builds for each system (win32, win64, win-arm, linux32, linux64, linux-arm), and compatibility layers are for apps that are not ported, not for developing in the first place. The people that are interested only in your application and not in any other unsupported stuff shouldn't be forced to carry too much bloatware P.S. I'm rereading my letter and noticed that I wrote it in a way that hard to keep in track, sorry if it's hard to read for you too
@wiktorwektor123
@wiktorwektor123 7 ай бұрын
@@stephenkamenar What do you think Proton is in it's core? It's customized Wine by Valve. Just like Steam OS on Steam Deck is customized Arch Linux. Finally OpenGL isn't piece of trash.
@stephenkamenar
@stephenkamenar 7 ай бұрын
@@wiktorwektor123sure but it's easy to use and stuff now. old wine was too annoying to use
Coding Adventure: Rendering Text
1:10:54
Sebastian Lague
Рет қаралды 595 М.
Sprinting with More and More Money
00:29
MrBeast
Рет қаралды 178 МЛН
Which one is the best? #katebrush #shorts
00:12
Kate Brush
Рет қаралды 21 МЛН
Rewriting Text Editor Renderer in OpenGL
2:45:17
Tsoding Daily
Рет қаралды 11 М.
What Is A Graphics Programmer?
30:21
Acerola
Рет қаралды 377 М.
I made a better Ray-Tracing engine
17:38
NamePointer
Рет қаралды 244 М.
Legendary Font Rendering
1:08:46
Tsoding Daily
Рет қаралды 20 М.
Rendering Context | Game Engine series
27:03
The Cherno
Рет қаралды 47 М.
I Made a Graphics Engine (again)
8:27
Zyger
Рет қаралды 158 М.
The Math Behind Font Rasterization | How it Works
16:07
GamesWithGabe
Рет қаралды 169 М.
Pyglet crash course 2023 - Python and OpenGL
2:30:39
AtiByte
Рет қаралды 7 М.
An introduction to Shader Art Coding
22:40
kishimisu
Рет қаралды 916 М.
WWDC 2024 Recap: Is Apple Intelligence Legit?
18:23
Marques Brownlee
Рет қаралды 5 МЛН
Мечта Каждого Геймера
0:59
ЖЕЛЕЗНЫЙ КОРОЛЬ
Рет қаралды 1,3 МЛН
iPhone 12 socket cleaning #fixit
0:30
Tamar DB (mt)
Рет қаралды 37 МЛН
КОПИМ НА АЙФОН В ТГК АРСЕНИЙ СЭДГАПП🛒
0:59
TOP-18 ФИШЕК iOS 18
17:09
Wylsacom
Рет қаралды 713 М.