浏览代码

Working Lightweight PBR Masters

/main
Matt Dean 7 年前
当前提交
6617bfcf
共有 28 个文件被更改,包括 1312 次插入630 次删除
  1. 2
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightFastBlinn.cginc
  2. 8
      MaterialGraphProject/Assets/TestAssets/bricks_normal.tga.meta
  3. 32
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/lightweightSubshaderPBR.template
  4. 102
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/AbstractLightweightPBRMasterNode.cs
  5. 179
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/ShaderTest.unity
  6. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Legacy.mat
  7. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBR.mat
  8. 378
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/MetallicTest.ShaderGraph
  9. 15
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/MetallicTest.ShaderGraph.meta
  10. 378
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/SpecularTest.ShaderGraph
  11. 15
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/SpecularTest.ShaderGraph.meta
  12. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials.meta
  13. 133
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRMetallic.mat
  14. 133
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRSpecular.mat
  15. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRSpecular.mat.meta
  16. 11
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/GraphTest.shader.meta
  17. 334
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/GraphTest.shader
  18. 77
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/TestyTest.ShaderGraph
  19. 11
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/TestyTest.ShaderGraph.meta
  20. 102
      MaterialGraphProject/Assets/TestGraph-PBR.mat
  21. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Legacy.mat
  22. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Legacy.mat.meta
  23. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBR.mat.meta
  24. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Unlit.mat
  25. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Unlit.mat.meta
  26. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRMetallic.mat.meta
  27. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBR.mat

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


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

8
MaterialGraphProject/Assets/TestAssets/bricks_normal.tga.meta


fileFormatVersion: 2
guid: e017404169662f041a969b0a924cc2ed
timeCreated: 1495717224
timeCreated: 1505497605
externalObjects: {}
sRGBTexture: 1
sRGBTexture: 0
linearTexture: 0
fadeOut: 0
borderMipMap: 0

alphaUsage: 1
alphaIsTransparency: 0
spriteTessellationDetail: -1
textureType: 0
textureType: 1
textureShape: 1
maxTextureSizeSet: 0
compressionQualitySet: 0

crunchedCompression: 0
allowsAlphaSplitting: 0
overridden: 0
androidETC2FallbackOverride: 0
spriteSheet:
serializedVersion: 2
sprites: []

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


UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.normal = normalize(UnityObjectToWorldNormal(v.normal));
${VertexShaderBody}

o.posWS.xyz = worldPos;
o.viewDir.xyz = normalize(_WorldSpaceCameraPos - worldPos);
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;
//o.tangent = normalize(UnityObjectToWorldDir(v.tangent));
//o.binormal = cross(normal, tangent) * v.tangent.w;
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;
//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);
#endif
// TODO: change to only support point lights per vertex. This will greatly simplify shader ALU

INITIALIZE_LIGHT(lightInput, lightIndex);
half3 lightDirection;
half atten = ComputeLightAttenuationVertex(lightInput, normal, worldPos, lightDirection);
half atten = ComputeLightAttenuationVertex(lightInput, o.normal, worldPos, lightDirection);
o.fogCoord.yzw += max(half3(0, 0, 0), ShadeSH9(half4(normal, 1)));
o.fogCoord.yzw += max(half3(0, 0, 0), ShadeSH9(half4(o.normal, 1)));
#endif
UNITY_TRANSFER_FOG(o, o.hpos);

