浏览代码

Added the "RenderPipeline" shader tag. moved all settings from QualitySettings to Pipeline asset.

/vr_sandbox
Felipe Lira 8 年前
当前提交
9bcbdc22
共有 6 个文件被更改,包括 1160 次插入45 次删除
  1. 5
      Assets/LowEndRenderLoop/LowEndPipeline.asset
  2. 87
      Assets/LowEndRenderLoop/LowEndRenderLoopScene.unity
  3. 1001
      Assets/LowEndRenderLoop/LowEndRenderLoopScene/Lightmap-0_comp_light.exr
  4. 10
      Assets/LowEndRenderLoop/LowEndRenderLoopShader.shader
  5. 93
      Assets/LowEndRenderLoop/LowEndRenderPipeline.cs
  6. 9
      Assets/LowEndRenderLoop/LowEndRenderLoopScene/LightingData.asset.meta

5
Assets/LowEndRenderLoop/LowEndPipeline.asset


m_SupportsVertexLight: 0
m_EnableLightmaps: 1
m_EnableAmbientProbe: 1
m_ShadowType: 1
m_ShadowNearPlaneOffset: 2
m_ShadowDistance: 50
m_ShadowCascades: 4
m_CascadeSplit: {x: 0.067, y: 0.2, z: 0.467}
m_ShadowFiltering: 1

87
Assets/LowEndRenderLoop/LowEndRenderLoopScene.unity


m_ReflectionIntensity: 0.5
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.323799, g: 0.3597683, b: 0.40908712, a: 0.5}
m_IndirectSpecularColor: {r: 0.091603205, g: 0.113415994, b: 0.14733817, a: 0.5}
m_GIWorkflowMode: 0
m_GIWorkflowMode: 1
m_GISettings:
serializedVersion: 2
m_BounceScale: 1

m_EnableBakedLightmaps: 1
m_EnableRealtimeLightmaps: 0
m_LightmapEditorSettings:
serializedVersion: 6
serializedVersion: 8
m_Resolution: 2
m_BakeResolution: 20
m_TextureWidth: 1024

m_FinalGatherFiltering: 1
m_FinalGatherRayCount: 256
m_ReflectionCompression: 2
m_StationaryBakeMode: 1
m_LightingDataAsset: {fileID: 0}
m_RuntimeCPUUsage: 25
m_MixedBakeMode: 1
m_BakeBackend: 0
m_PVRSampling: 1
m_PVRSampleCount: 500
m_PVRBounces: 2
m_PVRFiltering: 0
m_PVRFilteringMode: 1
m_PVRCulling: 1
m_PVRFilteringGaussRadiusDirect: 1
m_PVRFilteringGaussRadiusIndirect: 5
m_PVRFilteringGaussRadiusAO: 2
m_PVRFilteringAtrousColorSigma: 1
m_PVRFilteringAtrousNormalSigma: 1
m_PVRFilteringAtrousPositionSigma: 1
m_LightingDataAsset: {fileID: 112000002, guid: caf3024f11d329d4f976f542c8fc360c,
type: 2}
m_ShadowMaskMode: 2
--- !u!196 &4
NavMeshSettings:

m_Father: {fileID: 766602296}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: -0.33200002, y: -365.245, z: 189.77199}
--- !u!1 &472209899
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 472209901}
- component: {fileID: 472209900}
m_Layer: 0
m_Name: Sphere
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!135 &472209900
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 472209899}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 32.4691
m_Center: {x: -5.3164, y: -6.7591, z: 15.734}
--- !u!4 &472209901
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 472209899}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &529372582
GameObject:
m_ObjectHideFlags: 0

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1084503476}
m_Enabled: 1
serializedVersion: 2
serializedVersion: 3
m_RenderMode: 0
m_Camera: {fileID: 0}
m_PlaneDistance: 100

m_OverridePixelPerfect: 0
m_SortingBucketNormalizedSize: 0
m_AdditionalShaderChannelsFlag: 25
m_SortingLayerID: 0
m_SortingOrder: 0
m_TargetDisplay: 0

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6500
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1177504217

m_Lightmapping: 2
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1280249095

m_Lightmapping: 2
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1405931297

m_Lightmapping: 2
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!1 &1677622456

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1677622458

