|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// 1. Allocate if necessary target texture
|
|
|
|
var renderCamera = GetRenderCamera(); |
|
|
|
var hdCamera = HDCamera.Get(renderCamera); |
|
|
|
|
|
|
|
if (hdCamera == null) |
|
|
|
{ |
|
|
|
// Warning: this is a bad design pattern.
|
|
|
|
// An individual system should not create an HDCamera (which is a shared resource).
|
|
|
|
hdCamera = HDCamera.Create(renderCamera, null); |
|
|
|
} |
|
|
|
|
|
|
|
hdCamera.Update(probe.frameSettings, null, null); |
|
|
|
|
|
|
|
if (!IsRealtimeTextureValid(probe.realtimeTexture, hdCamera)) |
|
|
|
if (!IsRealtimeTextureValid(probe.realtimeTexture)) |
|
|
|
{ |
|
|
|
if (probe.realtimeTexture != null) |
|
|
|
probe.realtimeTexture.Release(); |
|
|
|
|
|
|
m_PlanarReflectionProbe_RequestRealtimeRender.Clear(); |
|
|
|
|
|
|
|
// 1. Allocate if necessary target texture
|
|
|
|
var camera = GetRenderCamera(); |
|
|
|
var hdCamera = HDCamera.Get(camera); |
|
|
|
|
|
|
|
if (hdCamera == null) |
|
|
|
{ |
|
|
|
// Warning: this is a bad design pattern.
|
|
|
|
// An individual system should not create an HDCamera (which is a shared resource).
|
|
|
|
hdCamera = HDCamera.Create(camera, null); |
|
|
|
} |
|
|
|
|
|
|
|
hdCamera.Update(probe.frameSettings, null, null); |
|
|
|
|
|
|
|
if (!IsRealtimeTextureValid(probe.realtimeTexture, hdCamera)) |
|
|
|
if (!IsRealtimeTextureValid(probe.realtimeTexture)) |
|
|
|
{ |
|
|
|
if (probe.realtimeTexture != null) |
|
|
|
probe.realtimeTexture.Release(); |
|
|
|
|
|
|
// }
|
|
|
|
//}
|
|
|
|
|
|
|
|
bool IsRealtimeTextureValid(RenderTexture renderTexture, HDCamera hdCamera) |
|
|
|
bool IsRealtimeTextureValid(RenderTexture renderTexture) |
|
|
|
{ |
|
|
|
return renderTexture != null |
|
|
|
&& renderTexture.width == m_Parameters.planarReflectionProbeSize |
|
|
|
|
|
|
|
|
|
|
public void Render(PlanarReflectionProbe probe, RenderTexture target, Camera viewerCamera = null) |
|
|
|
{ |
|
|
|
var renderCamera = GetRenderHDCamera(probe); |
|
|
|
renderCamera.camera.targetTexture = target; |
|
|
|
var renderCamera = GetRenderCamera(); |
|
|
|
SetupCameraForRender(renderCamera.camera, probe, viewerCamera); |
|
|
|
// Copy current frameSettings of this probe to the HDAdditionalData of the render camera
|
|
|
|
probe.frameSettings.CopyTo(s_RenderCameraData.GetFrameSettings()); |
|
|
|
|
|
|
|
renderCamera.targetTexture = target; |
|
|
|
|
|
|
|
SetupCameraForRender(renderCamera, probe, viewerCamera); |
|
|
|
renderCamera.camera.Render(); |
|
|
|
renderCamera.Render(); |
|
|
|
renderCamera.camera.targetTexture = null; |
|
|
|
renderCamera.targetTexture = null; |
|
|
|
target.IncrementUpdateCount(); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
var forward = reflectionMatrix.MultiplyVector(viewerCamera.transform.forward); |
|
|
|
var up = reflectionMatrix.MultiplyVector(viewerCamera.transform.up); |
|
|
|
captureRotation = Quaternion.LookRotation(forward, up); |
|
|
|
} |
|
|
|
|
|
|
|
public static HDCamera GetRenderHDCamera(PlanarReflectionProbe probe) |
|
|
|
{ |
|
|
|
var camera = GetRenderCamera(); |
|
|
|
|
|
|
|
probe.frameSettings.CopyTo(s_RenderCameraData.GetFrameSettings()); |
|
|
|
|
|
|
|
var hdCamera = HDCamera.Get(camera); |
|
|
|
|
|
|
|
if (hdCamera == null) |
|
|
|
{ |
|
|
|
// Warning: this is a bad design pattern.
|
|
|
|
// An individual system should not create an HDCamera (which is a shared resource).
|
|
|
|
hdCamera = HDCamera.Create(camera, null); |
|
|
|
} |
|
|
|
|
|
|
|
hdCamera.Update(probe.frameSettings, null, null); |
|
|
|
|
|
|
|
return hdCamera; |
|
|
|
} |
|
|
|
|
|
|
|
static Camera GetRenderCamera() |
|
|
|