{
SurfacePBR o = InitializeSurfacePBR();
DefineSurface(i, o);
o.Albedo = LIGHTWEIGHT_GAMMA_TO_LINEAR(o.Albedo);
//float2 uv = i.uv01.xy;
float2 lightmapUV = float2(0,0);//i.uv01.zw;

// TODO - Actually handle normal
half3 normal;
CalculateNormal(i.normal, normal);
#if _NORMALMAP
half3 tangentToWorld0 = half3(i.tangent.x, i.binormal.x, i.normal.x);
half3 tangentToWorld1 = half3(i.tangent.y, i.binormal.y, i.normal.y);
half3 tangentToWorld2 = half3(i.tangent.z, i.binormal.z, i.normal.z);
normal = normalize(half3(dot(o.Normal, tangentToWorld0), dot(o.Normal, tangentToWorld1), dot(o.Normal, tangentToWorld2)));
#else
normal = normalize(i.normal);
#endif
// TODO: shader keyword for occlusion
// TODO: Reflection Probe blend support.

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


}
public abstract string GetWorkflowName();
//public abstract string GetSurfaceOutputName();
//public abstract string GetLightFunction();
void GenerateNodeFunctionsAndPropertyUsages(

var shaderInputVisitor = new ShaderGenerator();
var shaderOutputVisitor = new ShaderGenerator();
var vertexShaderBlock = new ShaderGenerator();
var definesVisitor = new ShaderGenerator();
GenerateSurfaceShaderInternal(
shaderPropertyUsagesVisitor,

shaderOutputVisitor,
vertexShaderBlock,
definesVisitor,
mode);
GenerateVertexShaderInternal(

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);
var resultShader = templateText.Replace("${ShaderPropertyUsages}", shaderPropertyUsagesVisitor.GetShaderString(2));
//resultShader = resultShader.Replace("${LightingFunctionName}", GetLightFunction());
//resultShader = resultShader.Replace("${SurfaceOutputStructureName}", GetSurfaceOutputName());
resultShader = resultShader.Replace("${ShaderFunctions}", shaderFunctionVisitor.GetShaderString(2));
resultShader = resultShader.Replace("${VertexInputs}", shaderInputVisitor.GetShaderString(3));
resultShader = resultShader.Replace("${VertexOutputs}", shaderOutputVisitor.GetShaderString(3));

resultShader = resultShader.Replace("${LOD}", "" + m_MaterialOptions.lod);
resultShader = resultShader.Replace("${Defines}", definesVisitor.GetShaderString(2));
//resultShader = resultShader.Replace("${VertexShaderDecl}", "vertex:vert");
resultShader = resultShader.Replace("${VertexShaderBody}", vertexShaderBlock.GetShaderString(3));
return resultShader;

else
visitor.AddShaderChunk("", false);
visitor.AddShaderChunk("#define _GLOSSYREFLECTIONS_ON", true);
//visitor.AddShaderChunk("#define _SOFT_SHADOWS", true);
visitor.AddShaderChunk("#define _SPECULARHIGHLIGHTS_ON", true);
}

var resultShader = templateText.Replace("${ShaderName}", name);
resultShader = resultShader.Replace("${SubShader}", GetSubShader(mode, shaderPropertiesVisitor));
resultShader = resultShader.Replace("${ShaderPropertiesHeader}", shaderPropertiesVisitor.GetShaderString(2));
//resultShader = templateText.Replace("${Fallback}", "Diffuse");
configuredTextures = shaderPropertiesVisitor.GetConfiguredTexutres();
Debug.Log(resultShader);

