浏览代码

Merge branch 'HDRP/add-LightLayer-in-probes' of https://github.com/Unity-Technologies/ScriptableRenderPipeline into HDRP/add-LightLayer-in-probes

/main
RSlysz 6 年前
当前提交
bac41534
共有 38 个文件被更改,包括 144 次插入160 次删除
  1. 6
      com.unity.render-pipelines.high-definition/HDRP/HDRenderPipelineAsset.asset
  2. 15
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.hlsl
  3. 1
      com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl
  4. 10
      com.unity.render-pipelines.lightweight/CHANGELOG.md
  5. 20
      com.unity.render-pipelines.lightweight/LWRP/DefaultRendererSetup.cs
  6. 2
      com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGUI/LightweightShaderGUI.cs
  7. 4
      com.unity.render-pipelines.lightweight/LWRP/IRendererSetup.cs
  8. 80
      com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs
  9. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/BeginXRRenderingPass.cs
  10. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/CopyColorPass.cs
  11. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/CopyDepthPass.cs
  12. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/CreateLightweightRenderTexturesPass.cs
  13. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/DepthOnlyPass.cs
  14. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs
  15. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/DrawSkyboxPass.cs
  16. 4
      com.unity.render-pipelines.lightweight/LWRP/Passes/EndXRRenderingPass.cs
  17. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/FinalBlitPass.cs
  18. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/LightweightForwardPass.cs
  19. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/LocalShadowsPass.cs
  20. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/OpaquePostProcessPass.cs
  21. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/RenderOpaqueForwardPass.cs
  22. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/RenderTransparentForwardPass.cs
  23. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/SceneViewDepthCopy.cs
  24. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/ScreenSpaceShadowResolvePass.cs
  25. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/ScriptableRenderPass.cs
  26. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/SetupForwardRenderingPass.cs
  27. 50
      com.unity.render-pipelines.lightweight/LWRP/Passes/SetupLightweightConstanstPass.cs
  28. 2
      com.unity.render-pipelines.lightweight/LWRP/Passes/TransparentPostProcessPass.cs
  29. 15
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Core.hlsl
  30. 9
      com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Input.hlsl
  31. 4
      com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs
  32. 8
      com.unity.testing.srp.lightweight/Tests/Scenes/045_CustomLWPipe/CustomLWPipe.cs
  33. 11
      com.unity.render-pipelines.lightweight/LWRP/Passes/ForwardLitPass.cs.meta
  34. 0
      com.unity.render-pipelines.lightweight/LWRP/Passes/ForwardLitPass.cs
  35. 13
      com.unity.render-pipelines.lightweight/LWRP/LightweightConstantBuffer.cs.meta
  36. 8
      com.unity.render-pipelines.lightweight/LWRP/LightweightConstantBuffer.cs
  37. 0
      /com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs.meta
  38. 0
      /com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs

6
com.unity.render-pipelines.high-definition/HDRP/HDRenderPipelineAsset.asset


MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 0}
m_Enabled: 1
m_EditorHideFlags: 0

increaseSssSampleCount: 0
supportVolumetrics: 1
increaseResolutionOfVolumetrics: 0
supportLightLayers: 1
supportLightLayers: 0
supportOnlyForward: 0
supportDecals: 1
supportMSAA: 0

shadowInitParams:
shadowAtlasWidth: 4096
shadowAtlasHeight: 4096
shadowMap16Bit: 0
maxPointLightShadows: 6
maxSpotLightShadows: 12
maxDirectionalLightShadows: 1

15
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoop.hlsl


}
// Define macro for a better understanding of the loop
#define EVALUATE_BSDF_ENV(envLightData, TYPE, type) \
if (IsMatchingLightLayer(envLightData.lightLayers, builtinData.renderingLayers)) \
{ \
#define EVALUATE_BSDF_ENV_SKY(envLightData, TYPE, type) \
AccumulateIndirectLighting(lighting, aggregateLighting); \
}
AccumulateIndirectLighting(lighting, aggregateLighting);
// Environment cubemap test lightlayers, sky don't test it
#define EVALUATE_BSDF_ENV(envLightData, TYPE, type) if (IsMatchingLightLayer(envLightData.lightLayers, builtinData.renderingLayers)) { EVALUATE_BSDF_ENV_SKY(envLightData, TYPE, type) }
// First loop iteration
if (featureFlags & (LIGHTFEATUREFLAGS_ENV | LIGHTFEATUREFLAGS_SKY | LIGHTFEATUREFLAGS_SSREFRACTION | LIGHTFEATUREFLAGS_SSREFLECTION))

