浏览代码

Some channels working

/main
Matt Dean 7 年前
当前提交
2c7d3d45
共有 20 个文件被更改,包括 934 次插入162 次删除
  1. 8
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightCore.cginc
  2. 4
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightFastBlinn.cginc
  3. 4
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightPBR.cginc
  4. 14
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightShadows.cginc
  5. 2
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPBR.shader
  6. 17
      MaterialGraphProject/Assets/Test-Legacy.mat
  7. 17
      MaterialGraphProject/Assets/Test-PBR.mat
  8. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/lightweightSubshaderFastBlinn.template
  9. 244
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/lightweightSubshaderPBR.template
  10. 30
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/AbstractLightweightPBRMasterNode.cs
  11. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightMetallicMasterNode.cs
  12. 94
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/ShaderTest.unity
  13. 331
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/GraphTest.shader
  14. 11
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/GraphTest.shader.meta
  15. 77
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/TestyTest.ShaderGraph
  16. 11
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/TestyTest.ShaderGraph.meta
  17. 101
      MaterialGraphProject/Assets/TestGraph-PBR.mat
  18. 10
      MaterialGraphProject/Assets/TestGraph-PBR.mat.meta
  19. 94
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightSpecularMasterNode.cs
  20. 12
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightSpecularMasterNode.cs.meta

8
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightCore.cginc


#endif
}
// This is temp because the shader graph version does work
inline void CalculateNormal(half3 vNormal, out half3 normal)
{
normal = normalize(vNormal);
}
half4 OutputColor(half3 color, half alpha)
{
#if defined(_ALPHABLEND_ON) || defined(_ALPHAPREMULTIPLY_ON)

UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
ModifyVertex(v);
//ModifyVertex(v);
o.uv01.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
#ifdef LIGHTMAP_ON

4
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightFastBlinn.cginc


INITIALIZE_MAIN_LIGHT(lightInput);
half lightAtten = ComputeLightAttenuation(lightInput, normal, worldPos, lightDirection);
#ifdef _SHADOWS
lightAtten *= ComputeShadowAttenuation(i, _ShadowLightDirection.xyz);
lightAtten *= ComputeShadowAttenuation(normal, i.posWS, _ShadowLightDirection.xyz);
#endif
#ifdef LIGHTWEIGHT_SPECULAR_HIGHLIGHTS

half3 color = half3(0, 0, 0);
#ifdef _SHADOWS
half shadowAttenuation = ComputeShadowAttenuation(i, _ShadowLightDirection.xyz);
half shadowAttenuation = ComputeShadowAttenuation(i.normal, i.posWS, _ShadowLightDirection.xyz);
#endif
int pixelLightCount = min(globalLightCount.x, unity_LightIndicesOffsetAndCount.y);
for (int lightIter = 0; lightIter < pixelLightCount; ++lightIter)

4
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightPBR.cginc


half lightAtten = ComputeLightAttenuation(light, normal, i.posWS.xyz, lightDirection);
#ifdef _SHADOWS
lightAtten *= ComputeShadowAttenuation(i, _ShadowLightDirection.xyz);
lightAtten *= ComputeShadowAttenuation(i.normal, i.posWS, _ShadowLightDirection.xyz);
#endif
half NdotL = saturate(dot(normal, lightDirection));

#ifdef _SHADOWS
half shadowAttenuation = ComputeShadowAttenuation(i, _ShadowLightDirection.xyz);
half shadowAttenuation = ComputeShadowAttenuation(i.normal, i.posWS, _ShadowLightDirection.xyz);
#endif
int pixelLightCount = min(globalLightCount.x, unity_LightIndicesOffsetAndCount.y);
for (int lightIter = 0; lightIter < pixelLightCount; ++lightIter)

14
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightShadows.cginc


return attenuation * 0.25;
}
inline half ComputeShadowAttenuation(LightweightVertexOutput i, half3 shadowDir)
inline half ComputeShadowAttenuation(half3 normal, half4 posWS, half3 shadowDir)
#if _NORMALMAP
half3 vertexNormal = half3(i.tangentToWorld0.z, i.tangentToWorld1.z, i.tangentToWorld2.z);
#else
half3 vertexNormal = i.normal;
#endif
//#if _NORMALMAP
//half3 vertexNormal = half3(i.tangentToWorld0.z, i.tangentToWorld1.z, i.tangentToWorld2.z); // Fix this
//#else
half3 vertexNormal = normal;
//#endif
float3 posWorldOffsetNormal = i.posWS + vertexNormal * bias;
float3 posWorldOffsetNormal = posWS + vertexNormal * bias;
int cascadeIndex = 0;
#ifdef _SHADOW_CASCADES

2
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPBR.shader


#ifndef _EMISSION
s.Emission = 0;
#else
s.Emission = LIGHTWEIGHT_GAMMA_TO_LINEAR(tex2D(_EmissionMap, uv).rgb) * _EmissionColor.rgb;
s.Emission = LIGHTWEIGHT_GAMMA_TO_LINEAR(tex2D(_EmissionMap, i.uv01.xy).rgb) * _EmissionColor.rgb;
#endif
// Alpha
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A

