Shader Graph9-world space, object space, camera space, tangent space

1. World Space World Space

The Blender software used below creates a new plane. The small yellow dot in the middle indicates the origin of the world space. The positions of objects in the world space are all relative to this origin. The red arrow indicates the x-axis, the green arrow indicates the y-axis, and the blue arrow indicates the z-axis. The origin and three directions of the world space are always the same.

 

 Two, Object Space object space

The origin of the object space of the teapot is at the bottom of the teapot, the red arrow indicates the x-axis, the green arrow indicates the y-axis, and the blue arrow indicates the z-axis. When we move and rotate the teapot, the position and direction of the teapot space relative to the world space will change, but relative to the lid, it has no position and angle transformation, because it is relative to the bottom of the teapot, a bit like we are on the earth, the earth is revolving and rotating, but we don't feel the same.

The image on the left below causes the teapot to move upwards, and the image on the right makes some rotation.

 3. Camera camera space

 

 The origin of the camera space is a small yellow dot, the red arrow indicates the x-axis, the green arrow indicates the y-axis, and the blue arrow indicates the z-axis. The direction of the z-axis is the direction the eye is facing.

Four, Tangent tangent space

This is the enlarged surface of the teapot, each vertex has its own tangent space, the red arrow indicates the x-axis, the green arrow indicates the y-axis, the blue arrow indicates the z-axis, the x-axis is the vertex normal, and y and z are the uv coordinates.

To add, why does tangent space exist and what problems does it solve?

The tangent space is to solve the shading artifacts caused by the light formed by the normal map. Then there are the following types of defects. The first is called banding, which means that there are obvious color bands or stripes in areas that should be smooth; the second is called shadow acne, which means that it happens when small changes in the position of shadow-casting objects cause the shadow to look noisy or spotty; the third is called terminator artifacts, which means when there is a sharp transition between the illuminated area and the unlit area. This happens, as well as "subsurface scattering artifacts" when the rendering engine tries to simulate the way light scatters in translucent materials like skin or wax;

 

Because the tangent space is for each point, the calculation and lighting are more accurate, so the above problems can be solved.

5. Open UE, create a new material DemoSpace, and double-click to open it.

The Lerp node is to mix moss and stone to achieve the effect in reality. The function of TransformVector is to convert the tangent space to the world space. Mask (B) means to make the moss realistic on the top, and the denser it goes up.

If the project you created is a Thrid Person project, then we can find it in Textures, here we use 4 files of stone and moss materials.

For stones, we can use the ones that come with the project.

 The final effect is that when the stone is turned, the position of the moss always appears on top.

 So in some cases, if we move the stone, then strange behavior will appear. So if we want the moss not to move on the stone, then we only need to modify the Destination of TransformVector to Local Space.

Let's look at another example. We can find this kind of image as a texture image, and then use our shader below. No matter how we rotate the object, it seems to have light. This method can be used on mobile devices.

Here we use TransformVector to convert world space to view space (camera space).

6. Open Unity, create a new ShaderGraph, and enter the editing interface.

Note here that in Unity, Transform should choose Object->World, which means from object space to world space.

 The Transform here is from World to View, meaning from world space to camera space.

 

 

 

 

 

 

 

Guess you like

Origin blog.csdn.net/zhuziying99/article/details/130055397