// Only apply the sky if we haven't yet accumulated enough IBL lighting.
if (reflectionHierarchyWeight < 1.0)
{
EVALUATE_BSDF_ENV(envLightSky, REFLECTION, reflection);
EVALUATE_BSDF_ENV_SKY(envLightSky, REFLECTION, reflection);
}
if (featureFlags & LIGHTFEATUREFLAGS_SSREFRACTION)

EVALUATE_BSDF_ENV(envLightSky, REFRACTION, refraction);
EVALUATE_BSDF_ENV_SKY(envLightSky, REFRACTION, refraction);
#undef EVALUATE_BSDF_ENV_SKY
// Also Apply indiret diffuse (GI)
// PostEvaluateBSDF will perform any operation wanted by the material and sum everything into diffuseLighting and specularLighting

1
com.unity.render-pipelines.high-definition/HDRP/Lighting/LightLoop/LightLoopDef.hlsl


{
EnvLightData output;
ZERO_INITIALIZE(EnvLightData, output);
output.lightLayers = 0xFFFFFFFF; // Enable sky for all layers
output.influenceShapeType = ENVSHAPETYPE_SKY;
// 31 bit index, 1 bit cache type
output.envIndex = ENVCACHETYPE_CUBEMAP | (envIndex << 1);

10
com.unity.render-pipelines.lightweight/CHANGELOG.md


and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
## [3.3.0-preview]
### Added
- UNITY_DECLARE_FRAMEBUFFER_INPUT and UNITY_READ_FRAMEBUFFER_INPUT macros were added. They are necessary for reading transient attachments.
- UNITY_MATRIX_I_VP is now defined.
### Changed
- Renamed LightweightForwardRenderer to ScriptableRenderer.
- Moved all light constants to _LightBuffer CBUFFER. Now _PerCamera CBUFFER contains all other per camera constants.
### Fixed
- Lightweight Unlit shader UI doesn't throw an error about missing receive shadow property anymore.
## [3.2.0-preview]
### Changed

20
com.unity.render-pipelines.lightweight/LWRP/DefaultRendererSetup.cs


private DirectionalShadowsPass m_DirectionalShadowPass;
private LocalShadowsPass m_LocalShadowPass;
private SetupForwardRenderingPass m_SetupForwardRenderingPass;
private ScreenSpaceShadowResolvePass m_ScreenSpaceShadowResovePass;
private ScreenSpaceShadowResolvePass m_ScreenSpaceShadowResolvePass;
private CreateLightweightRenderTexturesPass m_CreateLightweightRenderTexturesPass;
private BeginXRRenderingPass m_BeginXrRenderingPass;
private SetupLightweightConstanstPass m_SetupLightweightConstants;

m_DirectionalShadowPass = new DirectionalShadowsPass();
m_LocalShadowPass = new LocalShadowsPass();
m_SetupForwardRenderingPass = new SetupForwardRenderingPass();
m_ScreenSpaceShadowResovePass = new ScreenSpaceShadowResolvePass();
m_ScreenSpaceShadowResolvePass = new ScreenSpaceShadowResolvePass();
m_CreateLightweightRenderTexturesPass = new CreateLightweightRenderTexturesPass();
m_BeginXrRenderingPass = new BeginXRRenderingPass();
m_SetupLightweightConstants = new SetupLightweightConstanstPass();

m_Initialized = true;
}
public void Setup(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults, ref RenderingData renderingData)
{
Init();

renderer.SetupPerObjectLightIndices(ref cullResults, ref renderingData.lightData);
RenderTextureDescriptor baseDescriptor = LightweightForwardRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor baseDescriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor shadowDescriptor = baseDescriptor;
shadowDescriptor.dimension = TextureDimension.Tex2D;

(requiresCameraDepth &&
!LightweightForwardRenderer.CanCopyDepth(ref renderingData.cameraData));
!ScriptableRenderer.CanCopyDepth(ref renderingData.cameraData));
// For now VR requires a depth prepass until we figure out how to properly resolve texture2DMS in stereo
requiresDepthPrepass |= renderingData.cameraData.isStereoEnabled;