17
MaterialGraphProject/Assets/Test-Legacy.mat


m_PrefabInternal: {fileID: 0}
m_Name: Test-Legacy
m_Shader: {fileID: 4800000, guid: 8d2bb70cbf9db8d4da26e15b26e74248, type: 3}
m_ShaderKeywords: _ALPHABLEND_ON _GLOSSYREFLECTIONS_ON _METALLICSPECGLOSSMAP _METALLIC_SETUP
_NORMALMAP _SPECGLOSSMAP_BASE_ALPHA _SPECULARHIGHLIGHTS_ON
m_ShaderKeywords: _GLOSSYREFLECTIONS_ON _METALLICSPECGLOSSMAP _METALLIC_SETUP _NORMALMAP
_SPECGLOSSMAP_BASE_ALPHA _SPECULARHIGHLIGHTS_ON
m_CustomRenderQueue: 3000
stringTagMap:
RenderType: Transparent
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3

- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 10
- _DstBlend: 0
- _Mode: 2
- _Mode: 0
- _OcclusionStrength: 0.5
- _Parallax: 0.02
- _ReflectionSource: 0

- _SpecularHighlights: 1
- _SrcBlend: 5
- _SrcBlend: 1
- _ZWrite: 0
- _ZWrite: 1
m_Colors:
- _Color: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}

17
MaterialGraphProject/Assets/Test-PBR.mat


