Geometry Shaders in URP - Plus how to create code shaders from shader graph

Описание к видео Geometry Shaders in URP - Plus how to create code shaders from shader graph

Geometry shaders are shader functions you can run after your vertex shader, and before the fragment shader. Today I’ll go over how to set one up in the Universal Render Pipeline, or URP. As a bonus, I’ll also be covering a trick for creating code shaders in URP that bypasses a lot of the effort and understanding generally required

For more details, see the written version of this: https://gamedevbill.com/geometry-shad...

I used Unity 2020.1 and Shader Graph 8.2

Chapters…
0:00 overview
2:33 shader graph setup
6:40 generated code file
9:48 geometry shader coding

Today's toy: https://amzn.to/3jODLLe
Today's shirt: https://amzn.to/34KCKxf

**** Update for Shader Graph 10.x
This video was made with Shader Graph 8.2
If you are using Shader Graph 10.x there are a couple key differences:

The create shader options have moved within a sub-menu called "Universal Render Pipeline, and some are renamed. So "Create--Shader--PBR graph" becomes "Create--Shader--Universal Render Pipeline--Lit Shader Graph"
The per-input settings that were in the blackboard are now in the "Graph Inspector" within the "Node Settings". You must have the input selected to see its settings in that window.
Some other settings that were on-node are now also in that Graph Inspector, though you can generally ignore these.
If you want to generate a code shader from the graph (as I do in this video), you do so on the graph asset inspector (not on the master node as you did in 8.2). Now select the graph asset, and hit "View Generated Shader" button in its inspector.
****

Since shader graph doesn’t support geometry shaders, we need a code shader. Once enough of the graph is filled out to give you the functionality you need, right click on the master node, and select “Show Generated Code”. This will create a file in Project/Temp/ that you can copy into /Assets/ and use as a normal code shader.

A geometry shader is a shader that runs on, well, geometry. More specifically, it’s run on every triangle. So for a quad, your vertex shader would be run 4 times, and a geometry shader would be run twice. It’s worth noting that in the quad example, the shared vertices are considered unique at this stage. So you technically have six vertices by the time the geometry shader is executing.

#ShaderGraph #Unity #GeometryShader

Комментарии

Информация по комментариям в разработке