浏览代码

PBR Parity between graph and bespoke

- Need to gamma convert albedo textures somehow
- Still no blending
/main
Matt Dean 7 年前
当前提交
22d054b1
共有 21 个文件被更改,包括 340 次插入325 次删除
  1. 14
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightCore.cginc
  2. 4
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightFastBlinn.cginc
  3. 16
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightInput.cginc
  4. 8
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightPBR.cginc
  5. 13
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightFastBlinn.shader
  6. 20
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightPBR.shader
  7. 34
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/MetallicTest.ShaderGraph
  8. 2
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/MetallicTest.ShaderGraph.meta
  9. 36
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/SpecularTest.ShaderGraph
  10. 2
      MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/SpecularTest.ShaderGraph.meta
  11. 235
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/lightweightSubshaderPBR.template
  12. 35
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/AbstractLightweightPBRMasterNode.cs
  13. 4
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-Legacy.mat
  14. 17
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRMetallic.mat
  15. 7
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRSpecular.mat
  16. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBRMetallic.mat
  17. 93
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/ShaderTest.unity
  18. 105
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBRSpecular.mat
  19. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBRSpecular.mat.meta
  20. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBRMetallic.mat.meta
  21. 0
      /MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-PBRMetallic.mat

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


#endif
}
void Vertex(inout VertexInput v);
LightweightVertexOutput LightweightVertex(LightweightVertexInput v)
VertOutput Vertex(VertInput v)
LightweightVertexOutput o = (LightweightVertexOutput)0;
VertOutput o = (VertOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);

o.meshUV0.xy = TRANSFORM_TEX(v.texcoord0, _MainTex);
o.meshUV0.xy = v.texcoord0.xy;// TRANSFORM_TEX(v.texcoord0, _MainTex);
o.tangent = normalize(UnityObjectToWorldDir(v.tangent));
o.binormal = cross(o.normal, o.tangent) * v.tangent.w;
//End VertexShaderBody
#ifdef VERTEX_CUSTOM
VERTEX_CUSTOM;
#endif
o.hpos = UnityObjectToClipPos(v.vertex);
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;

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