m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- Texture2D_Texture2D_2A5875FB_Uniform:
m_Texture: {fileID: 2800000, guid: 618126695341ad844ac048b062fd2688, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_87733D67_Uniform:
m_Texture: {fileID: 2800000, guid: 3f3b8bdf3ccd30c4fb97b62bd26ef1f6, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- Vector1_Vector1_5370E8F3_Uniform: 0
- _GlossMapScale: 0
- _Glossiness: 1
- _GlossMapScale: 1
- _Glossiness: 0
- _Metallic: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 0.5
- _Parallax: 0.02

- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- Color_Color_4467EDF0_Uniform: {r: 1, g: 0, b: 0, a: 0}
- Color_Color_8256B4E6_Uniform: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

4
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/lightweightSubshaderFastBlinn.template


CGPROGRAM
#pragma target 3.0
#include "UnityCG.cginc"
#include "CGIncludes/LightweightPBR.cginc"
#include "CGIncludes/LightweightFastBlinn.cginc"
#pragma multi_compile _ UNITY_SINGLE_PASS_STEREO STEREO_INSTANCING_ON STEREO_MULTIVIEW_ON
#pragma multi_compile_fog

#pragma fragment LightweightFragmentPBR
#pragma fragment LightweightFragmentFastBlinn
#pragma glsl
#pragma debug

244
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/lightweightSubshaderPBR.template


CGPROGRAM
#pragma target 3.0
#include "UnityCG.cginc"
#include "CGIncludes/LightweightFastBlinn.cginc"
#pragma multi_compile _ _SINGLE_DIRECTIONAL_LIGHT _SINGLE_SPOT_LIGHT _SINGLE_POINT_LIGHT
#pragma multi_compile _ LIGHTWEIGHT_LINEAR
#pragma multi_compile_fog
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ _LIGHT_PROBES_ON
#pragma multi_compile _ _HARD_SHADOWS _SOFT_SHADOWS _HARD_SHADOWS_CASCADES _SOFT_SHADOWS_CASCADES
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile_fog
#pragma vertex LightweightVertex
#pragma fragment LightweightFragmentFastBlinn
#pragma vertex LightweightVertexCustom
#pragma fragment LightweightFragmentPBR
${Defines}
/* struct LightweightVertexInput
struct vInput
struct LightweightVertexOutput
struct vOutput
{
${VertexOutputs}

LightweightVertexOutput LightweightVertexCustom(Input v)
vOutput LightweightVertexCustom(vInput v)
LightweightVertexOutput o = (LightweightVertexOutput)0;
${VertexShaderBody}
vOutput o = (vOutput)0;
${VertexShaderBody}
//o.uv01.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
#ifdef LIGHTMAP_ON
//o.uv01.zw = v.lightmapUV * unity_LightmapST.xy + unity_LightmapST.zw;
#endif
o.hpos = UnityObjectToClipPos(v.vertex);
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
o.posWS.xyz = worldPos;
o.viewDir.xyz = normalize(_WorldSpaceCameraPos - worldPos);
half3 normal = normalize(UnityObjectToWorldNormal(v.normal));
#if _NORMALMAP
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.tangentToWorld0 = half3(tangent.x, binormal.x, normal.x);
o.tangentToWorld1 = half3(tangent.y, binormal.y, normal.y);
o.tangentToWorld2 = half3(tangent.z, binormal.z, normal.z);
#else
o.normal = normal;
#endif
// TODO: change to only support point lights per vertex. This will greatly simplify shader ALU
#if defined(_VERTEX_LIGHTS) && defined(_MULTIPLE_LIGHTS)
half3 diffuse = half3(1.0, 1.0, 1.0);
// pixel lights shaded = min(pixelLights, perObjectLights)
// vertex lights shaded = min(vertexLights, perObjectLights) - pixel lights shaded
// Therefore vertexStartIndex = pixelLightCount; vertexEndIndex = min(vertexLights, perObjectLights)
int vertexLightStart = min(globalLightCount.x, unity_LightIndicesOffsetAndCount.y);
int vertexLightEnd = min(globalLightCount.y, unity_LightIndicesOffsetAndCount.y);
for (int lightIter = vertexLightStart; lightIter < vertexLightEnd; ++lightIter)
{
int lightIndex = unity_4LightIndices0[lightIter];
LightInput lightInput;
INITIALIZE_LIGHT(lightInput, lightIndex);
half3 lightDirection;
half atten = ComputeLightAttenuationVertex(lightInput, normal, worldPos, lightDirection);
o.fogCoord.yzw += LightingLambert(diffuse, lightDirection, normal, atten);
}
#endif
#if defined(_LIGHT_PROBES_ON) && !defined(LIGHTMAP_ON)
o.fogCoord.yzw += max(half3(0, 0, 0), ShadeSH9(half4(normal, 1)));
#endif
UNITY_TRANSFER_FOG(o, o.hpos);
}*/
}
void ModifyVertex(inout LightweightVertexInput v)
#include "UnityStandardInput.cginc"
#include "CGIncludes/LightweightShadows.cginc"
#include "CGIncludes/LightweightBRDF.cginc"
#include "CGIncludes/LightweightCore.cginc"
struct SurfacePBR
{
float3 Albedo; // diffuse color
float3 Specular; // specular color
float Metallic; // metallic
float3 Normal; // tangent space normal, if written
half3 Emission;
half Smoothness; // 0=rough, 1=smooth
half Occlusion; // occlusion (default 1)
float Alpha; // alpha for transparencies
};
SurfacePBR InitializeSurfacePBR()
${VertexShaderBody}
SurfacePBR o;
o.Albedo = float3(0.5, 0.5, 0.5);
o.Specular = float3(0, 0, 0);
o.Metallic = 0;
o.Normal = float3(.5, .5, 1);
o.Emission = 0;
o.Smoothness = 0;
o.Occlusion = 1;
o.Alpha = 1;
return o;
void DefineSurface(LightweightVertexOutput i, inout SurfaceFastBlinn s)
void DefineSurface(vOutput i, inout SurfacePBR o)
half3 MetallicSetup(SurfacePBR o, out half3 specular, out half smoothness, out half oneMinusReflectivity)
{
smoothness = o.Smoothness;// metallicGloss.g;
// We'll need oneMinusReflectivity, so
// 1-reflectivity = 1-lerp(dielectricSpec, 1, metallic) = lerp(1-dielectricSpec, 0, metallic)
// store (1-dielectricSpec) in unity_ColorSpaceDielectricSpec.a, then
// 1-reflectivity = lerp(alpha, 0, metallic) = alpha + metallic*(0 - alpha) =
// = alpha - metallic * alpha
half oneMinusDielectricSpec = _DieletricSpec.a;
oneMinusReflectivity = oneMinusDielectricSpec - o.Metallic * oneMinusDielectricSpec;
specular = lerp(_DieletricSpec.rgb, o.Albedo, o.Metallic);
return o.Albedo * oneMinusReflectivity;
}
half3 SpecularSetup(SurfacePBR o, out half3 specular, out half smoothness, out half oneMinusReflectivity)
{
half4 specGloss = float4(o.Specular, o.Smoothness);
#if defined(UNITY_COLORSPACE_GAMMA) && defined(LIGHTWEIGHT_LINEAR)
specGloss.rgb = LIGHTWEIGHT_GAMMA_TO_LINEAR(specGloss.rgb);
#endif
specular = specGloss.rgb;
smoothness = specGloss.a;
oneMinusReflectivity = 1.0h - SpecularReflectivity(specular);
return o.Albedo * (half3(1, 1, 1) - specular);
}
half4 LightweightFragmentPBR(vOutput i) : SV_Target
{
SurfacePBR o = InitializeSurfacePBR();
DefineSurface(i, o);
//float2 uv = i.uv01.xy;
float2 lightmapUV = float2(0,0);//i.uv01.zw;
half3 specColor;
half smoothness;
half oneMinusReflectivity;
//#ifdef _METALLIC_SETUP
//half3 diffColor = MetallicSetup(o, specColor, smoothness, oneMinusReflectivity);
//#else
half3 diffColor = SpecularSetup(o, specColor, smoothness, oneMinusReflectivity);
//#endif
diffColor = PreMultiplyAlpha(diffColor, o.Alpha, oneMinusReflectivity, /*out*/ o.Alpha);
// Roughness is (1.0 - smoothness)²
half perceptualRoughness = 1.0h - smoothness;
// TODO - Actually handle normal
half3 normal;
CalculateNormal(i.normal, normal);
// TODO: shader keyword for occlusion
// TODO: Reflection Probe blend support.
half3 reflectVec = reflect(-i.viewDir.xyz, normal);
UnityIndirect indirectLight = LightweightGI(lightmapUV, i.fogCoord.yzw, reflectVec, o.Occlusion, perceptualRoughness);
// PBS
// grazingTerm = F90
half grazingTerm = saturate(smoothness + (1 - oneMinusReflectivity));
half fresnelTerm = Pow4(1.0 - saturate(dot(normal, i.viewDir.xyz)));
half3 color = LightweightBRDFIndirect(diffColor, specColor, indirectLight, perceptualRoughness * perceptualRoughness, grazingTerm, fresnelTerm);
half3 lightDirection;
#ifndef _MULTIPLE_LIGHTS
LightInput light;
INITIALIZE_MAIN_LIGHT(light);
half lightAtten = ComputeLightAttenuation(light, normal, i.posWS.xyz, lightDirection);
//#ifdef _SHADOWS
lightAtten *= ComputeShadowAttenuation(i.normal, i.posWS, _ShadowLightDirection.xyz);
//#endif
half NdotL = saturate(dot(normal, lightDirection));
half3 radiance = light.color * (lightAtten * NdotL);
color += LightweightBDRF(diffColor, specColor, oneMinusReflectivity, perceptualRoughness, normal, lightDirection, i.viewDir.xyz) * radiance;
#else
//#ifdef _SHADOWS
half shadowAttenuation = ComputeShadowAttenuation(i.normal, i.posWS, _ShadowLightDirection.xyz);
//#endif
int pixelLightCount = min(globalLightCount.x, unity_LightIndicesOffsetAndCount.y);
for (int lightIter = 0; lightIter < pixelLightCount; ++lightIter)
{
LightInput light;
int lightIndex = unity_4LightIndices0[lightIter];
INITIALIZE_LIGHT(light, lightIndex);
half lightAtten = ComputeLightAttenuation(light, normal, i.posWS.xyz, lightDirection);
//#ifdef _SHADOWS
lightAtten *= max(shadowAttenuation, half(lightIndex != _ShadowData.x));
//#endif
half NdotL = saturate(dot(normal, lightDirection));
half3 radiance = light.color * (lightAtten * NdotL);
color += LightweightBDRF(diffColor, specColor, oneMinusReflectivity, perceptualRoughness, normal, lightDirection, i.viewDir.xyz) * radiance;
}
#endif
color += o.Emission;
UNITY_APPLY_FOG(i.fogCoord, color);
return OutputColor(color, o.Alpha);
}
ENDCG
}