if (renderingData.shadowData.renderDirectionalShadows &&
renderingData.shadowData.requiresScreenSpaceShadowResolve)
{
m_ScreenSpaceShadowResovePass.Setup(baseDescriptor, ScreenSpaceShadowmap);
renderer.EnqueuePass(m_ScreenSpaceShadowResovePass);
m_ScreenSpaceShadowResolvePass.Setup(baseDescriptor, ScreenSpaceShadowmap);
renderer.EnqueuePass(m_ScreenSpaceShadowResolvePass);
LightweightForwardRenderer.RequiresIntermediateColorTexture(
ScriptableRenderer.RequiresIntermediateColorTexture(
ref renderingData.cameraData,
baseDescriptor,
requiresDepthAttachment);

Camera camera = renderingData.cameraData.camera;
bool dynamicBatching = renderingData.supportsDynamicBatching;
RendererConfiguration rendererConfiguration = LightweightForwardRenderer.GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount);
RendererConfiguration rendererConfiguration = ScriptableRenderer.GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, LightweightForwardRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration,dynamicBatching);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ScriptableRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration,dynamicBatching);
renderer.EnqueuePass(m_RenderOpaqueForwardPass);
if (renderingData.cameraData.postProcessEnabled &&

2
com.unity.render-pipelines.lightweight/LWRP/Editor/ShaderGUI/LightweightShaderGUI.cs


cullingProp = FindProperty("_Cull", properties);
alphaClipProp = FindProperty("_AlphaClip", properties);
alphaCutoffProp = FindProperty("_Cutoff", properties);
receiveShadowsProp = FindProperty("_ReceiveShadows", properties);
receiveShadowsProp = FindProperty("_ReceiveShadows", properties, false);
}
public virtual void ShaderPropertiesGUI(Material material)

4
com.unity.render-pipelines.lightweight/LWRP/IRendererSetup.cs


{
public interface IRendererSetup
{
void Setup(LightweightForwardRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData);
void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, ref RenderingData renderingData);
}
}

80
com.unity.render-pipelines.lightweight/LWRP/LightweightPipeline.cs