ShaderGenerator shaderInputVisitor,
ShaderGenerator shaderOutputVisitor,
ShaderGenerator vertexShaderBlock,
ShaderGenerator definesVisitor,
GenerationMode mode)
{
var activeNodeList = new List<INode>();

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

bool requiresNormal = activeNodeList.OfType<IMayRequireNormal>().Any(x => x.RequiresNormal());
bool requiresScreenPosition = activeNodeList.OfType<IMayRequireScreenPosition>().Any(x => x.RequiresScreenPosition());
bool requiresVertexColor = activeNodeList.OfType<IMayRequireVertexColor>().Any(x => x.RequiresVertexColor());
foreach (var slot in GetInputSlots<MaterialSlot>())
{
if (surfaceInputs.Contains(slot.id))
{
foreach (var edge in owner.GetEdges(slot.slotReference))
{
var outputRef = edge.outputSlot;
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(outputRef.nodeGuid);
if (fromNode == null)
continue;
var remapper = fromNode as INodeGroupRemapper;
if (remapper != null && !remapper.IsValidSlotConnection(outputRef.slotId))
continue;
if (slot.id == NormalSlotId)
{
requiresBitangent = true;
requiresTangent = true;
definesVisitor.AddShaderChunk("#define _NORMALMAP 1", true);
}
}
}
}
for (int uvIndex = 0; uvIndex < ShaderGeneratorNames.UVCount; ++uvIndex)
{
var channel = (UVChannel)uvIndex;

shaderOutputVisitor.AddShaderChunk(string.Format("half4 meshUV{0} : TEXCOORD{1};", uvIndex, vertOutputIndex), true);
vertexShaderBlock.AddShaderChunk(string.Format("o.meshUV{0} = v.texcoord{1};", uvIndex, uvIndex/*uvIndex == 0 ? "" : uvIndex.ToString()*/), true);
vertexShaderBlock.AddShaderChunk(string.Format("o.meshUV{0} = v.texcoord{1};", uvIndex, uvIndex), true);
//shaderInputVisitor.AddShaderChunk(string.Format("half4 meshUV{0};", uvIndex), true);
//vertexShaderBlock.AddShaderChunk(string.Format("o.meshUV{0} = v.texcoord{1};", uvIndex, uvIndex == 0 ? "" : uvIndex.ToString()), true);
//shaderBody.AddShaderChunk(string.Format("half4 {0} = IN.meshUV{1};", channel.GetUVName(), uvIndex), true);
}
}

//shaderInputVisitor.AddShaderChunk("float3 worldViewDir;", true);
//shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceViewDirection + " = IN.worldViewDir;", true);
//shaderInputVisitor.AddShaderChunk("float3 worldPos;", true);
//shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpacePosition + " = IN.worldPos;", true);
}
if (requiresScreenPosition)

shaderBody.AddShaderChunk("float4 " + ShaderGeneratorNames.ScreenPosition + " = i.screenPos;", true);
vertInputIndex++;
vertOutputIndex++;
//shaderInputVisitor.AddShaderChunk("float4 screenPos;", true);
//shaderBody.AddShaderChunk("float4 " + ShaderGeneratorNames.ScreenPosition + " = IN.screenPos;", true);
shaderOutputVisitor.AddShaderChunk(string.Format("half4 tangentWS : TEXCOORD{0};", vertOutputIndex), true);
vertexShaderBlock.AddShaderChunk("o.tangentWS = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);", true);
shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceTangent + " = normalize(i.worldTangent.xyz);", true);
shaderOutputVisitor.AddShaderChunk(string.Format("half3 tangent : TEXCOORD{0};", vertOutputIndex), true);
vertexShaderBlock.AddShaderChunk("o.tangent = normalize(UnityObjectToWorldDir(v.tangent));", true);
shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceTangent + " = normalize(i.tangent.xyz);", true);
//shaderInputVisitor.AddShaderChunk("float4 worldTangent;", true);
//vertexShaderBlock.AddShaderChunk("o.worldTangent = float4(UnityObjectToWorldDir(v.tangent.xyz), v.tangent.w);", true);
//shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceTangent + " = normalize(IN.worldTangent.xyz);", true);
// is the normal connected?
var normalSlot = FindInputSlot<MaterialSlot>(NormalSlotId);
var edges = owner.GetEdges(normalSlot.slotReference);
shaderInputVisitor.AddShaderChunk(string.Format("half4 normalWS : TEXCOORD{0};", vertInputIndex), true);
shaderOutputVisitor.AddShaderChunk(string.Format("half4 normalWS : TEXCOORD{0};", vertOutputIndex), true);
vertexShaderBlock.AddShaderChunk("o.normalWS = unity_ObjectToWorld(v.normal);", true);
shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceNormal + " = normalize(i.normalWS);", true);
vertInputIndex++;
vertOutputIndex++;
//shaderInputVisitor.AddShaderChunk("float3 worldNormal;", true);
if (edges.Any())
shaderInputVisitor.AddShaderChunk("INTERNAL_DATA", true);
//shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceNormal + " = normalize(IN.worldNormal);", true);
shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceNormal + " = normalize(i.normal);", true);
shaderBody.AddShaderChunk(string.Format("float3 {0} = cross({1}, {2}) * i.tangentWS.w;", ShaderGeneratorNames.WorldSpaceBitangent, ShaderGeneratorNames.WorldSpaceNormal, ShaderGeneratorNames.WorldSpaceTangent), true);
//shaderBody.AddShaderChunk(string.Format("float3 {0} = cross({1}, {2}) * IN.worldTangent.w;", ShaderGeneratorNames.WorldSpaceBitangent, ShaderGeneratorNames.WorldSpaceNormal, ShaderGeneratorNames.WorldSpaceTangent), true);
shaderOutputVisitor.AddShaderChunk(string.Format("half3 binormal : TEXCOORD{0};", vertOutputIndex), true);
vertexShaderBlock.AddShaderChunk("o.binormal = cross(o.normal, o.tangent) * v.tangent.w;", true);
shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.WorldSpaceBitangent + " = i.binormal;", true);
vertOutputIndex++;
// shaderInputVisitor.AddShaderChunk("float3 tangentViewDir;", true);
// shaderBody.AddShaderChunk("float3 " + ShaderGeneratorNames.TangentSpaceViewDirection + " = IN.tangentViewDir;", true);
shaderBody.AddShaderChunk(
"float3 " + ShaderGeneratorNames.TangentSpaceViewDirection + ";", true);

