The parallax effect in Unity is used to create depth on a surface by applying textures based on the view angle. It is often applied to surfaces in 3D environments to make them look more complex without adding complex geometry.
The parallax mapping (or offset mapping) is a technique where the surface's texture coordinates are displaced depending upon the viewing angle.
Viewing angle: The texture coordinates are modified based on the view angle relative to the surface. The larger the angle, the more the texture coordinates are shifted.
Displacement: The displacement of the texture coordinates creates an illusion that parts of the texture are raised or lowered, giving a 3D effect to the surface.
Enhance visuals: It is used to enhance the visuals of the walls, floors, or other surfaces in 3D games and simulations.
Performance: It offers a way to create a complex appearance without adding additional polygons, thus enhancing the performance. Parallax effect saves us a lot of computational cost.
If we take a quad and look at its wireframe (as shown above), it is made up of two triangles. But if we look at the parallax effect applied onto the same GameObject (quad), we will be able to see a complex texture. This saves additional computation costs, improving performance.
Difficult setup: Parallax effects can cause visual anomalies in prefabs if not set up correctly or if used on surfaces with significant depth variations.
Complexity: Parallax effects are more complex to set up than the standard texturing techniques.
Given below is a sample project that demonstrates the parallax effect on a cube.
Control with the arrow keys and change the viewing angle to show the parallax effect on a quad.
import React from 'react'; require('./style.css'); import ReactDOM from 'react-dom'; import App from './app.js'; ReactDOM.render( <App />, document.getElementById('root') );
Free Resources