Repository: staffantan/unity-vhsglitch
Branch: master
Commit: 01f8eeccd9c2
Files: 4
Total size: 3.5 KB
Directory structure:
gitextract_bsseorug/
├── README.md
├── Scripts/
│ └── VHSPostProcessEffect.cs
├── Shaders/
│ └── VHSPostProcessEffect.shader
└── VHSGlitch.unitypackage
================================================
FILE CONTENTS
================================================
================================================
FILE: README.md
================================================
# unity-vhsglitch
glitched VHS post-processing shader for Unity3D
This work is licensed under a Creative Commons Attribution 3.0 Unported License.
http://creativecommons.org/licenses/by/3.0/deed.en_GB
You are free:
to copy, distribute, display, and perform the work
to make derivative works
to make commercial use of the work
This post-processing effect requires Unity Pro
USAGE:
Add VHSPostProcessEffect script to camera.
VHS Glitched Video footage by Christopher Huppertz:
https://www.youtube.com/watch?v=9eFVeErnUzg
Licensed under: Creative Commons Attribution licence (reuse allowed)
================================================
FILE: Scripts/VHSPostProcessEffect.cs
================================================
using UnityEngine;
using UnityEngine.Video;
[ExecuteInEditMode]
[AddComponentMenu("Image Effects/GlitchEffect")]
[RequireComponent(typeof(Camera))]
[RequireComponent(typeof(VideoPlayer))]
public class VHSPostProcessEffect : MonoBehaviour
{
public Shader shader;
public VideoClip VHSClip;
private float _yScanline;
private float _xScanline;
private Material _material = null;
private VideoPlayer _player;
void OnEnable()
{
_material = new Material(shader);
_player = GetComponent<VideoPlayer>();
_player.isLooping = true;
_player.renderMode = VideoRenderMode.APIOnly;
_player.audioOutputMode = VideoAudioOutputMode.None;
_player.clip = VHSClip;
_player.Play();
}
void OnRenderImage(RenderTexture source, RenderTexture destination)
{
_material.SetTexture("_VHSTex", _player.texture);
_yScanline += Time.deltaTime * 0.01f;
_xScanline -= Time.deltaTime * 0.1f;
if (_yScanline >= 1)
{
_yScanline = Random.value;
}
if (_xScanline <= 0 || Random.value < 0.05)
{
_xScanline = Random.value;
}
_material.SetFloat("_yScanline", _yScanline);
_material.SetFloat("_xScanline", _xScanline);
Graphics.Blit(source, destination, _material);
}
protected void OnDisable()
{
if (_material)
{
DestroyImmediate(_material);
}
}
}
================================================
FILE: Shaders/VHSPostProcessEffect.shader
================================================
Shader "Hidden/VHSPostProcessEffect" {
Properties {
_MainTex ("Base (RGB)", 2D) = "white" {}
_VHSTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
Pass {
ZTest Always Cull Off ZWrite Off
Fog { Mode off }
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag
#pragma fragmentoption ARB_precision_hint_fastest
#include "UnityCG.cginc"
uniform sampler2D _MainTex;
uniform sampler2D _VHSTex;
float _yScanline;
float _xScanline;
float rand(float3 co){
return frac(sin( dot(co.xyz ,float3(12.9898,78.233,45.5432) )) * 43758.5453);
}
fixed4 frag (v2f_img i) : COLOR{
fixed4 vhs = tex2D (_VHSTex, i.uv);
float dx = 1-abs(distance(i.uv.y, _xScanline));
float dy = 1-abs(distance(i.uv.y, _yScanline));
//float x = ((int)(i.uv.x*320))/320.0;
dy = ((int)(dy*15))/15.0;
dy = dy;
i.uv.x += dy * 0.025 + rand(float3(dy,dy,dy)).r/500;//0.025;
float white = (vhs.r+vhs.g+vhs.b)/3;
if(dx > 0.99)
i.uv.y = _xScanline;
//i.uv.y = step(0.99, dy) * (_yScanline) + step(dy, 0.99) * i.uv.y;
i.uv.x = i.uv.x % 1;
i.uv.y = i.uv.y % 1;
fixed4 c = tex2D (_MainTex, i.uv);
float bleed = tex2D(_MainTex, i.uv + float2(0.01, 0)).r;
bleed += tex2D(_MainTex, i.uv + float2(0.02, 0)).r;
bleed += tex2D(_MainTex, i.uv + float2(0.01, 0.01)).r;
bleed += tex2D(_MainTex, i.uv + float2(0.02, 0.02)).r;
bleed /= 6;
if(bleed > 0.1){
vhs += fixed4(bleed * _xScanline, 0, 0, 0);
}
float x = ((int)(i.uv.x*320))/320.0;
float y = ((int)(i.uv.y*240))/240.0;
c -= rand(float3(x, y, _xScanline)) * _xScanline / 5;
return c + vhs;
}
ENDCG
}
}
Fallback off
}
gitextract_bsseorug/ ├── README.md ├── Scripts/ │ └── VHSPostProcessEffect.cs ├── Shaders/ │ └── VHSPostProcessEffect.shader └── VHSGlitch.unitypackage
SYMBOL INDEX (4 symbols across 1 files)
FILE: Scripts/VHSPostProcessEffect.cs
class VHSPostProcessEffect (line 4) | [ExecuteInEditMode]
method OnEnable (line 18) | void OnEnable()
method OnRenderImage (line 29) | void OnRenderImage(RenderTexture source, RenderTexture destination)
method OnDisable (line 49) | protected void OnDisable()
Condensed preview — 4 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4K chars).
[
{
"path": "README.md",
"chars": 596,
"preview": "# unity-vhsglitch\nglitched VHS post-processing shader for Unity3D\n\nThis work is licensed under a Creative Commons Attrib"
},
{
"path": "Scripts/VHSPostProcessEffect.cs",
"chars": 1280,
"preview": "using UnityEngine;\nusing UnityEngine.Video;\n\n[ExecuteInEditMode]\n[AddComponentMenu(\"Image Effects/GlitchEffect\")]\n[Requi"
},
{
"path": "Shaders/VHSPostProcessEffect.shader",
"chars": 1750,
"preview": "Shader \"Hidden/VHSPostProcessEffect\" {\n\tProperties {\n\t\t_MainTex (\"Base (RGB)\", 2D) = \"white\" {}\n\t\t_VHSTex (\"Base (RGB)\""
}
]
// ... and 1 more files (download for full content)
About this extraction
This page contains the full source code of the staffantan/unity-vhsglitch GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 4 files (3.5 KB), approximately 1.4k tokens, and a symbol index with 4 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.