ShaderGeneratorNames.WorldSpaceNormal + ");", true);
}
if (requiresVertexColor)
{
shaderOutputVisitor.AddShaderChunk(string.Format("half4 color : TEXCOORD{0};", vertOutputIndex), true);

//shaderBody.AddShaderChunk("float4 " + ShaderGeneratorNames.VertexColor + " = IN.color;", true);
GenerateNodeCode(shaderBody, mode);
GenerateNodeCode(shaderBody, propertyUsages, mode);
public void GenerateNodeCode(ShaderGenerator shaderBody, GenerationMode generationMode)
public void GenerateNodeCode(ShaderGenerator shaderBody, ShaderGenerator propertyUsages, GenerationMode generationMode)
{
var nodes = ListPool<INode>.Get();

if (slot.id == NormalSlotId)
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " += 1e-6;", true);
if (slot.id == AlphaSlotId)
propertyUsages.AddShaderChunk("#define _ALPHAPREMULTIPLY_ON", true);
}
}
}

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


debug:
m_Flags: 0
m_NavMeshData: {fileID: 0}
--- !u!1 &38610488
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 38610489}
- component: {fileID: 38610492}
- component: {fileID: 38610491}
- component: {fileID: 38610490}
m_Layer: 0
m_Name: PBRMetallic (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &38610489
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38610488}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.099, y: 0, z: -1.277}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1220808772}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &38610490
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38610488}
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: 0b6bd1d9f8dca444aa8695ad2c1b7152, 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 &38610491
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38610488}
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 &38610492
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 38610488}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &250933708
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 250933710}
- component: {fileID: 250933709}
m_Layer: 0
m_Name: Sphere (3)
m_Name: PBRMetallic
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 250933708}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -1.27, y: 0, z: -1.277}
m_Father: {fileID: 0}
m_RootOrder: 5
m_Father: {fileID: 1220808772}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &301674285
GameObject:

- component: {fileID: 301674287}
- component: {fileID: 301674286}
m_Layer: 0
m_Name: Sphere (1)
m_Name: BlinnPhong
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 301674285}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_Father: {fileID: 1045077821}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1045077820
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1045077821}
m_Layer: 0
m_Name: Handwritten
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1045077821
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1045077820}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1225949933}
- {fileID: 301674289}
- {fileID: 1225352830}
--- !u!1 &1220808771
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1220808772}
m_Layer: 0
m_Name: Graph
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1220808772
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1220808771}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 250933712}
- {fileID: 38610489}
m_Father: {fileID: 0}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1225352826
GameObject:
m_ObjectHideFlags: 0

- component: {fileID: 1225352828}
- component: {fileID: 1225352827}
m_Layer: 0
m_Name: Sphere (2)
m_Name: Unlit
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1225352826}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_Father: {fileID: 0}
m_RootOrder: 4
m_Father: {fileID: 1045077821}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1225949929
GameObject:

- component: {fileID: 1225949931}
- component: {fileID: 1225949930}
m_Layer: 0
m_Name: Sphere
m_Name: PBRMetallic
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1225949929}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_Father: {fileID: 0}
m_RootOrder: 2
m_Father: {fileID: 1045077821}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1641918147
GameObject:

m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1913430569}
m_LocalRotation: {x: -0.23384847, y: 0.25512192, z: -0.06373714, w: -0.936037}
m_LocalPosition: {x: -0.034000266, y: 1.0085648, z: -1.8235388}
m_LocalRotation: {x: -0.28734982, y: 0.32602012, z: -0.10472839, w: -0.8945239}
m_LocalPosition: {x: -0.2865281, y: 1.3010813, z: -2.3694947}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}

2
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Legacy.mat


serializedVersion: 3
m_TexEnvs:
- _BumpMap:
m_Texture: {fileID: 2800000, guid: e017404169662f041a969b0a924cc2ed, type: 3}
m_Texture: {fileID: 2800000, guid: d63435d934a30fd439a005c25fa542f0, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _Cube:

10
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBR.mat


m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 330f42016073a97418a4aae5517e32c8, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:

- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _GlossMapScale: 0
- _Metallic: 0.5
- _Metallic: 1
- _OcclusionStrength: 0.5
- _OcclusionStrength: 1
- _Parallax: 0.02
- _ReflectionSource: 0
- _Shininess: 1

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

15
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/MetallicTest.ShaderGraph.meta


fileFormatVersion: 2
guid: 02a3ca69ec995e94aa47105621a17e4c
timeCreated: 1505497637
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures:
- Texture2D_Texture2D_AEB21289_Uniform: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a,
type: 3}
- Texture2D_Texture2D_87733D67_Uniform: {fileID: 2800000, guid: 3f3b8bdf3ccd30c4fb97b62bd26ef1f6,
type: 3}
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

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

15
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/SpecularTest.ShaderGraph.meta


fileFormatVersion: 2
guid: a96bafc6e4c6e7c4ca1fb43c905d7948
timeCreated: 1505498093
licenseType: Pro
ShaderImporter:
externalObjects: {}
defaultTextures:
- Texture2D_Texture2D_AEB21289_Uniform: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a,
type: 3}
- Texture2D_Texture2D_87733D67_Uniform: {fileID: 2800000, guid: 3f3b8bdf3ccd30c4fb97b62bd26ef1f6,
type: 3}
nonModifiableTextures: []
userData:
assetBundleName:
assetBundleVariant:

10
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials.meta


fileFormatVersion: 2
guid: 19fc28fd8cfc0e24185139d888b580e0
folderAsset: yes
timeCreated: 1505498024
licenseType: Pro
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

