浏览代码

Strip shadows on / off keyword (pretend shadows are always on and use a 4x4 texture)

/LW-LowEnd
Tim Cooper 7 年前
当前提交
5c9658dd
共有 6 个文件被更改,包括 12 次插入48 次删除
  1. 12
      ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs
  2. 4
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl
  3. 9
      ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl
  4. 7
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandard.shader
  5. 7
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardSimpleLighting.shader
  6. 21
      ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardTerrain.shader

12
ScriptableRenderPipeline/LightweightPipeline/LWRP/LightweightPipeline.cs


ShadowCollectPass(visibleLights, ref context, ref lightData);
}
if (!shadows)
{
var setRT = CommandBufferPool.Get("Generate Small Shadow Buffer");
setRT.GetTemporaryRT(m_ScreenSpaceShadowMapRTID, 4, 4, 0, FilterMode.Bilinear, RenderTextureFormat.R8);
setRT.Blit(Texture2D.whiteTexture, m_ScreenSpaceShadowMapRT);
context.ExecuteCommandBuffer(setRT);
}
ForwardPass(visibleLights, frameRenderingConfiguration, ref context, ref lightData, stereoEnabled);
var cmd = CommandBufferPool.Get("After Camera Render");

// There's no way to map shadow light indices. We need to pass in the original unsorted index.
// If no additional lights then no light sorting is performed and the indices match.
int shadowOriginalIndex = (lightData.totalAdditionalLightsCount > 0) ? GetLightUnsortedIndex(lightData.mainLightIndex) : lightData.mainLightIndex;
bool shadowsRendered = RenderShadows(ref m_CullResults, ref mainLight,
shadowOriginalIndex, ref context);
bool shadowsRendered = RenderShadows(ref m_CullResults, ref mainLight, shadowOriginalIndex, ref context);
if (shadowsRendered)
{
lightData.shadowMapSampleType = (m_Asset.ShadowSetting != ShadowType.SOFT_SHADOWS)

//TIM: Not used in shader for V1 to reduce keywords
CoreUtils.SetKeyword(cmd, "_MAIN_LIGHT_SPOT", mainLightIndex != -1 && visibleLights[mainLightIndex].lightType == LightType.Spot);
//TIM: Not used in shader for V1 to reduce keywords
CoreUtils.SetKeyword(cmd, "_SHADOWS_ENABLED", lightData.shadowMapSampleType != LightShadows.None);
//TIM: Not used in shader for V1 to reduce keywords

4
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/Lighting.hlsl


Light mainLight = GetMainLight(inputData.positionWS);
#ifdef _SHADOWS_ENABLED
#endif
MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, half4(0, 0, 0, 0));
half3 color = GlobalIllumination(brdfData, inputData.bakedGI, occlusion, inputData.normalWS, inputData.viewDirectionWS);

half4 LightweightFragmentBlinnPhong(InputData inputData, half3 diffuse, half4 specularGloss, half shininess, half3 emission, half alpha)
{
Light mainLight = GetMainLight(inputData.positionWS);
#ifdef _SHADOWS_ENABLED
#endif
MixRealtimeAndBakedGI(mainLight, inputData.normalWS, inputData.bakedGI, half4(0, 0, 0, 0));
half3 attenuatedLightColor = mainLight.color * mainLight.attenuation;

9
ScriptableRenderPipeline/LightweightPipeline/LWRP/ShaderLibrary/LightweightPassLit.hlsl


half3 viewDir : TEXCOORD6;
half4 fogFactorAndVertexLight : TEXCOORD7; // x: fogFactor, yzw: vertex light
#ifdef _SHADOWS_ENABLED
#endif
float4 clipPos : SV_POSITION;
UNITY_VERTEX_INPUT_INSTANCE_ID

inputData.viewDirectionWS = normalize(IN.viewDir);
#endif
#ifdef _SHADOWS_ENABLED
#else
inputData.shadowCoord = float4(0, 0, 0, 0);
#endif
inputData.fogCoord = IN.fogFactorAndVertexLight.x;
inputData.vertexLighting = IN.fogFactorAndVertexLight.yzw;

half3 vertexLight = VertexLighting(o.posWS, o.normal);
half fogFactor = ComputeFogFactor(o.clipPos.z);
o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
#ifdef _SHADOWS_ENABLED
#endif
return o;
}

7
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandard.shader


// -------------------------------------
// Lightweight Pipeline keywords
#pragma multi_compile _ _SHADOWS_ENABLED
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE

//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
// LW doesn't support dynamic GI. So we save 30% shader variants if we assume
// LIGHTMAP_ON when DIRLIGHTMAP_COMBINED is set
#ifdef DIRLIGHTMAP_COMBINED
#define LIGHTMAP_ON
#endif
#pragma vertex LitPassVertex
#pragma fragment LitPassFragment

7
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardSimpleLighting.shader


// -------------------------------------
// Lightweight Pipeline keywords
#pragma multi_compile _ _SHADOWS_ENABLED
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE

//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
// LW doesn't support dynamic GI. So we save 30% shader variants if we assume
// LIGHTMAP_ON when DIRLIGHTMAP_COMBINED is set
#ifdef DIRLIGHTMAP_COMBINED
#define LIGHTMAP_ON
#endif
#pragma vertex LitPassVertex
#pragma fragment LitPassFragmentSimple

21
ScriptableRenderPipeline/LightweightPipeline/LWRP/Shaders/LightweightStandardTerrain.shader


// -------------------------------------
// Lightweight Pipeline keywords
#pragma multi_compile _ _SHADOWS_ENABLED
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE

#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile __ _TERRAIN_NORMAL_MAP
// LW doesn't support dynamic GI. So we save 30% shader variants if we assume
// LIGHTMAP_ON when DIRLIGHTMAP_COMBINED is set
#ifdef DIRLIGHTMAP_COMBINED
#define LIGHTMAP_ON
#endif
#include "LWRP/ShaderLibrary/Lighting.hlsl"

#endif
half4 fogFactorAndVertexLight : TEXCOORD6; // x: fogFactor, yzw: vertex light
float3 positionWS : TEXCOORD7;
#ifdef _SHADOWS_ENABLED
float4 shadowCoord : TEXCOORD8;
#endif
float4 shadowCoord : TEXCOORD8;
float4 clipPos : SV_POSITION;
};

#endif
input.viewDirectionWS = SafeNormalize(GetCameraPositionWS() - IN.positionWS);
#ifdef _SHADOWS_ENABLED
#endif
input.fogCoord = IN.fogFactorAndVertexLight.x;

o.fogFactorAndVertexLight.yzw = VertexLighting(positionWS, o.normal);
o.positionWS = positionWS;
o.clipPos = clipPos;
#if defined(_SHADOWS_ENABLED) && !defined(_SHADOWS_CASCADE)
o.shadowCoord = ComputeShadowCoord(o.positionWS.xyz);
#endif
o.shadowCoord = ComputeScreenPos(o.clipPos);
return o;
}

正在加载...
取消
保存