#Foundations - Learning Graphics Programming with the Zig Programming language
1 messages · Page 4 of 1
that's the foundation section of the book
resources is in the next section
I have the older edition in digital format, I never read it though
Chapter 7
ah yeah you're way ahead
I have 3rd ed
No my physical copy is 1st edition
oh
the 3rd chapter is taking me a bit, I read every section, then come back and reread and write notes
all this talk reminds me that I should read real time rendering
I don't do any of the problems in the books though, I build scenes that do the things the books go over
some of I am not doing as I want to make progress
like plane intersection I didn't do
I haven't done any lighting yet either, I need to through the opengl book for that as I'm stuck on using opengl honestly, that's next after I get through chapter 3, 4 and 5 of GEA
I'm reading all the math review chapters too
just because I need it
You have other opportunities to study/apply math as far as I can see
So skipping those in GEA makes sense I think
I don't know
I switched to a high contrast light theme everywhere except on that laptop
it really doesn't have anything to do with zig?
yep 0
it's just like Loris's personal project
but it might install zig as a dependency
I went to the conference in Milan this year and it wasn't really about zig either, only most of the attendees were all zig devs and it was fun to meet them all, andrew mlugg a bunch of them
but like one talk out of 3 days of talks were about zig, the workshops were zig
the sycl conference which is Loris's
I don't know
sycl is such a misleading term
yeah
like i am here just to see what other people make and how cool their shit is 🙂
i wanted to write a message based chat platform since forever, i might actually write one this year
what would you write it in
c# most likely
but it would just be an api and some websocket bs so that anyone could make a client in any language
more or less
you can aim much lower, and not support 100mio concurrent users, but just 200 or so
lets see 🙂
or i just go back to irc and click on links to see the image 😄
I once made a messaging app thing
Was able to support 11k concurrent users with minimal effort
Granted I also didn’t have anything being saved to disk
11k was what happened to be the amount it was able to deal with before connections started timing out iirc
Like socket time out I think it was, not timeout implemented by me
What was the stack?
Iirc
Java socket connections for both server and client
Like 4 threads dedicated to processing clients, 4 dedicated to accepting them
was a while ago, I don’t remember exactly
On just a single server?
Just my desktop computer
What were those 11k connections doing?
Why did a football stadium worth of people join your desktop server?
They were all my own desktop 
I see
Basically, I wrote a program to just spawn a bajillion dummy client connections to see how many I could handle
TCP?
Whatever java websockets do 
Oh web socket
Probably TCP behind the scenes somewhere
Oh not websocket just socket
why are those two terms so similar
I mean
They are similar things but like
One’s general, one’s for websites
Websockets aren’t a part of java api
robber_fly: swift predatory fly having a strong body like a bee with the proboscis hardened for sucking juices of other insects captured on the wing
robber_fly: swift predatory fly having a strong body like a bee with the proboscis hardened for sucking juices of other insects captured on the wing
tensor(0.0339, device='cuda:0', grad_fn=<NllLossBackward0>)
Also adventures in AI
My AI can recite dictionary definitions
Related note
TIL I learned that hugger-mugger is an actual word in dictionaries 
Is it verbatim
Of those two
Top is dictionary, bottom is AI
It does learn verbatim, because well, that’s kinda how AIs often are, especially if there’s not a lot of variety to the dataset
Btw, are you a hugger-mugger?
idk what that is
even after looking it up I don't know what it means
a hugger-mugger presentation of the facts of the case that left everyone confused
a tale of hugger-mugger doings and international espionage
the definition of hugger-mugger is a bit of a hugger-mugger
its definition is a state of confusion and the word leaves people in a state of confusion
if you said it to the wrong person they may challenge you to a duel
lol
optimizer: refating of near theptputscdchnr georgair bual sfnpor the rig ers of the amsica coronisers(1727-17rndt follraofwo thoserneinpes os ahp aupl thelfbclan anogrti enoliaid analartomethe pndpereoraora tnelthelipandlipatndlphelandlrahd theloeanelopand tndlopasend porlhaa and eartraane tagar andlitnemand iala tarlonasand phu anoloane phepopases and porliaa and cuugras andlianeaoanu ialerthelonasand slupieand ece ialahclopnand phuliaa and eoriraerandliprnelr phd ial andloandrparaoeneand tor ancland porlian and phuedialerand eadiing plrlialeranolacurthepoendand the i
what happens when my model tries to actually predict a definition
OH
My model's only 6.5M parameters currently 
that is smol
AI status update...
this is a single entry in my dataset that I'm hand typing
:/
I didn't expect AI to have emotions
in 1998 or so, i wrote a "chat" application which used txt files and a ftp server as the transport medium 😛
each client would connect to the ftp, check the last file date, and if its newer than last time, would pull the txt file, show the content in some textbox, and when i entered a message hit send, it would upload the whole stuff again 😛 with my text appended
I wrote an IRC client once and lots of IRC bots. An IRC bot used to be my default first project for a new programming language. I spent a long time on that IRC client it was pretty good.
hehe yea, everyone joining irc did and does : )
like kids write discord bots these days hehe
I also worked on the imgur mobile web site web sockets nodejs backend, so probably most of the people who were on the internet 10 years ago and saw a cat gif connected with code I wrote :P
i have never used any mobile website though, but i appreciate it that you did work on it 🙂
besides mobile banking
You haven’t open a browser on a phone ? 🤔
Just your bank?
You clicked links in reddit? 
Well probably for the best
i dont do reddit
i have an account but i never use it really
and pc masterrace, im not a fan of mobile/web/console platforms
Reddit is evidence that the internet was a mistake
not just reddit
hehe
Personally I choose to only play geometry dash on mobile 
btw I haven't updated with any foundation updates because I've just been reading
I got about 4 more chapters to go before I'm back to rendering anything
I'm about 30 pages into chapter 4 of GEA and it's a 160 page chapter, then I'll read the math chapter and the math chapter in my opengl book and then I'm probably going to be rendering quite a bit, I want to iterate between chapters that I'll build things with and GEA though so I can get through that book as part of my goal for the first set of books that I initially started with
looking forward to what comes out of this this time : >
the vector/plane visualization🇮🇸🇲🇸 last time were super cool already
thanks, even though it doesn't lead to any rendering I've already learned so much from GEA that I'm doing wrong just with my zig code, I haven't thought about alignment at all or cache performance and if I want this to be a good engine I'll have to consider it, so I am glad I'm reading that book
: )
Lemme just say
Alignment and cache performance are not explicitly required for good performance
Just having a good data structure in the first place goes a long way
And also skipping over useless calculations
I.e. the player’s hitbox already contains some block
There’s no reason to handle that block when checking for collisions for motion, since the player isn’t going to properly collide with that block anyway
makes sense
Mojang checks all blocks in old position to new position and it makes their code run way worse than it needs to 
Iteration order can also be important
Sometimes it’s objectively better to go xzy instead of xyz
Ex, Minecraft; you can grab the chunk instance on the z of the xzy loop and use that single chunk grab for the entirety of the y loop
Can’t do that with xyz
The Graphics Programming With C++ book publisher sent me the companion files 
Mode Size (KB) LastWriteTime Name
---- --------- ------------- ----
la--- 1214 2024-09-07 12:57:08 grid.obj
la--- 2 2024-09-07 12:57:08 icosahedron.obj
la--- 1 2024-09-07 12:57:08 pyr.obj
la--- 0 2024-09-07 12:57:08 pyrSimple.obj
obj files :P
all obj
cool though
neat
yeah I like it
pretty good and doesn't cost any where near as much as adobe stuff
good enough for me
better than gimp by a mile
I was looking at other formats besides gltf, like USD and FBX and I think I'll just stick with gltf
and I guess obj files since I have some
I think it wouldn't be to hard to just wrap the meash and gltf loader that's in the fastgltf example and then export a C function that calls that code via extern C wrapper https://github.com/spnda/fastgltf/blob/main/examples/gl_viewer/gl_viewer.cpp
tinyobject-c and fastgltf I think is what I'll go with
if I get that to work easy enough with zig which I expect to
unless there's something non ABI compliant about the types
usd seems like the jpeg2000 of fbx
they turned that format into a weird collection of things, nothing straight forward, like gltf where you just look at the spec and find what you need to know
instead usd seems to be a collection of 20 things with weird ass names again where each stands for some facet of the universe usd supports
the sdk for fbx is kind of intimidating
from a zig perspective anyway
if I was just writing C++ and using visual studio it wouldn't be a problem
I think gltf does everything I want for now though
yeah i think its more than enough
USD doesn't seem like it's intended use is real time rendering
although it can be used for that
my understanding its more like a transport format for inbetween all sorts of software in the industy
something like collada tried to be 20 years ago
oh shit, maybe I can't use these assets from the book in my open source project
you might find similar ones on sketchfab.com
I think maybe I create a branch I don't push to my repo for now
for just the assets idk
I'm not going to push anything copyrighted to it
oh I'll just put them into the application data folder I already have
and show an error if that scene is loaded with those files I guess
what I should do actually is just create a generic viewer
and it can load any of these things based on what's in that folder
and just shows an empty list if nothing is in there
idk
very nice assets here which are all CC0 https://polyhaven.com/models
they are all extremely high poly
wow thank you
these 150+ page chapters are so exhausting
even if I am learning
I thought this diagram was unintentionally funny
if you were looking for a way to get your multi-threaded concurrency to operate as fast as a single thread using a mutex will do it for you
based on my current progress I think I'll be rendering again by next weekend
if work doesn't end up taking up my evenings
#1248864886772072591 message last time I did any rendering was 2 weeks ago, so 3 weeks of reading 😅
this should probably be the last time there's so much reading without rendering as I had these GEA big chapters on hold until I got through the basic math through projections, it's like all rendering from here on out, with some physics and animations somewhere along the way, but the big meaty render-free chapters will all be behind me
well two of the last three chapters in game math are purely physics and they're big chapters, but that's a while from now
Ya‘ll GEA is really transparent about who this book‘s intended audience is and it’s not individual devs building their own engine
A hundred or more developers plus a QA team is a minimum requirement for the book to be applicable
@delicate delta https://vkguide.dev/docs/extra-chapter/multithreading/
btw that atomic-fence assert thingy is very useful
but using volatile in 2024 is absurd
use atomic but use relaxed mode which is basically the same as a volatile load
btw I'm totally going to cheat and read the spec and the vulkan programming guide book before I do your guide :P
but I'll do it
I might actually do it in C++ though because you use the bootstrap stuff, or partially in C++
for multithreading if you are interested just go grab taskflow
holy shit this is great, thank you
just make absolutely sure you quarantine the fuck out of it into a pimpl or similar with a wrapper
taskflow oblierates compile times on anything that includes it directly
oh ok
what do you mean obstruct
does work ever wait to be done
the parallel for does, the other doesnt
see the future.wait() on the parallel for, while the other has nothing
oh I see
I meant more does it block waiting for work to start
as in waiting for other threads to finish
I see a count but it's not clear to me how it's used
it looks it just returns without doing the work
oh you're scheduling multiple workers there
up to 4 workers
its a very simple atomic style parallel for
it launches 4 workers, then each worker does atomic add to grab what index they are going to execute
taskflow has its own parallel for, but you cant control how many workers it launches
FYI bjorn you can multithread GL rendering just fine you just need to use persistently mapped indirect draw buffers and a bit of extra structure to manage what's being recorded
It's not like Vulkan where you can write commands to switch pipelines and vertex buffers and stuff but the draw calls themselves (assuming the state setup is handled elsewhere) work fine
So it won't be as generic as Vulkan threading but if you have several systems that have a large specialized workload like CPU particle systems or foliage instancing or whatever you can easily fill the data/draw buffers on a thread
And then at the final render step you pull up each system, use its internal state to bind whatever input data it needs, and then dispatch your indirect draw buffers
Ah I tried something like with blockens but hadn’t gotten to indirect
i wouldnt recomend it
for gl what works great is a custom RHI command system
kinda like how unreal works, you have a thread whose sole thing is to do ogl api commands
the rest of the threads build a command buffer and throw it into that api thread
as a bonus if you have that sort of thing you can also use it with vulkan and others
I don't have an RHI at all I use GL directly
thing is that if you are going full indirect your cpu cost goes so fast you dont even really need to MT it
my current block engine is fully ST on the renderer
Mine isn't full indirect since there are a lot of things I need to do on the CPU but it's still fairly indirect
Like my foliage system still has a lot of CPU labor to fill draw buffers but since it just fills data and indirect buffers (double buffered too) it could trivially be moved to a thread
I am running it single threaded too but I'm just extrapolating
Or if you're going to just do CPU frustum culling or something
But yeah it's true if you rolled your own command system then you could multithread the actual swapping of pipelines and stuff as well
I'm a bit of a ways away from this probably being anything I will have to tackle, I think once I get to building a game it will be small levels with low mesh counts to start with, but I am trying to build out a broad foundation of understanding so I recognize problems and understand things people are talking about on this server
I finished Chapter 5 of GEA
I read straight from Chapter 2 to 5, 350+ pages and took comprehensive notes
I am over it lol
Chapter 5, a basic game math overview, was very good. I think it's very much worth reading. I really liked reading about the math from someone who is not a mathematician but actually creates games, shipped The Last of Us 2 and Uncharted, and Medal of Honor. I get a sense of what's important. I also found his short explanations and definitions way better than the math heavy explanations from my math books and I liked his description of how he's used some of the math in games.
I am basically going to focus on https://athena.ecs.csus.edu/~gordonvs/textC3E.html now and get through OpenGL stuff and actually render. I might switch back to GEA every couple of chapters so I can make a little bit of progress on it a bit at a time and not do another 300+ pages of it
I'm going to get back to my math books after C3E, it's all just rendering from here on with physics at the end
Actually
I realized something today from reading chapter 5, my matrix rotations are incorrect for a left handed coordinate system
If I stick my thumb out and curl my left hand, my fingers rotate clockwise
my rotations are all righthanded!
pub inline fn rotationY(angle: f32) matrix {
return mc(.{
- @cos(angle), 0, @sin(angle), 0,
- 0, 1, 0, 0,
- -@sin(angle), 0, @cos(angle), 0,
- 0, 0, 0, 1,
+ @cos(angle), 0, -@sin(angle), 0,
+ 0, 1, 0, 0,
+ @sin(angle), 0, @cos(angle), 0,
+ 0, 0, 0, 1,
});
}
fixed
None of my other books explicitly said it, but GEA did
they did point it out when talking about the cross product but my brain never connected it to the rotation matrices when I wrote them
like this would still be wrong if I had skipped this chapter or hadn't read this book, this is why I'm reading
im picturing you doing that finger thing 😄
hrm
im not trying to make fun of you
but my rotation around the y should be reflected across the diagonal?
pub inline fn rotationX(angle: f32) matrix {
return mc(.{
1, 0, 0, 0,
0, @cos(angle), -@sin(angle), 0,
0, @sin(angle), @cos(angle), 0,
0, 0, 0, 1,
});
}
pub inline fn rotationY(angle: f32) matrix {
return mc(.{
@cos(angle), 0, -@sin(angle), 0,
0, 1, 0, 0,
@sin(angle), 0, @cos(angle), 0,
0, 0, 0, 1,
});
}
pub inline fn rotationZ(angle: f32) matrix {
return mc(.{
@cos(angle), -@sin(angle), 0, 0,
@sin(angle), @cos(angle), 0, 0,
0, 0, 1, 0,
0, 0, 0, 1,
});
}
is that just for right handed systems?
oh I know :P
they all rotate clockwise now when looking from positive into negative
which, making a hand gesture is correct
hmm rotationy looks different
i thought the sign is flipped for the two sin()
pub inline fn rotationY(angle: f32) matrix {
return mc(.{
@cos(angle), 0, @sin(angle), 0,
0, 1, 0, 0,
-@sin(angle), 0, @cos(angle), 0,
0, 0, 0, 1,
});
}
but this is correct given the left hand rule
you can see I move the y positive
then looking from the positive into my thumb
the thing rotates the same direction as my fingers
so I think the matrix is correct
and that's how all the other axis rotate
is the Y supposed to rotate opposite the other axis?
what is your world up here +X Up?
so if this were right handed it would be reflected
but because my coordinate system is cursed it's not
I want to hire a math professor to evaluate my zig math
hmm what if you flip the two sins?
it rotates the wrong way
Claude says this is correct for a right handed coordinate system
i dont trust LLMs
Discord is a flawless piece of software with absolutely no bugs or glitches whatsoever
Especially with obscure things!
What does claude say if you ask it to design an LLM architecture?
as I have a left handed coordinate system
https://en.wikipedia.org/wiki/Rotation_matrix#Basic_3D_rotations it is right handed, indeed
that embed
ok well everything is rotating around correctly with my matrices that I pasted above
so I'm keeping them
also, when you flip the coordinate systems you flip one of the axis right
so this makes sense I think
if my translations are correct and my rotations are correct and I don't have two left hands then this is correct
perhaps add some conversion matrices
so that you can easily convert from XUpRH to YUpLH or something
so much stuff breaks if I do that though
unit tests : >
no no the math breaks
my projection will break, my frustum extraction breaks
actually no my projection is fine
so your code breaks, not the maffematics : >
because I convert to Y up prior to projecting
no
the math is different
I would have to write both right handed and left handed math
you are extracting planes always the same way, no matter how the frustum is oriented
that shouldnt break
when I extract the planes from the frustum the frustum is Y up
but my coordinate system is X up
so I have to convert them back
as long as all operations happen in the same coordinate space its fine, and then you just convert to/from if needed
plane extraction is not happening in the same coordinate system it's in clip space
I take the extracted planes and transform it by my full MVP matrix
then it works
they're antivectors
the planes
Alternatively
Hard code the transformation 
each one of my math books has a completely different coordinate system and the projection matrices they all use are different
😄
here's blender
it's a right handed coordinate system
it goes counterclockwise when looking in the direction from positive
so I'm doing it right
so unity is left handed
I think something is wrong in my math
I'm sorry I wasted time on this but everything is behaving correctly even though my matrices don't look anything like anyone elses
☑️ my GL winding order is clockwise
☑️ my matrix rotations rotate clockwise when angle is increased across all 3 axes
☑️ my quaternions rotate clockwise for positive angle changes across their rotation axis
☑️ my positive x translate goes up, my positive y translate goes into the screen, my positive z translate goes right
things that are weird:
my coordinate system transform doesn't have a reflection ?
my extracted frustum plane normals require negating the normal to work?
my extracted frustum planes require a transposed perspective matrix to extract?
my y rotation matrix negative sin is not reflected across the diagonal compared to x and z rotation?
Tfw you choose an exotic coordinate system and have to suffer the strange consequences of it 😭