m_Lightmapping: 4
m_AreaSize: {x: 1, y: 1}
m_BounceIntensity: 1
m_CCT: 6570
m_ColorTemperature: 6570
m_UseColorTemperature: 0
m_ShadowRadius: 0
m_ShadowAngle: 0
--- !u!4 &1900527475

1001
Assets/LowEndRenderLoop/LowEndRenderLoopScene/Lightmap-0_comp_light.exr
文件差异内容过多而无法显示
查看文件

10
Assets/LowEndRenderLoop/LowEndRenderLoopShader.shader


SubShader
{
Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" }
Tags { "RenderType" = "Opaque" "PerformanceChecks" = "False" "RenderPipeline" = "LDRenderPipeline"}
// Include forward (base + additive) pass from regular Standard shader.
// They are not used by the scriptable render loop; only here so that
// if we turn off our example loop, then regular forward rendering kicks in
// and objects look just like with a Standard shader.
UsePass "Standard (Specular setup)/FORWARD"
UsePass "Standard (Specular setup)/FORWARD_DELTA"
Pass
{

ENDCG
}
}
Fallback "Standard (Specular setup)"
CustomEditor "StandardShaderGUI"
}

93
Assets/LowEndRenderLoop/LowEndRenderPipeline.cs


using UnityEngine;
using System;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;

public override void Render(ScriptableRenderContext context, Camera[] cameras)
{
var prevPipe = Shader.globalRenderPipeline;
Shader.globalRenderPipeline = "LDRenderPipeline";
base.Render(context, cameras);
foreach (Camera camera in cameras)

if (!CullResults.GetCullingParameters(camera, out cullingParameters))
continue;
cullingParameters.shadowDistance = QualitySettings.shadowDistance;
cullingParameters.shadowDistance = m_ShadowSettings.maxShadowDistance;
CullResults cull = CullResults.Cull(ref cullingParameters, context);
var cmd = new CommandBuffer() { name = "Clear" };

if (shadowsRendered)
SetupShadowShaderVariables(context, camera.nearClipPlane, cullingParameters.shadowDistance, m_ShadowSettings.directionalLightCascadeCount);
// Rende Opaques
// Render Opaques
var settings = new DrawRendererSettings(cull, camera, new ShaderPassName("LowEndForwardBase"));
settings.sorting.flags = SortFlags.CommonOpaque;
settings.inputFilter.SetQueuesOpaque();

// TODO: Check skybox shader
context.DrawSkybox(camera);
// Rende Alpha blended
// Render Alpha blended
settings.sorting.flags = SortFlags.CommonTransparent;
settings.inputFilter.SetQueuesTransparent();
context.DrawRenderers(ref settings);

Shader.globalRenderPipeline = prevPipe;
m_ShadowSettings.directionalLightCascadeCount = QualitySettings.shadowCascades;
m_ShadowSettings.directionalLightCascadeCount = m_Asset.CascadeCount;
m_ShadowSettings.maxShadowDistance = QualitySettings.shadowDistance;
m_ShadowSettings.maxShadowDistance = m_Asset.ShadowDistance;
switch (m_ShadowSettings.directionalLightCascadeCount)
{

case 2:
m_ShadowSettings.directionalLightCascades = new Vector3(QualitySettings.shadowCascade2Split, 1.0f, 0.0f);
break;
case 4:
m_ShadowSettings.directionalLightCascades = QualitySettings.shadowCascade4Split;
m_ShadowSettings.directionalLightCascades = new Vector3(m_Asset.CascadeSplit.x, 1.0f, 0.0f);
Debug.LogError("Invalid Shadow Cascade Settings");
m_ShadowSettings = ShadowSettings.Default;
m_ShadowSettings.directionalLightCascades = m_Asset.CascadeSplit;
break;
}
}