#include "CGIncludes/LightweightPass.cginc"
#pragma vertex depthVert
#pragma fragment depthFrag
ENDCG
}
Pass
{
Tags{ "LightMode" = "Meta" }
Cull Off
CGPROGRAM
#define UNITY_SETUP_BRDF_INPUT SpecularSetup
#pragma shader_feature EDITOR_VISUALIZATION
#include "UnityCG.cginc"
#include "CGIncludes/LightweightPass.cginc"
#pragma vertex vert_meta
#pragma fragment frag_meta_ld
void DefineSurfaceMeta(v2f_meta i, inout SurfaceFastBlinn s)
{
float2 uv = ${UV} //i.uv.xy
${PixelShaderBody}
}
ENDCG
}
}

30
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/AbstractLightweightPBRMasterNode.cs


get { return m_MaterialOptions; }
}
public abstract string GetWorkflowName();
//public abstract string GetSurfaceOutputName();
//public abstract string GetLightFunction();

var cullingVisitor = new ShaderGenerator();
var zTestVisitor = new ShaderGenerator();
var zWriteVisitor = new ShaderGenerator();
var definesVisitor = new ShaderGenerator();
m_MaterialOptions.GetTags(tagsVisitor);
m_MaterialOptions.GetBlend(blendingVisitor);

GetDefines(definesVisitor);
resultShader = resultShader.Replace("${ShaderInputs}", shaderInputVisitor.GetShaderString(3));
resultShader = resultShader.Replace("${ShaderOutputs}", shaderOutputVisitor.GetShaderString(3));
resultShader = resultShader.Replace("${VertexInputs}", shaderInputVisitor.GetShaderString(3));
resultShader = resultShader.Replace("${VertexOutputs}", shaderOutputVisitor.GetShaderString(3));
resultShader = resultShader.Replace("${PixelShaderBody}", shaderBodyVisitor.GetShaderString(3));
resultShader = resultShader.Replace("${Tags}", tagsVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${Blending}", blendingVisitor.GetShaderString(2));

resultShader = resultShader.Replace("${LOD}", "" + m_MaterialOptions.lod);
resultShader = resultShader.Replace("${Defines}", definesVisitor.GetShaderString(2));
public void GetDefines(ShaderGenerator visitor)
{
if(GetWorkflowName() == "Metallic")
visitor.AddShaderChunk("#define _METALLIC_SETUP 1", false);
else
visitor.AddShaderChunk("", false);
}
public override string GetFullShader(GenerationMode mode, string name, out List<PropertyGenerator.TextureInfo> configuredTextures)
{
var templateLocation = ShaderGenerator.GetTemplatePath("shader.template");

resultShader = resultShader.Replace("${ShaderPropertiesHeader}", shaderPropertiesVisitor.GetShaderString(2));
//resultShader = templateText.Replace("${Fallback}", "Diffuse");
configuredTextures = shaderPropertiesVisitor.GetConfiguredTexutres();
Debug.Log(resultShader);
return Regex.Replace(resultShader, @"\r\n|\n\r|\n|\r", Environment.NewLine);
}

}
int vertInputIndex = 1; // DIRTY
int vertOutputIndex = 3; // DIRTY
int vertOutputIndex = 4; // DIRTY
// Need these for lighting
shaderInputVisitor.AddShaderChunk("float4 vertex : POSITION;", true);

