浏览代码

Update to match core code.

/main
Tim Cooper 7 年前
当前提交
74bdfc61
共有 2 个文件被更改,包括 30 次插入31 次删除
  1. 40
      Assets/Scripts/Rendering/MyLWRenderer.cs
  2. 21
      Assets/Scripts/Rendering/WaterFXPass.cs

40
Assets/Scripts/Rendering/MyLWRenderer.cs


#endif
private WaterFXPass m_WaterFXPass;
public RenderTargetHandle Color;
public RenderTargetHandle DepthAttachment;
public RenderTargetHandle DepthTexture;
public RenderTargetHandle OpaqueColor;
public RenderTargetHandle DirectionalShadowmap;
public RenderTargetHandle LocalShadowmap;
public RenderTargetHandle ScreenSpaceShadowmap;
private RenderTargetHandle Color;
private RenderTargetHandle DepthAttachment;
private RenderTargetHandle DepthTexture;
private RenderTargetHandle OpaqueColor;
private RenderTargetHandle DirectionalShadowmap;
private RenderTargetHandle LocalShadowmap;
private RenderTargetHandle ScreenSpaceShadowmap;
[NonSerialized]
private bool m_Initialized = false;

// RenderTexture format depends on camera and pipeline (HDR, non HDR, etc)
// Samples (MSAA) depend on camera and pipeline
renderer.RegisterSurface("_CameraColorTexture", out Color);
renderer.RegisterSurface("_CameraDepthAttachment", out DepthAttachment);
renderer.RegisterSurface("_CameraDepthTexture", out DepthTexture);
renderer.RegisterSurface("_CameraOpaqueTexture", out OpaqueColor);
renderer.RegisterSurface("_DirectionalShadowmapTexture", out DirectionalShadowmap);
renderer.RegisterSurface("_LocalShadowmapTexture", out LocalShadowmap);
renderer.RegisterSurface("_ScreenSpaceShadowMapTexture", out ScreenSpaceShadowmap);
Color.Init("_CameraColorTexture");
DepthAttachment.Init("_CameraDepthAttachment");
DepthTexture.Init("_CameraDepthTexture");
OpaqueColor.Init("_CameraOpaqueTexture");
DirectionalShadowmap.Init("_DirectionalShadowmapTexture");
LocalShadowmap.Init("_LocalShadowmapTexture");
ScreenSpaceShadowmap.Init("_ScreenSpaceShadowMapTexture");
m_Initialized = true;
}

ref renderingData.cameraData,
baseDescriptor,
requiresDepthAttachment);
RenderTargetHandle colorHandle = (requiresColorAttachment) ? Color : RenderTargetHandle.BackBuffer;
RenderTargetHandle depthHandle = (requiresDepthAttachment) ? DepthAttachment : RenderTargetHandle.BackBuffer;
RenderTargetHandle colorHandle = (requiresColorAttachment) ? Color : RenderTargetHandle.CameraTarget;
RenderTargetHandle depthHandle = (requiresDepthAttachment) ? DepthAttachment : RenderTargetHandle.CameraTarget;
var sampleCount = (SampleCount)renderingData.cameraData.msaaSamples;
m_CreateLightweightRenderTexturesPass.Setup(baseDescriptor, colorHandle, depthHandle, sampleCount);

renderer.EnqueuePass(m_SetupLightweightConstants);
//renderer.EnqueuePass(m_WaterFXPass);
renderer.EnqueuePass(m_WaterFXPass);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, LightweightForwardRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration, dynamicBatching);
renderer.EnqueuePass(m_RenderOpaqueForwardPass);

if (camera.clearFlags == CameraClearFlags.Skybox)
renderer.EnqueuePass(m_DrawSkyboxPass);
if (depthHandle != RenderTargetHandle.BackBuffer)
if (depthHandle != RenderTargetHandle.CameraTarget)
{
m_CopyDepthPass.Setup(depthHandle, DepthTexture);
renderer.EnqueuePass(m_CopyDepthPass);

m_TransparentPostProcessPass.Setup(baseDescriptor, colorHandle);
renderer.EnqueuePass(m_TransparentPostProcessPass);
}
else if (!renderingData.cameraData.isOffscreenRender && colorHandle != RenderTargetHandle.BackBuffer)
else if (!renderingData.cameraData.isOffscreenRender && colorHandle != RenderTargetHandle.CameraTarget)
{
m_FinalBlitPass.Setup(baseDescriptor, colorHandle);
renderer.EnqueuePass(m_FinalBlitPass);

21
Assets/Scripts/Rendering/WaterFXPass.cs


public class WaterFXPass : ScriptableRenderPass
{
const string k_RenderWaterFXTag = "Render Water FX";
RenderTexture m_WaterFXTexture;
private RenderTargetHandle m_WaterFX = RenderTargetHandle.CameraTarget;
m_WaterFX.Init("_WaterFXMap");
}
public override void Execute(ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData)

RenderTextureDescriptor descriptor = renderer.CreateRTDesc(ref renderingData.cameraData);
//descriptor.width = (int)(descriptor.width * 0.5f);
//descriptor.height = (int)(descriptor.height * 0.5f);
descriptor.width = (int)(descriptor.width * 0.5f);
descriptor.height = (int)(descriptor.height * 0.5f);
m_WaterFXTexture = RenderTexture.GetTemporary(descriptor);
m_WaterFXTexture.filterMode = FilterMode.Bilinear;
m_WaterFXTexture.wrapMode = TextureWrapMode.Clamp;
cmd.GetTemporaryRT(m_WaterFX.id, descriptor, FilterMode.Bilinear);
//m_WaterFXTexture.wrapMode = TextureWrapMode.Clamp;
m_WaterFXTexture,
m_WaterFX.Identifier(),
RenderBufferLoadAction.DontCare,
RenderBufferStoreAction.Store,
ClearFlag.Color,

else
context.DrawRenderers(cullResults.visibleRenderers, ref drawSettings, renderer.transparentFilterSettings);
cmd.SetGlobalTexture("_WaterFXMap", m_WaterFXTexture);
}
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);

{
if (m_WaterFXTexture)
if (m_WaterFX != RenderTargetHandle.CameraTarget)
RenderTexture.ReleaseTemporary(m_WaterFXTexture);
m_WaterFXTexture = null;
cmd.ReleaseTemporaryRT(m_WaterFX.id);
}
}
}
正在加载...
取消
保存