return s;
}
void DefineSurface(LightweightVertexOutput i, inout SurfaceFastBlinn o);
void DefineSurface(VertOutput i, inout SurfaceFastBlinn o);
half4 LightweightFragmentFastBlinn(LightweightVertexOutput i) : SV_Target
half4 LightweightFragmentFastBlinn(VertOutput i) : SV_Target
{
SurfaceFastBlinn o = InitializeSurfaceFastBlinn();
DefineSurface(i, o);

16
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/CGIncludes/LightweightInput.cginc


//#define LIGHTWEIGHT_LINEAR_TO_GAMMA(linColor) sqrt(color)
#define LIGHTWEIGHT_GAMMA_TO_LINEAR(sRGB) sRGB * (sRGB * (sRGB * 0.305306011h + 0.682171111h) + 0.012522878h)
#define LIGHTWEIGHT_LINEAR_TO_GAMMA(linRGB) max(1.055h * pow(max(linRGB, 0.h), 0.416666667h) - 0.055h, 0.h)
#define LIGHTWEIGHT_GAMMA_TO_LINEAR4(sRGBA) float4(sRGBA.rgb * (sRGBA.rgb * (sRGBA.rgb * 0.305306011h + 0.682171111h) + 0.012522878h), sRGBA.a)
#define LIGHTWEIGHT_LINEAR_TO_GAMMA4(linRGBA) float4(max(1.055h * pow(max(linRGBA.rgb, 0.h), 0.416666667h) - 0.055h, 0.h), linRGBA.a)
#define LIGHTWEIGHT_GAMMA_TO_LINEAR4(color) color
#define LIGHTWEIGHT_LINEAR_TO_GAMMA4(color) color
#endif

samplerCUBE _Cube;
half4 _ReflectColor;
struct LightweightVertexInput
struct VertInput
{
float4 vertex : POSITION;
float3 normal : NORMAL;

#ifdef VERTINPUT_CUSTOM
VERTINPUT_CUSTOM;
#endif
struct LightweightVertexOutput
struct VertOutput
{
float4 posWS : TEXCOORD0;
float4 viewDir : TEXCOORD1; // xyz: viewDir

half3 tangent : TEXCOORD5;
half3 binormal : TEXCOORD6;
#ifdef VERTOUTPUT_CUSTOM
VERTOUTPUT_CUSTOM
#endif
float4 hpos : SV_POSITION;
UNITY_VERTEX_OUTPUT_STEREO
};

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


return s;
}
void DefineSurface(LightweightVertexOutput i, inout SurfacePBR s);
void DefineSurface(VertOutput i, inout SurfacePBR o);
half3 MetallicSetup(float2 uv, SurfacePBR s, out half3 specular, out half smoothness, out half oneMinusReflectivity)
{

{
half4 specGloss = float4(s.Specular, s.Smoothness);
#if defined(UNITY_COLORSPACE_GAMMA) && defined(LIGHTWEIGHT_LINEAR)
/*#if defined(UNITY_COLORSPACE_GAMMA) && defined(LIGHTWEIGHT_LINEAR)
#endif
#endif*/
specular = specGloss.rgb;
smoothness = specGloss.a;

half4 LightweightFragmentPBR(LightweightVertexOutput i) : SV_Target
half4 LightweightFragmentPBR(VertOutput i) : SV_Target
{
SurfacePBR o = InitializeSurfacePBR();
DefineSurface(i, o);

13
MaterialGraphProject/Assets/SRP/ScriptableRenderPipeline/LightweightPipeline/Shaders/LightweightFastBlinn.shader


#pragma multi_compile_instancing
#include "UnityCG.cginc"
#define VERTEX_CUSTOM \
o.tangent = normalize(UnityObjectToWorldDir(v.tangent)); \
o.binormal = cross(o.normal, o.tangent) * v.tangent.w;
#define VERTOUTPUT_CUSTOM \
half3 tangent : TEXCOORD5; \
half3 binormal : TEXCOORD6;
#pragma vertex LightweightVertex
#pragma vertex Vertex
void DefineSurface(LightweightVertexOutput i, inout SurfaceFastBlinn s)
void DefineSurface(VertOutput i, inout SurfaceFastBlinn s)
{
// Albedo
float4 c = tex2D(_MainTex, i.meshUV0.xy);

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


#pragma multi_compile_instancing
#include "UnityCG.cginc"
#define VERTEX_CUSTOM \
o.tangent = normalize(UnityObjectToWorldDir(v.tangent)); \
o.binormal = cross(o.normal, o.tangent) * v.tangent.w;
#define VERTOUTPUT_CUSTOM \
half3 tangent : TEXCOORD5; \
half3 binormal : TEXCOORD6;
#pragma vertex LightweightVertex
#pragma vertex Vertex
void DefineSurface(LightweightVertexOutput i, inout SurfacePBR s)
void DefineSurface(VertOutput i, inout SurfacePBR s)
float4 metallicMap = tex2D(_MetallicSpecGlossMap, i.uv01.xy).r;
float4 metallicMap = tex2D(_MetallicSpecGlossMap, i.meshUV0.xy);
s.Metallic = metallicMap.r;
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
s.Smoothness = c.a;

s.Smoothness *= _GlossMapScale;
s.Specular = _SpecColor.rgb;
#ifdef _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A
s.Smoothness = c.a * _GlossMapScale;
#else

// Normal
#if _NORMALMAP
s.Normal = UnpackNormal(tex2D(_BumpMap, i.meshUV0.xy));

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

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


fileFormatVersion: 2
guid: 02a3ca69ec995e94aa47105621a17e4c
timeCreated: 1505507124
timeCreated: 1505516015
licenseType: Pro
ShaderImporter:
externalObjects: {}

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

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


fileFormatVersion: 2
guid: a96bafc6e4c6e7c4ca1fb43c905d7948
timeCreated: 1505507152
timeCreated: 1505517630
licenseType: Pro
ShaderImporter:
externalObjects: {}

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


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_fog
#pragma multi_compile_instancing
#pragma vertex LightweightVertexCustom
#pragma vertex Vertex
${ShaderPropertyUsages}
${ShaderFunctions}
struct vInput
{
${VertexInputs}
UNITY_VERTEX_INPUT_INSTANCE_ID
};
struct vOutput
{
${VertexOutputs}
UNITY_VERTEX_OUTPUT_STEREO
};
vOutput LightweightVertexCustom(vInput v)
{
vOutput o = (vOutput)0;
UNITY_SETUP_INSTANCE_ID(v);
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
o.normal = normalize(UnityObjectToWorldNormal(v.normal));
o.meshUV0.xy = v.texcoord0.xy;//TRANSFORM_TEX(v.texcoord0, _MainTex);
#ifdef LIGHTMAP_ON
o.meshUV0.zw = v.lightmapUV * unity_LightmapST.xy + unity_LightmapST.zw;
#endif
${VertexShaderBody}
o.hpos = UnityObjectToClipPos(v.vertex);
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz;
o.posWS.xyz = worldPos;
o.viewDir.xyz = normalize(_WorldSpaceCameraPos - worldPos);
// 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, o.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(o.normal, 1)));
#endif
UNITY_TRANSFER_FOG(o, o.hpos);
return o;
}
#include "UnityCG.cginc"
#include "UnityStandardInput.cginc"
#include "CGIncludes/LightweightShadows.cginc"
#include "CGIncludes/LightweightBRDF.cginc"
#include "CGIncludes/LightweightCore.cginc"
//#define UNITY_SAMPLE_TEX2D(tex, coord) LIGHTWEIGHT_GAMMA_TO_LINEAR4(tex.Sample (sampler##tex,coord))
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
};
#define VERTEX_CUSTOM \
${VertexShaderBody}
//#define VERTINPUT_CUSTOM \
//${VertexInputs}
#define VERTOUTPUT_CUSTOM \
${VertexOutputs}
#include "CGIncludes/LightweightPBR.cginc"
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;
}
${ShaderPropertyUsages}
${ShaderFunctions}
void DefineSurface(vOutput i, inout SurfacePBR o)
void DefineSurface(VertOutput i, inout SurfacePBR o)
}
half3 MetallicSetup(SurfacePBR o, out half3 specular, out half smoothness, out half oneMinusReflectivity)
{
smoothness = o.Smoothness;
// 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);
o.Albedo = LIGHTWEIGHT_GAMMA_TO_LINEAR(o.Albedo);
// TODO - Handle lightmaps
// 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;
half3 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.
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;
#ifdef _SHADOWS
#if _NORMALMAP
half3 vertexNormal = half3(tangentToWorld0.z, tangentToWorld1.z, tangentToWorld2.z); // Fix this
#else
half3 vertexNormal = normal;
#endif
#endif
#ifndef _MULTIPLE_LIGHTS
LightInput light;
INITIALIZE_MAIN_LIGHT(light);
half lightAtten = ComputeLightAttenuation(light, normal, i.posWS.xyz, lightDirection);
#ifdef _SHADOWS
lightAtten *= ComputeShadowAttenuation(vertexNormal, 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(vertexNormal, 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

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


int vertOutputIndex = 5;
// always add everything because why not.
shaderInputVisitor.AddShaderChunk("float4 vertex : POSITION;", true);
shaderInputVisitor.AddShaderChunk("half3 normal : NORMAL;", true);
shaderInputVisitor.AddShaderChunk("half4 tangent : TANGENT;", true);
shaderInputVisitor.AddShaderChunk("half4 color : COLOR;", true);
shaderInputVisitor.AddShaderChunk("half4 texcoord0 : TEXCOORD0;", true);
shaderInputVisitor.AddShaderChunk("float2 lightmapUV : TEXCOORD1;", true);
/*shaderInputVisitor.AddShaderChunk("float4 vertex : POSITION; \\", true);
shaderInputVisitor.AddShaderChunk("half3 normal : NORMAL; \\", true);
shaderInputVisitor.AddShaderChunk("half4 tangent : TANGENT; \\", true);
shaderInputVisitor.AddShaderChunk("half4 color : COLOR; \\", true);
shaderInputVisitor.AddShaderChunk("half4 texcoord0 : TEXCOORD0; \\", true);
shaderInputVisitor.AddShaderChunk("float2 lightmapUV : TEXCOORD1;", true);*/
shaderInputVisitor.AddShaderChunk("half4 texcoord1 : TEXCOORD1;", 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("half4 meshUV0 : TEXCOORD4;", true);
shaderOutputVisitor.AddShaderChunk("float4 hpos : SV_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("half4 meshUV0 : TEXCOORD4; \\", true);
shaderOutputVisitor.AddShaderChunk("float4 hpos : SV_POSITION; \\", true);*/
bool requiresBitangent = activeNodeList.OfType<IMayRequireBitangent>().Any(x => x.RequiresBitangent());
bool requiresTangent = activeNodeList.OfType<IMayRequireTangent>().Any(x => x.RequiresTangent());
bool requiresViewDirTangentSpace = activeNodeList.OfType<IMayRequireViewDirectionTangentSpace>().Any(x => x.RequiresViewDirectionTangentSpace());

if (requiresBitangent || requiresTangent || requiresViewDirTangentSpace)
{
shaderOutputVisitor.AddShaderChunk(string.Format("half3 tangent : TEXCOORD{0};", vertOutputIndex), true);
vertexShaderBlock.AddShaderChunk("o.tangent = normalize(UnityObjectToWorldDir(v.tangent));", 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);
vertOutputIndex++;
}

continue;
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
if (slot.id == AlbedoSlotId)
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " += 1e-6;", true);
if (slot.id == NormalSlotId)
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " += 1e-6;", true);

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


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

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

17
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRMetallic.mat


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_Texture: {fileID: 2800000, guid: e017404169662f041a969b0a924cc2ed, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_9508545D_Uniform:

- Texture2D_Texture2D_AEB21289_Uniform:
m_Texture: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_C4394658_Uniform:
m_Texture: {fileID: 2800000, guid: 79b61ba99411748ae8fa11666dceaee5, type: 3}
m_Texture: {fileID: 2800000, guid: 1085d6f82e40b31428079b25ebee7d74, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:

m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
m_Floats:
- Vector1_Vector1_20D3DC06_Uniform: 1
- Vector1_Vector1_20D3DC06_Uniform: 0
- Vector1_Vector1_5370E8F3_Uniform: 1
- Vector1_Vector1_5370E8F3_Uniform: 0
- Vector1_Vector1_6E27ABB0_Uniform: 1
- Vector1_Vector1_7EC3DCBC_Uniform: 0.5
- Vector1_Vector1_7EC3DCBC_Uniform: 1
- _BumpScale: 1
- _Cutoff: 0.5
- _DetailNormalMapScale: 1

7
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/TestGraph-PBRSpecular.mat


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_Texture: {fileID: 2800000, guid: e017404169662f041a969b0a924cc2ed, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture2D_Texture2D_9508545D_Uniform:

- Texture2D_Texture2D_AEB21289_Uniform:
m_Texture: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a, type: 3}
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 1085d6f82e40b31428079b25ebee7d74, type: 3}
m_Texture: {fileID: 0}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _BumpMap:

- 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}
- Color_Color_DF8C830F_Uniform: {r: 0.5019608, g: 0.5019608, b: 0.5019608, a: 0}
- 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}

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


m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: Test-PBR
m_Name: Test-PBRMetallic
m_ShaderKeywords: _GLOSSYREFLECTIONS_ON _METALLIC_SETUP _SPECULARHIGHLIGHTS_ON
m_ShaderKeywords: _GLOSSYREFLECTIONS_ON _METALLIC_SETUP _NORMALMAP _SPECULARHIGHLIGHTS_ON
m_LightmapFlags: 4
m_EnableInstancingVariants: 0
m_DoubleSidedGI: 0

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

- _DetailNormalMapScale: 1
- _DstBlend: 0
- _GlossMapScale: 0
- _Glossiness: 0.5
- _Glossiness: 1
- _Metallic: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 1
- _Parallax: 0.02

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


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

- component: {fileID: 38610491}
- component: {fileID: 38610490}
m_Layer: 0
m_Name: PBRMetallic (1)
m_Name: PBRSpecular
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1045077821}
m_RootOrder: 1
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1045077820
GameObject:

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1225949933}
- {fileID: 1117495945}
--- !u!1 &1117495944
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 5
m_Component:
- component: {fileID: 1117495945}
- component: {fileID: 1117495948}
- component: {fileID: 1117495947}
- component: {fileID: 1117495946}
m_Layer: 0
m_Name: PBRSpecular
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1117495945
Transform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1117495944}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.099, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1045077821}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!23 &1117495946
MeshRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1117495944}
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: 74be5c6f41091b447bed7d64251620ee, 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 &1117495947
SphereCollider:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1117495944}
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 &1117495948
MeshFilter:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1117495944}
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
--- !u!1 &1220808771
GameObject:
m_ObjectHideFlags: 0

