smellymumbler
Does anyone know how this thing works?
Any article that could help me understand it?
Does anyone know how this thing works?
Any article that could help me understand it?
He uses the direction from the player
to the vertex to offset XZ and determines everything from the absolute distance to the surface of a sphere. The rest of the shader is controls, partially for tweaks and partially for fudging the curved look.
All of the gradients are unnecessary if designing by convention where the implied model-space gradient is a-ok (vertices are all in a unorm/snorm space on certain axes).
Everything else is just falloff control and other controls.
float3 playerToVertex = vertexPosition - playerPosition;
float3 directionFromPlayer = normalize(playerToVertex);
float distanceFromSphere = abs(length(playerToVertex) - sphereRadius);
float3 baseXZOffset = float3(directionFromPlayer.x, 0, directionFromPlayer.z) * distanceFromSphere;
float gravityFactor = ... gravity determination here ...
float bendinessFactor = ... bendiness/XZ determination here ...
float3 vertexOffset = (baseXZOffset * bendinessFactor) - float3(0, distanceFromSphere * gravityFactor, 0);
outputVertexPosition += vertexOffset;