(just teasing)
I honestly couldn't say whether those weird things are expected or not though
But I would definitely expect sign changes and flipped columns and stuff
the y rotation one seems plausible
haha
I'm sure the moment I import a gltf I will have something fucked, if not, then good, if so, I fix whatever happens then
but I'll wait until then
You should just be able to pass all transformations through a matrix that converts coordinate systems
yes
@elder kettle your winding order in your RHS coordinate system is counterclockwise and your rotations for increased angles all go counterclockwise?
Yeah
nice
oh right winding order
yeah you may need to swap the winding order or reorder the indices
no I just did that
so they're all clockwise now
they were counterclockwise which is incorrect for LHS
I was wondering if in your coordinate system they're counterclockwise
I sunk some time into this today so a bit of lost day progress wise, but I want to be intentional about my coordinate system and have it all be correct as much as I'm capable of, glad I read that chapter though
the right handedness is applied to everything generally
I guess you could choose left handed winding in a right handed system but idk why you would
don't you have to be intentional about it if you do your own geometry
The choice of handedness is arbitrary so you may as well choose them to be the same
Yeah you do but it's arbitrary
the cross product produces a vector in a direction based on handedness, I would like my surfaces to be visible in the direction the cross product produces a surface normal given the same handed winding order
I had to fix that today
oh yeah changes the cross product too lmao
I hope you try a right handed coordinate system sometime before you get too used to this one because if you ever get a job where you actually need to do math it's going to be unbelievably confusing to be more intuitively familiar with this extremely nonstandard system
some game engines are left handed though
yeah but I was just doing it differently as a means to learn so I wouldn't just copy and paste matrices, but had to figure this stuff out
if I had just gone with a RHS Y up I wouldn't have had to fix all this and wouldn't have learned what I've learned
fair enough
these math books just declare what coordinate system they use and never explain how that choice changes the math
all these books are like that
they do go over the cross product though
yeah that's what I appreciated about GEA, it actually mentions that explicitly
it's not even a math book, it just has a math chapter
that actually was the first thing I thought about when I woke up this morning, I finished reading at like 1 am, went to bed and woke up thinking wait are my rotations going in the right direction? lol
they weren't
Someone leant me this book at work last year when we were working on a particularly nasty rotation problem and it was very unhelpful because it just assumed one specific choice of convention
and we were trying to work out the impact of those choices
actually that was 2 years ago damn
Oh damn, that book looks cool though
my enthusiasm for it was rather dampened by its lack of rigor in that regard but it was decent yeah
still helped me understand the problem I just had to figure it out myself
Yeah that sucks
Your team are like the people that get called when Apollo 13 is stranded in space and they need math to rescue the crew
Alright finished the 3D math chapter in the Graphics Programming in OpenGL with C++ book. There's was nothing new in that one. It's just rendering now, with some GEA progress every so often along the way.
Same tbh
I'm also not pushing models due to both copyright & size
Yeah it was a long read and I think I successfully managed to forget most of it lol. But it's a nice overview. I'd still take a look at this chapter if I wanted to delve deep into multithreading, just to see a big picture view again, before moving on to detailed resources.
Hmm maybe I shouldn't have skipped it
Not necessarily
You can transform the transformations too
For example I use LH coord system where Z points forward (towards the screen), x to the right and y up. glTF uses the same X & Y, but it is right-handed so its Z axis points towards the user.
So when importing node transforms from glTF, I construct a change of basis matrix from glTF's to mine, which consists of my x y z cardinal axes, just the z is inverted, as that is the only difference between the two systems.
I just have to sandwich the glTF space transformation between this change of basis matrix & the other way around change of basis matrix (from my system to glTF), which happens to be the same matrix if you think about it!
How do you translate back and forth between coordinate systems that use different basis vectors?
Help fund future projects: https://www.patreon.com/3blue1brown
An equally valuable form of support is to simply share some of the videos.
Home page: https://www.3blue1brown.com/
Future series like this are funded by the community, through Patreon, w...
The second part of this video is a good touch up on the subject of change of basis for linear transformations
Exactly ...
Thanks!
You probably knew these as well but just wanted to hint at it. You can of course create conversion functions between coord systems too but if it is just to interface with different formats, maybe you can "cheat" like this too.
I am not sure, but I will find out how much trouble I am in when I add a mesh loader 😅
It should be fine I will just always apply the transformation to my coordinate system at the end after all object space transformations and animations
chapter 4 CGPOC first program a plain red cube, with zig and my existing scene flavor

