On this page
Bulge UVs
A bulge pushes the texture’s UVs radially away from a point, so the texture appears to swell outward around it, like the surface is inflating under your finger. It is the effect behind the Diablo style “peek”, where clicking a locked chest or a sealed door bulges the texture and reveals what is hidden underneath.
float2 d = uv - _Center;
float dist = length(d);
float push = smoothstep(_Radius, 0.0, dist); // 1 at center, 0 past the radius
float2 uvOut = uv + (d / max(dist, 1e-4)) * push * _Strength;
Push, with a falloff¶
The effect is a radial displacement of the UV, and it has three ingredients. The center is the point the bulge radiates from, which you author as a UV coordinate or drive with a pointer or a hit position. The radius is how far the push reaches. And the falloff is the curve that decides how hard each texel is pushed, strong at the center, zero past the radius, so the effect fades out instead of ending in a hard ring.
The displacement direction is the normalized vector from center to point, and the amount is the falloff times a strength:
float2 dir = d / max(dist, 1e-4); // unit vector, away from center
float push = smoothstep(_Radius, 0.0, dist); // 1 inside, fading to 0
uv += dir * push * _Strength;
smoothstep here is used with its arguments reversed on purpose: smoothstep(edge0, edge1, x) with edge0 > edge1 gives a 1 at the center falling smoothly to 0 at the radius, a soft lens profile. The max(dist, 1e-4) keeps the normalize from blowing up exactly at the center, where the direction is undefined, and the one texel that hits it is invisible anyway.
The peek: hide one texture behind another¶
The famous use is a reveal. The surface shows texture A on top of texture B. The bulge is not the effect itself, it is the mask: where the UVs have been pushed, the top texture is now sampling a displaced spot, and you use the push amount to crossfade to the hidden texture underneath:
half3 top = SAMPLE_TEXTURE2D(_TopTex, s, uvOut).rgb; // displaced
half3 hidden = SAMPLE_TEXTURE2D(_HiddenTex, s, uv).rgb; // not displaced
half3 color = lerp(top, hidden, saturate(push * _Reveal));
The hidden layer samples at the original UV, so it does not move. The top layer moves out of the way. The result reads as the surface swelling to show what was behind it, and it costs one extra sample and a lerp. The same shape of trick, displaced top layer, static bottom layer, is how you would do a ripple that uncovers a layer, or a magnet that pulls a pattern toward a point, by flipping the sign of the strength to pull instead of push.
One art direction note: because the falloff is a curve, the look of the bulge is almost entirely the shape of that curve. A smoothstep is a soft lens, a sharper pow of the falloff is a tight poke, and an animated radius gives the swelling its sense of physical pressure. The math is simple; the feel is the curve.
What the shader does¶
The shader displaces the top layer radially around a bulge center while the bottom layer stays put. A reveal property decides how much of the hidden layer the bulge exposes, and the seam between the two layers traces the falloff curve.
Illustrative schematic: Top layer displaces radially; the reveal decides what shows.
Center, radius, strength, and the reveal blend between a displaced top texture and a static hidden one.
Shader "DecompiledArt/Textures/Projections/BulgeUVs/BulgeUVs"
{
Properties
{
_TopTex("Top Texture", 2D) = "white" {}
_HiddenTex("Hidden Texture", 2D) = "black" {}
[MainColor] _BaseColor("Base Color", Color) = (1, 1, 1, 1)
_Center("Bulge Center", Vector) = (0.5, 0.5, 0, 0)
_Radius("Radius", Range(0.01, 0.5)) = 0.2
_Strength("Push Strength", Range(0, 0.5)) = 0.15
_Reveal("Reveal", Range(0, 1)) = 1
}
SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "UniversalPipeline" "Queue" = "Geometry" }
Pass
{
Name "ForwardOnly"
Tags { "LightMode" = "UniversalForward" }
HLSLPROGRAM
#pragma vertex Vert
#pragma fragment Frag
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
TEXTURE2D(_TopTex); SAMPLER(sampler_TopTex);
TEXTURE2D(_HiddenTex); SAMPLER(sampler_HiddenTex);
struct Attributes
{
float4 positionOS : POSITION;
float2 uv : TEXCOORD0;
};
struct Varyings
{
float4 positionCS : SV_POSITION;
float2 uv : TEXCOORD0;
};
CBUFFER_START(UnityPerMaterial)
half4 _BaseColor;
half2 _Center;
half _Radius;
half _Strength;
half _Reveal;
CBUFFER_END
Varyings Vert(Attributes IN)
{
Varyings OUT;
OUT.positionCS = TransformObjectToHClip(IN.positionOS.xyz);
OUT.uv = IN.uv;
return OUT;
}
half4 Frag(Varyings IN) : SV_Target
{
float2 d = IN.uv - _Center;
float dist = length(d);
float push = smoothstep(_Radius, 0.0, dist);
float2 dir = d / max(dist, 1e-4);
float2 uvOut = IN.uv + dir * push * _Strength;
half3 top = SAMPLE_TEXTURE2D(_TopTex, sampler_TopTex, uvOut).rgb;
half3 hidden = SAMPLE_TEXTURE2D(_HiddenTex, sampler_HiddenTex, IN.uv).rgb;
half3 color = lerp(top, hidden, saturate(push) * _Reveal);
return half4(_BaseColor.rgb * color, _BaseColor.a);
}
ENDHLSL
}
}
FallBack Off
}
🔗 Related Chapters¶
Rotating UVs • Parallax Mapping
Related functions: Smoothstep • Length
❤️ Support Shader Story¶
If this article helped you, consider supporting the project on Patreon: you’ll get access to the related source files and reference cheat-sheets.
Your support helps keep this library open and free for everyone.