카테고리 없음

CSM 디버깅 화면 출력

newpolaris 2018. 10. 26. 22:39

결국 가장 기본 방법으로도 아리펙트는 존재하지만 화면에 제대로 출력된다

기본만 계속 시도했으면 빠르게 결과를 얻을 수 있었을 건데;

아리펙트 개선판 더해서 되는건가 해서 시간만 낭비했다

기본 방법인 아래 걸로 시도

http://ogldev.atspace.co.uk/www/tutorial49/tutorial49.html

여러 오류가 존재하지만,

마지막 까지 괴롭힌 오류는 UV 좌표 넘어가는 부분

결국, matrix 역계산과 좌표 문제였다

minPoint = glm::min(minPoint, positionLS);
maxPoint = glm::max(maxPoint, positionLS);

m_ShadowOrthoProject[i] = { minPoint.x, maxPoint.x, minPoint.y, maxPoint.y, -maxPoint.z, -minPoint.z };

glm::orth는 n, f 를 입력으로 받음. view에서의 양수값을 기대하기에 뒤집어 줘야한다.

float aspect = (float)Graphics::g_NativeHeight/Graphics::g_NativeWidth;
float tanHalfHorizontalFOV = glm::tan(glm::radians(m_Settings.fov / 2.f));
float tanHalfVerticalFOV = glm::tan(glm::radians(m_Settings.fov*aspect/ 2.f));

우선, 원본은 glm 안쓰는데;

depth, ligthveiw depth 의 경우

uv >= 1 인 부분 출력

하고, world position 구해서

uv 값 계산해보니 실제로도 1 이상의 값이 나왔다.

glm의 경우에서와 같이

float aspect = (float)Graphics::g_NativeWidth/Graphics::g_NativeHeight;
float halfFovY = glm::radians(m_Settings.fov / 2.f);
float tanHalfVerticalFOV = glm::tan(halfFovY);
float tanHalfHorizontalFOV = tanHalfVerticalFOV*aspect;

위와 같이 바꾸니 문제 없어졌다.

근접시 그림자 안 맺히는 문제는,

DX 할땐 shadow caster 를 포함하도록 크기 조작했던 것 같은데;

// depth clamping so that the shadow maps keep from moving 
// through objects which causes shadows to disappear.
glEnable(GL_DEPTH_CLAMP)

위에거 괜찮은 듯?

https://icedmaster.wordpress.com/2016/12/13/glenablegl_depth_clamp/

적고나니 간단하고 시간 쏟은 이유를 모르겠지만;

(기본 예제가 적고 개선판만 존재하는 이유도 알겠지만)

분명 오후 3시에 lightdpeth 가 1 보다 큰 부분에 대해서

예외처리해야하는가 고민했던건 사실이다;

정리전의 작업 코드

https://github.com/newpolaris/Atmospheric-Scattering/tree/BasicCSM