program: u32,
location: c.GLint,
const Uniform = @This();
pub fn init(prog: u32, name: []const u8) Uniform {
const loc: c.GLint = c.glGetUniformLocation(@intCast(prog), @ptrCast(name));
return .{
.program = prog,
.location = loc,
};
}
pub fn setUniformMatrix(self: Uniform, m: math.matrix) void {
const v = math.matrix.array(m);
c.glProgramUniformMatrix4fv(@intCast(self.program), self.location, 1, c.GL_FALSE, &v);
}
const c = @import("../c.zig").c;
const math = @import("../math/math.zig");
my little don't look uniforms up by name every frame code :/
idk
Fortunately I can't make heads or tails of this language so I can't pass judgement on any of your code
yeah the casting is a bit noisy
because I'm dealing with C types and I am using zig
otherwise this would look a lot like C
it just builds a struct with a method that I can call setUniformMatrix on every frame with a 4x4 matrix by location
const Uniform = @This(); is just a compile time thing to assign the surrounding struct type as variable with a name to use
I am going to have to add stb_include to proceed
the book wants me to add a bunch of matrix math in the shader
and I don't want to copy and paste
What's the math for
it's not really math it's just transformation matrices actually
I'm just curious what you're doing that already has so much matrix math, tbh 90% of my vertex shaders are like a 3-liner
void main()
{
gl_Position = viewProj * model * vec4(in_position, 1);
out_normal = model * in_normal;
out_uv = in_uv;
}
well I'm just following the book, but this example is a bunch of instanced cubes that rotate every frame and it does all the rotations in the shader
I'd do the rotation on the CPU tbh
it's like 10K cubes
well it's just a tutorial in the book
Alright fair enough
also 10k isn't that many you could still easily do it on the CPU
after this it does a hiearchy mesh with animations, sorry its 100k
I agree though
it's being silly in an early chapter
Generally the scenario will either be CPU transforms put into an SSBO for rendering, or transforms done in compute and then read in the VS
it's like teaching instancing
because the odds that you only need the transformation matrices once is unlikely
I just kind of want to see if I can use stb_include in zig
stb_include is uncessary I can just use std.mem.concat and @embedFile
I just copy paste personally
yeah that works
I have 16 vert shaders for my project, they don't get made that often so idrc
Most things that are complex enough to warrant reusing aren't generic enough to need to be reused
I have a whole bunch, each scene has its own, and they're all the same
this is the first time I'm doing anything fancy with a shader in this project
Well I only have one scene
Mine are all different
But they're short enough to not be worth trying to use common code
But I did recently start using stb_include for my foliage stuff but that's because it's a relatively complex system with many SSBOs and interpretation steps to generate the actual transform data from the compressed buffer elements
for stb_include what do you use for your path?
file path
is it part of the project root?
do you have like a resources or app_folder that you use?
I guess it's a visual studio thing
I have a resources/shaders folder
Eventually I'd have the game exe in root and then access the resources folder from there but for the time being I set a specific working dir in VS
looks cool 🙂
also cool to see these patterns emerge everytime you do silly stuff like that
GPU instancing, I’m assuming?
Just draw elements instanced, but all the animations are in the vertex shader
I am just sending frame time and using instanced id
GPUs are cool
That’s GPU instancing, yeah
Nah, not in this case
I need a Graphics Programming dictionary to understand the words people use on this server
me too
I generally just use terms I see others use or terms I come up with on my own, lol
GPU instancing is one of the ones I saw someone else use
I think GPU instancing is just another term for draw instanced but I’m not 100% sure
Probably
This is a great new addition to my tech
babble speak I use to ask product managers for more time to get something done
Just kidding I don’t do that