{
public partial class LightweightPipeline : RenderPipeline
{
private static class PerFrameBuffer
static class PerFrameBuffer
}
static class PerCameraBuffer
{
// TODO: This needs to account for stereo rendering
public static int _InvCameraViewProj;
public static int _ScaledScreenParams;
}
public LightweightPipelineAsset pipelineAsset { get; private set; }

CameraComparer m_CameraComparer = new CameraComparer();
LightweightForwardRenderer m_Renderer;
ScriptableRenderer m_Renderer;
bool m_IsCameraRendering;
public LightweightPipeline(LightweightPipelineAsset asset)
{

PerFrameBuffer._GlossyEnvironmentColor = Shader.PropertyToID("_GlossyEnvironmentColor");
PerFrameBuffer._SubtractiveShadowColor = Shader.PropertyToID("_SubtractiveShadowColor");
SetupLightweightConstanstPass.PerCameraBuffer._ScaledScreenParams = Shader.PropertyToID("_ScaledScreenParams");
m_Renderer = new LightweightForwardRenderer(asset);
PerCameraBuffer._InvCameraViewProj = Shader.PropertyToID("_InvCameraViewProj");
PerCameraBuffer._ScaledScreenParams = Shader.PropertyToID("_ScaledScreenParams");
m_Renderer = new ScriptableRenderer(asset);
// Let engine know we have MSAA on for cases where we support MSAA backbuffer
if (QualitySettings.antiAliasing != pipelineAsset.msaaSampleCount)

m_IsCameraRendering = false;
}
public override void Dispose()

public override void Render(ScriptableRenderContext context, Camera[] cameras)
{
if (m_IsCameraRendering)
{
Debug.LogWarning("Nested camera rendering is forbidden. If you are calling camera.Render inside OnWillRenderObject callback, use BeginCameraRender callback instead.");
return;
}
pipelineAsset.savedXRGraphicsConfig.renderScale = pipelineAsset.renderScale;
pipelineAsset.savedXRGraphicsConfig.viewportScale = 1.0f; // Placeholder until viewportScale is all hooked up
// Apply any changes to XRGConfig prior to this point

foreach (Camera camera in cameras)
{
BeginCameraRendering(camera);
string renderCameraTag = "Render " + camera.name;
string renderCameraTag = camera.name;
CommandBuffer cmd = CommandBufferPool.Get(renderCameraTag);
using (new ProfilingSample(cmd, renderCameraTag))
{

cmd.Clear();
#if UNITY_EDITOR
try
// Emit scene view UI
if (cameraData.isSceneViewCamera)
ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
{
m_IsCameraRendering = true;
#if UNITY_EDITOR
// Emit scene view UI
if (cameraData.isSceneViewCamera)
ScriptableRenderContext.EmitWorldGeometryForSceneView(camera);
#endif
CullResults.Cull(ref cullingParameters, context, ref m_CullResults);
List<VisibleLight> visibleLights = m_CullResults.visibleLights;
CullResults.Cull(ref cullingParameters, context, ref m_CullResults);
List<VisibleLight> visibleLights = m_CullResults.visibleLights;
RenderingData renderingData;
InitializeRenderingData(ref cameraData, visibleLights,
m_Renderer.maxSupportedLocalLightsPerPass, m_Renderer.maxSupportedVertexLights,
out renderingData);
RenderingData renderingData;
InitializeRenderingData(ref cameraData, visibleLights,
m_Renderer.maxSupportedLocalLightsPerPass, m_Renderer.maxSupportedVertexLights,
out renderingData);
var setup = cameraData.camera.GetComponent<IRendererSetup>();
if (setup == null)
setup = defaultRendererSetup;
var setup = cameraData.camera.GetComponent<IRendererSetup>();
if (setup == null)
setup = defaultRendererSetup;
setup.Setup(m_Renderer, ref context, ref m_CullResults, ref renderingData);
setup.Setup(m_Renderer, ref context, ref m_CullResults, ref renderingData);
m_Renderer.Execute(ref context, ref m_CullResults, ref renderingData);
}
#if UNITY_EDITOR
catch (Exception)
{
CommandBufferPool.Release(cmd);
throw;
}
finally
#endif
{
m_IsCameraRendering = false;
}
m_Renderer.Execute(ref context, ref m_CullResults, ref renderingData);
}
context.ExecuteCommandBuffer(cmd);
CommandBufferPool.Release(cmd);

void SetupPerCameraShaderConstants(CameraData cameraData)
{
Camera camera = cameraData.camera;
Shader.SetGlobalVector(SetupLightweightConstanstPass.PerCameraBuffer._ScaledScreenParams, new Vector4(cameraWidth, cameraHeight, 1.0f + 1.0f / cameraWidth, 1.0f + 1.0f / cameraHeight));
Shader.SetGlobalVector(PerCameraBuffer._ScaledScreenParams, new Vector4(cameraWidth, cameraHeight, 1.0f + 1.0f / cameraWidth, 1.0f + 1.0f / cameraHeight));
Matrix4x4 projMatrix = GL.GetGPUProjectionMatrix(camera.projectionMatrix, false);
Matrix4x4 viewMatrix = camera.worldToCameraMatrix;
Matrix4x4 viewProjMatrix = projMatrix * viewMatrix;
Matrix4x4 invViewProjMatrix = Matrix4x4.Inverse(viewProjMatrix);
Shader.SetGlobalMatrix(PerCameraBuffer._InvCameraViewProj, invViewProjMatrix);
}
}
}

4
com.unity.render-pipelines.lightweight/LWRP/Passes/BeginXRRenderingPass.cs


{
public class BeginXRRenderingPass : ScriptableRenderPass
{
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

}
}
}

