Texture LOD calculation (useful for atlasing)
최근에 본 코드중에 재미있는게 있어서 정리함.
원문 :
Texture LOD calculation (useful for atlasing)
텍스쳐 아틀라스에서 가장자리 필터 문제가 없는 셰이더를 작성중이며 이를 공유한다.
(텍스쳐 배열을 지원하지 않는 하드웨어에서 텍스쳐 배열 에뮬레이팅)
float MipLevel( float2 uv ) { float2 dx = ddx( uv * SUB_TEXTURE_SIZE ); float2 dy = ddy( uv * SUB_TEXTURE_SIZE ); float d = max( dot( dx, dx ), dot( dy, dy ) ); // Clamp the value to the max mip level counts const float rangeClamp = pow(2, (SUB_TEXTURE_MIPCOUNT - 1) * 2); d = clamp(d, 1.0, rangeClamp); float mipLevel = 0.5 * log2(d); mipLevel = floor(mipLevel); return mipLevel; }
ㅇㅇ
Reference Link
- https://cgl.ethz.ch/teaching/former/vc_master_06/Downloads/Mipmaps_1.pdf
(mipmap 원리, 필터링 기본 방식 설명)
-
https://studfile.net/preview/5125756/page:70/
https://usermanual.wiki/Document/GPU20Pro2036020Guide20to20Rendering.927333407/help
https://aras-p.info/blog/2011/05/03/a-way-to-visualize-mip-levels/
https://community.khronos.org/t/texture-lod-calculation-useful-for-atlasing/61475
http://www.aclockworkberry.com/shader-derivative-functions/
https://forum.unity.com/threads/calculate-used-mipmap-level-ddx-ddy.255237/
https://kblog.popekim.com/2011/04/tex2dlod.html
https://3dmpengines.tistory.com/1484
Reference Link
- What Is Ddx And Ddy
'정리요망' 카테고리의 다른 글
ddx와 ddy (0) | 2020.01.29 |
---|---|
wrapped diffuse (2) | 2013.12.24 |