How to calculate Normal Vectors in Shader Graph

Описание к видео How to calculate Normal Vectors in Shader Graph

Fix up normals in your Shader Graphs after manipulating vertices!

In Shader Graph, you can move your vertices around, causing your model to take on a new shape. This will often cause the normal vectors to be incorrect, which will ruin your lighting. In this video I'll cover how to fix your normals all within shader graph.

The math is a bit complicated, but I've created two subgraphs which will do this for you.

Subgraphs on github: https://github.com/gamedevbill/Tutori...
Full written tutorial: https://gamedevbill.com/shader-graph-...
Schoolhouse Rocks shirt: https://amzn.to/38QQIRA
Side note, I wore that shirt because, well, I'm a Bill. But as the lyrics to that song go on to say "sitting here on Capitol Hill", I'm wishing I hadn't worn this shirt in a video posted right after rioters stormed Capitol Hill. I recorded the video before those events, so I just ask that you take it as a humorous look at my name, and not some sort of weird political statement.

**** 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, 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.
****

0:00 Intro
2:15 Algo in 2D
4:13 Demo Start
8:07 Algo Subgraph
9:59 Demo End

Normals, or more formally normal vectors, are vectors of length 1 that are perpendicular to the surface of the object. They are used by the engine to calculate lighting. After moving vertices, you can end up with the wrong parts of your surface being bright, dim, or shiny. Fixing your normals is the way to fix that lighting.

Комментарии

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