瀏覽代碼

fixed all noise/displacement effects

master
父節點
當前提交
0a3c0ddc78
共有 3 個檔案被更改,包括 16 行新增14 行删除
  1. +6
    -5
      neercs/video/noise.lolfx
  2. +1
    -1
      neercs/video/postfx.lolfx
  3. +9
    -8
      neercs/video/render.cpp

+ 6
- 5
neercs/video/noise.lolfx 查看文件

@@ -19,20 +19,21 @@ uniform vec2 offset;
uniform float noise;
uniform vec3 retrace;

float rand(in vec2 p)
float rand(in vec2 p,in float t,in float v)
{
return fract(sin(dot(p,vec2(12.9898,78.233)))*43758.5453);
return fract(sin(dot(p+t,vec2(12.9898,78.233)))*v);
}

void main(void)
{
vec2 p=gl_FragCoord.xy/screen_size.xy;

float rnd=rand(p+time);
vec2 o=(offset-offset*2.0*rnd)/screen_size;
float r1=rand(p,time,43758.5453);
float r2=rand(p,time,70425.2854);
vec2 o=(offset-offset*2.0*r1)/screen_size;

vec3 c=texture2D(texture,p+o).xyz; // offset
c-=rnd*noise; // noise
c*=1.0+(noise-noise*2.0*r1); // noise
c-=retrace.x*mod(p.y*retrace.y+time*retrace.z,1.0); // retrace
gl_FragColor=vec4(c,1.0);
}

+ 1
- 1
neercs/video/postfx.lolfx 查看文件

@@ -83,6 +83,6 @@ void main(void)
c*=scanline_h.x+scanline_h.y*cos(z.y*float(screen_size.y*scanline_h.z+scanline_h.w)); // scanline h
c*=scanline_v.x+scanline_v.y*cos(z.x*float(screen_size.x*scanline_v.z+scanline_v.w)); // scanline v
c*=(mask-vignetting); // vignetting
c*=letterbox(z,corner.x,corner.y); // letterbox
c*=letterbox(z,corner.x,corner.y); // corner
gl_FragColor=vec4(c,1.0);
}

+ 9
- 8
neercs/video/render.cpp 查看文件

@@ -92,9 +92,9 @@ vec2 glow_mix(0.6f,0.4f); // glow mix [source mix,glow mix]
vec2 glow_large(2.0f,2.0f); // large glow radius [center,corner]
vec2 glow_small(1.0f,1.0f); // small glow radius [center,corner]
vec2 blur(0.25f,0.5f); // glow radius [center,corner]
vec2 noise_offset(3.0f,3.0f); // random line [horizontal,vertical]
vec2 noise_offset(1.5f,1.5f); // random line [horizontal,vertical]
float noise_noise = 0.15f; // noise
vec3 noise_retrace(0.05f,2.0f,4.0f); // retrace [strength,length,speed]
vec3 noise_retrace(0.02f,1.0f,0.5f); // retrace [strength,length,speed]
vec2 postfx_deform(0.7f,0.54f); // deformation [ratio,zoom]
vec3 postfx_filter(0.8f,0.9f,0.4f); // color filter [red,green,blue]
vec3 postfx_color(1.8f,1.5f,0.5f); // color modifier [brightness,contrast,grayscale]
@@ -183,6 +183,7 @@ char const *setup_text[] = {
"aberration",
"",
"noise",
"enable",
"offset h",
"offset v",
"noise",
@@ -190,7 +191,6 @@ char const *setup_text[] = {
"retrace length",
"retrace speed",
"",
"",
"ghost",
"back x",
"back y",
@@ -249,8 +249,8 @@ vec4 setup_var[]={ // setup variable [start,end,step,value]
vec4(0),
vec4(0), /* blur */
vec4(0, 1, 1, 1),
vec4(0.0f, 2.0f, 0.1f, blur.x),
vec4(0.0f, 2.0f, 0.1f, blur.y),
vec4(0.0f, 2.0f, 0.05f, blur.x),
vec4(0.0f, 2.0f, 0.05f, blur.y),
vec4(0),
vec4(0),
vec4(0),
@@ -275,14 +275,14 @@ vec4 setup_var[]={ // setup variable [start,end,step,value]
vec4(0.0f, 8.0f, 0.5f, postfx_aberration),
vec4(0),
vec4(0), /* noise */
vec4( 0, 1, 1, 1),
vec4(0.0f, 4.0f, 0.50f, noise_offset.x),
vec4(0.0f, 4.0f, 0.50f, noise_offset.y),
vec4(0.0f, 1.0f, 0.05f, noise_noise),
vec4(0.0f, 0.5f, 0.25f, noise_noise),
vec4(0.0f, 0.2f, 0.01f, noise_retrace.x),
vec4(0.0f, 8.0f, 0.50f, noise_retrace.y),
vec4(0.0f, 4.0f, 0.25f, noise_retrace.z),
vec4(0),
vec4(0),
vec4(0), /* ghost */
vec4(-0.5f, 0.5f, 0.01f, postfx_ghost1.x),
vec4(-0.5f, 0.5f, 0.01f, postfx_ghost1.y),
@@ -338,10 +338,11 @@ void Render::UpdateVar()
postfx_color = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
postfx_aberration = setup_var[k].w; k++;
k += 2; /* noise */
m_shader_noise = (setup_var[k].w == 1) ? true : false; k++;
noise_offset = vec2(setup_var[k].w, setup_var[k + 1].w); k += 2;
noise_noise = setup_var[k].w; k++;
noise_retrace = vec3(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w); k += 3;
k += 3; /* ghost */
k += 2; /* ghost */
postfx_ghost1 = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
postfx_ghost2 = vec4(setup_var[k].w, setup_var[k + 1].w, setup_var[k + 2].w, setup_var[k + 3].w); k += 4;
k += 1; /* moire */


Loading…
取消
儲存