When working on a shader, you must use position information other than the standard coordinates. With the position node you can select the coordinate system to be used.
Shader graphic: vertex position
Create the shader graph
1. Right click in your project and select Create> Shader> PBR Graph.
2. Name the new shader "SampleGraph".
3. Double click on the new shader to open it.
4. In the following window click with the right mouse button to select "Create Node".
5. Enter the "position" and click on the corresponding result.
You now have a position node in your diagram.
The location node provides access to the location of the mesh vertex or fragment. This controls how a shader behaves in a scene and in which area it is rendered. For example, if you change the position in "View", the shader will always be rendered from the viewing direction of the camera. The output is the coordinate space, which can be specified from the Space drop-down list. This node has a single output and one parameter.
Output:
Out: Outputs the standard created by the node.
Parameter:
Room / Space: Here you can select the coordinate space of the position to be output. The following options are available: Object, View, World and Tangent.
Object: If you want the position to be based on the object coordinates in the scene. It is useful to use coordinates that are specific to the object that the shader is attached to.
View: If you want to use the viewer coordinates. This is useful when you want to use the position and direction the viewer is facing to manipulate the shader.
World: This option is useful when you want to use the same coordinate system for the entire scene. Useful when you want to use the position data of the entire scene instead of being limited to the object or view coordinates.
Tangente: This option derives the position coordinates that are best approximated to an object as a given point. Imagine a point on a sphere through which different planes fly. One of these planes touches the sphere very gently, at the same time approaching all nearby points as closely as possible.
Absolute World / Absolute World: This option returns the absolute world position of the object in the scene in all scriptable render pipelines. This is the standard space of the Universal Render Pipeline, in which the High Definition Render Pipeline uses camera-relative space.
What if we use the position canvas to render a simple texture for a sphere in our scene?
1. Create a 2D sample texture node and enter a texture in the text input.
2. Take the RGBA pin of the Sample Texture 2D node and connect it to the Albedo input of the PBR master node.
3. Take the Out pin of the Position node and connect it to the Position input of the PBR master node
This connects your work to the last node of the shader graph to be rendered. The PBR master node has a small preview below that shows you the final live result of the shader.
Complete the SampleGraph
The final step to view your shader is to save your asset:
1. Click the Save Asset button in the upper left corner of the PBRGraph (Figure 03).
2. Create a new material in your project window by right-clicking and selecting
Create> Material.
3. In the Material window, select the Shader drop-down list and the shader you created.
Apply the material to an object in your scene.
If you have your camera circling the scene at a fixed point, you will find that when the camera faces the object it disappears and then reappears in your peripherals, with the front of the texture always facing the camera.
Originally posted on 2020-03-21 11:41:00.