Rounded rectangle, circle, ellipse shaders in Unity
μ΄ μ½λμ λν κ°μ’λ μ¬κΈ°μ λ³Ό μ μμ΅λλ€ : https://lee-seokhyun.gitbook.io/workspace/client/shader/roundedrect_shader
μ °μ΄λλ‘ λ₯κ·Ό μ¬κ°νμ λ§λ€κΈ° μν΄ κ΅¬κΈμ κ²μν΄ λ³΄λ μλ λκ°μ μ¬μ΄νΈκ° μλ¨μ 보μμ΅λλ€.
https://www.shadertoy.com/view/ldfSDj
https://github.com/Nobinator/Unity-UI-Rounded-Corners
νλλ ShadertoyλΌκ³ μ °μ΄λμ κ΄λ ¨ν΄μ μμ£Ό μ λͺ ν μ¬μ΄νΈμ λλ€.
λ€λ₯Έ νλλ githubμ μ¬λΌμ μλ κ³³μΈλ° μ κ° κ΅¬ννλ €λ λͺ¨μ΅κ³Ό ν‘μ¬νμ¬ λ§μ΄ μ°Έκ³ λ₯Ό νμμ΅λλ€.
μ μ½λμμλ μ£μ§λ₯Ό λΆλλ½κ² νκΈ° μν΄ fwidth()λΌλ ν¨μλ₯Ό μ¬μ©νμλλ° μ¬μ€ μ΄λ€ μ리μΈμ§ μ νν μ΄ν΄κ° μκ°μ΅λλ€.
κ·Έλμ μ κ° μκ°ν λ°©μμΌλ‘ λ€μ μμ±νμκ³ κ·Έ κ²°κ³Όλ¬Όμ μ¬κΈ°μ μ¬λ¦½λλ€.
λλΆμ΄ μ λͺ¨μμ λ§λλ μ °μ΄λλ μΆκ°λ‘ λ§λ€μλλ°,
λ₯κ·Ό μ¬κ°νμ λ§λ€μ΄ 보λ μ λͺ¨μμ λ§λλκ²λ μ½κ² μμ©μ΄ κ°λ₯νμΌλ©° νμ©λλ λμκ² κ°μμ μΆκ°νμμ΅λλ€.
The below two web sites appeared when I searched on google.
https://www.shadertoy.com/view/ldfSDj
https://github.com/Nobinator/Unity-UI-Rounded-Corners
The first one is the Shadertoy which is very famous web site about shaders.
The second web site also gave me an idea to implement it.
I have read the shader codes which made by Nobinator, but I didn't understand full of it.
I was not cleared about fwidth() function in cg shader.
So, I have re-written the shader codes more understandable and added a circle shader.
- μμ€μ½λμ μ΄λ―Έμ§λ μλ¬΄λ° μ μ½ μμ΄ μμ λ‘κ² μ¬μ© κ°λ₯ν©λλ€.
- All source codes and images are free to use.
/* * ------------------------------------------------------------ * "THE BEERWARE LICENSE" (Revision 42): * I wrote this code. As long as you retain this * notice, you can do whatever you want with this stuff. If we * meet someday, and you think this stuff is worth it, you can * buy me a beer in return. * ------------------------------------------------------------ */

