- Home /
Draw sprite by calling function for each pixel.
I have a spline class, which i want to draw to the screen in game. It has a GetDistance(point) functions that finds the distance between the spline and the point. The way i thought i would do it, is to call this function for every pixel in a sprite, and set it to a color if the distance is less than some value. However, i have no idea how to actually do this. I looked into it for a while, but it quickly became too complicated trying to convert uv coordinates to world space etc. There must be a simple way to draw a dynamic shape right?
Wait what UV coordinates are you talking about, exactly?
Answer by ravenclarico · Jun 29, 2021 at 03:01 AM
Unity is highly averse to this type of rendering through C# because of the problems it can cause with interplatform portability.(I tried it myself. got it to work in editor, but it was un-buildable, even after a month of coding.) If you really want to render shapes that way you may need to learn how to write compute shaders for unity, and even those can have problems with compatability. Instead of building an image pixel by pixel, May I suggest building a mesh triangle by triangle?
Your answer
![](https://koobas.hobune.stream/wayback/20220613035533im_/https://answers.unity.com/themes/thub/images/avi.jpg)