shaderOutputVisitor.AddShaderChunk("float4 posWS : TEXCOORD0;", true);
shaderOutputVisitor.AddShaderChunk("half4 viewDir : TEXCOORD1;", true);
shaderOutputVisitor.AddShaderChunk("half4 fogCoord : TEXCOORD2;", true);
shaderOutputVisitor.AddShaderChunk("half3 normal : TEXCOORD3;", true);
shaderOutputVisitor.AddShaderChunk("float4 hpos : SV_POSITION;", true);
bool requiresBitangent = activeNodeList.OfType<IMayRequireBitangent>().Any(x => x.RequiresBitangent());

//shaderBody.AddShaderChunk("float4 " + ShaderGeneratorNames.VertexColor + " = IN.color;", true);
}
GenerateNodeCode(shaderBody, mode);
}

if (remapper != null && !remapper.IsValidSlotConnection(outputRef.slotId))
continue;
shaderBody.AddShaderChunk("s." + slot.shaderOutputName + " = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
if (slot.id == NormalSlotId)
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " += 1e-6;", true);

11
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightMetallicMasterNode.cs


namespace UnityEngine.MaterialGraph
{
[Serializable]
[Title("Master/Metallic")]
[Title("Master/Lightweight/PBR Metallic")]
public const string MetallicSlotName = "Lightweight PBR Metallic";
public const string MetallicSlotName = "Metallic";
public const string WorkflowName = "Metallic";
//public const string LightFunctionName = "Standard";
//public const string SurfaceOutputStructureName = "SurfaceOutputStandard";

VertexOffsetId
};
}
}
public override string GetWorkflowName()
{
return WorkflowName;
}
/*public override string GetSurfaceOutputName()

94
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/ShaderTest.unity


m_ReflectionIntensity: 1
m_CustomReflection: {fileID: 0}
m_Sun: {fileID: 0}
m_IndirectSpecularColor: {r: 0.44657898, g: 0.4964133, b: 0.5748178, a: 1}
m_IndirectSpecularColor: {r: 0.45131707, g: 0.5009549, b: 0.5731141, a: 1}
--- !u!157 &3
LightmapSettings:
m_ObjectHideFlags: 0

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 301674285}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.323, y: 0.913, z: -0.176}
m_LocalPosition: {x: -0.782, y: 0.909, z: 1.006}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1225949929}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 0, y: 0, z: 1.466}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1641918147}
m_LocalRotation: {x: 0.40821788, y: -0.23456968, z: 0.10938163, w: 0.8754261}
m_LocalRotation: {x: -0.008174583, y: 0.5575213, z: -0.47586024, w: 0.68019146}
m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0}
m_LocalEulerAnglesHint: {x: 31.298002, y: 63.729004, z: -50.198}
--- !u!1 &1913430569
GameObject:
m_ObjectHideFlags: 0

m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2131834041
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 2131834045}
- component: {fileID: 2131834044}
- component: {fileID: 2131834043}
- component: {fileID: 2131834042}
m_Layer: 0
m_Name: Sphere (3)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!23 &2131834042
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2131834041}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_Materials:
- {fileID: 2100000, guid: 093053a5cbe55cc48a60db27e2b28232, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 1
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!135 &2131834043
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2131834041}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
serializedVersion: 2
m_Radius: 0.5
m_Center: {x: 0, y: 0, z: 0}
--- !u!33 &2131834044
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2131834041}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &2131834045
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2131834041}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0.323, y: 0.913, z: -0.176}
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}

331
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/GraphTest.shader


Shader "GraphOutputTest"
{
Properties
{
Vector1_Vector1_4B0AEC3F_Uniform("Smoothness", Float) = 0.5
Vector1_Vector1_5370E8F3_Uniform("Metallic / Specular", Float) = 0.5
Color_Color_8256B4E6_Uniform("Color", Color) = (0,0,0,0)
}
SubShader
{
Tags{ "RenderType" = "Opaque" "RenderPipeline" = "LightweightPipeline" }
LOD 200
Pass
{
Tags
{
"LightMode" = "LightweightForward"
"RenderType" = "Opaque"
"Queue" = "Geometry"
}
Blend One Zero
Cull Back
ZTest LEqual
ZWrite On
CGPROGRAM
#pragma target 3.0
#include "UnityCG.cginc"
#pragma multi_compile _ _SINGLE_DIRECTIONAL_LIGHT _SINGLE_SPOT_LIGHT _SINGLE_POINT_LIGHT
#pragma multi_compile _ LIGHTWEIGHT_LINEAR
#pragma multi_compile _ UNITY_SINGLE_PASS_STEREO STEREO_INSTANCING_ON STEREO_MULTIVIEW_ON
#pragma multi_compile _ LIGHTMAP_ON
#pragma multi_compile _ _LIGHT_PROBES_ON
#pragma multi_compile _ _HARD_SHADOWS _SOFT_SHADOWS _HARD_SHADOWS_CASCADES _SOFT_SHADOWS_CASCADES
#pragma multi_compile _ _VERTEX_LIGHTS
#pragma multi_compile_fog
#pragma multi_compile_instancing
#pragma vertex LightweightVertexCustom
#pragma fragment LightweightFragmentPBR
//#pragma glsl
//#pragma debug
float Vector1_Vector1_4B0AEC3F_Uniform;
float Vector1_Vector1_5370E8F3_Uniform;
float4 Color_Color_8256B4E6_Uniform;
//sampler2D _MainTex;
//float4 _MainTex_ST;
struct vInput
{
float4 vertex : POSITION;
float4 normal : NORMAL;
float2 lightmapUV : TEXCOORD0;
float4 color : COLOR;
float2 texcoord : TEXCOORD1;
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct vOutput
{
float4 posWS : TEXCOORD0;
half4 viewDir : TEXCOORD1;
half4 fogCoord : TEXCOORD2;
half3 normal : TEXCOORD3;
float4 hpos : SV_POSITION;
float4 uv01 : TEXCOORD4;
UNITY_VERTEX_OUTPUT_STEREO
};
#include "UnityStandardInput.cginc"
vOutput LightweightVertexCustom(vInput v)
{
vOutput o = (vOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.uv01.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
//o.uv01.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
#ifdef LIGHTMAP_ON
o.uv01.zw = v.lightmapUV * unity_LightmapST.xy + unity_LightmapST.zw;
#endif
o.hpos = UnityObjectToClipPos(v.vertex);
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
o.posWS.xyz = worldPos;
o.viewDir.xyz = normalize(_WorldSpaceCameraPos - worldPos);
half3 normal = normalize(UnityObjectToWorldNormal(v.normal));
#if _NORMALMAP
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.tangentToWorld0 = half3(tangent.x, binormal.x, normal.x);
o.tangentToWorld1 = half3(tangent.y, binormal.y, normal.y);
o.tangentToWorld2 = half3(tangent.z, binormal.z, normal.z);
#else
o.normal = normal;
#endif
// TODO: change to only support point lights per vertex. This will greatly simplify shader ALU
#if defined(_VERTEX_LIGHTS) && defined(_MULTIPLE_LIGHTS)
half3 diffuse = half3(1.0, 1.0, 1.0);
// pixel lights shaded = min(pixelLights, perObjectLights)
// vertex lights shaded = min(vertexLights, perObjectLights) - pixel lights shaded
// Therefore vertexStartIndex = pixelLightCount; vertexEndIndex = min(vertexLights, perObjectLights)
int vertexLightStart = min(globalLightCount.x, unity_LightIndicesOffsetAndCount.y);
int vertexLightEnd = min(globalLightCount.y, unity_LightIndicesOffsetAndCount.y);
for (int lightIter = vertexLightStart; lightIter < vertexLightEnd; ++lightIter)
{
int lightIndex = unity_4LightIndices0[lightIter];
LightInput lightInput;
INITIALIZE_LIGHT(lightInput, lightIndex);
half3 lightDirection;
half atten = ComputeLightAttenuationVertex(lightInput, normal, worldPos, lightDirection);
o.fogCoord.yzw += LightingLambert(diffuse, lightDirection, normal, atten);
}
#endif
#if defined(_LIGHT_PROBES_ON) && !defined(LIGHTMAP_ON)
o.fogCoord.yzw += max(half3(0, 0, 0), ShadeSH9(half4(normal, 1)));
#endif
UNITY_TRANSFER_FOG(o, o.hpos);
return o;
}
#include "CGIncludes/LightweightShadows.cginc"
#include "CGIncludes/LightweightBRDF.cginc"
#include "CGIncludes/LightweightCore.cginc"
struct SurfacePBR
{
float3 Albedo; // diffuse color
float3 Specular; // specular color
float Metallic; // metallic
float3 Normal; // tangent space normal, if written
half3 Emission;
half Smoothness; // 0=rough, 1=smooth
half Occlusion; // occlusion (default 1)
float Alpha; // alpha for transparencies
};
SurfacePBR InitializeSurfacePBR()
{
SurfacePBR o;
o.Albedo = float3(0.5, 0.5, 0.5);
o.Specular = float3(0, 0, 0);
o.Metallic = 0;
o.Normal = float3(.5, .5, 1);
o.Emission = 0;
o.Smoothness = 0;
o.Occlusion = 1;
o.Alpha = 1;
return o;
}
void DefineSurface(vOutput i, inout SurfacePBR o)
{
o.Albedo = Color_Color_8256B4E6_Uniform;
o.Specular = Vector1_Vector1_5370E8F3_Uniform;
o.Smoothness = Vector1_Vector1_4B0AEC3F_Uniform;
}
half3 MetallicSetup(SurfacePBR o, out half3 specular, out half smoothness, out half oneMinusReflectivity)
{
smoothness = o.Smoothness;// metallicGloss.g;
// We'll need oneMinusReflectivity, so
// 1-reflectivity = 1-lerp(dielectricSpec, 1, metallic) = lerp(1-dielectricSpec, 0, metallic)
// store (1-dielectricSpec) in unity_ColorSpaceDielectricSpec.a, then
// 1-reflectivity = lerp(alpha, 0, metallic) = alpha + metallic*(0 - alpha) =
// = alpha - metallic * alpha
half oneMinusDielectricSpec = _DieletricSpec.a;
oneMinusReflectivity = oneMinusDielectricSpec - o.Metallic * oneMinusDielectricSpec;
specular = lerp(_DieletricSpec.rgb, o.Albedo, o.Metallic);
return o.Albedo * oneMinusReflectivity;
}
half3 SpecularSetup(SurfacePBR o, out half3 specular, out half smoothness, out half oneMinusReflectivity)
{
half4 specGloss = float4(o.Specular, o.Smoothness);
#if defined(UNITY_COLORSPACE_GAMMA) && defined(LIGHTWEIGHT_LINEAR)
specGloss.rgb = LIGHTWEIGHT_GAMMA_TO_LINEAR(specGloss.rgb);
#endif
specular = specGloss.rgb;
smoothness = specGloss.a;
oneMinusReflectivity = 1.0h - SpecularReflectivity(specular);
return o.Albedo * (half3(1, 1, 1) - specular);
}
half4 LightweightFragmentPBR(vOutput i) : SV_Target
{
SurfacePBR o = InitializeSurfacePBR();
DefineSurface(i, o);
//float2 uv = i.uv01.xy;
float2 lightmapUV = i.uv01.zw;
half3 specColor;
half smoothness;
half oneMinusReflectivity;
//#ifdef _METALLIC_SETUP
//half3 diffColor = MetallicSetup(o, specColor, smoothness, oneMinusReflectivity);
//#else
half3 diffColor = SpecularSetup(o, specColor, smoothness, oneMinusReflectivity);
//#endif
diffColor = PreMultiplyAlpha(diffColor, o.Alpha, oneMinusReflectivity, /*out*/ o.Alpha);
// Roughness is (1.0 - smoothness)²
half perceptualRoughness = 1.0h - smoothness;
// TODO - Actually handle normal
half3 normal;
CalculateNormal(i.normal, normal);
// TODO: shader keyword for occlusion
// TODO: Reflection Probe blend support.
half3 reflectVec = reflect(-i.viewDir.xyz, normal);
UnityIndirect indirectLight = LightweightGI(lightmapUV, i.fogCoord.yzw, reflectVec, o.Occlusion, perceptualRoughness);
// PBS
// grazingTerm = F90
half grazingTerm = saturate(smoothness + (1 - oneMinusReflectivity));
half fresnelTerm = Pow4(1.0 - saturate(dot(normal, i.viewDir.xyz)));
half3 color = LightweightBRDFIndirect(diffColor, specColor, indirectLight, perceptualRoughness * perceptualRoughness, grazingTerm, fresnelTerm);
half3 lightDirection;
#ifndef _MULTIPLE_LIGHTS
LightInput light;
INITIALIZE_MAIN_LIGHT(light);
half lightAtten = ComputeLightAttenuation(light, normal, i.posWS.xyz, lightDirection);
//#ifdef _SHADOWS
lightAtten *= ComputeShadowAttenuation(i.normal, i.posWS, _ShadowLightDirection.xyz);
//#endif
half NdotL = saturate(dot(normal, lightDirection));
half3 radiance = light.color * (lightAtten * NdotL);
color += LightweightBDRF(diffColor, specColor, oneMinusReflectivity, perceptualRoughness, normal, lightDirection, i.viewDir.xyz) * radiance;
#else
//#ifdef _SHADOWS
half shadowAttenuation = ComputeShadowAttenuation(i.normal, i.posWS, _ShadowLightDirection.xyz);
//#endif
int pixelLightCount = min(globalLightCount.x, unity_LightIndicesOffsetAndCount.y);
for (int lightIter = 0; lightIter < pixelLightCount; ++lightIter)
{
LightInput light;
int lightIndex = unity_4LightIndices0[lightIter];
INITIALIZE_LIGHT(light, lightIndex);
half lightAtten = ComputeLightAttenuation(light, normal, i.posWS.xyz, lightDirection);
//#ifdef _SHADOWS
lightAtten *= max(shadowAttenuation, half(lightIndex != _ShadowData.x));
//#endif
half NdotL = saturate(dot(normal, lightDirection));
half3 radiance = light.color * (lightAtten * NdotL);
color += LightweightBDRF(diffColor, specColor, oneMinusReflectivity, perceptualRoughness, normal, lightDirection, i.viewDir.xyz) * radiance;
}
#endif
color += o.Emission;
//UNITY_APPLY_FOG(i.fogCoord, color);
return OutputColor(color, o.Alpha);
}
ENDCG
}
Pass
{
Tags{ "Lightmode" = "ShadowCaster" }
ZWrite On ZTest LEqual
CGPROGRAM
#pragma target 2.0
#include "UnityCG.cginc"
#include "CGIncludes/LightweightPass.cginc"
#pragma vertex shadowVert
#pragma fragment shadowFrag
ENDCG
}
Pass
{
Tags{ "Lightmode" = "DepthOnly" }
ZWrite On
CGPROGRAM
#pragma target 2.0
#include "UnityCG.cginc"
#include "CGIncludes/LightweightPass.cginc"
#pragma vertex depthVert
#pragma fragment depthFrag
ENDCG
}
}
//FallBack "Diffuse"
CustomEditor "LegacyIlluminShaderGUI"
}

