|
|
|
|
|
|
cmd.Dispose(); |
|
|
|
} |
|
|
|
|
|
|
|
void DoTiledDeferredLighting(RenderLoop loop, Matrix4x4 viewToWorld, Matrix4x4 scrProj, Matrix4x4 incScrProj, ComputeBuffer lightList) |
|
|
|
void DoTiledDeferredLighting(Camera camera, RenderLoop loop, Matrix4x4 viewToWorld, Matrix4x4 scrProj, Matrix4x4 incScrProj, ComputeBuffer lightList) |
|
|
|
{ |
|
|
|
m_DeferredMaterial.SetBuffer("g_vLightList", lightList); |
|
|
|
m_DeferredReflectionMaterial.SetBuffer("g_vLightList", lightList); |
|
|
|
|
|
|
//cmd.SetRenderTarget(new RenderTargetIdentifier(kGBufferEmission), new RenderTargetIdentifier(kGBufferZ));
|
|
|
|
|
|
|
|
// for whatever reason, the output is flipped in the scene view whenever writing to the camera target.
|
|
|
|
// TODO: fix this properly.
|
|
|
|
if (camera.cameraType == CameraType.SceneView) |
|
|
|
{ |
|
|
|
cmd.SetGlobalFloat("g_flipVertical", 0); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
cmd.SetGlobalFloat("g_flipVertical", 1); |
|
|
|
} |
|
|
|
|
|
|
|
cmd.SetGlobalMatrix("g_mViewToWorld", viewToWorld); |
|
|
|
cmd.SetGlobalMatrix("g_mWorldToView", viewToWorld.inverse); |
|
|
|
cmd.SetGlobalMatrix("g_mScrProjection", scrProj); |
|
|
|
|
|
|
cmd.Blit(kGBufferEmission, (RenderTexture)null, m_DeferredMaterial, 0); |
|
|
|
cmd.Blit(kGBufferEmission, (RenderTexture)null, m_DeferredReflectionMaterial, 0); |
|
|
|
|
|
|
|
cmd.Blit(kGBufferEmission, BuiltinRenderTextureType.CameraTarget, m_DeferredMaterial, 0); |
|
|
|
cmd.Blit(kGBufferEmission, BuiltinRenderTextureType.CameraTarget, m_DeferredReflectionMaterial, 0); |
|
|
|
loop.ExecuteCommandBuffer(cmd); |
|
|
|
cmd.Dispose(); |
|
|
|
} |
|
|
|
|
|
|
loop.ExecuteCommandBuffer(cmd); |
|
|
|
cmd.Dispose(); |
|
|
|
|
|
|
|
DoTiledDeferredLighting(loop, camera.cameraToWorldMatrix, projscr, invProjscr, lightList); |
|
|
|
DoTiledDeferredLighting(camera, loop, camera.cameraToWorldMatrix, projscr, invProjscr, lightList); |
|
|
|
|
|
|
|
|
|
|
|
//lightList.Release();
|
|
|
|