[Community Project] WIP Weather & Water Shader

I figured I should post my findings for anyone who might be interested about stuff. @

After spending a few days experimenting with various ideas and normal interpolation methods I ended up using bicubic B-Spline interpolation, it’s considered to be on the blurry side out of all the bicubic methods but it’s the only one I found that can completely eliminate pixelation artifacts even with really low-res maps (like 64x64) so it’s a perfect fit in case.

Linear interpolation between the 3 triangle vertex normals (using barycentric coordinates) doesn’t seem to smooth it at all for whatever reason.

Quick comparison screens between trilinear texture sampling and bicubic.

That’s a huge difference if you ask me! in case it makes a 128x128 normal map look like 4k.

Here is the custom node code for bicubic sampling.
Required inputs: Tex, UV


float2 res;
Tex.GetDimensions(res.x, res.y);

UV = UV*res-0.5;
float2 index = floor(UV);
float2 fraction = frac(UV);
float2 one_frac = 1.0 - fraction;
float2 one_frac2 = one_frac * one_frac;
float2 fraction2 = fraction * fraction;

float2 w0 = 1.0/6.0 * one_frac2 * one_frac;
float2 w1 = 2.0/3.0 - 0.5 * fraction2 * (2.0-fraction);
float2 w2 = 2.0/3.0 - 0.5 * one_frac2 * (2.0-one_frac);
float2 w3 = 1.0/6.0 * fraction2 * fraction;
float2 g0 = w0 + w1;
float2 g1 = w2 + w3;

float2 h0 = ((w1 / g0) - 0.5 + index) / res;
float2 h1 = ((w3 / g1) + 1.5 + index) / res;

float3 tex00 = Texture2DSample(Tex, TexSampler, h0);
float3 tex10 = Texture2DSample(Tex, TexSampler, float2(h1.x, h0.y));
float3 tex01 = Texture2DSample(Tex, TexSampler, float2(h0.x, h1.y));
float3 tex11 = Texture2DSample(Tex, TexSampler, h1);

tex00 = lerp(tex01, tex00, g0.y);
tex10 = lerp(tex11, tex10, g0.y);
return lerp(tex10, tex00, g0.x);