Texture LOD calculation (useful for atlasing)

반응형

최근에 본 코드중에 재미있는게 있어서 정리함. 

원문 : 

Texture LOD calculation (useful for atlasing)


텍스쳐 아틀라스에서 가장자리 필터 문제가 없는 셰이더를 작성중이며 이를 공유한다.

(텍스쳐 배열을 지원하지 않는 하드웨어에서 텍스쳐 배열 에뮬레이팅)



#define SUB_TEXTURE_SIZE 512.0 #define SUB_TEXTURE_MIPCOUNT 10 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://developer.nvidia.com/gpugems/gpugems2/part-iii-high-quality-rendering/chapter-28-mipmap-level-measurement

https://studfile.net/preview/5125756/page:70/

https://usermanual.wiki/Document/GPU20Pro2036020Guide20to20Rendering.927333407/help

https://gamedev.stackexchange.com/questions/130888/what-are-screen-space-derivatives-and-when-would-i-use-them

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/

http://webcache.googleusercontent.com/search?q=cache:http://www.jiajianhudong.com/question/575425.html

https://stackoverflow.com/questions/24568918/why-are-dfdx-ddx-and-dfdy-ddy-2-dimension-variables-when-quering-a-2d-texture

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

https://www.sysnet.pe.kr/2/0/11613

https://lifeisforu.tistory.com/388

'정리요망' 카테고리의 다른 글

ddx와 ddy  (0) 2020.01.29
wrapped diffuse  (2) 2013.12.24
TAGS.

Comments