Skip to content

sunduk/UnityRoundedShader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

25 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

UnityRoundedShader

Rounded rectangle, circle, ellipse shaders in Unity

alt tag

alt tag f(x)=x^2

Description

이 μ½”λ“œμ— λŒ€ν•œ κ°•μ’ŒλŠ” μ—¬κΈ°μ„œ λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€ : 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.

License

  • μ†ŒμŠ€μ½”λ“œμ™€ μ΄λ―Έμ§€λŠ” μ•„λ¬΄λŸ° μ œμ•½ 없이 자유둭게 μ‚¬μš© κ°€λŠ₯ν•©λ‹ˆλ‹€.
  • 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.
 * ------------------------------------------------------------
 */
 

About

Rounded rectangle, circle, ellipse shaders in Unity

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published