Fullscreen glass gracks

Hello everybody!
I just tried to make some fullscreen glass cracks with offset screen UV by map.

But i have troubles on map’s borders. Maybe someone did some same anytime and can give me an advice how to make it smoother?

Thank you and sorry for my English. I’m working on it))

2 Likes

Screen buffers are usually set to clamp, rather than repeat or mirror, when going outside the normalized UV range. That’s the stretching you’re seeing, your offsets are large enough that it’s moving the UVs outside of the valid 0.0 to 1.0 UV range.

The simpliest solution is to scale the UVs prior to offsetting them by the maximum offset you want to apply. That’ll have the side effect of making the screen slightly blurry as the on screen pixels won’t be 1:1 anymore.

screenUV = (screenUV - 0.5) * (1.0 - _OffsetScale * 2.0) + 0.5;
screenUV += offset * _OffsetScale;

The next best solution is to make sure you’re only ever offsetting away from the center of the screen rather than towards it. This would be a content change to the colors you’re choosing in the glass crack offset texture. Also make sure you’re treating it as a vector direction. RG 127,127 should be no offset, with RG 0,127 being the maximum offset to the left, RG 255,127 being the maximum to the right, and RG 127,255 and RG 127,0 being up and down (or down and up … it depends what engine you’re using, but should be the same orientation as normal maps). As long as the colors you use on the edges of the screen aren’t pushing in, then you shouldn’t ever get stuff outside that 0.0 to 1.0 UV range.

Other options are to scale down the offset itself as it gets away from the center of the screen, either in the content or in the shader, or add a vignetting to fade the screen color to black outside the UV range.

3 Likes

Thank you! I will try.