浏览代码

Name refactors and conversion from tabs to spaces.

/vr_sandbox
Felipe Lira 8 年前
当前提交
fba67c86
共有 10 个文件被更改,包括 233 次插入246 次删除
  1. 12
      Assets/LowEndMobilePipeline/Editor/LegacyMobileToLowendMobileUpgrader.cs
  2. 8
      Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs
  3. 2
      Assets/LowEndMobilePipeline/Editor/StandardToLowEndMaterialUpgrader.cs
  4. 20
      Assets/LowEndMobilePipeline/LowEndMobilePipeline.cs
  5. 375
      Assets/LowEndMobilePipeline/LowEndMobilePipeline.shader
  6. 4
      Assets/LowEndMobilePipeline/LowEndMobilePipelineAsset.asset
  7. 2
      Assets/LowEndMobilePipeline/LowEndMobilePipelineAsset.asset.meta
  8. 4
      Assets/LowEndMobilePipeline/LowEndMobilePipelineAsset.cs
  9. 49
      Assets/LowEndMobilePipeline/LowEndMobilePipelineCore.cginc
  10. 3
      Assets/LowEndMobilePipeline/TestScenes/Materials/LDRenderPipeMaterials/MobileColorsTile.mat

12
Assets/LowEndMobilePipeline/Editor/LegacyMobileToLowendMobileUpgrader.cs


public class LegacyMobileToLowendMobileUpgrader : MaterialUpgrader
{
[MenuItem("LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Mobile Materials to LowEndMobile")]
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Legacy Mobile Materials to LowEndMobile")]
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Diffuse"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Bumped Specular"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Bumped Specular(1 Directional Light)"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Bumped Diffuse"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Unlit (Supports Lightmap)"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Diffuse"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Bumped Specular"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Bumped Specular(1 Directional Light)"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Bumped Diffuse"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/Unlit (Supports Lightmap)"));
materialUpgraders.Add(new LegacyMobileToLowendMobileUpgrader("Mobile/VertexLit"));
MaterialUpgrader.UpgradeProjectFolder(materialUpgraders, "Upgrade to LD Materials");

8
Assets/LowEndMobilePipeline/Editor/LowendMobilePipelineMaterialEditor.cs


public enum GlossinessSource
{
AlphaFromBaseTextureAndColor,
AlphaFromSpecularTextureAndColor
BaseAlpha,
SpecularAlpha
}
private void Awake()

{
specularSource.floatValue = source;
if (source == (int)SpecularSource.BaseTexture)
glossinessSourceProp.floatValue = (float)GlossinessSource.AlphaFromBaseTextureAndColor;
glossinessSourceProp.floatValue = (float)GlossinessSource.BaseAlpha;
}
SpecularSource specSource = (SpecularSource)specularSource.floatValue;

}
GlossinessSource glossSource = (GlossinessSource)glossinessSourceProp.floatValue;
if (glossSource == GlossinessSource.AlphaFromBaseTextureAndColor)
if (glossSource == GlossinessSource.BaseAlpha)
SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", true);
else
SetKeyword(material, "_GLOSSINESS_FROM_BASE_ALPHA", false);

2
Assets/LowEndMobilePipeline/Editor/StandardToLowEndMaterialUpgrader.cs