4
com.unity.render-pipelines.lightweight/LWRP/Passes/CopyColorPass.cs


this.destination = destination;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

float opaqueScaler = m_OpaqueScalerValues[(int)downsampling];
RenderTextureDescriptor opaqueDesc = LightweightForwardRenderer.CreateRTDesc(ref renderingData.cameraData, opaqueScaler);
RenderTextureDescriptor opaqueDesc = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData, opaqueScaler);
RenderTargetIdentifier colorRT = source.Identifier();
RenderTargetIdentifier opaqueColorRT = destination.Identifier();

4
com.unity.render-pipelines.lightweight/LWRP/Passes/CopyDepthPass.cs


this.destination = destination;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

Material depthCopyMaterial = renderer.GetMaterial(MaterialHandles.DepthCopy);
RenderTextureDescriptor descriptor = LightweightForwardRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor descriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
descriptor.colorFormat = RenderTextureFormat.Depth;
descriptor.depthBufferBits = 32; //TODO: fix this ;
descriptor.msaaSamples = 1;

2
com.unity.render-pipelines.lightweight/LWRP/Passes/CreateLightweightRenderTexturesPass.cs


descriptor = baseDescriptor;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/DepthOnlyPass.cs


};
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/DirectionalShadowsPass.cs


this.destination = destination;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

4
com.unity.render-pipelines.lightweight/LWRP/Passes/DrawSkyboxPass.cs


{
public class DrawSkyboxPass : ScriptableRenderPass
{
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

}
}

4
com.unity.render-pipelines.lightweight/LWRP/Passes/EndXRRenderingPass.cs


{
public class EndXRRenderingPass : ScriptableRenderPass
{
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

}
}
}
}

2
com.unity.render-pipelines.lightweight/LWRP/Passes/FinalBlitPass.cs


this.descriptor = baseDescriptor;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/LightweightForwardPass.cs


}
[Conditional("DEVELOPMENT_BUILD"), Conditional("UNITY_EDITOR")]
protected void RenderObjectsWithError(LightweightForwardRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, Camera camera, FilterRenderersSettings filterSettings, SortFlags sortFlags)
protected void RenderObjectsWithError(ScriptableRenderer renderer, ref ScriptableRenderContext context, ref CullResults cullResults, Camera camera, FilterRenderersSettings filterSettings, SortFlags sortFlags)
{
Material errorMaterial = renderer.GetMaterial(MaterialHandles.Error);
if (errorMaterial != null)

2
com.unity.render-pipelines.lightweight/LWRP/Passes/LocalShadowsPass.cs


}
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/OpaquePostProcessPass.cs


descriptor = baseDescriptor;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/RenderOpaqueForwardPass.cs


};
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/RenderTransparentForwardPass.cs


};
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/SceneViewDepthCopy.cs


this.source = source;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/ScreenSpaceShadowResolvePass.cs


descriptor = baseDescriptor;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/ScriptableRenderPass.cs


public virtual void FrameCleanup(CommandBuffer cmd)
{}
public abstract void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public abstract void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData);

2
com.unity.render-pipelines.lightweight/LWRP/Passes/SetupForwardRenderingPass.cs


