One more simple parallax shader

Shaders with the parallax effect looks very impressive when modeling windows – if the camera moves around the scene, the view from the window also shifts slightly, creating the illusion of a large open space outside the window.

Let’s add a plane to the scene (shift + a – Mesh – Plain) that will simulate a window, create a new material in the Shader Editor and replace the Principled BSDF node with an Image Texture node. Select a suitable image as a texture.

To get the parallax effect, we will use two nodes, the Texture Coordinate node and the Geometry node. From the Texture Coordinate node, we can get the coordinates of the texture points from the UV Map. And using the Geometry node, we will take the Incoming vector, which is directed from the point of view (from the camera) to the current point of the shader.

Add these two nodes to the shader node tree: shift + a – Input – Texture Coordinate and shift + a – Input – Geometry.

If we take the difference between these two vectors, we will shift the texture location from the Plane to the camera.

Add the Vector Math node (shift + a – Converter – Vector Math) and switch it to the “Subtract” mode. Connect its Vector inputs to the UV output of the Texture Coordinate node and the Incoming output of the Geometry node. Connect its Vector output with the Vector input of the Image Texture node to apply the coordinate transformation to the image points.

The image has decreased in size, but the parallax effect is already visible. If we move the camera that looks at the plane, we can see that the image “floats” relative to the plane.

It remains to bring the image to the required size. To do this, before the Texture Coordinate node, insert the Mapping node (shift + a – Vector – Mapping). Set the scale in its “Scale” field to 0.3 and shift the image by 0.4 along the X and Y axes, specifying this value in its “Location” field.

By stretching the image beyond the boundaries of the plane, we create a margin that will become visible when the camera moves.

Now, when the camera moves relative to the plane, we see the parallax effect.

This bundle of nodes works both in the Cycles render engine and in EEVEE.

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments