# Why does the sphere rendered by my shader code on the model appear distorted (not a perfect circle), especially at the edges/corners of the model?

**URL:** <https://forums.unrealengine.com/t/why-does-the-sphere-rendered-by-my-shader-code-on-the-model-appear-distorted-not-a-perfect-circle-especially-at-the-edges-corners-of-the-model/2708232>\
**Category:** Rendering\
**Tags:** unreal-engine, shader, question\
**Created:** [March 23, 2026, 1:05am UTC](https://forums.unrealengine.com/t/why-does-the-sphere-rendered-by-my-shader-code-on-the-model-appear-distorted-not-a-perfect-circle-especially-at-the-edges-corners-of-the-model/2708232 "2026-03-23T01:05:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Knight\_Steven](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Knight\_Steven](https://forums.unrealengine.com/u/Knight_Steven)\
**Post date:** [March 23, 2026, 1:05am UTC](https://forums.unrealengine.com/t/why-does-the-sphere-rendered-by-my-shader-code-on-the-model-appear-distorted-not-a-perfect-circle-especially-at-the-edges-corners-of-the-model/2708232/1 "2026-03-23T01:05:05Z")

</div>

If you’re familiar with ray marching in Unreal Engine 5.7:Why does the sphere rendered via my ray marching shader code on 3D models (e.g., cylinders, cubes) appear distorted (not a perfect circle), with obvious deformation at the edges/corners of the model surfaces?

float3 rayOrigin = worldPos;

float3 rayStep = viewDir \* 1;

for (int i = 0; i \< 256; i++)

{

float dist = length(rayOrigin - sphereCenter) - sphereRadius;

if (dist \< 0.01)

{

opacityMask = 1;

return float3(1, 0, 0);

}

rayOrigin += rayStep;

}

opacityMask = 0;

return float3(0, 0, 0);

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/a/e/4ae568e024dd6cbc1181e0d07b1500915ade31da.jpeg)

---

<div class="post-metadata">

**Author:** ![jblackwell](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@jblackwell](https://forums.unrealengine.com/u/jblackwell)\
**Post date:** [March 24, 2026, 12:12am UTC](https://forums.unrealengine.com/t/why-does-the-sphere-rendered-by-my-shader-code-on-the-model-appear-distorted-not-a-perfect-circle-especially-at-the-edges-corners-of-the-model/2708232/2 "2026-03-24T00:12:24Z")

</div>

Does it have this effect when rendered across a normal plane as well? Because it looks to me like the boundaries of the planes of the cube line up with the deformations of the sphere, so (without looking at your code yet) I wonder if the planes of the cube are being treated as separate surfaces to trace rays against, instead of enclosing a bounding of the whole. Can you share screenshots of what your shader looks like on a few different basic primitives?

---

<div class="post-metadata">

**Author:** ![Cubeap](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cubeap/32/1160640_2.png) [@Cubeap](https://forums.unrealengine.com/u/Cubeap)\
**Post date:** [March 24, 2026, 12:47am UTC](https://forums.unrealengine.com/t/why-does-the-sphere-rendered-by-my-shader-code-on-the-model-appear-distorted-not-a-perfect-circle-especially-at-the-edges-corners-of-the-model/2708232/3 "2026-03-24T00:47:47Z")

</div>

Check if everything matches my version. Pay attention to the correction in the custom node.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/d/3/6d369e9a2aa2bbebf111040191d8594ede5f6815.jpeg)