public class StandardToLowEndMaterialUpgrader : MaterialUpgrader
{
[MenuItem("LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile")]
[MenuItem("RenderPipeline/LowEndMobilePipeline/Material Upgraders/Upgrade Standard Materials to Low End Mobile")]
private static void UpgradeMaterialsToLD()
{
List<MaterialUpgrader> upgraders = new List<MaterialUpgrader>();

20
Assets/LowEndMobilePipeline/LowEndMobilePipeline.cs


// Setup light and shadow shader constants
SetupLightShaderVariables(cull.visibleLights, context);
if (shadowsRendered)
SetupShadowShaderVariables(context, camera.nearClipPlane, cullingParameters.shadowDistance,
m_ShadowSettings.directionalLightCascadeCount);
SetupShadowShaderVariables(context, m_ShadowSettings.directionalLightCascadeCount);
// Render Opaques
var settings = new DrawRendererSettings(cull, camera, m_ForwardBasePassName);

return resolution;
}
void SetupShadowShaderVariables(ScriptableRenderContext context, float shadowNear, float shadowFar,
int cascadeCount)
void SetupShadowShaderVariables(ScriptableRenderContext context, int cascadeCount)
// PSSM distance settings
float shadowFrustumDepth = shadowFar - shadowNear;
Vector3 shadowSplitRatio = m_ShadowSettings.directionalLightCascades;
// We set PSSMDistance to infinity for non active cascades so the comparison test always fails for unavailable cascades
Vector4 PSSMDistances = new Vector4(
shadowNear + shadowSplitRatio.x*shadowFrustumDepth,
(shadowSplitRatio.y > 0.0f) ? shadowNear + shadowSplitRatio.y*shadowFrustumDepth : Mathf.Infinity,
(shadowSplitRatio.z > 0.0f) ? shadowNear + shadowSplitRatio.z*shadowFrustumDepth : Mathf.Infinity,
1.0f/shadowResolution);
const int maxShadowCascades = 4;
Matrix4x4[] shadowMatrices = new Matrix4x4[maxShadowCascades];

var setupShadow = new CommandBuffer() {name = "SetupShadowShaderConstants"};
SetShadowKeywords(setupShadow);
setupShadow.SetGlobalMatrixArray("_WorldToShadow", shadowMatrices);
setupShadow.SetGlobalVector("_PSSMDistancesAndShadowResolution", PSSMDistances);
setupShadow.SetGlobalVectorArray("g_vDirShadowSplitSpheres", m_DirectionalShadowSplitDistances);
setupShadow.SetGlobalVectorArray("_DirShadowSplitSpheres", m_DirectionalShadowSplitDistances);
setupShadow.SetGlobalFloatArray("_PCFKernel", pcfKernel);
SetShadowKeywords(setupShadow);
context.ExecuteCommandBuffer(setupShadow);

375
Assets/LowEndMobilePipeline/LowEndMobilePipeline.shader


// Shader targeted for LowEnd mobile devices. Single Pass Forward Rendering. Shader Model 2
Shader "ScriptableRenderPipeline/LowEndMobile"
{
// Keep properties of StandardSpecular shader for upgrade reasons.
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Base (RGB) Glossiness / Alpha (A)", 2D) = "white" {}
// Keep properties of StandardSpecular shader for upgrade reasons.
Properties
{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Base (RGB) Glossiness / Alpha (A)", 2D) = "white" {}
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Cutoff("Alpha Cutoff", Range(0.0, 1.0)) = 0.5
_Glossiness("Shininess", Range(0.0, 1.0)) = 0.5
_SpecularStrength("Specular Strength", Range(0.0, 255.0)) = 200
_GlossMapScale("Smoothness Factor", Range(0.0, 1.0)) = 1.0
[Enum(Specular Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
_Glossiness("Shininess", Range(0.0, 1.0)) = 0.5
_SpecularStrength("Specular Strength", Range(0.0, 255.0)) = 200
_GlossMapScale("Smoothness Factor", Range(0.0, 1.0)) = 1.0
[Enum(Specular Alpha,0,Albedo Alpha,1)] _SmoothnessTextureChannel("Smoothness texture channel", Float) = 0
[HideInInspector] _SpecSource("Specular Color Source", Float) = 0.0
_SpecColor("Specular", Color) = (1.0, 1.0, 1.0)
_SpecGlossMap("Specular", 2D) = "white" {}
[HideInInspector] _GlossinessSource("Glossiness Source", Float) = 0.0
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0
[HideInInspector] _SpecSource("Specular Color Source", Float) = 0.0
_SpecColor("Specular", Color) = (1.0, 1.0, 1.0)
_SpecGlossMap("Specular", 2D) = "white" {}
[HideInInspector] _GlossinessSource("Glossiness Source", Float) = 0.0
[ToggleOff] _SpecularHighlights("Specular Highlights", Float) = 1.0
[ToggleOff] _GlossyReflections("Glossy Reflections", Float) = 1.0
[HideInInspector] _BumpScale("Scale", Float) = 1.0
[NoScaleOffset] _BumpMap("Normal Map", 2D) = "bump" {}
[HideInInspector] _BumpScale("Scale", Float) = 1.0
[NoScaleOffset] _BumpMap("Normal Map", 2D) = "bump" {}
_Parallax("Height Scale", Range(0.005, 0.08)) = 0.02
_ParallaxMap("Height Map", 2D) = "black" {}
_Parallax("Height Scale", Range(0.005, 0.08)) = 0.02
_ParallaxMap("Height Map", 2D) = "black" {}
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
_OcclusionMap("Occlusion", 2D) = "white" {}
_OcclusionStrength("Strength", Range(0.0, 1.0)) = 1.0
_OcclusionMap("Occlusion", 2D) = "white" {}
_EmissionColor("Emission Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
_EmissionColor("Emission Color", Color) = (0,0,0)
_EmissionMap("Emission", 2D) = "white" {}
_DetailMask("Detail Mask", 2D) = "white" {}
_DetailMask("Detail Mask", 2D) = "white" {}
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
_DetailNormalMapScale("Scale", Float) = 1.0
_DetailNormalMap("Normal Map", 2D) = "bump" {}
_DetailAlbedoMap("Detail Albedo x2", 2D) = "grey" {}
_DetailNormalMapScale("Scale", Float) = 1.0
_DetailNormalMap("Normal Map", 2D) = "bump" {}
[Enum(UV0,0,UV1,1)] _UVSec("UV Set for secondary textures", Float) = 0
[Enum(UV0,0,UV1,1)] _UVSec("UV Set for secondary textures", Float) = 0
// Blending state
[HideInInspector] _Mode("__mode", Float) = 0.0
[HideInInspector] _SrcBlend("__src", Float) = 1.0
[HideInInspector] _DstBlend("__dst", Float) = 0.0
[HideInInspector] _ZWrite("__zw", Float) = 1.0
}
// Blending state
[HideInInspector] _Mode("__mode", Float) = 0.0
[HideInInspector] _SrcBlend("__src", Float) = 1.0
[HideInInspector] _DstBlend("__dst", Float) = 0.0
[HideInInspector] _ZWrite("__zw", Float) = 1.0
}
SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "LowEndMobilePipeline" }
LOD 300
SubShader
{
Tags { "RenderType" = "Opaque" "RenderPipeline" = "LowEndMobilePipeline" }
LOD 300
Pass
{
Name "LD_SINGLE_PASS_FORWARD"
Tags { "LightMode" = "LowEndMobileForward" }
Pass
{
Name "LD_SINGLE_PASS_FORWARD"
Tags { "LightMode" = "LowEndMobileForward" }
// Use same blending / depth states as Standard shader
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
// Use same blending / depth states as Standard shader
Blend[_SrcBlend][_DstBlend]
ZWrite[_ZWrite]
CGPROGRAM
#pragma target 2.0
#pragma vertex vert
#pragma fragment frag
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON
#pragma shader_feature _ _SHARED_SPECULAR_DIFFUSE _SPECGLOSSMAP _SPECULAR_COLOR
#pragma shader_feature _GLOSSINESS_FROM_BASE_ALPHA
#pragma shader_feature _NORMALMAP
CGPROGRAM
#pragma target 2.0
#pragma vertex vert
#pragma fragment frag
#pragma shader_feature _ _ALPHATEST_ON _ALPHABLEND_ON
#pragma shader_feature _ _SHARED_SPECULAR_DIFFUSE _SPECGLOSSMAP _SPECULAR_COLOR
#pragma shader_feature _GLOSSINESS_FROM_BASE_ALPHA
#pragma shader_feature _NORMALMAP
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ HARD_SHADOWS SOFT_SHADOWS
#pragma multi_compile_fog
#pragma only_renderers d3d9 d3d11 d3d11_9x glcore gles gles3 metal
#pragma enable_d3d11_debug_symbols
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ HARD_SHADOWS SOFT_SHADOWS
#pragma multi_compile_fog
#pragma only_renderers d3d9 d3d11 d3d11_9x glcore gles gles3 metal
#pragma enable_d3d11_debug_symbols
#include "UnityCG.cginc"
#include "UnityStandardBRDF.cginc"
#include "UnityStandardInput.cginc"
#include "UnityStandardUtils.cginc"
#include "UnityCG.cginc"
#include "UnityStandardBRDF.cginc"
#include "UnityStandardInput.cginc"
#include "UnityStandardUtils.cginc"
v2f vert(LowendVertexInput v)
{
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f, o);
v2f vert(LowendVertexInput v)
{
v2f o;
UNITY_INITIALIZE_OUTPUT(v2f, o);
o.uv01.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
o.uv01.zw = v.lightmapUV * unity_LightmapST.xy + unity_LightmapST.zw;
o.hpos = UnityObjectToClipPos(v.vertex);
o.uv01.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
o.uv01.zw = v.lightmapUV * unity_LightmapST.xy + unity_LightmapST.zw;
o.hpos = UnityObjectToClipPos(v.vertex);
o.posWS.xyz = mul(unity_ObjectToWorld, v.vertex).xyz;
o.posWS.w = -UnityObjectToViewPos(v.vertex).z;
o.posWS.xyz = mul(unity_ObjectToWorld, v.vertex).xyz;
o.viewDir.xyz = normalize(_WorldSpaceCameraPos - o.posWS.xyz);
half3 normal = normalize(UnityObjectToWorldNormal(v.normal));
o.viewDir.xyz = normalize(_WorldSpaceCameraPos - o.posWS.xyz);
half3 normal = normalize(UnityObjectToWorldNormal(v.normal));
half sign = v.tangent.w * unity_WorldTransformParams.w;
half3 tangent = normalize(UnityObjectToWorldDir(v.tangent));
half3 binormal = cross(normal, tangent) * v.tangent.w;
half sign = v.tangent.w * unity_WorldTransformParams.w;
half3 tangent = normalize(UnityObjectToWorldDir(v.tangent));
half3 binormal = cross(normal, tangent) * v.tangent.w;
// Initialize tangetToWorld in column-major to benefit from better glsl matrix multiplication code
o.tangentToWorld[0] = half3(tangent.x, binormal.x, normal.x);
o.tangentToWorld[1] = half3(tangent.y, binormal.y, normal.y);
o.tangentToWorld[2] = half3(tangent.z, binormal.z, normal.z);
// Initialize tangetToWorld in column-major to benefit from better glsl matrix multiplication code
o.tangentToWorld[0] = half3(tangent.x, binormal.x, normal.x);
o.tangentToWorld[1] = half3(tangent.y, binormal.y, normal.y);
o.tangentToWorld[2] = half3(tangent.z, binormal.z, normal.z);
o.normal = normal;
o.normal = normal;
half4 diffuseAndSpecular = half4(1.0, 1.0, 1.0, 1.0);
for (int lightIndex = globalLightCount.x; lightIndex < globalLightCount.y; ++lightIndex)
{
LightInput lightInput;
INITIALIZE_LIGHT(lightInput, lightIndex);
o.fogCoord.yzw += EvaluateOneLight(lightInput, diffuseAndSpecular.rgb, diffuseAndSpecular, normal, o.posWS.xyz, o.viewDir.xyz);
}
half4 diffuseAndSpecular = half4(1.0, 1.0, 1.0, 1.0);
for (int lightIndex = globalLightCount.x; lightIndex < globalLightCount.y; ++lightIndex)
{
LightInput lightInput;
INITIALIZE_LIGHT(lightInput, lightIndex);
o.fogCoord.yzw += EvaluateOneLight(lightInput, diffuseAndSpecular.rgb, diffuseAndSpecular, normal, o.posWS.xyz, o.viewDir.xyz);
}
o.fogCoord.yzw += max(half3(0, 0, 0), ShadeSH9(half4(normal, 1)));
o.fogCoord.yzw += max(half3(0, 0, 0), ShadeSH9(half4(normal, 1)));
UNITY_TRANSFER_FOG(o, o.hpos);
return o;
}
UNITY_TRANSFER_FOG(o, o.hpos);
return o;
}
half4 frag(v2f i) : SV_Target
{
half4 diffuseAlpha = tex2D(_MainTex, i.uv01.xy);
half3 diffuse = diffuseAlpha.rgb * _Color.rgb;
half alpha = diffuseAlpha.a * _Color.a;
half4 frag(v2f i) : SV_Target
{
half4 diffuseAlpha = tex2D(_MainTex, i.uv01.xy);
half3 diffuse = diffuseAlpha.rgb * _Color.rgb;
half alpha = diffuseAlpha.a * _Color.a;
// Keep for compatibility reasons. Shader Inpector throws a warning when using cutoff
// due overdraw performance impact.
clip(alpha - _Cutoff);
clip(alpha - _Cutoff);
half4 specularGloss;
half4 specularGloss;
// Indirect Light Contribution
half3 indirectDiffuse;
// Indirect Light Contribution
half3 indirectDiffuse;
// Compute direct contribution from main directional light.
// Only a single directional shadow caster is supported.
LightInput mainLight;
INITIALIZE_LIGHT(mainLight, 0);
// Compute direct contribution from main directional light.
// Only a single directional shadow caster is supported.
LightInput mainLight;
INITIALIZE_LIGHT(mainLight, 0);
return half4(EvaluateMainLight(mainLight, diffuse, specularGloss, normal, i.posWS, viewDir), 1.0);
return half4(EvaluateMainLight(mainLight, diffuse, specularGloss, normal, i.posWS, viewDir), 1.0);
// Compute direct contribution from additional lights.
for (int lightIndex = 1; lightIndex < globalLightCount.x; ++lightIndex)
{
LightInput additionalLight;
INITIALIZE_LIGHT(additionalLight, lightIndex);
directColor += EvaluateOneLight(additionalLight, diffuse, specularGloss, normal, posWorld, viewDir);
}
// Compute direct contribution from additional lights.
for (int lightIndex = 1; lightIndex < globalLightCount.x; ++lightIndex)
{
LightInput additionalLight;
INITIALIZE_LIGHT(additionalLight, lightIndex);
directColor += EvaluateOneLight(additionalLight, diffuse, specularGloss, normal, posWorld, viewDir);
}
half3 color = directColor + indirectDiffuse + _EmissionColor;
UNITY_APPLY_FOG(i.fogCoord, color);
half3 color = directColor + indirectDiffuse + _EmissionColor;
UNITY_APPLY_FOG(i.fogCoord, color);
};
ENDCG
}
};
ENDCG
}
Pass
{
Name "LD_SHADOW_CASTER"
Tags { "Lightmode" = "ShadowCaster" }
Pass
{
Name "LD_SHADOW_CASTER"
Tags { "Lightmode" = "ShadowCaster" }
ZWrite On ZTest LEqual
ZWrite On ZTest LEqual
CGPROGRAM
#pragma target 2.0
#pragma vertex vert
#pragma fragment frag
CGPROGRAM
#pragma target 2.0
#pragma vertex vert
#pragma fragment frag
float4 _WorldLightDirAndBias;
float4 _WorldLightDirAndBias;
#include "UnityCG.cginc"
#include "UnityCG.cginc"
struct VertexInput
{
float4 pos : POSITION;
float3 normal : NORMAL;
};
struct VertexInput
{
float4 pos : POSITION;
float3 normal : NORMAL;
};
// Similar to UnityClipSpaceShadowCasterPos but using LDPipeline lightdir and bias and applying near plane clamp
float4 ClipSpaceShadowCasterPos(float4 vertex, float3 normal)
{
float4 wPos = mul(unity_ObjectToWorld, vertex);
// Similar to UnityClipSpaceShadowCasterPos but using LDPipeline lightdir and bias and applying near plane clamp
float4 ClipSpaceShadowCasterPos(float4 vertex, float3 normal)
{
float4 wPos = mul(unity_ObjectToWorld, vertex);
if (_WorldLightDirAndBias.w > 0.0)
{
float3 wNormal = UnityObjectToWorldNormal(normal);
if (_WorldLightDirAndBias.w > 0.0)
{
float3 wNormal = UnityObjectToWorldNormal(normal);
// apply normal offset bias (inset position along the normal)
// bias needs to be scaled by sine between normal and light direction
// (http://the-witness.net/news/2013/09/shadow-mapping-summary-part-1/)
//
// _WorldLightDirAndBias.w shadow bias defined in LRRenderPipeline asset
// apply normal offset bias (inset position along the normal)
// bias needs to be scaled by sine between normal and light direction
// (http://the-witness.net/news/2013/09/shadow-mapping-summary-part-1/)
//
// _WorldLightDirAndBias.w shadow bias defined in LRRenderPipeline asset
float shadowCos = dot(wNormal, _WorldLightDirAndBias.xyz);
float shadowSine = sqrt(1 - shadowCos*shadowCos);
float normalBias = _WorldLightDirAndBias.w * shadowSine;
float shadowCos = dot(wNormal, _WorldLightDirAndBias.xyz);
float shadowSine = sqrt(1 - shadowCos*shadowCos);
float normalBias = _WorldLightDirAndBias.w * shadowSine;
wPos.xyz -= wNormal * normalBias;
}
wPos.xyz -= wNormal * normalBias;
}
float4 clipPos = mul(UNITY_MATRIX_VP, wPos);
float4 clipPos = mul(UNITY_MATRIX_VP, wPos);
clipPos.z = min(clipPos.z, UNITY_NEAR_CLIP_VALUE);
clipPos.z = min(clipPos.z, UNITY_NEAR_CLIP_VALUE);
clipPos.z = max(clipPos.z, UNITY_NEAR_CLIP_VALUE);
clipPos.z = max(clipPos.z, UNITY_NEAR_CLIP_VALUE);
return clipPos;
}
return clipPos;
}
float4 vert(VertexInput i) : SV_POSITION
{
return ClipSpaceShadowCasterPos(i.pos, i.normal);
}
float4 vert(VertexInput i) : SV_POSITION
{
return ClipSpaceShadowCasterPos(i.pos, i.normal);
}
half4 frag() : SV_TARGET
{
return 0;
}
ENDCG
}
half4 frag() : SV_TARGET
{
return 0;
}
ENDCG
}
// This pass it not used during regular rendering, only for lightmap baking.
Pass
{
Name "LD_META"
Tags{ "LightMode" = "Meta" }
// This pass it not used during regular rendering, only for lightmap baking.
Pass
{
Name "LD_META"
Tags{ "LightMode" = "Meta" }
Cull Off
Cull Off
CGPROGRAM
#pragma vertex vert_meta
#pragma fragment frag_meta
CGPROGRAM
#pragma vertex vert_meta
#pragma fragment frag_meta
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICGLOSSMAP
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature ___ _DETAIL_MULX2
#pragma shader_feature EDITOR_VISUALIZATION
#pragma shader_feature _EMISSION
#pragma shader_feature _METALLICGLOSSMAP
#pragma shader_feature _ _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
#pragma shader_feature ___ _DETAIL_MULX2
#pragma shader_feature EDITOR_VISUALIZATION
#include "UnityStandardMeta.cginc"
ENDCG
}
}
Fallback "Standard (Specular setup)"
CustomEditor "LowendMobilePipelineMaterialEditor"
#include "UnityStandardMeta.cginc"
ENDCG
}
}
Fallback "Standard (Specular setup)"
CustomEditor "LowendMobilePipelineMaterialEditor"
}

