문제

I have implemented bloom post process effect in my game for Android using render to texture and proper shaders. It works, but the performance hit is unacceptable. So I thought that I could render the scene to smaller texture and then stretch the texture to fullscreen. The trouble is that when I attach a texture that is smaller than the viewport to the off screen framebuffer, the scene is cropped. The image below illustrates the issue:

illustration

Is there any way I could "map" the attached texture to the framebuffer somehow, so the whole viewport gets rendered to it? I could probably modify the projection matrix to achieve the goal, but that would complicate my code and I would rather avoid it.

도움이 되었습니까?

해결책

I think you can do that by simply changing the Viewport to match the texture dimensions before you do the render to texture, then set the viewport back to the dimensions of the View before you render to the framebuffer. There should be no significant performance loss because you will be calling glViewport() twice as often.

Your suggestion about scaling the projection matrix should also work.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top