generated from ShadowMario/FNF-PsychEngine
-
Notifications
You must be signed in to change notification settings - Fork 0
Shaders
HackDev edited this page Aug 1, 2024
·
4 revisions
Convert Shadertoy To GLSL Shader
Here's some info about GLSL Shaders.
Initial Shadertoy Code.
Color Shifting Shader
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
float amp = 0.0125;
vec2 uv = fragCoord/iResolution.xy;
vec4 tex;
tex.r = texture(iChannel0, vec2(uv.x-amp,uv.y)).r;
tex.g = texture(iChannel0, uv).g;
tex.b = texture(iChannel0, vec2(uv.x+amp,uv.y)).b;
tex.a = texture(iChannel0, uv).a;
fragColor = tex;
}
- Header:
Add#pragma header
at the first line of the shader.
#pragma header
void mainImage()
{
}
- Converting Variables:
Adduniform float name;
before the mainImage() function.
#pragma header
uniform float iTime;
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
}
- FragCoord:
If you seefragCoord/iResolution.xy
, change that code toopenfl_TextureCoordv
#pragma header
uniform float iTime;
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 uv = openfl_TextureCoordv;
}
- Texture:
Thetexture()
should betexture2D()
texture2D()
- iChannel#:
iChannel's are samplers (That displays images) If there is onlyiChannel0
, orsampler
, change them tobitmap
. If there is more than one then useBitmapData
.
texture2D(bitmap, x)
- End:
Add this to the end of the shader
void main(out vec4 fragColor, in vec2 fragCoord)
{
mainImage(gl_FragColor, gl_FragCoord);
}
#pragma header
uniform float iTime;
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
float amp = 0.0125;
vec2 uv = openfl_TextureCoordv;
vec4 tex;
tex.r = texture2D(bitmap, vec2(uv.x-amp,uv.y)).r;
tex.g = texture2D(bitmap, uv).g;
tex.b = texture2D(bitmap, vec2(uv.x+amp,uv.y)).b;
tex.a = texture2D(bitmap, uv).a;
fragColor = tex;
}
void main() {
mainImage(gl_FragColor, gl_FragCoord);
}