@cybereality said:
See if this works:
COLOR = texture(SCREEN_TEXTURE, SCREEN_UV * 0.8 + uv);
It seems to fix it on one side, as if it's offsetting rather than scaling, I've been sort of plugging different combinations in to try and actually make it scale, but nothing seems to make much difference. Here's a Unity shader that seems to account for it by zoom (the -0.5 and +0.5 part I think?)
Shader "Hidden/QuakeUnderWater"
{
Properties
{
_MainTex("Texture", 2D) = "white" {}
_WaveFrequency("Wave Frequency", Float) = 0.5
_WaveScale("Wave Scale", Float) = 0.8
_WaveAmplitude("Wave Amplitude", Range(0,0.33)) = 0.15
_Color("Color Tint", Color) = (1,1,1,1)
}
SubShader
{
// No culling or depth
Cull Off ZWrite Off ZTest Always
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
float _WaveScale, _WaveAmplitude, _WaveFrequency;
float4 _Color;
fixed4 frag(v2f i) : SV_Target
{
float aspect = _ScreenParams.y / _ScreenParams.x;
float2 waveAmplitude = float2(aspect * _WaveAmplitude, _WaveAmplitude) / _WaveScale;
float2 uv = (i.uv - 0.5) * (1.0 - abs(waveAmplitude) * 2.0) + 0.5;
float2 sinTime = (float2((uv.y - 0.5) * aspect, uv.x - 0.5) * _WaveScale + _Time.y * _WaveFrequency) * UNITY_PI;
uv += float2(sin(sinTime.x), sin(sinTime.y)) * waveAmplitude;
fixed4 col = tex2D(_MainTex, uv) * _Color;
return col;
}
ENDCG
}
}
}