Add parameters to the Vignette shader

This commit is contained in:
Henrik Rydgård committed 2022-12-08 13:16:44 +01:00
1 parent a5cb357058
commit 2a9d4b53cb
2 files changed
+18 -2

No files matched your search

+11 -1
View File
@@ -28,6 +28,16 @@ Name=Vignette
Author=Henrik
Fragment=vignette.fsh
Vertex=fxaa.vsh
SettingName1=Power
SettingDefaultValue1=0.6
SettingMaxValue1=2.0
SettingMinValue1=0.1
SettingStep1=0.1
SettingName2=Aspect
SettingDefaultValue2=1.0
SettingMaxValue2=2.0
SettingMinValue2=0.5
SettingStep2=0.1
[Bloom]
Name=Bloom Shader
Fragment=bloom.fsh
@@ -47,7 +57,7 @@ Vertex=fxaa.vsh
SettingName1=Amount
SettingDefaultValue1=1.5
SettingMaxValue1=3.0
SettingMinValue1=1.0
SettingMinValue1=0.1
SettingStep1=0.1
[Scanlines]
Name=Scanlines (CRT)
+7 -1
View File
@@ -8,9 +8,15 @@ precision mediump int;
uniform sampler2D sampler0;
varying vec2 v_texcoord0;
uniform vec4 u_setting;
void main() {
float vignette = 1.1 - 0.6 * (dot(v_texcoord0 - 0.5, v_texcoord0 - 0.5) * 2.0);
vec2 diff = v_texcoord0 - 0.5;
diff.x *= u_setting.y;
diff.y /= u_setting.y;
float vignette = 1.0 - min(1.0, u_setting.x * (dot(diff, diff) * 2.0));
vec3 rgb = texture2D(sampler0, v_texcoord0.xy).xyz;
rgb *= vignette;
gl_FragColor.rgb = vignette * rgb;
gl_FragColor.a = 1.0;
}