浏览代码

Merge remote-tracking branch 'refs/remotes/origin/master' into new-light-editor

/main
sebastienlagarde 7 年前
当前提交
eb326aeb
共有 9 个文件被更改,包括 1262 次插入26 次删除
  1. 94
      TestbedPipelines/Fptl/FptlLighting.cs
  2. 10
      SampleScenes/OnTileDeferredTest/ParticleAdd.meta
  3. 1001
      SampleScenes/OnTileDeferredTest/ParticleAdd/ParticleAdd.unity
  4. 9
      SampleScenes/OnTileDeferredTest/ParticleAdd/ParticleAdd.unity.meta
  5. 77
      SampleScenes/OnTileDeferredTest/ParticleAdd/PlaneMat.mat
  6. 10
      SampleScenes/OnTileDeferredTest/ParticleAdd/PlaneMat.mat.meta
  7. 77
      SampleScenes/OnTileDeferredTest/ParticleAdd/StdParticles.mat
  8. 10
      SampleScenes/OnTileDeferredTest/ParticleAdd/StdParticles.mat.meta

94
TestbedPipelines/Fptl/FptlLighting.cs


// build per tile light lists
var numLights = GenerateSourceLightBuffers(camera, cullResults);
CommandBuffer cmdPreShadows = CommandBufferPool.Get();
GPUFence preShadowsFence = cmdPreShadows.CreateGPUFence();
loop.ExecuteCommandBuffer(cmdPreShadows);
CommandBufferPool.Release(cmdPreShadows);
GPUFence postLightListFence;
if (k_UseAsyncCompute)
{
CommandBuffer cmdPreShadows = CommandBufferPool.Get();
GPUFence preShadowsFence = cmdPreShadows.CreateGPUFence();
loop.ExecuteCommandBuffer(cmdPreShadows);
CommandBufferPool.Release(cmdPreShadows);
GPUFence postLightListFence = BuildPerTileLightLists(camera, loop, numLights, projscr, invProjscr, preShadowsFence);
postLightListFence = BuildPerTileLightListsAsync(camera, loop, numLights, projscr, invProjscr, preShadowsFence);
}
else
{
BuildPerTileLightLists(camera, loop, numLights, projscr, invProjscr);
}
CommandBuffer cmdShadow = CommandBufferPool.Get();
m_ShadowMgr.RenderShadows( m_FrameId, loop, cmdShadow, cullResults, cullResults.visibleLights );

// Push all global params
var numDirLights = UpdateDirectionalLights(camera, cullResults.visibleLights, m_ShadowIndices);
PushGlobalParams(camera, loop, CameraToWorld(camera), projscr, invProjscr, numDirLights, postLightListFence);
if (k_UseAsyncCompute)
{
PushGlobalParamsWithFence(camera, loop, CameraToWorld(camera), projscr, invProjscr, numDirLights, postLightListFence);
}
else
{
PushGlobalParams(camera, loop, CameraToWorld(camera), projscr, invProjscr, numDirLights);
}
// do deferred lighting
DoTiledDeferredLighting(camera, loop, numLights, numDirLights);

