Shaderfilter custom shader file

gomi

New Member
Hello, I am trying to make a shader which will be like VHS

I got a problem which caused that I offfset rgb from main channel. Here is the code I wrote based on example files and web page : https://www.shadertoy.com/view/4dBGzK
anyone can use it:


//------------------------------------------------------------------------
//----------------VHS_DISTORTION_STYLE1-----------------------------------
//------------------------------------------------------------------------


uniform int pulse_speed_percent = 0;
float nrand(float x, float y)
{
float value = dot(float2(x, y), float2(12.9898 , 78.233 ));
return frac(sin(value) * 43758.5453);
}
float4 mainImage(VertData v_in) : TARGET
{
float speed = (float)pulse_speed_percent * 0.01;
float t = sin(elapsed_time * speed) * 2 - 1;
float u = v_in.uv.x;
float v = v_in.uv.y;
float magnitude = 0.0009;
float2 offsetRedUV = v_in.uv;
offsetRedUV.x = u + nrand(t*0.03,v*0.42) * 0.001;
offsetRedUV.x += sin(nrand(t*0.2, v))*magnitude;
float2 offsetGreenUV = v_in.uv;
offsetGreenUV.x = u + nrand(t*0.004,v*0.002) * 0.004;
offsetGreenUV.x += sin(t*9.0)*magnitude;


float2 offsetBlueUV = v_in.uv;

offsetGreenUV.y += sin(t*0.002)+0.001;
offsetRedUV.x -= sin(t*0.002)+0.001;


//DAMAGES
offsetBlueUV.x+= sin(nrand(t*0.01, v));


float colorR = image.Sample(textureSampler, offsetRedUV).r;
float colorG = image.Sample(textureSampler, offsetGreenUV).g;
float colorB = image.Sample(textureSampler, offsetBlueUV).b;
float4 color = float4(colorR,colorG,colorB,1);
return color;
}


The problem is I get yellow color change so I want to prevent it. I just want to add damages (parazytes). I do not know much about this things. If I add damage for all rgb I get damages on black screen so that looks like exacly what I want. However, at this time I can not render the main captured screen.If that was possible to remove black background and add only damages to the screen I would reach what I wanted. Second thing is when I use this shader I get flashes for other programs. What is the reason of this ? Can we please discuss the possible solution ?




UPDATE:

//--------------------------------------------------
// --------------------METZAMOR---------------------
//----------------VHS_DISTORTION_V2-----------------
//--------------------------------------------------
//uniform texture2d other_image;
uniform int pulse_speed_percent = 0;
float nrand(float x, float y)
{
float value = dot(float2(x, y), float2(12.9898 , 78.233 ));
return frac(sin(value) * 43758.5453);
}
float4 mainImage(VertData v_in) : TARGET
{
float speed = (float)pulse_speed_percent * 0.01;
float t = sin(elapsed_time * speed) * 2 - 1;
float u = v_in.uv.x;
float v = v_in.uv.y;
float magnitude = 0.0009;
float4 color=float4(0,0,0,1);


/////UVS//////
float2 offsetRedUV = v_in.uv;
float2 offsetGreenUV = v_in.uv;
float2 offsetBlueUV = v_in.uv;


offsetRedUV.x = u + nrand(t*0.03,v*0.42) * 0.001;
offsetRedUV.x += sin(nrand(t*0.2, v))*magnitude;


offsetGreenUV.x = u + nrand(t*0.004,v*0.002) * 0.004;
offsetGreenUV.x += sin(t*9.0)*magnitude;



float testy = sin(nrand(t*0.01, 0.1));
float testx = sin(nrand(t*0.01, 0.1));
if(testy<0.06)
{
offsetGreenUV.y += testy;
offsetGreenUV.x -= testy;
}
if(testx <0.1){
offsetRedUV.x -= testx;
}


float colorR = image.Sample(textureSampler, offsetRedUV).r;
float colorG = image.Sample(textureSampler, offsetGreenUV).g;
float colorB = image.Sample(textureSampler, offsetBlueUV).b;
color += float4(colorR,colorG,colorB,1);
float damageLinePass = sin(nrand(t*0.1, v));
if(damageLinePass < 0.055)
{
color +=damageLinePass,0.1;
color.r += damageLinePass;
color.g += damageLinePass;
color.b +=damageLinePass;
}
float damageLinePassMedium = sin(nrand(t*0.01, v));


if(damageLinePassMedium < 0.001)
{
color +=damageLinePass*2*float4(0.3,0.2,0.1,1);
}
return color;
}


This code is relatively better. Still I did not get the damage style I wanted.

Update END.
 
Last edited:
Top