4
Assets/LowEndMobilePipeline/LowEndMobilePipelineAsset.asset


m_Script: {fileID: 11500000, guid: bf2edee5c58d82540a51f03df9d42094, type: 3}
m_Name: LowEndMobilePipelineAsset
m_EditorClassIdentifier:
m_MaxPixelLights: 4
m_MaxPixelLights: 1
m_ShadowType: 2
m_ShadowType: 1
m_ShadowAtlasResolution: 2048
m_ShadowNearPlaneOffset: 2
m_ShadowDistance: 50

2
Assets/LowEndMobilePipeline/LowEndMobilePipelineAsset.asset.meta


fileFormatVersion: 2
guid: 877878ed40e8ad94095582ff91179016
timeCreated: 1488808435
timeCreated: 1489068733
licenseType: Pro
NativeFormatImporter:
mainObjectFileID: 11400000

4
Assets/LowEndMobilePipeline/LowEndMobilePipelineAsset.cs


#region AssetAndPipelineCreation
#if UNITY_EDITOR
[UnityEditor.MenuItem("LowEndMobilePipeline/Create Pipeline Asset")]
[UnityEditor.MenuItem("RenderPipeline/LowEndMobilePipeline/Create Pipeline Asset")]
static void CreateLowEndPipeline()
{
var instance = ScriptableObject.CreateInstance<LowEndMobilePipelineAsset>();

#endregion
}
}
}