So
Pytorch
Having had rewritten my AI like 7 times so far
… pytorch is great, though I’m still not a fan of python’s lack of explicit typing
… and the lack of curlies
… or even at leastlua if (condition) then logic endlike LUA or TI basic
Yeah I don’t like python or ruby or any of these languages where white space is a significant part of the syntax
I used to write python as a job, like in 2010
But it was a step up from PHP at the time so I was happy
I like being encouraged to type things and discouraged from not typing things
Because having that makes it a lot easier to just grab library, go since I can use the type hints to resolve how to use a library far faster than without those
I also like having something equivalent to curlies because copy/pasting and formatting becomes painful without those 
It’s kind of crazy how python is dominating again, I thought for sure python 3 debacle and Go were going to be the end of python
Being able to arbitrarily separate a random snippet of code into its own block is… pretty nice as a formatting option
Lets me indent a thing to make it stand out without having a syntax error, and I can just put a comment above the block to state the blocks purpose
I frequently use just two curly braces in zig just to create a block to temporary scope and isolate work
Yep
I do that sometimes in java too
And it makes code more readable
And my god do I wish I could do that in python 
Need it there more than I do in java 
Have to make a bunch of inline functions or use a lambda
You can nest functions in python
if True:
# code
Nah just lambda it
funfact; scopes don’t really exist in python!
It’s definitely more fluid
if cond:
x = 5
print(x) # error if cond is false, elsewise prints 5```
usability of python
python’s syntax
ehhhh not sure about that one
struct Matrix[type: DType, rows: Int, cols: Int]:
oh
Struct syntax is closer to records than classes
The life of a value in Mojo begins when a variable is initialized and continues up until the value is last used, at which point Mojo destroys it. This page describes how every value in Mojo is created, copied, and moved
Mojo seems like an improvement to me

