So we went through a lot of fragment shaders. Did some vertex displacement. Went through tessellation. Now, some geometry. I don't have much to say about it. Just keep poking at it with a proverbial stick and eventually situations start to look familiar and you know what to do because it's similar to stuff you've encountered before. It does seem to me that there's not a lot of variety in geometry shaders. There's a bit, though. Enough to make it interesting. But grab these shaders and you'll have the gist of it.
Here's a normals visualizer. This is like the first geometry shader everyone makes. The blue lines are the faces, the yellow lines are the vertices:
A simple instance geometry shader. There's a bool in the geometry stage. If you set it to true it works for simple boxes but not for more complex shapes. If set to false the corners break on the box but the more complex shapes look great. There are two instances here and in the shader you'll notice "EndPrimitive()" after each. You'll also always see "EmitVertex()." You can emit many vertices per primitive. But once you end primitive it means you're moving on to something else. Check it out:
This shader uses a technique called shell texturing. In it, the geometry shader is used to duplicate the surface several times according to a height map, and with each new layer the alpha areas grow. I call this "short fur" because it's a little temperamental. If your fur is too long you need more steps, which eats at your FPS. Too short and you don't get much of an effect. I come back to this shader periodically, just trying to improve it, and you will probably be able to see why. It gets a little "twinkly" around the edges due to the viewing angle. But it's a nice little shader. Not too complex:
Same basic idea in the geometry shader as the previous. Just set the cloud plane in the scene and attach the script and it will set it up in the sky for you. Also included the cloudless skybox material and shader:
I want to make a LOD system for this in the future so I can make whole fields. In the pic it's scaled to about 20x1x20 and the tessellation is set at about 32 in the control stage. There are three noise textures. One for wind, one for grass heights, and one which I used to randomize the grass blade positions so they didn't look like nice little rows and columns. By all means mess with all the numbers, but it's kind of nice to just sit and watch this one blow in the wind (also set the wind texture to uncompressed to eliminate some of that banding - that way you get a nice rolling wind).. Check the links in the shader to see how it's done, but basically you just draw one blade of grass in the geometry shader and then tessellate it. That blade of grass reoccurs at every vertex. Throw in some bada-bing/bada-boom and it looks pretty natural:
I'm thinking I'm going to attempt to do a PBR shader. So I'll call that next. But it may take me several weeks so I may vanish for a bit. Let me know if there are any shaders you want to see in the future. I'm thinking after I hit 52 shaders I'll just keep posting. But at that point I'll just do it more at my leisure. There's a lot of things I still want to make.