11
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/GraphTest.shader.meta


fileFormatVersion: 2
guid: 542ef8f442f720644896ebc5885e65f6
timeCreated: 1505451746
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

77
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/TestyTest.ShaderGraph
文件差异内容过多而无法显示
查看文件

11
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/TestyTest.ShaderGraph.meta


fileFormatVersion: 2
guid: 02a3ca69ec995e94aa47105621a17e4c
timeCreated: 1505452895
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures: []
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

101
MaterialGraphProject/Assets/TestGraph-PBR.mat


%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!21 &2100000
Material:
serializedVersion: 6
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: TestGraph-PBR
m_Shader: {fileID: 4800000, guid: 02a3ca69ec995e94aa47105621a17e4c, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_ON _METALLIC_SETUP _SPECULARHIGHLIGHTS_ON
m_LightmapFlags: 2
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0
m_CustomRenderQueue: -1
stringTagMap: {}
disabledShaderPasses: []
m_SavedProperties:
serializedVersion: 3
m_TexEnvs:
- Texture2D_Texture2D_2A5875FB_Uniform:
m_Texture: {fileID: 2800000, guid: 618126695341ad844ac048b062fd2688, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_87733D67_Uniform:
m_Texture: {fileID: 2800000, guid: 3f3b8bdf3ccd30c4fb97b62bd26ef1f6, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Cube:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailAlbedoMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailMask:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _DetailNormalMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _EmissionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicSpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _SpecGlossMap:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- Vector1_Vector1_5370E8F3_Uniform: 0
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 1
- _GlossinessSource: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 0.5
- _Parallax: 0.02
- _ReflectionSource: 0
- _Shininess: 1
- _SmoothnessTextureChannel: 0
- _SpecSource: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkflowMode: 1
- _ZWrite: 1
m_Colors:
- Color_Color_4467EDF0_Uniform: {r: 1, g: 0, b: 0, a: 0}
- Color_Color_8256B4E6_Uniform: {r: 1, g: 1, b: 1, a: 1}
- _Color: {r: 1, g: 1, b: 1, a: 1}
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
- _SpecColor: {r: 1, g: 1, b: 1, a: 1}

10
MaterialGraphProject/Assets/TestGraph-PBR.mat.meta


fileFormatVersion: 2
guid: d6c557b0ad00a7946b27400b33a390ac
timeCreated: 1505335385
licenseType: Pro
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 2100000
userData:
assetBundleName:
assetBundleVariant:

94
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightSpecularMasterNode.cs


using System;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Serializable]
[Title("Master/Lightweight/PBR Specular")]
public class LightweightSpecularMasterNode : AbstractLightweightPBRMasterNode
{
public const string SpecularSlotName = "Specular";
public const int SpecularSlotId = 2;
public const string WorkflowName = "Specular";
//public const string LightFunctionName = "Standard";
//public const string SurfaceOutputStructureName = "SurfaceOutputStandard";
public LightweightSpecularMasterNode()
{
name = "LightweightSpecularMasterNode";
UpdateNodeAfterDeserialization();
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(VertexOffsetId, VertexOffsetName, VertexOffsetName, SlotType.Input, SlotValueType.Vector3, Vector4.zero, ShaderStage.Vertex));
AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(SpecularSlotId, SpecularSlotName, SpecularSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
AddSlot(new MaterialSlot(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero, ShaderStage.Fragment));
// clear out slot names that do not match the slots
// we support
RemoveSlotsNameNotMatching(
new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
SpecularSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId,
VertexOffsetId
});
}
protected override int[] surfaceInputs
{
get
{
return new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
SpecularSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId,
};
}
}
protected override int[] vertexInputs
{
get
{
return new[]
{
VertexOffsetId
};
}
}
public override string GetWorkflowName()
{
return WorkflowName;
}
/*public override string GetSurfaceOutputName()
{
return SurfaceOutputStructureName;
}
public override string GetLightFunction()
{
return LightFunctionName;
}*/
}
}

12
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/LightweightSpecularMasterNode.cs.meta


fileFormatVersion: 2
guid: bf358c1c084b6cf4b9a4a9cc49cd61f0
timeCreated: 1478188276
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存