您最多选择25个主题
主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
67 行
3.0 KiB
67 行
3.0 KiB
using System;
|
|
using UnityEngine.Rendering;
|
|
|
|
namespace UnityEngine.Experimental.Rendering.LightweightPipeline
|
|
{
|
|
[Flags]
|
|
public enum PipelineCapabilities
|
|
{
|
|
AdditionalLights = (1 << 0),
|
|
VertexLights = (1 << 1),
|
|
DirectionalShadows = (1 << 2),
|
|
LocalShadows = (1 << 3),
|
|
SoftShadows = (1 << 4),
|
|
}
|
|
|
|
public class LightweightKeywords
|
|
{
|
|
public static readonly string AdditionalLightsText = "_ADDITIONAL_LIGHTS";
|
|
public static readonly string VertexLightsText = "_VERTEX_LIGHTS";
|
|
public static readonly string MixedLightingSubtractiveText = "_MIXED_LIGHTING_SUBTRACTIVE";
|
|
public static readonly string MainLightCookieText = "_MAIN_LIGHT_COOKIE";
|
|
public static readonly string DirectionalShadowsText = "_SHADOWS_ENABLED";
|
|
public static readonly string LocalShadowsText = "_LOCAL_SHADOWS_ENABLED";
|
|
public static readonly string SoftShadowsText = "_SHADOWS_SOFT";
|
|
public static readonly string CascadeShadowsText = "_SHADOWS_CASCADE";
|
|
|
|
public static readonly ShaderKeyword AdditionalLights = new ShaderKeyword(AdditionalLightsText);
|
|
public static readonly ShaderKeyword VertexLights = new ShaderKeyword(VertexLightsText);
|
|
public static readonly ShaderKeyword MixedLightingSubtractive = new ShaderKeyword(MixedLightingSubtractiveText);
|
|
public static readonly ShaderKeyword MainLightCookie = new ShaderKeyword(MainLightCookieText);
|
|
public static readonly ShaderKeyword DirectionalShadows = new ShaderKeyword(DirectionalShadowsText);
|
|
public static readonly ShaderKeyword LocalShadows = new ShaderKeyword(LocalShadowsText);
|
|
public static readonly ShaderKeyword SoftShadows = new ShaderKeyword(SoftShadowsText);
|
|
}
|
|
|
|
public partial class LightweightPipeline
|
|
{
|
|
static PipelineCapabilities s_PipelineCapabilities;
|
|
|
|
public static PipelineCapabilities GetPipelineCapabilities()
|
|
{
|
|
return s_PipelineCapabilities;
|
|
}
|
|
|
|
static void SetPipelineCapabilities(LightweightPipelineAsset pipelineAsset)
|
|
{
|
|
s_PipelineCapabilities = 0U;
|
|
|
|
if (pipelineAsset.MaxPixelLights < 1 && !pipelineAsset.SupportsVertexLight)
|
|
s_PipelineCapabilities |= PipelineCapabilities.AdditionalLights;
|
|
|
|
if (pipelineAsset.SupportsVertexLight)
|
|
s_PipelineCapabilities |= PipelineCapabilities.VertexLights;
|
|
|
|
if (pipelineAsset.IsDirectionalShadowsSupported)
|
|
s_PipelineCapabilities |= PipelineCapabilities.DirectionalShadows;
|
|
|
|
if (pipelineAsset.IsLocalShadowsSupported)
|
|
s_PipelineCapabilities |= PipelineCapabilities.LocalShadows;
|
|
|
|
bool anyShadows = pipelineAsset.IsDirectionalShadowsSupported || pipelineAsset.IsLocalShadowsSupported;
|
|
if (pipelineAsset.IsSoftShadowsSupported && anyShadows)
|
|
s_PipelineCapabilities |= PipelineCapabilities.SoftShadows;
|
|
}
|
|
}
|
|
}
|
|
|