Live data from Hacker News

3D Game Shaders for Beginners

github.com

11–20 of 46 posts

Re: 3D Game Shaders for Beginners

#11

Cool! Is there a tutorial for cell shading? (The Borderlands 2 or Paper Mario look.)

Those are two drastically different artstyles. Neither of them really are engine shader stuff, just someone drawing good textures in Photoshop.

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.

Re: 3D Game Shaders for Beginners

#12
post #8
post #4

Am I just out of touch with what the kids today are doing, or is this formatting really as bonkers as it seems? 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've noticed this formatting in sql scripts before too - the biggest benefit I see is making source control diffs only show one line changed rather than two when adding/removing lines.

[deleted]

Re: 3D Game Shaders for Beginners

#13
post #11

Cool! Is there a tutorial for cell shading? (The Borderlands 2 or Paper Mario look.)

Those are two drastically different artstyles. Neither of them really are engine shader stuff, just someone drawing good textures in Photoshop. 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 --…

>find depth discontinuities and drawing lines there, but most interior lines are on the texture itself

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.

Re: 3D Game Shaders for Beginners

#14

Cool! Is there a tutorial for cell shading? (The Borderlands 2 or Paper Mario look.)

A very simple implementation of cell shading is to run the result of traditional lighting through a lookup table in the form of a 1D texture. Having runs and steps of solid color posterizes the smooth lighting input so that it resembles painted cell artwork.

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

Re: 3D Game Shaders for Beginners

#15
post #8
post #4

Am I just out of touch with what the kids today are doing, or is this formatting really as bonkers as it seems? 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've noticed this formatting in sql scripts before too - the biggest benefit I see is making source control diffs only show one line changed rather than two when adding/removing lines.

Is that a benefit?

Re: 3D Game Shaders for Beginners

#16
post #8

Earlier quoted context omitted.

I've noticed this formatting in sql scripts before too - the biggest benefit I see is making source control diffs only show one line changed rather than two when adding/removing lines.

Is that a benefit?

Yes. When you git blame a line you won't get a commit just adding/removing a comma changing on that line.

Re: 3D Game Shaders for Beginners

#17
post #8
post #4

Am I just out of touch with what the kids today are doing, or is this formatting really as bonkers as it seems? 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've noticed this formatting in sql scripts before too - the biggest benefit I see is making source control diffs only show one line changed rather than two when adding/removing lines.

Unless you're inserting as the first line ...

Re: 3D Game Shaders for Beginners

#18

Earlier quoted context omitted.

Is that a benefit?

Yes. When you git blame a line you won't get a commit just adding/removing a comma changing on that line.

Some languages/DSL's allow for a comma at the end of the list too, thereby getting the same result but without the slightly strange comma at the start of the line. Adding additional lines is simple then and doesn't cause the line above to be pulled in to any git action

Re: 3D Game Shaders for Beginners

#19
post #4

Am I just out of touch with what the kids today are doing, or is this formatting really as bonkers as it seems? 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...

In languages that don't allow trailing commas, I prefer this comma-first style. It makes it easy to avoid missing or extra commas, which shortens my feedback loop a bit. But I usually don't use it, because a lot of people react the way you do, and I want you to be able to read and enjoy my code despite your irrational and bizarrely extreme prejudice.
Post reply on HN