{
public class SetupForwardRenderingPass : ScriptableRenderPass
{
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

50
com.unity.render-pipelines.lightweight/LWRP/Passes/SetupLightweightConstanstPass.cs


{
public class SetupLightweightConstanstPass : ScriptableRenderPass
{
public static class PerCameraBuffer
public static class LightConstantBuffer
{
public static int _MainLightPosition;
public static int _MainLightColor;

public static int _AdditionalLightSpotAttenuation;
public static int _LightIndexBuffer;
public static int _ScaledScreenParams;
}
MixedLightingSetup m_MixedLightingSetup;

public SetupLightweightConstanstPass()
{
PerCameraBuffer._MainLightPosition = Shader.PropertyToID("_MainLightPosition");
PerCameraBuffer._MainLightColor = Shader.PropertyToID("_MainLightColor");
PerCameraBuffer._MainLightCookie = Shader.PropertyToID("_MainLightCookie");
PerCameraBuffer._WorldToLight = Shader.PropertyToID("_WorldToLight");
PerCameraBuffer._AdditionalLightCount = Shader.PropertyToID("_AdditionalLightCount");
PerCameraBuffer._AdditionalLightPosition = Shader.PropertyToID("_AdditionalLightPosition");
PerCameraBuffer._AdditionalLightColor = Shader.PropertyToID("_AdditionalLightColor");
PerCameraBuffer._AdditionalLightDistanceAttenuation = Shader.PropertyToID("_AdditionalLightDistanceAttenuation");
PerCameraBuffer._AdditionalLightSpotDir = Shader.PropertyToID("_AdditionalLightSpotDir");
PerCameraBuffer._AdditionalLightSpotAttenuation = Shader.PropertyToID("_AdditionalLightSpotAttenuation");
PerCameraBuffer._LightIndexBuffer = Shader.PropertyToID("_LightIndexBuffer");
LightConstantBuffer._MainLightPosition = Shader.PropertyToID("_MainLightPosition");
LightConstantBuffer._MainLightColor = Shader.PropertyToID("_MainLightColor");
LightConstantBuffer._MainLightCookie = Shader.PropertyToID("_MainLightCookie");
LightConstantBuffer._WorldToLight = Shader.PropertyToID("_WorldToLight");
LightConstantBuffer._AdditionalLightCount = Shader.PropertyToID("_AdditionalLightCount");
LightConstantBuffer._AdditionalLightPosition = Shader.PropertyToID("_AdditionalLightPosition");
LightConstantBuffer._AdditionalLightColor = Shader.PropertyToID("_AdditionalLightColor");
LightConstantBuffer._AdditionalLightDistanceAttenuation = Shader.PropertyToID("_AdditionalLightDistanceAttenuation");
LightConstantBuffer._AdditionalLightSpotDir = Shader.PropertyToID("_AdditionalLightSpotDir");
LightConstantBuffer._AdditionalLightSpotAttenuation = Shader.PropertyToID("_AdditionalLightSpotAttenuation");
LightConstantBuffer._LightIndexBuffer = Shader.PropertyToID("_LightIndexBuffer");
m_LightPositions = new Vector4[0];
m_LightColors = new Vector4[0];

{
Matrix4x4 lightCookieMatrix;
LightweightPipeline.GetLightCookieMatrix(mainLight, out lightCookieMatrix);
cmd.SetGlobalTexture(PerCameraBuffer._MainLightCookie, mainLightRef.cookie);
cmd.SetGlobalMatrix(PerCameraBuffer._WorldToLight, lightCookieMatrix);
cmd.SetGlobalTexture(LightConstantBuffer._MainLightCookie, mainLightRef.cookie);
cmd.SetGlobalMatrix(LightConstantBuffer._WorldToLight, lightCookieMatrix);
cmd.SetGlobalVector(PerCameraBuffer._MainLightPosition, new Vector4(lightPos.x, lightPos.y, lightPos.z, lightDistanceAttenuation.w));
cmd.SetGlobalVector(PerCameraBuffer._MainLightColor, lightColor);
cmd.SetGlobalVector(LightConstantBuffer._MainLightPosition, new Vector4(lightPos.x, lightPos.y, lightPos.z, lightDistanceAttenuation.w));
cmd.SetGlobalVector(LightConstantBuffer._MainLightColor, lightColor);
}
void SetupAdditionalLightConstants(CommandBuffer cmd, ref LightData lightData)

}
}
cmd.SetGlobalVector(PerCameraBuffer._AdditionalLightCount, new Vector4(lightData.pixelAdditionalLightsCount,
cmd.SetGlobalVector(LightConstantBuffer._AdditionalLightCount, new Vector4(lightData.pixelAdditionalLightsCount,
lightData.totalAdditionalLightsCount, 0.0f, 0.0f));
// if not using a compute buffer, engine will set indices in 2 vec4 constants

}
else
{
cmd.SetGlobalVector(PerCameraBuffer._AdditionalLightCount, Vector4.zero);
cmd.SetGlobalVector(LightConstantBuffer._AdditionalLightCount, Vector4.zero);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightPosition, m_LightPositions);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightColor, m_LightColors);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightDistanceAttenuation, m_LightDistanceAttenuations);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightSpotDir, m_LightSpotDirections);
cmd.SetGlobalVectorArray(PerCameraBuffer._AdditionalLightSpotAttenuation, m_LightSpotAttenuations);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightPosition, m_LightPositions);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightColor, m_LightColors);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightDistanceAttenuation, m_LightDistanceAttenuations);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightSpotDir, m_LightSpotDirections);
cmd.SetGlobalVectorArray(LightConstantBuffer._AdditionalLightSpotAttenuation, m_LightSpotAttenuations);
}
void SetShaderKeywords(CommandBuffer cmd, ref CameraData cameraData, ref LightData lightData, ref ShadowData shadowData)