m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1045077821}
m_RootOrder: 2
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &1225949929
GameObject:

105
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/LightweightPipeline/Materials/Test-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: Test-PBRSpecular
m_Shader: {fileID: 4800000, guid: 933532a4fcc9baf4fa0491de14d08ed7, type: 3}
m_ShaderKeywords: _GLOSSYREFLECTIONS_ON _NORMALMAP _SPECULARHIGHLIGHTS_ON _SPECULAR_SETUP
m_LightmapFlags: 4
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: 2800000, guid: e017404169662f041a969b0a924cc2ed, type: 3}
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: 2800000, guid: 330f42016073a97418a4aae5517e32c8, type: 3}
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: 2800000, guid: 70218f73fcdf828428151dfdd3104a8f, type: 3}
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: 0.435
- _Glossiness: 0.498
- _GlossinessSource: 0
- _GlossyReflections: 1
- _Metallic: 0
- _Mode: 0
- _OcclusionStrength: 0
- _Parallax: 0.02
- _ReflectionSource: 0
- _Shininess: 1
- _SmoothnessTextureChannel: 0
- _SpecSource: 0
- _SpecularHighlights: 1
- _SrcBlend: 1
- _UVSec: 0
- _WorkflowMode: 0
- _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: 0.5019608, g: 0.5019608, b: 0.5019608, a: 0}

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


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

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

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

正在加载...
取消
保存