성능 저하 문제 (Performance issue) - NabiEILAB/ProjectionMappingSimulator GitHub Wiki
성능 저하의 원인 (The cause of bad performance)
3D 연산을 많이 하는 프로그램인 만큼 다양한 이유로
그리고, 다양한 사양으로도 성능의 차이가 생길 여지가 크다.
비디오 영상 해상도 (Video resolution)
https://github.com/NabiEILAB/ProjectionMappingSimulator/blob/master/wiki/PerformanceProblem/screenshot01.png
https://github.com/NabiEILAB/ProjectionMappingSimulator/blob/master/wiki/PerformanceProblem/screenshot02.png
https://github.com/NabiEILAB/ProjectionMappingSimulator/blob/master/wiki/PerformanceProblem/screenshot03.png
비디오 파일들마다 제각각 다른 러닝타임, 용량, 해상도를 가지기 마련이다.
이중 성능에 가장 큰 영향을 미치는것은 영상의 해상도라는 것을 알 수 있다.
렌더링 범위 (Rendering scope)
https://github.com/NabiEILAB/ProjectionMappingSimulator/blob/master/wiki/PerformanceProblem/screenshot04.png
보통 빔 프로젝터와 피투영체와의 거리가 멀어질수록 투사되는 영상의 크기는 커지기 마련이다.
-3000 이내로 존재하는 모델링의 모든 텍스쳐 좌표에 텍스쳐가 입혀지려면
빔 프로젝터의 현 z좌표 위치와 -3000 좌표까지의 거리에 따른 영상의 크기를 계산하여
해당 크기만큼 FBO를 할당하기 때문에 렌더링 범위가 -3000보다 더 깊은 곳으로 설정되면
결국 큰 메모리를 이용하게 되어 범위가 넓어질수록 성능이 저하되는 설계를 따른다.
다중 빔 프로젝터 렌더링 (Multiple beam projectors rendering)
https://github.com/NabiEILAB/ProjectionMappingSimulator/blob/master/wiki/PerformanceProblem/screenshot05.png
프로젝션 맵핑 연산을 빔 프로젝터마다 하나씩 수행하는데
빔 프로젝터가 늘어나면 연산량이 늘어나 성능저하가 일어날 수 밖에 없다.
쉐이더 연산 (Shader calculation)
프로젝션 맵핑 연산의 핵심인 쉐이더 연산이 복잡할수록
성능저하의 원인이 될 수 있다.
현재 계산의 영향을 미치는 기법은 다음과 같다.
Per pixel lighting 연산 (Per pixel lighting calculation)
https://github.com/NabiEILAB/ProjectionMappingSimulator/blob/master/wiki/PerformanceProblem/screenshot06.png
광원 효과를 보다 사실적으로 처리하기 위해 광원 연산을
Vertex수준이 아닌 보다 세부적인 Pixel당 계산으로 처리하기 때문에
연산량이 엄청나게 늘어나게 된다.
https://github.com/NabiEILAB/ProjectionMappingSimulator/blob/master/wiki/PerformanceProblem/screenshot07.png
쉐이더 파일을 보면 알 수 있듯이 vert 파일보다 frag파일에 훨씬 코드량이 많고 그 코드가 전부
복잡한 수치연산식임을 알 수 있다. 이런식으로 픽셀단위로 광원계산을 하게되므로
연산량이 많아지기 마련이다.
Poisson Disk 슈퍼샘플링 (Poisson Disk supersampling)
https://github.com/NabiEILAB/ProjectionMappingSimulator/blob/master/wiki/PerformanceProblem/screenshot08.png
그림자를 표현할때 경계부가 너무 거칠어서 이를 부드럽게 해주는
슈퍼샘플링 기법으로 '포아송-디스크' 기법을 이용하였다.
쉐이더 내에서 아주 간단하게 구현할 수 있어서 이용하였지만
실시간 렌더링에서는 사실 반복되는 연산량으로 인해 성능저하를 일으킨다.