49
Assets/LowEndMobilePipeline/LowEndMobilePipelineCore.cginc


struct v2f
{
float4 uv01 : TEXCOORD0; // uv01.xy: uv0, uv01.zw: uv1
float4 posWS : TEXCOORD1; // xyz: posWorld, w: eyeZ
float4 posWS : TEXCOORD1; // xyz: posWorld
#if _NORMALMAP
half3 tangentToWorld[3] : TEXCOORD2; // tangentToWorld matrix
#else

float _PCFKernel[8];
half4x4 _WorldToShadow[MAX_SHADOW_CASCADES];
float4 g_vDirShadowSplitSpheres[MAX_SHADOW_CASCADES];
half4 _PSSMDistancesAndShadowResolution; // xyz: PSSM Distance for 4 cascades, w: 1 / shadowmap resolution. Used for filtering
float4 _DirShadowSplitSpheres[MAX_SHADOW_CASCADES];
half _SpecularStrength;

specularGloss.rgb = diffuse;
specularGloss.a = alpha;
#elif defined(_SHARED_SPECULAR_DIFFUSE)
#if _GLOSSINESS_FROM_BASE_ALPHA
specularGloss.rgb = tex2D(_SpecGlossMap, i.uv01.xy) * _SpecColor;
specularGloss.a = alpha;
#else
specularGloss = tex2D(_SpecGlossMap, i.uv01.xy) * _SpecColor;
#endif
#if _GLOSSINESS_FROM_BASE_ALPHA
specularGloss.rgb = tex2D(_SpecGlossMap, i.uv01.xy) * _SpecColor;
specularGloss.a = alpha;
#else
specularGloss = tex2D(_SpecGlossMap, i.uv01.xy) * _SpecColor;
#endif
#else
#if _GLOSSINESS_FROM_BASE_ALPHA
specularGloss.rgb = _SpecColor;
specularGloss.a = alpha;
#if _GLOSSINESS_FROM_BASE_ALPHA
specularGloss.rgb = _SpecColor;
specularGloss.a = alpha;
#else
specularGloss = _SpecColor;
#endif
specularGloss = _SpecColor;
#endif
#endif
}