133
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRMetallic.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-PBRMetallic
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_30A72685_Uniform:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_6C206BFC_Uniform:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_87733D67_Uniform:
m_Texture: {fileID: 2800000, guid: d63435d934a30fd439a005c25fa542f0, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_9508545D_Uniform:
m_Texture: {fileID: 2800000, guid: 330f42016073a97418a4aae5517e32c8, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_AEB21289_Uniform:
m_Texture: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_FE1ED0E8_Uniform:
m_Texture: {fileID: 2800000, guid: 1085d6f82e40b31428079b25ebee7d74, 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}
- _MetallicGlossMap:
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_20D3DC06_Uniform: 1
- Vector1_Vector1_4B0AEC3F_Uniform: 0.5
- Vector1_Vector1_5370E8F3_Uniform: 1
- Vector1_Vector1_69199BC_Uniform: 0
- Vector1_Vector1_72A1F5A1_Uniform: 1
- Vector1_Vector1_7EC3DCBC_Uniform: 0.5
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 1
- _GlossinessSource: 0
- _GlossyReflections: 1
- _Metallic: 1
- _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_5648C58E_Uniform: {r: 0, g: 0, b: 0, a: 0}
- Color_Color_8256B4E6_Uniform: {r: 1, g: 1, b: 1, a: 1}
- Color_Color_A536DDF7_Uniform: {r: 1, g: 1, b: 1, a: 1}
- Vector3_Vector3_D670D52C_Uniform: {r: 0, g: 0, b: 0, a: 0}
- _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}

133
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRSpecular.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-PBRSpecular
m_Shader: {fileID: 4800000, guid: a96bafc6e4c6e7c4ca1fb43c905d7948, 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_30A72685_Uniform:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_6C206BFC_Uniform:
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_87733D67_Uniform:
m_Texture: {fileID: 2800000, guid: d63435d934a30fd439a005c25fa542f0, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_9508545D_Uniform:
m_Texture: {fileID: 2800000, guid: 330f42016073a97418a4aae5517e32c8, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_AEB21289_Uniform:
m_Texture: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_FE1ED0E8_Uniform:
m_Texture: {fileID: 2800000, guid: 1085d6f82e40b31428079b25ebee7d74, 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}
- _MetallicGlossMap:
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_20D3DC06_Uniform: 1
- Vector1_Vector1_4B0AEC3F_Uniform: 0.5
- Vector1_Vector1_5370E8F3_Uniform: 0.5
- Vector1_Vector1_69199BC_Uniform: 0
- Vector1_Vector1_72A1F5A1_Uniform: 1
- Vector1_Vector1_7EC3DCBC_Uniform: 0.5
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 1
- _GlossinessSource: 0
- _GlossyReflections: 1
- _Metallic: 1
- _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_5648C58E_Uniform: {r: 0, g: 0, b: 0, a: 0}
- Color_Color_8256B4E6_Uniform: {r: 1, g: 1, b: 1, a: 1}
- Color_Color_A536DDF7_Uniform: {r: 1, g: 1, b: 1, a: 1}
- Vector3_Vector3_D670D52C_Uniform: {r: 0, g: 0, b: 0, a: 0}
- _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/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRSpecular.mat.meta


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

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:

334
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
#define _GLOSSYREFLECTIONS_ON
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.Metallic = 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"
}

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

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


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

102
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_4B0AEC3F_Uniform: 0.5
- Vector1_Vector1_5370E8F3_Uniform: 0.5
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 1
- _Glossiness: 1
- _GlossinessSource: 0
- _GlossyReflections: 1
- _Metallic: 1
- _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}

/MaterialGraphProject/Assets/Test-Legacy.mat → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Legacy.mat

/MaterialGraphProject/Assets/Test-Legacy.mat.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Legacy.mat.meta

/MaterialGraphProject/Assets/Test-PBR.mat.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBR.mat.meta

/MaterialGraphProject/Assets/Test-Unlit.mat → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Unlit.mat

/MaterialGraphProject/Assets/Test-Unlit.mat.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Unlit.mat.meta

/MaterialGraphProject/Assets/TestGraph-PBR.mat.meta → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRMetallic.mat.meta

/MaterialGraphProject/Assets/Test-PBR.mat → /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBR.mat

正在加载...
取消
保存