context.ExecuteCommandBuffer(setRenderTargetCommandBuffer);
setRenderTargetCommandBuffer.Dispose();
float shadowNearPlane = QualitySettings.shadowNearPlaneOffset;
float shadowNearPlane = m_Asset.ShadowNearOffset;
Vector3 splitRatio = m_ShadowSettings.directionalLightCascades;
for (int cascadeIdx = 0; cascadeIdx < cascadeCount; ++cascadeIdx)
{

private void RenderShadowSlice(ref ScriptableRenderContext context, int cascadeIndex, Matrix4x4 proj, Matrix4x4 view, DrawShadowsSettings settings, float shadowBias)
{
var buffer = new CommandBuffer() { name = "RenderShadowMap" };
var buffer = new CommandBuffer() { name = "Prepare Shadowmap Slice" };
buffer.SetViewport(new Rect(m_ShadowSlices[cascadeIndex].atlasX, m_ShadowSlices[cascadeIndex].atlasY, m_ShadowSlices[cascadeIndex].shadowResolution, m_ShadowSlices[cascadeIndex].shadowResolution));
buffer.SetViewProjectionMatrices(view, proj);
buffer.SetGlobalVector("_ShadowBias", new Vector4(shadowBias, 0.0f, 0.0f, 0.0f));

int resolution = Mathf.Min(atlasWidth, atlasHeight);
if (tileCount > Mathf.Log(resolution))
{
//Debug.LogError(String.Format("Cannot fit {0} tiles into current shadowmap atlas of size ({1}, {2}). ShadowMap Resolution set to zero.", tileCount, atlasWidth, atlasHeight));
Debug.LogError(String.Format("Cannot fit {0} tiles into current shadowmap atlas of size ({1}, {2}). ShadowMap Resolution set to zero.", tileCount, atlasWidth, atlasHeight));
return 0;
}

void SetShadowKeywords(CommandBuffer cmd)
{
if (QualitySettings.shadows == ShadowQuality.Disable)
if (m_Asset.CurrShadowType == LowEndRenderPipeline.ShadowType.NO_SHADOW)
cmd.DisableShaderKeyword("SHADOWS_DEPTH");
else
cmd.EnableShaderKeyword("SHADOWS_DEPTH");

PCF = 0,
NONE
}
public bool m_SupportsVertexLight = true;
public bool m_EnableLightmaps = true;
public bool m_EnableAmbientProbe = true;
public int m_ShadowAtlasResolution = 1024;
public ShadowFiltering m_ShadowFiltering = ShadowFiltering.NONE;
public enum ShadowCascades
{
NO_CASCADES = 1,
TWO_CASCADES = 2,
FOUR_CASCADES = 4,
}
public enum ShadowType
{
NO_SHADOW = 0,
HARD_SHADOWS,
}
[SerializeField]
private bool m_SupportsVertexLight = true;
[SerializeField]
private bool m_EnableLightmaps = true;
[SerializeField]
private bool m_EnableAmbientProbe = true;
[SerializeField]
private ShadowType m_ShadowType = ShadowType.HARD_SHADOWS;
[SerializeField]
private float m_ShadowNearPlaneOffset = 2.0f;
[SerializeField]
private float m_ShadowDistance = 50.0f;
[SerializeField]
private int m_ShadowAtlasResolution = 1024;
[SerializeField]
private ShadowCascades m_ShadowCascades = ShadowCascades.NO_CASCADES;
[SerializeField]
private Vector3 m_CascadeSplit = new Vector3(0.067f, 0.2f, 0.467f);
[SerializeField]
private ShadowFiltering m_ShadowFiltering = ShadowFiltering.NONE;
public bool SupportsVertexLight { get { return m_SupportsVertexLight;} private set { m_SupportsVertexLight = value; } }

public ShadowType CurrShadowType { get { return m_ShadowType;} private set { m_ShadowType = value; } }
public float ShadowNearOffset { get { return m_ShadowNearPlaneOffset; } private set { m_ShadowNearPlaneOffset = value; } }
public float ShadowDistance { get { return m_ShadowDistance; } private set { m_ShadowDistance = value; } }
public int CascadeCount { get { return (int)m_ShadowCascades; } private set { m_ShadowCascades = (ShadowCascades)value; } }
public Vector3 CascadeSplit { get { return m_CascadeSplit; } private set { m_CascadeSplit = value; } }
public ShadowFiltering CurrShadowFiltering { get { return m_ShadowFiltering; } private set { m_ShadowFiltering = value; } }

9
Assets/LowEndRenderLoop/LowEndRenderLoopScene/LightingData.asset.meta


fileFormatVersion: 2
guid: caf3024f11d329d4f976f542c8fc360c
timeCreated: 1487246046
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 25800000
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存