티스토리 뷰

카테고리 없음

HLSL to GLSL

newpolaris 2018. 10. 17. 21:19
  1. atan vs atan2

texture에 검은선이 나와서 먼지 찾았다. clamp 로 했으니 검은선은 텍스쳐 범위를 벗어났다는 건데

https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/atan.xhtml http://egloos.zum.com/indra207/v/4856054

우선 Direct9 기준으론 atan2 의 경우 x가 작은경우에도 작동한다

논의는 아래 있었고

https://stackoverflow.com/questions/26070410/robust-atany-x-on-glsl-for-converting-xy-coordinate-to-angle

좀더 정리된 것은,

https://qiita.com/7CIT/items/ad76cfa6771641951d31

// glsl의 atan은 다른 프로그래밍 언어 구현의 atan2의 180도 이상의 값에 대한
// 처리는되어 있지만, 0으로 나누기 만 대응하고 있지 않습니다.

float  atan2 ( in  float  y ,  in  float  x ) { 
    return  x  ==  0 . 0  ?  sign ( y ) * PI / 2  :  atan ( y ,  x ); 
}
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크