inline half ComputeCascadeIndex(float3 wpos)
{
float3 fromCenter0 = wpos.xyz - g_vDirShadowSplitSpheres[0].xyz;
float3 fromCenter1 = wpos.xyz - g_vDirShadowSplitSpheres[1].xyz;
float3 fromCenter2 = wpos.xyz - g_vDirShadowSplitSpheres[2].xyz;
float3 fromCenter3 = wpos.xyz - g_vDirShadowSplitSpheres[3].xyz;
float3 fromCenter0 = wpos.xyz - _DirShadowSplitSpheres[0].xyz;
float3 fromCenter1 = wpos.xyz - _DirShadowSplitSpheres[1].xyz;
float3 fromCenter2 = wpos.xyz - _DirShadowSplitSpheres[2].xyz;
float3 fromCenter3 = wpos.xyz - _DirShadowSplitSpheres[3].xyz;
vDirShadowSplitSphereSqRadii.x = g_vDirShadowSplitSpheres[0].w;
vDirShadowSplitSphereSqRadii.y = g_vDirShadowSplitSpheres[1].w;
vDirShadowSplitSphereSqRadii.z = g_vDirShadowSplitSpheres[2].w;
vDirShadowSplitSphereSqRadii.w = g_vDirShadowSplitSpheres[3].w;
vDirShadowSplitSphereSqRadii.x = _DirShadowSplitSpheres[0].w;
vDirShadowSplitSphereSqRadii.y = _DirShadowSplitSpheres[1].w;
vDirShadowSplitSphereSqRadii.z = _DirShadowSplitSpheres[2].w;
vDirShadowSplitSphereSqRadii.w = _DirShadowSplitSpheres[3].w;
fixed4 weights = float4(distances2 < vDirShadowSplitSphereSqRadii);
weights.yzw = saturate(weights.yzw - weights.xyz);
return 4 - dot(weights, float4(4, 3, 2, 1));

shadowCoord.z = saturate(shadowCoord.z);
#ifdef SOFT_SHADOWS
shadowAttenuation = ShadowPCF(shadowCoord);
shadowAttenuation = ShadowPCF(shadowCoord);
shadowAttenuation = ShadowAttenuation(shadowCoord.xy, shadowCoord.z);
shadowAttenuation = ShadowAttenuation(shadowCoord.xy, shadowCoord.z);
#endif
}

3
Assets/LowEndMobilePipeline/TestScenes/Materials/LDRenderPipeMaterials/MobileColorsTile.mat


m_PrefabInternal: {fileID: 0}
m_Name: MobileColorsTile
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
m_ShaderKeywords: _EMISSION _SPECULAR_COLOR
m_ShaderKeywords: _EMISSION _GLOSSINESS_FROM_BASE_ALPHA _SPECULAR_COLOR
m_LightmapFlags: 1
m_EnableInstancingVariants: 0
m_CustomRenderQueue: -1

- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 0.474
- _GlossinessSource: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0

正在加载...
取消
保存