# Shader graph : drawing an ovale based on the distance between two points

Hi !

I’m pretty new to shader graph, and to shaders in general. I’m stuck in a math problem and I don’t have a clue on how to manage it… Here’s the thing. I work on a 2D toon shader. The shadows are ruled by a gradient projected on the texture based on the distance between an emitter center position and a current object position.

And the distance rules the offset of this texture. The more an object is far from the emitter, the more a black range appears on the texture. So, I can clamp the maximum distance to define a range to the light. Here’s an exemple :

(a is the emitter, b is the position of a current object, and the range is clamp to 10)

So in here, the distance is clamped to 10, and it draws me a light circle on this plane surface.

Everythings works as I want to, except that : it’s a top down view game, so basically I need this circle to be an ovale to simulate perspective. And this is where i’m stuck… Any clues on how to achieve the effect ?

My first though (probably because i’m quite lame in geometry !) is : I got a vector with a and b , so I got an angle. Maybe it could work if I find the way to set the max distance based on the angle of the vector. Like 0°=10, 90°= 15, 180°=10, 270°=15).

If it’s a simple ovale, you can squash the circle:

``````difference = position1 - position2;
difference.y *= sqashFactor;
distance = length(difference.xy);