CoreUtils.SetKeyword(cmd, "SOFTPARTICLES_ON", cameraData.requiresSoftParticles);
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

2
com.unity.render-pipelines.lightweight/LWRP/Passes/TransparentPostProcessPass.cs


descriptor = baseDescriptor;
}
public override void Execute(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public override void Execute(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults,
ref RenderingData renderingData)
{

15
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Core.hlsl


#define UNITY_Z_0_FAR_FROM_CLIPSPACE(coord) (coord)
#endif
// TODO: Really need a better define for iOS Metal than the framebuffer fetch one, that's also enabled on android and webgl (???)
#if defined(SHADER_API_VULKAN) || (defined(SHADER_API_METAL) && defined(UNITY_FRAMEBUFFER_FETCH_AVAILABLE))
// Renderpass inputs: Vulkan/Metal subpass input
#define UNITY_DECLARE_FRAMEBUFFER_INPUT_FLOAT(idx) cbuffer hlslcc_SubpassInput_f_##idx { float4 hlslcc_fbinput_##idx; }
#define UNITY_DECLARE_FRAMEBUFFER_INPUT_HALF(idx) cbuffer hlslcc_SubpassInput_h_##idx { half4 hlslcc_fbinput_##idx; }
#define UNITY_READ_FRAMEBUFFER_INPUT(idx, v2fname) hlslcc_fbinput_##idx
#else
// Renderpass inputs: General fallback path
#define UNITY_DECLARE_FRAMEBUFFER_INPUT_FLOAT(idx) TEXTURE2D_FLOAT(_UnityFBInput##idx); float4 _UnityFBInput##idx##_TexelSize
#define UNITY_DECLARE_FRAMEBUFFER_INPUT_HALF(idx) TEXTURE2D_HALF(_UnityFBInput##idx); float4 _UnityFBInput##idx##_TexelSize
#define UNITY_READ_FRAMEBUFFER_INPUT(idx, v2fvertexname) _UnityFBInput##idx.Load(uint3(v2fvertexname.xy, 0))
#endif
float4 GetScaledScreenParams()
{
return _ScaledScreenParams;

9
com.unity.render-pipelines.lightweight/LWRP/ShaderLibrary/Input.hlsl


CBUFFER_END
CBUFFER_START(_PerCamera)
float4x4 _InvCameraViewProj;
float4 _ScaledScreenParams;
CBUFFER_END
CBUFFER_START(_LightBuffer)
float4 _MainLightPosition;
half4 _MainLightColor;
float4x4 _WorldToLight;

half4 _AdditionalLightDistanceAttenuation[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightSpotDir[MAX_VISIBLE_LIGHTS];
half4 _AdditionalLightSpotAttenuation[MAX_VISIBLE_LIGHTS];
float4 _ScaledScreenParams;
CBUFFER_END
#if USE_STRUCTURED_BUFFER_FOR_LIGHT_DATA

#define UNITY_MATRIX_P OptimizeProjectionMatrix(glstate_matrix_projection)
#define UNITY_MATRIX_I_P ERROR_UNITY_MATRIX_I_P_IS_NOT_DEFINED
#define UNITY_MATRIX_VP unity_MatrixVP
#define UNITY_MATRIX_I_VP ERROR_UNITY_MATRIX_I_VP_IS_NOT_DEFINED
#define UNITY_MATRIX_I_VP _InvCameraViewProj
#define UNITY_MATRIX_MV mul(UNITY_MATRIX_V, UNITY_MATRIX_M)
#define UNITY_MATRIX_T_MV transpose(UNITY_MATRIX_MV)
#define UNITY_MATRIX_IT_MV transpose(mul(UNITY_MATRIX_I_M, UNITY_MATRIX_I_V))

4
com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs


namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{
public class LightweightForwardRenderer
public class ScriptableRenderer
{
// Lights are culled per-object. In platforms that don't use StructuredBuffer
// the engine will set 4 light indices in the following constant unity_4LightIndices0

readonly Material[] m_Materials;
public LightweightForwardRenderer(LightweightPipelineAsset pipelineAsset)
public ScriptableRenderer(LightweightPipelineAsset pipelineAsset)
{
this.pipelineAsset = pipelineAsset;

8
com.unity.testing.srp.lightweight/Tests/Scenes/045_CustomLWPipe/CustomLWPipe.cs


m_Initialized = true;
}
public void Setup(LightweightForwardRenderer renderer, ref ScriptableRenderContext context,
public void Setup(ScriptableRenderer renderer, ref ScriptableRenderContext context,
ref CullResults cullResults, ref RenderingData renderingData)
{
Init();

renderer.SetupPerObjectLightIndices(ref cullResults, ref renderingData.lightData);
RenderTextureDescriptor baseDescriptor = LightweightForwardRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor baseDescriptor = ScriptableRenderer.CreateRTDesc(ref renderingData.cameraData);
RenderTextureDescriptor shadowDescriptor = baseDescriptor;
shadowDescriptor.dimension = TextureDimension.Tex2D;

Camera camera = renderingData.cameraData.camera;
bool dynamicBatching = renderingData.supportsDynamicBatching;
RendererConfiguration rendererConfiguration = LightweightForwardRenderer.GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount);
RendererConfiguration rendererConfiguration = ScriptableRenderer.GetRendererConfiguration(renderingData.lightData.totalAdditionalLightsCount);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, LightweightForwardRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration, dynamicBatching);
m_RenderOpaqueForwardPass.Setup(baseDescriptor, colorHandle, depthHandle, ScriptableRenderer.GetCameraClearFlag(camera), camera.backgroundColor, rendererConfiguration, dynamicBatching);
renderer.EnqueuePass(m_RenderOpaqueForwardPass);
}
}

11
com.unity.render-pipelines.lightweight/LWRP/Passes/ForwardLitPass.cs.meta


fileFormatVersion: 2
guid: 6ff0f03778c60ae42890954fcf650d4c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

0
com.unity.render-pipelines.lightweight/LWRP/Passes/ForwardLitPass.cs

13
com.unity.render-pipelines.lightweight/LWRP/LightweightConstantBuffer.cs.meta


fileFormatVersion: 2
guid: 2462b9b2044ad4b62a8c7fcd6f012f8e
timeCreated: 1506514389
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

8
com.unity.render-pipelines.lightweight/LWRP/LightweightConstantBuffer.cs


using UnityEngine;
namespace UnityEngine.Experimental.Rendering.LightweightPipeline
{
}

/com.unity.render-pipelines.lightweight/LWRP/LightweightForwardRenderer.cs.meta → /com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs.meta

/com.unity.render-pipelines.lightweight/LWRP/LightweightForwardRenderer.cs → /com.unity.render-pipelines.lightweight/LWRP/ScriptableRenderer.cs

正在加载...
取消
保存