From 403726131f9b460c3264e4f64c46f8aaa82978fe Mon Sep 17 00:00:00 2001 From: hgn Date: Fri, 2 Dec 2022 17:41:10 +0000 Subject: [PATCH] fixes some artifacting --- shaders/alphatest.h | 13 ++++++++++++- shaders/gpos.h | 6 ++++++ shaders/menu.h | 6 ++++++ shaders/motion_vectors_common.glsl | 1 + shaders/motion_vectors_fs.glsl | 5 ++++- shaders/motion_vectors_vs.glsl | 4 ++++ shaders/route.h | 13 ++++++++++++- shaders/scoretext.h | 13 ++++++++++++- shaders/sky.h | 13 ++++++++++++- shaders/standard.h | 13 ++++++++++++- shaders/terrain.h | 13 ++++++++++++- shaders/vblend.h | 13 ++++++++++++- shaders/viewchar.h | 13 ++++++++++++- shaders/water.h | 13 ++++++++++++- shaders/water_fast.h | 13 ++++++++++++- 15 files changed, 141 insertions(+), 11 deletions(-) create mode 100644 shaders/motion_vectors_common.glsl diff --git a/shaders/alphatest.h b/shaders/alphatest.h index d5c38d0..8b06893 100644 --- a/shaders/alphatest.h +++ b/shaders/alphatest.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_alphatest = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -176,6 +182,10 @@ static struct vg_shader _shader_alphatest = { "\n" "#line 13 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -186,7 +196,8 @@ static struct vg_shader _shader_alphatest = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 14 0 \n" diff --git a/shaders/gpos.h b/shaders/gpos.h index b60fb75..a41a7f7 100644 --- a/shaders/gpos.h +++ b/shaders/gpos.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_gpos = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" diff --git a/shaders/menu.h b/shaders/menu.h index 2a14ac1..a0baa70 100644 --- a/shaders/menu.h +++ b/shaders/menu.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_menu = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" diff --git a/shaders/motion_vectors_common.glsl b/shaders/motion_vectors_common.glsl new file mode 100644 index 0000000..1d6ed97 --- /dev/null +++ b/shaders/motion_vectors_common.glsl @@ -0,0 +1 @@ +const float k_motion_lerp_amount = 0.05; diff --git a/shaders/motion_vectors_fs.glsl b/shaders/motion_vectors_fs.glsl index e6d2759..315416b 100644 --- a/shaders/motion_vectors_fs.glsl +++ b/shaders/motion_vectors_fs.glsl @@ -1,3 +1,5 @@ +#include "motion_vectors_common.glsl" + layout (location = 1) out vec2 oMotionVec; in vec3 aMotionVec0; @@ -8,5 +10,6 @@ void compute_motion_vectors() // Write motion vectors vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z; vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z; - oMotionVec = vmotion1-vmotion0; + + oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount); } diff --git a/shaders/motion_vectors_vs.glsl b/shaders/motion_vectors_vs.glsl index 25c176d..63a17db 100644 --- a/shaders/motion_vectors_vs.glsl +++ b/shaders/motion_vectors_vs.glsl @@ -1,8 +1,12 @@ +#include "motion_vectors_common.glsl" + out vec3 aMotionVec0; out vec3 aMotionVec1; void vs_motion_out( vec4 vproj0, vec4 vproj1 ) { + vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount; + aMotionVec0 = vec3( vproj0.xy, vproj0.w ); aMotionVec1 = vec3( vproj1.xy, vproj1.w ); } diff --git a/shaders/route.h b/shaders/route.h index 521df23..b003858 100644 --- a/shaders/route.h +++ b/shaders/route.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_route = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -176,6 +182,10 @@ static struct vg_shader _shader_route = { "\n" "#line 13 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -186,7 +196,8 @@ static struct vg_shader _shader_route = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 14 0 \n" diff --git a/shaders/scoretext.h b/shaders/scoretext.h index 55734a3..06fa719 100644 --- a/shaders/scoretext.h +++ b/shaders/scoretext.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_scoretext = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -197,6 +203,10 @@ static struct vg_shader _shader_scoretext = { "\n" "#line 12 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -207,7 +217,8 @@ static struct vg_shader _shader_scoretext = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 13 0 \n" diff --git a/shaders/sky.h b/shaders/sky.h index fa0546f..931dec1 100644 --- a/shaders/sky.h +++ b/shaders/sky.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_sky = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -69,6 +75,10 @@ static struct vg_shader _shader_sky = { "in vec3 aCo;\n" "\n" "#line 1 1 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -79,7 +89,8 @@ static struct vg_shader _shader_sky = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 13 0 \n" diff --git a/shaders/standard.h b/shaders/standard.h index 3c759b6..319e6be 100644 --- a/shaders/standard.h +++ b/shaders/standard.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_standard = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -176,6 +182,10 @@ static struct vg_shader _shader_standard = { "\n" "#line 13 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -186,7 +196,8 @@ static struct vg_shader _shader_standard = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 14 0 \n" diff --git a/shaders/terrain.h b/shaders/terrain.h index 460ba9e..cf32d5e 100644 --- a/shaders/terrain.h +++ b/shaders/terrain.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_terrain = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -177,6 +183,10 @@ static struct vg_shader _shader_terrain = { "\n" "#line 14 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -187,7 +197,8 @@ static struct vg_shader _shader_terrain = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 15 0 \n" diff --git a/shaders/vblend.h b/shaders/vblend.h index 2a5dacf..ad3f82b 100644 --- a/shaders/vblend.h +++ b/shaders/vblend.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_vblend = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -175,6 +181,10 @@ static struct vg_shader _shader_vblend = { "\n" "#line 12 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -185,7 +195,8 @@ static struct vg_shader _shader_vblend = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 13 0 \n" diff --git a/shaders/viewchar.h b/shaders/viewchar.h index 20f33d3..e8d6fe7 100644 --- a/shaders/viewchar.h +++ b/shaders/viewchar.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_viewchar = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -185,6 +191,10 @@ static struct vg_shader _shader_viewchar = { "\n" "#line 11 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -195,7 +205,8 @@ static struct vg_shader _shader_viewchar = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 12 0 \n" diff --git a/shaders/water.h b/shaders/water.h index 109f29d..710d5c1 100644 --- a/shaders/water.h +++ b/shaders/water.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_water = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -183,6 +189,10 @@ static struct vg_shader _shader_water = { "\n" "#line 20 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -193,7 +203,8 @@ static struct vg_shader _shader_water = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 21 0 \n" diff --git a/shaders/water_fast.h b/shaders/water_fast.h index 3da3db2..756f308 100644 --- a/shaders/water_fast.h +++ b/shaders/water_fast.h @@ -17,11 +17,17 @@ static struct vg_shader _shader_water_fast = { "\n" "#line 2 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "out vec3 aMotionVec0;\n" "out vec3 aMotionVec1;\n" "\n" "void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n" "{\n" +" vproj1 = vproj0*(1.0-k_motion_lerp_amount) + vproj1*k_motion_lerp_amount;\n" +"\n" " aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n" " aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n" "}\n" @@ -180,6 +186,10 @@ static struct vg_shader _shader_water_fast = { "\n" "#line 17 0 \n" "#line 1 2 \n" +"const float k_motion_lerp_amount = 0.05;\n" +"\n" +"#line 2 0 \n" +"\n" "layout (location = 1) out vec2 oMotionVec;\n" "\n" "in vec3 aMotionVec0;\n" @@ -190,7 +200,8 @@ static struct vg_shader _shader_water_fast = { " // Write motion vectors\n" " vec2 vmotion0 = aMotionVec0.xy / aMotionVec0.z;\n" " vec2 vmotion1 = aMotionVec1.xy / aMotionVec1.z;\n" -" oMotionVec = vmotion1-vmotion0;\n" +"\n" +" oMotionVec = (vmotion1-vmotion0) * (1.0/k_motion_lerp_amount);\n" "}\n" "\n" "#line 18 0 \n" -- 2.25.1