obviously the solution is to make the best language model on the market, and then make it only run on my own custom AI framework written in java
Or zig
I still need to take a closer try at zig 
Not quite a good time to try zig imo unless you are cool with rewriting code a bunch of times all the time
Just kidding it’s not really that bad, but it’s a new language still under significant development
You are signing up for that when you use zig
cube and pyramid from chapter 4
my colors aren't nice as in the book
it's like a combination of my x up and my own geometry is a little different, I don't like theirs, but I'm using their colors
sRGB moment probably
it's all srgb
but yeah in the book they don't use it
so yes, that's part of it
I can disable it easy enough per object idk
There is "Line" support in stb_include, which looks %99.9 trivial to implement but I didn't bother with it and just used stb_incude for shader includes
Not necessary yeah
I just was able to use zig’s std library to concatenate shader source I can directly embed using zig built in ‘@embedFile’ so I just didn’t need to deal with run time file loading and C memory management and c null terminated char arrays in zig
I will eventually just compile shaders to spirv from straight zig source anyway so all my shader code will get reworked
perhaps you can also make the background color not true black, but {0.01f} or so
yeah that black background is terrible
I keep forgetting to change it when I'm working on the project
been meaning to for weeks now
: )
that and the imgui theme
this new coderabbit ai PR review feature is neat
using the green theme you shared
looks way nicer than black
and default imgui theme imo
I like that green dear imgui theme
it has orange highlights
I see no orange
I am going to alternate each chapter of CGPOC with one with GEA so I keep making progress on that giant book
so chapter 6 of GEA is next
Damn that imgui color scheme is nice
It is very cool bateman but that's nothing
Yeah I agree
I think my eventual game will be construction zone themed, so bright orange and yellows
concrete gray
I should start working on the 3D models for that game while I learn about graphics programming
Sounds cool can’t wait to see what you come up with
I have a tower defense project in mind but not sure if I’m gonna follow through on that one
I love tower defense games
especially if it's not on rails and the creeps have to pathfind and you can build obstacles
That’s the exact game I had in mind 😄
You build the path by placing towers on a grid
I really like chapter 6 of GEA, the memory section in particular with per frame memory and all the custom allocators
the rest of it was like CS101 and otherwise felt like big studio problems though, like internationalization and configuring a massive engine
yeah for sure I'm going to build a web portal for my internationalized strings and engine configuration
oh though I did love the scheme -> C++ header section for building configurations for animations, physics parameters, player mechanics and stuff
reminded me of Madrigal's tools
one GEA chapter at a time is the way to go, way easier to deal with, did one chapter in a single day today, back to rendering tomorrow, CGPOC chapter 5 is about textures 
i18n is a mess especially in windows with all this utf crap
Ryan Fleury’s videos on memory arenas are nice too
Zig actually ships with an arena allocator
I am going to have to build an asset loader to do this chapter, I'm not just calling stb_load_image in the middle of my scene code
just going to build the bare minimum to load textures but in a way I can add models and other stuff later
not going to get fancy with comptime I just want to make progress and I'll probably change the loader once I get through GEA and learn more about it
and after read some of the other engine books I have too
still quite a bit of work even so
I tried to do the bare minimum but it took a lot of time still
ok ok ok ok so close
so much work
it's like 3 lines of code in the book, it's a massive PR in my engine
ok texture is loading
now to add texture coordinates
much work, but real close now
this is my DSA texture object in zig
name: c.GLuint = 0,
texture_unit: c.GLuint = 0,
const Texture = @This();
pub fn init(image: *assets.Image) Texture {
var t: Texture = .{};
var name: u32 = undefined;
c.glCreateTextures(c.GL_TEXTURE_2D, 1, @ptrCast(&name));
c.glTextureParameteri(name, c.GL_TEXTURE_WRAP_S, c.GL_CLAMP_TO_EDGE);
c.glTextureParameteri(name, c.GL_TEXTURE_WRAP_T, c.GL_CLAMP_TO_EDGE);
c.glTextureParameteri(name, c.GL_TEXTURE_MIN_FILTER, c.GL_LINEAR_MIPMAP_LINEAR);
c.glTextureParameteri(name, c.GL_TEXTURE_MAG_FILTER, c.GL_LINEAR);
c.glTextureStorage2D(name, 1, c.GL_RGBA8, @intCast(image.width), @intCast(image.height));
c.glTextureSubImage2D(
name,
0,
0,
0,
@intCast(image.width),
@intCast(image.height),
c.GL_RGBA,
c.GL_UNSIGNED_BYTE,
image.stb_data.ptr,
);
c.glGenerateTextureMipmap(name);
t.name = name;
return t;
}
pub fn bind(self: Texture) void {
c.glBindTextureUnit(self.texture_unit, self.name);
}
const c = @import("../c.zig").c;
const assets = @import("../assets/assets.zig");
just hard coding all those settings atm
success
doesn't look like much but I now have a full fledged texture asset loader
that caches
adding additional textures is super easy
and it loads from the windows app data directory so none of these copyrighted files are in my repo
unless they are HDR because I skipped that