cmd.DispatchCompute(buildPerVoxelLightListShader, s_GenListPerVoxelKernel, nrTilesClustX, nrTilesClustY, 1);
}
GPUFence BuildPerTileLightLists(Camera camera, ScriptableRenderContext loop, int numLights, Matrix4x4 projscr, Matrix4x4 invProjscr, GPUFence startFence)
void BuildPerTileLightLists(Camera camera, ScriptableRenderContext loop, int numLights, Matrix4x4 projscr, Matrix4x4 invProjscr)
{
var cmd = CommandBufferPool.Get("Build light list");
BuildPerTileLightListsCommon(camera, loop, numLights, projscr, invProjscr, cmd);
loop.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);
}
GPUFence BuildPerTileLightListsAsync(Camera camera, ScriptableRenderContext loop, int numLights, Matrix4x4 projscr, Matrix4x4 invProjscr, GPUFence startFence)
{
var cmd = CommandBufferPool.Get("Build light list");
cmd.WaitOnGPUFence(startFence);
BuildPerTileLightListsCommon(camera, loop, numLights, projscr, invProjscr, cmd);
GPUFence completeFence = cmd.CreateGPUFence();
loop.ExecuteCommandBufferAsync(cmd, ComputeQueueType.Default);
CommandBufferPool.Release(cmd);
return completeFence;
}
void BuildPerTileLightListsCommon(Camera camera, ScriptableRenderContext loop, int numLights, Matrix4x4 projscr, Matrix4x4 invProjscr, CommandBuffer cmd)
{
var w = camera.pixelWidth;
var h = camera.pixelHeight;

var numBigTilesY = (h + 63) / 64;
var cmd = CommandBufferPool.Get("Build light list" );
cmd.WaitOnGPUFence(startFence);
bool isOrthographic = camera.orthographic;

VoxelLightListGeneration(cmd, camera, numLights, projscr, invProjscr);
}
GPUFence completeFence = cmd.CreateGPUFence();
}
if (k_UseAsyncCompute)
{
loop.ExecuteCommandBufferAsync(cmd, ComputeQueueType.Default);
}
else
{
loop.ExecuteCommandBuffer(cmd);
}
void PushGlobalParams(Camera camera, ScriptableRenderContext loop, Matrix4x4 viewToWorld, Matrix4x4 scrProj, Matrix4x4 incScrProj, int numDirLights)
{
var cmd = CommandBufferPool.Get("Push Global Parameters");
PushGlobalParamsCommon(camera, loop, viewToWorld, scrProj, incScrProj, numDirLights, cmd);
return completeFence;
void PushGlobalParams(Camera camera, ScriptableRenderContext loop, Matrix4x4 viewToWorld, Matrix4x4 scrProj, Matrix4x4 incScrProj, int numDirLights, GPUFence startFence)
void PushGlobalParamsWithFence(Camera camera, ScriptableRenderContext loop, Matrix4x4 viewToWorld, Matrix4x4 scrProj, Matrix4x4 incScrProj, int numDirLights, GPUFence startFence)
PushGlobalParamsCommon(camera, loop, viewToWorld, scrProj, incScrProj, numDirLights, cmd);
CommandBufferPool.Release(cmd);
}
void PushGlobalParamsCommon(Camera camera, ScriptableRenderContext loop, Matrix4x4 viewToWorld, Matrix4x4 scrProj, Matrix4x4 incScrProj, int numDirLights, CommandBuffer cmd)
{
cmd.SetGlobalFloat("g_isOrthographic", (float) (isOrthographic ? 1 : 0));
cmd.SetGlobalFloat("g_isOrthographic", (float)(isOrthographic ? 1 : 0));
cmd.SetGlobalFloat("g_widthRT", (float)camera.pixelWidth);
cmd.SetGlobalFloat("g_heightRT", (float)camera.pixelHeight);

cmd.SetGlobalVector("g_vShadow3x3PCFTerms3", m_Shadow3X3PCFTerms[3]);
loop.ExecuteCommandBuffer(cmd);
}
}
}

10
SampleScenes/OnTileDeferredTest/ParticleAdd.meta


fileFormatVersion: 2
guid: dd93be8a256b64de28900fcc9e11931c
folderAsset: yes
timeCreated: 1505339552
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

1001
SampleScenes/OnTileDeferredTest/ParticleAdd/ParticleAdd.unity
文件差异内容过多而无法显示
查看文件

9
SampleScenes/OnTileDeferredTest/ParticleAdd/ParticleAdd.unity.meta


fileFormatVersion: 2
guid: 2a5f5c6ec05084393a12f7af029efa90
timeCreated: 1505339562
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

77
SampleScenes/OnTileDeferredTest/ParticleAdd/PlaneMat.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: PlaneMat
m_Shader: {fileID: 4800000, guid: b262af00aeb504b0a8eba68d77150908, type: 3}
m_ShaderKeywords: _ALPHAPREMULTIPLY_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _GlossMapScale: 1
- _Glossiness: 1
- _GlossyReflections: 1
- _Metallic: 0.884
- _Mode: 3
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 0.48529398, g: 0.9361055, b: 1, a: 0.166}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

10
SampleScenes/OnTileDeferredTest/ParticleAdd/PlaneMat.mat.meta


fileFormatVersion: 2
guid: 49e94d65997c242858db4531fea4f4b4
timeCreated: 1505339736
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

77
SampleScenes/OnTileDeferredTest/ParticleAdd/StdParticles.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: StdParticles
m_Shader: {fileID: 4800000, guid: b262af00aeb504b0a8eba68d77150908, type: 3}
m_ShaderKeywords: _ALPHABLEND_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 10300, guid: 0000000000000000f000000000000000, type: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _GlossMapScale: 1
- _Glossiness: 1
- _GlossyReflections: 1
- _Metallic: 0.403
- _Mode: 2
- _OcclusionStrength: 1
- _Parallax: 0.02
- _SmoothnessTextureChannel: 0
- _SpecularHighlights: 1
- _SrcBlend: 5
- _UVSec: 0
- _ZWrite: 0
m_Colors:
- _Color: {r: 0.91551733, g: 1, b: 0.125, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

10
SampleScenes/OnTileDeferredTest/ParticleAdd/StdParticles.mat.meta


fileFormatVersion: 2
guid: ed6ae5849a13146e08712fb517e7eebb
timeCreated: 1505339751
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存