Jump to content

Geometry


havenphillip

2,116 views

 Share

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:

1185985324_normalsvisualizer.thumb.jpg.8a38c0a4eef3749f83fdfffdfaab53ff.jpg

43_normals visualizer.zip

 

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:

silhouette.thumb.jpg.3ad6657a713c41d53a4ee818c9cb00b3.jpg

44_silhouette.zip

 

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:

1599578471_shortfur.thumb.jpg.5449d1ff8498aa4825cee327c8d1ebfc.jpg

45_short fur.zip

 

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:

420765357_volumetricclouds.thumb.jpg.429662987c06ca505bf1abae59bd4723.jpg

46_volumetric clouds.zip

 

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:

1985064287_grasspatch.thumb.jpg.349b443f324f8e61d3a447572c6daa68.jpg

47_geometry grass.zip

 

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.

 

Happy shading!

 

Next: PBR...

 

  • Like 10
  • Thanks 1
  • Upvote 1
 Share

10 Comments


Recommended Comments

Love these and what you do. Keep it up and I hope you do the same thing for Ultra Engine shaders in the future. ?

  • Like 1
Link to comment

Thanks I appreciate it. I will keep it up. If Josh keeps making quality stuff that I can use then I'll annoy him forever. Brand loyalty.

  • Haha 1
Link to comment

This is beautiful. I have always thought that a game is made based on the talent of many people. Thank you for your work.

Link to comment

 

The most complicated thing about this is that I am not a shader programmer, and I have to deal with making all possible configurations look correct, but I can't get it right. 

I guess all this would have to go in a single shader, but no way, I'm just testing. 

But you have done a great job.

image.thumb.png.e68167fa5ff0db339864b18a59e26cd1.png

 

  • Like 1
Link to comment
Guest
Add a comment...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...