I'm going to fix my 100 shaders
all my scenes have their own shaders
I'm going to make it so my vertex vao/buffer code owns the vertex attributes part of the vertex shader, my instance buffer code owns the that part of the vertex attributes, and then the scenes can submit a main function, and most of my frag code is pretty much one of three, color, normals as color or, as of today, a texture coordinates sampler
it was really painful to add texture coordinates to all those shaders
I also want to switch to TQS instead of a 4x4 matrix for my instance matrices
I'm not going to do that right now
but this change will make that easier
mojang moment 
mojang has several shaders they don't even use in minecraft
the corresponding java code just flat out doesn't exist in the game's jar
which-
implies they generated stuff using scripts tbh
several of them are just rearranged element orders of others
they're likely not doing it at runtime nor comptime
hrm, right as part of baking a model or something is ok too
any kind of automation that's smart and efficient is good
mine were just literally copy and pasted
so a step up
there is a little mistake in it
in the storage call
you want to calculate the miplevels, and pass that in, instead of the 1
since you are generating mips
Oh
1 + floor(log2(max(width, height)))
might be 1 + ceil(...) i always mix the two
but for a 1024 texture you should get 10
Because I went the DSA way I didn’t exactly follow the book with that code and I will fix it thank you!
1 miplevel textures are the ones you use for fbos most likely
like gbuffer attachments
for those you dont have to call generatemips either
I was talking about the shaders 
so looks like the book didn't cover this at all because it uses SOIL2 to load the images and it does that automatically. I looked at SOIL2's code
int MIPlevel = 1;
int MIPwidth = (width+1) / 2;
int MIPheight = (height+1) / 2;
unsigned char *resampled = (unsigned char*)malloc( channels*MIPwidth*MIPheight );
while( ((1<<MIPlevel) <= width) || ((1<<MIPlevel) <= height) )
I am not using SOIL2 I'm using stb_image which doesn't do any of this and anyway I want to learn OpenGL.
Thanks for letting me know, they did discuss mipmap levels in the book but the book is more about concepts and not about the OpenGL API specifics and they say to go look it up
in this case I didn't follow the book's instructions to look at all the parameters of the functions I was using 😅
soil and stb just load the pixel data from disk/memory
and their documentation
nah
SOIL2 is a tiny C library used primarily for uploading textures into OpenGL. - SpartanJ/SOIL2
this is SOIL2
they might have opengl helper functions to also create a texture
it creates texture objects directly
you just get your GLuid and you're good to go, you do have to specify sampling
++MIPlevel;
they upload every mip manually
i was about to mention earlier that you can do that as well
but you still need to allocate those maps in the storage, when using glTextureStorage
would prefer to just call the glTextureStorage2D unless that's not performant or something
I don't know I guess it depends on the outcome
just cater for mips if you need them, otherwise miplevels 1 is fine
if there's some issue with how I'm doing it and I get artifacts or it looks wrong or is slow I can revisit but I will fix that 1 level I have right now
cater for mips? what does that mean?
make space for them, when calling glTextureStorage, by telling it how many mip levels there are
I'm going to go read the spec I guess
glTexImage2D != glTextureStorage
yes
thats what i am talking about
i omitted the 2d because there is a 3d variant too
i thought that was obvious 🙂
my reading of this in the spec is that by supplying a levels will result in the storage for the arrays required for when I call glGenerateMipmap
oh that's what you said
ok ok I think I understand thank you!
looking at the SOIL2 code makes sense now
I changed it to
const w: f32 = @floatFromInt(image.width);
const h: f32 = @floatFromInt(image.height);
const mip_map_levels: c.GLsizei = @intFromFloat(@ceil(@log2(@max(w, h))));
c.glTextureStorage2D(name, mip_map_levels, c.GL_RGBA8, @intCast(image.width), @intCast(image.height));
just your regular zig casting mayhem
I am going to add this to my notes
these are my mipmapping notes
- Mipmapping
- MIP stands for Multum In Parvo, Latin for "much in a small space"
- stores a series of successively lower-resolution copies of a texture imagee
and then repeating the process in the remaining one-quater of the image
space for the same image at one-quarter of the previous level or the
original resolution if at the beginning, and then subdividing further until
the remaining quadrant is too small to contain any useful image data.- will require storage that is 1/3rd larger than the original image
- in older systems it might possibly do this in separate R, G, and B
components- used for preventing artifacts caused by image resolution issues when
texturing mapping objects during rendering.- can be used with linear filtering, bilinear filtering and trilinear
filtering using one or two mipmaps at nearest resolution and use one more
texels to interpolate a color- levels to mimpap to depend on context, but given width w and height h for an
imageceil(log2(max(w, h))will produce the max possible levels
if you have no mips, but have enabled generating mipmaps. you will get a fancy effect going which looks like "fog"
because when it samples into nothing ness (because you have mipmap filtering going) it will returnnothing and that will most likely black, but since its interpolated you see something like fog
oh neat hrmmm
so it's sampling the texture and undefined values and interpolating them?
asking the old gods for what the color should be at the pixel location
yeah
my notes btw
$ .\Count-Lines.ps1
Current markdown line count: 12861
who needs functional memory when you can just write it all down
: )
finished chapter 7 of GEA, pretty cool stuff about asset conditioning pipeline and resource management and file system stuff
time for loading 3D models I guess
switched my sphere to use the one from the book, it's better, mine was over complicated, and it had texture coordinates
I did the single point at the ends thing with mine, I also had way too many vertices
the one in the book you can set a precision on it
too spherical? :O
Just trying to tempt you down the nightmare of physical geodesy
// Generate bindless handle
t.handle = c.glGetTextureHandleARB(t.name);
if (t.handle == 0) {
return TextureError.BindlessHandleCreationFailed;
}
// Make the texture resident
c.glMakeTextureHandleResidentARB(t.handle);
t.uniform = Uniform.init(program, uniform_name);
pub fn setUniformHandleui64ARB(self: Uniform, handle: c.GLuint64) void {
c.glProgramUniformHandleui64ARB(@intCast(self.program), self.location, handle);
}
#version 460 core
#extension GL_ARB_bindless_texture : require
out vec4 fo_frag_color;
in vec2 f_tc;
layout(bindless_sampler) uniform sampler2D f_samp;
void main()
{
fo_frag_color = texture(f_samp, f_tc);
}
idk why people need to use radian conversion when dealing with 360 or 180, that's just 2 * pi and pi
actually zig has std.math.tau 
this book is creating the same matrix in a loop over and over again
// rotate the first ring about Y to get the other rings
for (int ring = 1; ring < prec + 1; ring++) {
for (int i = 0; i < prec + 1; i++) {
float amt = (float)toRadians((float)ring * 360.0f / (prec));
glm::mat4 rMat = glm::rotate(glm::mat4(1.0f), amt, glm::vec3(0.0f, 1.0f, 0.0f));
vertices[ring*(prec + 1) + i] = glm::vec3(rMat * glm::vec4(vertices[i], 1.0f));
texCoords[ring*(prec + 1) + i] = glm::vec2((float)ring*2.0f / (float)prec, texCoords[i].t);
rMat = glm::rotate(glm::mat4(1.0f), amt, glm::vec3(0.0f, 1.0f, 0.0f));
sTangents[ring*(prec + 1) + i] = glm::vec3(rMat * glm::vec4(sTangents[i], 1.0f));
rMat = glm::rotate(glm::mat4(1.0f), amt, glm::vec3(0.0f, 1.0f, 0.0f));
tTangents[ring*(prec + 1) + i] = glm::vec3(rMat * glm::vec4(tTangents[i], 1.0f));
rMat = glm::rotate(glm::mat4(1.0f), amt, glm::vec3(0.0f, 1.0f, 0.0f));
normals[ring*(prec + 1) + i] = glm::vec3(rMat * glm::vec4(normals[i], 1.0f));
}
}
they could just create rMat once in the outer loop?
something I don't get about C++?
glm::mat4 rMat = glm::rotate(glm::mat4(1.0f), amt, glm::vec3(0.0f, 1.0f, 0.0f))
rMat = glm::rotate(glm::mat4(1.0f), amt, glm::vec3(0.0f, 1.0f, 0.0f));
rMat = glm::rotate(glm::mat4(1.0f), amt, glm::vec3(0.0f, 1.0f, 0.0f));
the state of wavefront obj loaders in C and zig is not great
I will have to write my own
tinyobjloader_c loads from files
that was my problem with stb_include as well
I don't want to use C to read files
stb_image lets me give it the bits
every time I want to use a dependency, some other library, and I see the state of zig I just feel despair man
people just cannot keep their shit up to date
if you aren't along for the ride don't write a library in zig you know
you're just creating litter, it's littering, it should be an arrestable offense, straight to jail
I have never written a zig library and I never will
I'll probably end up writing my own gltf parser too
and eventually replace all my dependencies with just my own zig code
this looks weird though
I don't think that's in the texture
I had to
- self.texture_coordinates[t_index] = .{ s, 1 - t };
- exchange the first face with the third face for all f 1/1/1 2/2/2 3/3/3 (so had to switch 1 and 3)
- I had to add a reflection matrix in my shader that reflected along one of the axis
- turn off SRGB
cuz LH x up mayhem never ends
oh and also write my own obj parser
when doing lights
PLEASE add options for falloff modes 
inverse square is annoying to work with if you want a specific light length 
I don't make these things, they came with the book
:\
that's good to know though
is that a material thing
like I am just going to write my own lights?
uh
whenever doing lights, you're going to have do some kinda shader
somewhere in that shader will be a falloff mechanism
the physically accurate one is inverse square falloff, which tends to result in lights either not going far enough or being way too freaking bright 
in my case, it's ending up with the light not falling off fast enough, since I'm not going for stylistic lighting rather than realistic lighting
ok what's the light GUI thing you're showing
is that a godot thing
are you doing things in blender? do you import that somehow? I'm just not following
this is blender
I'm familiar with fall off
I just don't know why you're showing me light settings in blender :P
because it seems the fall off setting was removed from blender and it's bothering me 
hrm
basically
inverse square falloff is a lot harder to tune in, but it's physically accurate
linear falloff is really easy to tune, but is not physically accurate
I assume
ngl I kinda feel like linear is the more accurate one
solution for my problem: use a negative brightness sun 
why? yes 
what are you doing in blender
Recreate and pose a model to use it as a reference for a drawing
Obj is such a nice and simple format
it was fun yeah, but my weird coordinate system always ruins all the fun
everything I do is always broken at first
and broken in just the weirdest way
3 of those sound relatively standard for objs, actually
and what incantation of flipped signs, subtract from one, reflection, switch around vertices will I have to do perform to fix whatever thing is always a mystery
Obj uvs tend to be upsidedown for some reason 
maybe grassman algebra avoids all this maybe I should get serious about it
I just have to think in 4 dimensions across hyper geometry

