浏览代码

fixed scene view

/main
vlad-andreev 8 年前
当前提交
4382d424
共有 3 个文件被更改,包括 22 次插入8 次删除
  1. 20
      Assets/ScriptableRenderLoop/fptl/FptlLighting.cs
  2. 5
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader
  3. 5
      Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader

20
Assets/ScriptableRenderLoop/fptl/FptlLighting.cs


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();

5
Assets/ScriptableRenderLoop/fptl/Internal-DeferredReflections.shader


uniform float4x4 g_mWorldToView;
uniform float4x4 g_mInvScrProjection;
uniform float4x4 g_mScrProjection;
uniform float g_flipVertical; // giant temp hack, see DoTiledDeferredLighting()
Texture2D _CameraDepthTexture;
Texture2D _CameraGBufferTexture0;

uint nrTilesX = (iWidth+15)/16;
uint nrTilesY = (iHeight+15)/16;
pixCoord.y = (iHeight-1) - pixCoord.y;
if (g_flipVertical > 0)
pixCoord.y = (iHeight - 1) - pixCoord.y;
uint2 tileIDX = pixCoord / 16;
const int offs = tileIDX.y*nrTilesX+tileIDX.x + nrTilesX*nrTilesY; // offset to where the reflection probes are

5
Assets/ScriptableRenderLoop/fptl/Internal-DeferredShading.shader


uniform float4x4 g_mViewToWorld;
uniform float4x4 g_mInvScrProjection;
uniform float4x4 g_mScrProjection;
uniform float g_flipVertical; // giant temp hack, see DoTiledDeferredLighting()
Texture2D _CameraDepthTexture;
Texture2D _CameraGBufferTexture0;

uint nrTilesX = (iWidth+15)/16;
uint nrTilesY = (iHeight+15)/16;
pixCoord.y = (iHeight-1) - pixCoord.y;
if (g_flipVertical > 0)
pixCoord.y = (iHeight-1) - pixCoord.y;
uint2 tileIDX = pixCoord / 16;
const int offs = tileIDX.y*nrTilesX+tileIDX.x;

正在加载...
取消
保存