projects
/
carveJwlIkooP6JGAAIwe30JlM.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
fix motion vectors going through gate
[carveJwlIkooP6JGAAIwe30JlM.git]
/
shaders
/
water_fast.h
diff --git
a/shaders/water_fast.h
b/shaders/water_fast.h
index 3da3db2a41d926b782ec57a83679fbdfe686b94b..196c71ee738a0adea3e3f5860dccde17da6fab71 100644
(file)
--- a/
shaders/water_fast.h
+++ b/
shaders/water_fast.h
@@
-17,11
+17,19
@@
static struct vg_shader _shader_water_fast = {
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
"\n"
"#line 2 0 \n"
"#line 1 2 \n"
+"const float k_motion_lerp_amount = 0.01;\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"
"out vec3 aMotionVec0;\n"
"out vec3 aMotionVec1;\n"
"\n"
"void vs_motion_out( vec4 vproj0, vec4 vproj1 )\n"
"{\n"
+" // This magically solves some artifacting errors!\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"
" aMotionVec0 = vec3( vproj0.xy, vproj0.w );\n"
" aMotionVec1 = vec3( vproj1.xy, vproj1.w );\n"
"}\n"
@@
-180,6
+188,10
@@
static struct vg_shader _shader_water_fast = {
"\n"
"#line 17 0 \n"
"#line 1 2 \n"
"\n"
"#line 17 0 \n"
"#line 1 2 \n"
+"const float k_motion_lerp_amount = 0.01;\n"
+"\n"
+"#line 2 0 \n"
+"\n"
"layout (location = 1) out vec2 oMotionVec;\n"
"\n"
"in vec3 aMotionVec0;\n"
"layout (location = 1) out vec2 oMotionVec;\n"
"\n"
"in vec3 aMotionVec0;\n"
@@
-190,7
+202,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"
" // 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"
"}\n"
"\n"
"#line 18 0 \n"