it's how we will ascend

:P
I should put that emote in my about me whenever I next get nitro
which, quite literally, might happen if I go on hiatus for a week 
pretty sure there have been like 3 instances of discord just giving me nitro because I was offline on vacation for a week 
nitro is your drawing app? you have like 10 projects
discord nitro
oh

you have to have nitro to put an image in your bio?
Yes
I’m like
99% sure
I’m pretty sure I only have an animated emoji in my bio because discord is funky and didn’t automatically remove it 
I’m not sure, and I don’t want to test, because if I’m right, I can’t undo my test 
10 might be a tiny bit of an underestimate
(Most of these are on indefinite hiatus)
There’s also a few not included in that count 
Drawing app is doodlart 
But currently I just use krita
ok ok ok, I finished the 3D models 6th chapter of CGPOC, I finished writing my notes. Next is a relatively short chapter in GEA, chapter 8, which is about the game loop and real time simulation, and then next in chapter CGPOC is lighting, which will be the first time I ever do lighting that isn't the fake minecraft lighting I did in Blockens
yeah chapter 8 of GEA is like 34 pages, which is probably the shortest chapter in that book
I have to read like 3 or 4 pages in GEA for every page in CGPOC
This is a new book I got
Convenient timing with me getting annoyed with blender’s lights 
At least it’s not 6 days 
I'm going to exercise and go to bed, good luck with your drawings in Krita
Oh I’m not on pc
Nor do I have the model (it’s a minecraft model and I need to deblockify it before I can draw it because perspective and shapes are not things I’m great at)
I’m about to go to bed too 
But something tells me you have a healthier sleep schedule than me 
gotta get rest!
As I understand it
With inverse square, the brightness falls off with distance automatically based on the brightness
So if you have a stupidly large room, you need the power of the entire sun to light it up, even if all your objects are also scaled up to match
Can’t really tell it hey go further without telling it hey be as bright as the freaking sun afaik
With linear this is not a problem
You specify brightness, and distance
It linearly fades off based on vector length between the source and the fragment from brightness to 0
That’s good to know!
Next week I have to go to Salt Lake City for work and drag two work computers with me so I probably will not make much progress then. I may just read the Vulkan spec or something
Completely unnecessary trip tbh
The Mastering Vulkan book would fit in a plane seat.
mastering vulkan book is amazing
its deeply under-rated
the thing actually walks you in detail into implementing quite a few fancy modern techniques
the volumetrics i have on my engine are copied from there, it was a huge help
yes it looks really good
Hmmm good to know
Advice: don’t accidentally offset a model by 0.00001 pixels
Someone may notice it 
(One of my online friends accidentally offsetted a model by a very small value a long time ago, and well… I was the one who noticed
)
pixels?
that's a value approaching a number lower than ULP
say ULP is v 1 + less then v doesn't change anything
unit in last place or whatever
I don’t remember exactly what the value was
But it was small enough that it was like maybe a pixel’s difference from less than a unit away iirc
hrm
sorry I was referring to machine epislon
I finished chapter 8 of GEA, pretty short chapter about render loop and time delta and a job system. I read chapter 7 of CGPOC which is all lighting and so I'll be starting on some lighting work today, I also noticed the chapters have exercises for extra things to do and I like them and I think I will do some of them. Really excited
I also realized I can still work with renderdoc, my texture abstraction is pretty great, I'm going to add a command line arg the texture object is aware of and switch between bindless and texture binding based on it so I can just pass in a command line arg in renderdoc and it will use the old style of texture binding
I'm also going to add a default magenta 1 px texture whenever a texture doesn't load instead of it just appearing black
I have a lot of work to do the rest of this week just on lighting, then on to shadows probably after next week, I won't be able to do much due to work travel but the weekend I should be productive again
This is an interesting blog post from Ryan Fleury from Rad Game Tools at Epic about memory allocation https://www.rfleury.com/p/untangling-lifetimes-the-arena-allocator
I'm going to read it a few times
remember when I spoke about discord giving me nitro? 
yea they just randomly decided to give me a full month for free
why
no idea

i just cancelled mine, after 5 years
discord™️
hrm
discord was like
nitro (one month free)

