3D Game Shaders for Beginners
github.com
github.com
What's even more wild, is that modern engines include all of this stuff out of the box, you just have to tick a few check boxes to enable them in your game. :) For example, check out these postprocessing filters built into Unity and Unreal - a ton of person-hours went into these:
https://docs.unity3d.com/Manual/PostProcessingOverview.html
https://docs.unrealengine.com/en-us/Engine/Rendering/PostPro...
This means traditional advice for "the basics of a good game engine" doesn't really apply, because if you're just making a bog standard game engine you're wasting your time and making a crappier version of Unity or Unreal.
https://geometrian.com/programming/tutorials/write-games-not...
- "How do I render things?"
- "How do I integrate sound?"
- "How should I handle events?"
I don't know if anything like THREE exists for OpenGL, though.
The upshot of THREE is its super easy to develop with (alls you need is a browser). The downside is that it slows down very quickly for even simple things.
(I am a security analyst, not an engineer, but I'm transitioning to engineering roles now, so this might change in future, who knows :) )
For a deep dive into all game engine topics I would recommend the Handmade Hero dev streams: https://handmadehero.org
(Note that Handmade is not a useful model for an actual game production, it's more like a platform for investigating cutting-edge engine topics, so you can pick and choose parts to get what you need. It's been going for years and remains mostly a tech demo.)
But post fx like bloom or vignette? I'm okay using a stock shader for that, it's not worth spending the time on building one from scratch. :)
int main
( int argc
, char *argv[]
) {
// ...
LColor backgroundColor =
LColor
( generateLightColorPart(207, 1)
, generateLightColorPart(154, 1)
, generateLightColorPart(108, 1)
, 1
);
// ...
}
I can (sort of) see that this makes it easy to comment out parameters - except for the first one...I’ll often reformat when I’m done so it fits our code review style.
Also I’m usually working systemverilog so 5-10 parameters are common and 50 or more isn’t rare.
If adding stuff to the end of a class or of an argument list is your most frequent case, you might have a software design problem.
If(predicate
&& nextPredicate
&& lastPredicate)
{
DoStuff();
}
Which I don't mind but also don't write. However, I do prefer ternary expressions like int someNum = somePred
? firstVal + 42
: 1000;FWIW, everything seen here has options in Clang Format: https://clang.llvm.org/docs/ClangFormatStyleOptions.html
Personally, I like what this looks like. Leading commas are nice in situations where the first argument is fixed, but the remaining arguments move a lot while I’m tweaking & refactoring. I also like leading operators in long multi line math expressions, it’s easier to see at a glance how everything is combined when the operators are in front. I also like seeing arguments aligned, it’s easier to spot mistakes, easier to move things around, easier to use column selection, etc.
I rarely actually use the formatting I like because at work my team uses clang format so we’re standardized. Despite whatever formatting opinions I like, I love not arguing about formatting and having the formatter dictate and handle it for everyone.
The big issue with using WebGL at the current moment, to do large scale sims, is that fragment shaders dont have an entire workload barrier capability - so you cant do interdependent work.
Compute shaders have full workload execution and memory barriers.
Just something to be aware of if you are trying to jerry rig fragment shaders to do more advanced things like HDR via min/max over all colors..there is no way to these kind of aggregates without calling the shader twice, unfortunately.
(I didn't know it was on the horizon until I saw your link). I wonder if getting to ES 3.2 is on the horizon as well? That would bring geometry and tessellation shader support.
> Using geometry shading will generally lead to worse performance, high memory bandwidth, and increased system power consumption. Assert if geometry shaders are used
Geometry shaders are not what you want. They should not have been included in GL ES, and I will fight their inclusion into WebGL 2.1.
Tessellation shaders are better, but still kinda ultimately useless.
And there are things like line drawing algorithms that have uses for geometry shaders: https://github.com/paulhoux/Cinder-Samples/tree/master/Geome...
It's not like geometry shaders are specific to OpenGL ES. Desktop OpenGL has them, as does DirectX and Vulkan.
Paper Mario is all hand-authored baked vertex colors and very simple textures. Artists spent a lot of time in Maya hand-tweaking each vertex individually, e.g. see my viewer here https://noclip.website/#ttyd/jin_00
Borderlands has some basic engine technology with outlines -- running a basic Sobel on the depth buffer to find depth discontinuities and drawing lines there, but most interior lines are on the texture itself. Lighting is also modified with a ramp -- the "raw" incoming radiance from lighting is thrown into an artist-authored lookup table and tweaked before being thrown to the shader. Normal maps are seldom used.
I honestly thought a lot more was going on here but now that I look back at it you seem to be correct. Impressive how simple it is.
A very simple implementation of outlining is to draw the object a second time solid black, with the vertex positions extruded out in the direction of the vertex normals, and with backface culling flipped so that you see only internal faces. Those black, internal faces peeking out around the edge of the regular mesh form the outlines.
That's a good starting point. Many iterations and improvements from there gets you to this: https://www.youtube.com/watch?v=yhGjCzxJV3E
1) good texturing (including some linework and hatching)
2) diffuse only (more or less)
3) draw edges in black
Which is pretty vanilla techniques, shader wise. The hard part is doing the textures well.
Somebody on reddit did a character model walkthrough back in 2014: https://www.reddit.com/r/gamedev/comments/2bftyc/i_reverse_e...