This method is not optimized, I am only giving you the main idea so, so you know how it is possible, so you do it on your own
Introduction
Visual effects can greatly enhance the atmosphere of a game. Chromatic aberration is one such effect that can give your game a unique, stylistic edge by adding a subtle distortion of colors, often seen in vintage photography or to create a disorienting effect. In this tutorial, I’ll guide you through the steps to create a chromatic aberration effect, adding a professional touch to your game’s visuals.
Before we start, make sure you have a basic understanding of Roblox Studio and scripting
Please note that the use of continuous updates and frequent object management operations can impact game performance, particularly on lower-end devices.
Step 1: Set Up Your Environment
- Insert a
Screengui
.
- Insert
3
Viewportframes.
- Name them
Red
,Green
andBlue
- Insert
WorldModel
in each frame:
WorldModel
basically provides some physics features to the viewportframe
Read more about it here
Step 2: Adjust the Viewportframes Transparency and Colors
Settings for Red
Viewportframe:
Settings for Green
Viewportframe:
Settings for Blue
Viewportframe:
Now time to start scripting!
Step 3: Scripting the Chromatic Aberration Effect
- Insert a local script inside the
Screengui
- Create a table for viewportframes
- Cloning function:
We first loop through the children of the workspace. If the object is not a terrain or a camera, we loop through the table of theViewportFrames
, finding theWorldModel
inside each one. If aWorldModel
exists and the object is not already inside theWorldModel
(to prevent duplication), we clone the object, check if the cloned part exists, and then finally parent it to theWorldModel
.
- Cleaning Function:
We first loop through theviewportFrames
. For eachviewport
, we find theWorldModel
inside it. If aWorldModel
exists, we then loop through its children. For each child, we destroy it
- SetCamera Function:
ThesetCamera
function updates theCurrentCamera
property of eachViewportFrame
in theviewportFrames
table to match theCurrentCamera
of the workspace. After defining the function, it is immediately called to apply the changes.
- Updating Function:
This function ensures that thecloneObjects
andcleanUpObjects
functions run continuously and match with the game’s rendering process. By usingRenderStepped
, the update occurs every frame, providing a consistent and smooth experience. Thetask.wait()
adds a small delay to potentially balance the load, preventing thecleanUpObjects
function from executing immediately aftercloneObjects
.
The End
Final Code:
Result:
How Would You Rate This Tutorial?
- 5 - Excellent: The tutorial was clear, comprehensive, and very helpful.
- 4 - Good: The tutorial was helpful and well-explained, with minor areas for improvement.
- 3 - Average: The tutorial was okay but could use improvements.
- 2 - Poor: The tutorial had some useful information but was lacking in key areas.
- 1 - Very Poor: The tutorial was unclear or unhelpful.
0 voters