there's no viable alternative to discord
so I'm not making any changes personally
but I respect these choices, discord has many flaws
yeah discord just give me nitro randomly
🤷 idk why
takes up 37 characters in my about me 
it didn't notify you in some way with a message?
I think you just paid for it and are lying 
ok I am sorry I doubted you and accused you of telling untruths
pretty sure I've gotten like 3 trials of nitro at this point 
Long read but worth it imo
His language seemed a bit abstract at the beginning parts of the post
I also re-read it a couple of times and aside from the beginning parts, the rest flowed more naturally imo
the handmade club also likes to sound a little elite
hey, zig nightly now has labeled switches!
const val = s: switch (six) {
0...4 => break :s false,
5 => break :s false,
6...7 => break :s true,
else => break :s false,
};
this is amaze
assign to variable directly from a switch
so I made a command line arg to use texture binding
and now I have a working renderdoc again
also added a 1 texel sized debug texture for when loading a texture fails
Hey this is that thing in J16 that was added that I didn’t realize how good it was until I didn’t have it 
There’s a lot of those
yeah it's really nice
Really basic Gouraud Shading, all in the vertex shader. First time I've ever done any lighting. My torus normals are mirrored so I need to fix that.
I had to fix so much shit. I had to separate out my matrices in camera, I had to add SSBO buffers. I had to add materials and lights. I had to idk, this took all afternoon and evening.
looks quite verbose, its neater in c#
You needed SSBOs for this?
no
No you can just spam uniforms
I can stick all my lights and materials in the ssbbos I made
can be an ubo too
True
ok fixed my normals and my colorspace, the gouraud shading looks correct now
can tell the normals are fixed better with this
ok on to phong shading
hrm
a torus is an interesting shape to test lighting with
trying blinn-phong next
SSBOs mainly become necessary when you need a lot of data. For example animation bone transforms.
makes sense
they're just nice to have though, why use UBO if I can use an SSBO
UBOs are potentially faster but it depends on the implementation
SSBOs are often implemented as a texture lookup
And you may or may not have any texture bandwidth to spare
you're saying it uses texture unit hardware?
This is what I've heard, but it's also possible to implement differently
interesting
For small buffers you should generally prefer UBOs
good to know, thank you!
a lot of gpu stuff is implementation dependent
you actually aren't even guaranteed to even have support for GL_NEAREST
I mean, I'm only targeting my own GPU :/
and any brave soul that wants to pull my repo
I do want to make a game eventually though
x up lh is not for the faint of heart though
Me later
Oh wait I might need to install a zig compiler

yes, and I stay up to date with zig nightly, I literally update my compiler every day
Damn
I use zigup if you're interested, but there's zigvm too
yeah, zig is...a lifestyle choice you know
Ah I see
I don't know if there will be a standard
They drop new C++ like every 3 years
I like C++ I wish I had good editor tools and nice dependencies
the community uses ZLS which is a language server, and it is frequently behind or broken
well it's not that bad
but it can be bad sometimes
huh
I think the blinn-phong in the book is incorrect
it calculates the halfway vector in the vertex shader
and then uses the interpolated value in the fragment shader
it loses all specular
if I do it in the fragment shader and use the L and V and H from there it looks correct
I have their C++ code but I don't want to build it
void main()
{
Material f_m = f_materials[0];
Light f_l = f_lights[0];
vec3 f_L = normalize(fo_lightdir);
vec3 f_V = normalize(-v_matrix[3].xyz - fo_vert);
vec3 f_N = normalize(fo_normals);
vec3 f_H = normalize(f_L + f_V).xyz;
float cosTheta = dot(f_L, f_N);
float cosPhi = dot(f_H, f_N);
vec4 f_global_ambient = vec4(0.7, 0.7, 0.7, 1.0);
vec3 f_ambient = ((f_global_ambient * f_m.ambient) + (f_l.ambient * f_m.ambient)).xyz;
vec3 f_diffuse = f_l.diffuse.xyz * f_m.diffuse.xyz * max(cosTheta, 0.0);
vec3 f_specular = f_m.specular.xyz * f_l.specular.xyz * pow(max(cosPhi, 0.0), f_m.shininess);
fo_frag_color = vec4((f_ambient + f_diffuse + f_specular), 1.0);
}
this works for me
made it a bit shinier with a f_m.shininess * 4.0
cool cool
lighting, we did it
vec3 f_ambient = (fma(f_global_ambient, f_m.ambient, (f_l.ambient * f_m.ambient))).xyz;
should be equivalent I think
what's fma
fused multiply add
I've never heard of that, I am getting a refund for all these books
I believe it's a little faster than (a*b)+c
I learn more from this server than from this tower of books fml
but I'm not actually sure if it is meaningfully faster 
it's also cleaner in some scenarios
Fma isn't just a GPU thing either x64 has it
I think what you're thinking of is image load/store
Texture logic is still specialized, and UBOs are ostensibly similar in perf because they may be put into special memory closer to the core
But SSBOs and image load/store are basically both just standard main VRAM read/write
I'm guessing texture lookup is quite a bit faster than SSBOs and image load/store still
This server is likely also a lot more willing to jump into the deep end than your books 
I'm still in the shallow end of the pool
Ok I changed what kind of game I want to make. I have a good idea for a simple game with a simple concept and small levels
An escape game, each level is a puzzle while your being chased kind of like RE2 but without any zombies or combat
The character you play is a little old obsolete robot scheduled for reclamation and you’re trying to avoid being caught
Not a new idea of course but would be fun to make and simple
No giant open world maps, easy occlusion, immutable terrain, hand made levels
Just like every small level has its set geometry and models and lights etc
And each level is its own small achievable goal to make and measure progress on
The fun will be in making cool looking levels and thinking of puzzles
Going to keep going on these books for now though
also I think my approach to making a game will be to make it playable, and then make it look good, and then iterate on making them each better in turn, but before I do anything at all fancy just have a bare bones thing that is playable instead of working on rendering first
like if it's just a couple of pixels moving around and that's a playable game that works as a start
like for the first level
If I didn't have a no combat rule I think I would just make a Doom clone, but I'm making this instead, which I think will be very similar and fun
This is where I first heard it at 38:20 https://www.youtube.com/watch?v=-bCeNzgiJ8I
Although this talk is 10 years old now
so maybe things are different
In this session, Cass Everitt and John McDonald from NVIDIA will talk about some newer extensions to OpenGL and how they can reduce (or even eliminate) driver overhead. We'll discuss where performance goes, how to effectively profile GL, as well as specific extensions such as bindless rendering and MultiDraw commands.
Speakers: Cass Everitt (NV...
ah the OG azdo vijeo
I'm going to add some more lights also
just wait till you learn about shadows
that's the next chapter
meanwhile I just accidentally setup a while true loop to create windows
for some reason
ctrl+alt+delete temporarily paused the window creation
which like, not gonna question it, considering that was my saving grace there 
you made an AOL punter
reason is because I'm making an ANTLR parser, and wanted to get a list of every statement in a sequence of statements
but I didn't know what to make my stop condition and accidentally ran with run instead of debug 
the freaking one time where it is extremely important for me to use debug is the one time I accidentally use run 
nice
that's kind of cool
each statement is open in its own window
Nice imgui theme haha

