fte-team/fteqw

defaultwarp.glsl should use sin and cos, not just sin

hemebond opened this issue · 1 comments

defaultwarp.glsl has the following code:

	vec2 ntc;
	ntc.s = tc.s + sin(tc.t+e_time)*0.125;
	ntc.t = tc.t + sin(tc.s+e_time)*0.125;

but should use cos for one of them to more closely match the original Quake water warp.

https://github.com/id-Software/Quake/blob/master/WinQuake/d_scan.c#L106-L107
both are using the same table. there is no 90-degree offset on either (eg to turn the sin to a cos).

r_turb_turb = sintable + ((int)(cl.timeSPEED)&(CYCLE-1));
see, sin.
sintable[i] = AMP + sin(i
3.14159*2/CYCLE)AMP;
(also AMP is 8
0x10000, and i ranges up to CYCLE=128(with extra slop for wrapping) so the table's validity is from 0 to 2PI radians aka the full 360 degree range in 128 levels)
which I suppose means it technically ranges from 0-16 instead of +/-8
so feel free to add ((8.0/64)=0.125) to match that small bias, but cos is wrong.

it should be noted that certain other engines (like QS) disregard the texture offsets completely - https://github.com/sezero/quakespasm/blob/master/Quake/gl_warp.c#L145-L146 disregards vecs[][3]
QS does not always do a good job of matching vanilla quake. water is one of these areas.