浏览代码

Update LW master nodes to work with latest SRP repo

/main
Peter Bay Bastian 7 年前
当前提交
5399d0b1
共有 7 个文件被更改,包括 40 次插入93 次删除
  1. 1
      com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs
  2. 25
      com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs
  3. 2
      com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs
  4. 26
      com.unity.shadergraph/Editor/Templates/lightweightPBRExtraPasses.template
  5. 50
      com.unity.shadergraph/Editor/Templates/lightweightPBRForwardPass.template
  6. 26
      com.unity.shadergraph/Editor/Templates/lightweightUnlitExtraPasses.template
  7. 3
      com.unity.shadergraph/Editor/Templates/shader.template

1
com.unity.shadergraph/Editor/Data/Nodes/MasterNode.cs


foreach (var subShader in m_SubShaders)
finalShader.AddShaderChunk(subShader.GetSubshader(this, mode), true);
finalShader.AddShaderChunk(@"FallBack ""Hidden/InternalErrorShader""", false);
finalShader.Deindent();
finalShader.AddShaderChunk("}", false);

25
com.unity.shadergraph/Editor/Data/Util/ShaderGenerator.cs


{
var path = new List<string>
{
Application.dataPath,
"ShaderGraph",
"com.unity.shadergraph",
DefaultShaderIncludes.GetAssetsPackagePath() ?? Path.GetFullPath("Packages/com.unity.shadergraph"),
"Editor",
"Templates"
};

if (File.Exists(result))
return result;
//todo: fix this up... quick hack for working
// in a package
var path2 = new List<string>
{
"Packages",
"com.unity.shadergraph",
"Editor",
"Templates"
};
string result2 = path2[0];
for (int i = 1; i < path2.Count; i++)
result2 = Path.Combine(result2, path2[i]);
result2 = Path.Combine(result2, templateName);
result2 = Path.GetFullPath(result2);
if (File.Exists(result2))
return result2;
return string.Empty;
}

2
com.unity.shadergraph/Editor/Importers/ShaderGraphImporter.cs


using UnityEditor.Experimental.AssetImporters;
using UnityEditor.ShaderGraph.Drawing;
[ScriptedImporter(11, ShaderGraphImporter.ShaderGraphExtension)]
[ScriptedImporter(12, ShaderGraphImporter.ShaderGraphExtension)]
public class ShaderGraphImporter : ScriptedImporter
{
public const string ShaderGraphExtension = "shadergraph";

26
com.unity.shadergraph/Editor/Templates/lightweightPBRExtraPasses.template


{
Tags{"LightMode" = "ShadowCaster"}
ZWrite On ZTest LEqual
ZWrite On
ZTest LEqual
#pragma fragment ShadowPassFragment
#pragma fragment LitPassFragmentNull
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl"
ENDHLSL

// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma target 2.0
#pragma vertex vert
#pragma fragment frag
#include "LWRP/ShaderLibrary/Core.hlsl"
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
float4 vert(float4 pos : POSITION) : SV_POSITION
{
return TransformObjectToHClip(pos.xyz);
}
#pragma vertex LitPassVertex
#pragma fragment LitPassFragmentNull
half4 frag() : SV_TARGET
{
return 0;
}
#include "LWRP/ShaderLibrary/LightweightPassLit.hlsl"
ENDHLSL
}

50
com.unity.shadergraph/Editor/Templates/lightweightPBRForwardPass.template


#pragma prefer_hlslcc gles
#pragma target 3.0
// -------------------------------------
// Lightweight Pipeline keywords
// We have no good approach exposed to skip shader variants, e.g, ideally we would like to skip _CASCADE for all puctual lights
// Lightweight combines light classification and shadows keywords to reduce shader variants.
// Lightweight shader library declares defines based on these keywords to avoid having to check them in the shaders
// Core.hlsl defines _MAIN_LIGHT_DIRECTIONAL and _MAIN_LIGHT_SPOT (point lights can't be main light)
// Shadow.hlsl defines _SHADOWS_ENABLED, _SHADOWS_SOFT, _SHADOWS_CASCADE, _SHADOWS_PERSPECTIVE
#pragma multi_compile _ _MAIN_LIGHT_DIRECTIONAL_SHADOW _MAIN_LIGHT_DIRECTIONAL_SHADOW_CASCADE _MAIN_LIGHT_DIRECTIONAL_SHADOW_SOFT _MAIN_LIGHT_DIRECTIONAL_SHADOW_CASCADE_SOFT _MAIN_LIGHT_SPOT_SHADOW _MAIN_LIGHT_SPOT_SHADOW_SOFT
#pragma multi_compile _ _MAIN_LIGHT_COOKIE
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
#pragma multi_compile _ FOG_LINEAR FOG_EXP2
// -------------------------------------
// Lightweight Pipeline keywords
#pragma multi_compile _ _ADDITIONAL_LIGHTS
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
#pragma multi_compile _ FOG_LINEAR FOG_EXP2
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ UNITY_SINGLE_PASS_STEREO STEREO_INSTANCING_ON STEREO_MULTIVIEW_ON
#pragma multi_compile _ DIRLIGHTMAP_COMBINED LIGHTMAP_ON
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
// -------------------------------------
// Unity defined keywords
#pragma multi_compile _ DIRLIGHTMAP_COMBINED
#pragma multi_compile _ LIGHTMAP_ON
// 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
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#pragma vertex vert
#pragma fragment frag

o.fogFactorAndVertexLight = half4(fogFactor, vertexLight);
o.clipPos = clipPos;
#if defined(_SHADOWS_ENABLED) && !defined(_SHADOWS_CASCADE)
o.shadowCoord = ComputeShadowCoord(lwWorldPos);
#else
o.shadowCoord = float4(0, 0, 0, 0);
#endif
o.shadowCoord = ComputeShadowCoord(o.clipPos);
return o;
}

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

26
com.unity.shadergraph/Editor/Templates/lightweightUnlitExtraPasses.template


{
Tags{"LightMode" = "ShadowCaster"}
ZWrite On ZTest LEqual
ZWrite On
ZTest LEqual
#pragma fragment ShadowPassFragment
#pragma fragment LitPassFragmentNull
#include "LWRP/ShaderLibrary/LightweightPassShadow.hlsl"
ENDHLSL

// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma target 2.0
#pragma vertex vert
#pragma fragment frag
#include "LWRP/ShaderLibrary/Core.hlsl"
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
float4 vert(float4 pos : POSITION) : SV_POSITION
{
return TransformObjectToHClip(pos.xyz);
}
#pragma vertex LitPassVertex
#pragma fragment LitPassFragmentNull
half4 frag() : SV_TARGET
{
return 0;
}
#include "LWRP/ShaderLibrary/LightweightPassLit.hlsl"
ENDHLSL
}

3
com.unity.shadergraph/Editor/Templates/shader.template


${SubShader}
FallBack "Diffuse"
CustomEditor "LegacyIlluminShaderGUI"
FallBack "Hidden/InternalErrorShader"
}
正在加载...
取消
保存