Game Development

Godot Shader Tutorial: Make a 2D VHS and CRT Effect

Set up a CanvasLayer, assign a shader material, paste the shader code, fix the screen texture uniform, and tune the parameters for a 2D visual effect in Godot 4.

6 min read
Godot editor open with a game preview in the center showing a VHS-style visual effect and shader settings in the inspector.
The Godot editor displays a game preview with a visible CRT-like VHS effect and shader controls. — footage: Godot Knowledge Hub

To add a 2D CRT or VHS shader in Godot, set up a CanvasLayer with a ColorRect that covers the screen, assign a ShaderMaterial to it, paste the effect's shader code, and add the required screen texture uniform if prompted. Finally, resize the ColorRect to fit your viewport and tweak the shader parameters until the look matches your needs.

What you need on the scene tree

prerequisites

  • CanvasLayer: Add this node to your main scene to ensure your effect displays above your game content.
  • ColorRect: Place this as a child of CanvasLayer to serve as the target for the shader effect.
  • Coverage: Make sure the ColorRect is ready to cover the entire game view or camera area so the effect applies everywhere you want.

Godot editor with the scene tree on the left, a 2D level in the center, and shader properties in the Inspector on the right.

The Godot editor shows a scene tree on the left, a 2D game view in the middle, and shader settings in the Inspector on the right. — Godot Knowledge Hub

Create the shader resource and assign it to the material

steps

  1. Create a new Shader resource: In your file system panel, right-click inside your desired folder and choose to create a new Shader resource.
  2. Name the resource: Give it a memorable name, such as "VHS_2", so you can find it later.
  3. Assign the shader to the ColorRect: Drag your shader resource into the empty material slot of the ColorRect node in the Inspector.
  4. Open the shader code editor: Double-click the shader resource to open its script area, then paste the shader code you want to use.

Godot editor is open with a Create New Resource dialog centered on screen and a Shader option visible in the resource list, while the file browser and inspector panels are shown around it.

The Godot editor shows the Create New Resource dialog with Shader available to create, alongside the file browser and inspector panels. — Godot Knowledge Hub

The Godot editor is open with the Inspector on the right showing a ColorRect node and its Material section, while a shader file is selected in the file dock.

The Godot editor shows the Inspector for a ColorRect with the Material section visible and a shader resource selected in the project files. — Godot Knowledge Hub

Fix the screen texture error

If Godot complains about a missing screen texture uniform when you paste the shader, add the required line near your uniform declarations.

before after

Before

Before

// Uniform declarations...
// (Missing required screen texture uniform)
After

After

// Uniform declarations...
uniform sampler2D screen_texture : hint_screen_texture, filter_linear_mipmap;
// (Now the shader should accept the screen texture)

The Godot editor is open with a shader script in the bottom code panel, showing shader code and a red error message about SCREEN_TEXTURE being removed in favor of using a uniform.

The Godot shader code editor is open with an error message about SCREEN_TEXTURE and the script visible below the scene view. — Godot Knowledge Hub

Resize the effect to cover the view

Godot editor with a running scene viewport mostly covered by a black ColorRect effect and shader-related properties open in the inspector.

Godot editor shows a large black ColorRect covering most of the game view in the running scene. — Godot Knowledge Hub

Tweak the shader parameters for the final look

steps

  1. Locate Shader Parameters: In the Inspector, select your ColorRect and find the shader material. The parameters exposed by the shader will be listed there.
  2. Adjust effect values: Change the settings to increase or decrease visual features such as scanlines, color distortion, or glitching as needed.
  3. Preview in scene: Keep testing these changes with your scene running until you are happy with the appearance.

A game editor is open with the Inspector panel on the right showing a selected shader material and shader parameters.

The Inspector displays the selected material with Shader Parameters visible on the right. — Godot Knowledge Hub

Also worth knowing

  • Shader error workaround: If you get an error about screen textures, insert the screen texture sampler uniform at the top of your shader code to resolve it.

FAQ

Godot 4 shader tutorial for 2D games

To use this shader in a 2D game, set up a CanvasLayer and ColorRect, then assign the effect shader as described. This overlays the visual effect above your game's content.

How to make a CRT shader in Godot

Copy a CRT-style shader code, create a Shader resource, assign it to your ColorRect's material, add the required screen texture uniform if needed, and adjust parameters to match the CRT look.

Godot shader tutorial for beginners

This approach is friendly for beginners: set up the right nodes, create a Shader resource, paste existing shader code, fix any uniform errors, and change settings in the Inspector.

2D visual effects in Godot 4

Adding visual effect shaders in Godot 4 involves layering a ColorRect above your scene, using a ShaderMaterial, and configuring GLSL shader code to affect the pixels underneath.

Godot shader guide for game polish

Applying a VHS or CRT shader with this method is a quick way to add polish and atmosphere to your game, enhancing mood and visual style without changing gameplay or UI logic.


Official reference: Godot documentation.

Sources

Screenshots on this page are frames from the videos below, used to illustrate the steps they describe. All rights remain with their creators.

Checked against: