我在我的场景中做了一个镜面的效果,使用的SceneCapture2D组件渲染到一张RenderTarget上再作为模型贴图放到场景模型上去。
但我发现当我将RenderTarget的大小设置的超过1920*1080(我设置的是2048*2048)的时候,不用编辑器模式(使用客户端进程连接服务器)运行的时候,场景会变的很卡,当然用编辑器模式运行也会有点卡只是不是那么明显。
后来我将客户端日志打出来后发现是系统渲染的时候一直不停地在重新分配RenderTarget的大小,差不多是每隔1帧就会重新分配RenderTarget的大小为1920*1080然后再分配为2048*2048,具体日志如下:
LogRenderer:Reallocating scene render targets to support 1920x1080 (Frame:371).
LogRenderer:Reallocating scene render targets to support 2048x2048 (Frame:371).LogRenderer:Reallocating scene render targets to support 1920x1080 (Frame:373).
LogRenderer:Reallocating scene render targets to support 2048x2048 (Frame:373).
LogRenderer:Reallocating scene render targets to support 1920x1080 (Frame:375).
LogRenderer:Reallocating scene render targets to support 2048x2048 (Frame:375).
LogRenderer:Reallocating scene render targets to support 1920x1080 (Frame:377).
LogRenderer:Reallocating scene render targets to support 2048x2048 (Frame:377).
LogRenderer:Reallocating scene render targets to support 1920x1080 (Frame:379).
LogRenderer:Reallocating scene render targets to support 2048x2048 (Frame:379)....
如果设置RenderTarget大小小于1920*1080就不会出现以上的问题和log,蓝瘦香菇,求大神帮忙看一下这是什么问题导致的,该如何解决
后来我发现在Engine代码SceneCapture.cpp中第208行有这样一段注释:
//NOTE: ikrimae: Ensure that the main gameview is > CaptureWidth x CaptureHeight. Bug in UE4 that won't re-alloc scene render targets to the correct size
// when the scenecapture component > current window render target. https://answers.unrealengine.com ... max-resolution.html
//TODO: ikrimae: Ensure that r.SceneRenderTargetResizeMethod=2
所以看来这是ue4的一个BUG,就是不能将Capture的精度设置的超过窗口大小