浏览代码

Merge branch 'hackweek2017' of https://github.com/stramit/MaterialGraph into hackweek2017

/main
Jennifer Nordwall 8 年前
当前提交
c51c8ff3
共有 19 个文件被更改,包括 492 次插入46 次删除
  1. 2
      MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
  2. 2
      MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs
  3. 2
      MaterialGraphProject/Assets/Eduardo/HeightToNormalNode.cs
  4. 98
      MaterialGraphProject/Assets/Matt/AbstractAdvancedMasterNode.cs
  5. 2
      MaterialGraphProject/Assets/Matt/AnisotropicMaster.ShaderGraph
  6. 12
      MaterialGraphProject/Assets/Matt/AnisotropicMetallicMasterNode.cs
  7. 2
      MaterialGraphProject/Assets/Matt/New Material.mat
  8. 10
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/advancedSubshader.template
  9. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/shader.template
  10. 12
      MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs
  11. 15
      MaterialGraphProject/Assets/Vlad/UVTriPlanar.cs
  12. 46
      MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs
  13. 12
      MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs.meta
  14. 1
      MaterialGraphProject/Assets/Matt/SubsurfaceMaster.ShaderGraph
  15. 9
      MaterialGraphProject/Assets/Matt/SubsurfaceMaster.ShaderGraph.meta
  16. 86
      MaterialGraphProject/Assets/Matt/SubsurfaceMetallicMasterNode.cs
  17. 12
      MaterialGraphProject/Assets/Matt/SubsurfaceMetallicMasterNode.cs.meta
  18. 202
      MaterialGraphProject/Assets/NewNodes/WIP/MultiLayerParallaxNode.cs
  19. 12
      MaterialGraphProject/Assets/NewNodes/WIP/MultiLayerParallaxNode.cs.meta

2
MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
文件差异内容过多而无法显示
查看文件

2
MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs


private string GetOutputDeclaration()
{
string outDeclaration = "";
foreach (ISlot outSlot in GetOutputSlots<ISlot>())
foreach (MaterialSlot outSlot in GetOutputSlots<MaterialSlot>())
{
outDeclaration += "\n " + precision + GetSlotTypeName(outSlot.id) + " " + GetVariableNameForSlot(outSlot.id) + ";\n";
}

2
MaterialGraphProject/Assets/Eduardo/HeightToNormalNode.cs


namespace UnityEngine.MaterialGraph
{
[Title("HeightToNormal")]
[Title("Utility/Heightmap To Normalmap")]
public class HeightToNormalNode : FunctionNInNOut, IGeneratesFunction
{

98
MaterialGraphProject/Assets/Matt/AbstractAdvancedMasterNode.cs


public abstract string GetSurfaceOutputName();
public abstract string GetLightFunction();
public abstract string GetMaterialID();
public abstract int[] GetCustomDataSlots();
public abstract string[] GetCustomData();
public override string GetSubShader(GenerationMode mode, PropertyGenerator shaderPropertiesVisitor)
{

(node as IGeneratesBodyCode).GenerateNodeCode(shaderBody, generationMode);
}
ListPool<INode>.Release(nodes);
foreach (var slot in GetInputSlots<MaterialSlot>())
{
if (!CheckForCustomData(slot.id)) // Check to ignore writing surface data for items getting packed into custom data
{
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;
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
if (slot.id == NormalSlotId)
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " += 1e-6;", true);
}
// Write tangent data to WorldVectors input on SurfaceOutput
if (slot.id == TangentSlotId)
{
var edges = owner.GetEdges(slot.slotReference);
if (edges.Any())
{
shaderBody.AddShaderChunk("float3x3 worldToTangent;", false);
shaderBody.AddShaderChunk("worldToTangent[0] = float3(1, 0, 0);", false);
shaderBody.AddShaderChunk("worldToTangent[1] = float3(0, 1, 0);", false);
shaderBody.AddShaderChunk("worldToTangent[2] = float3(0, 0, 1);", false);
shaderBody.AddShaderChunk("float3 tangentTWS = mul(o." + slot.shaderOutputName + ", worldToTangent);", false);
shaderBody.AddShaderChunk("o.WorldVectors = float3x3(tangentTWS, " + ShaderGeneratorNames.WorldSpaceBitangent + ", " + ShaderGeneratorNames.WorldSpaceNormal + ");", false);
}
else
{
shaderBody.AddShaderChunk("o.WorldVectors = float3x3(" + ShaderGeneratorNames.WorldSpaceTangent + ", " + ShaderGeneratorNames.WorldSpaceBitangent + ", " + ShaderGeneratorNames.WorldSpaceNormal + ");", false);
}
}
}
}
string[] customData = GetCustomData();
foreach(string data in customData)
{
shaderBody.AddShaderChunk(data, false);
}
}
public MaterialSlot GetMaterialSlot(int id)
{
if (slot.id == id)
return slot;
}
return null;
}
public string GetVariableNameForSlotAtId(int id)
{
MaterialSlot slot = GetMaterialSlot(id);
if (slot != null)
{
foreach (var edge in owner.GetEdges(slot.slotReference))
{
var outputRef = edge.outputSlot;

if (remapper != null && !remapper.IsValidSlotConnection(outputRef.slotId))
continue;
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
if (slot.id == NormalSlotId)
shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " += 1e-6;", true);
return fromNode.GetVariableNameForSlot(outputRef.slotId);
//shaderBody.AddShaderChunk("o." + slot.shaderOutputName + " = " + fromNode.GetVariableNameForSlot(outputRef.slotId) + ";", true);
}
return "";
}
// Write tangent data to WorldVectors input on SurfaceOutput
if (slot.id == TangentSlotId)
{
var edges = owner.GetEdges(slot.slotReference);
if (edges.Any())
{
shaderBody.AddShaderChunk("float3x3 worldToTangent;", false);
shaderBody.AddShaderChunk("worldToTangent[0] = float3(1, 0, 0);", false);
shaderBody.AddShaderChunk("worldToTangent[1] = float3(0, 1, 0);", false);
shaderBody.AddShaderChunk("worldToTangent[2] = float3(0, 0, 1);", false);
shaderBody.AddShaderChunk("float3 tangentTWS = mul(o." + slot.shaderOutputName + ", worldToTangent);", false);
shaderBody.AddShaderChunk("o.WorldVectors = float3x3(tangentTWS, "+ ShaderGeneratorNames.WorldSpaceBitangent + ", "+ ShaderGeneratorNames.WorldSpaceNormal+ ");", false);
}
else
{
shaderBody.AddShaderChunk("o.WorldVectors = float3x3(" + ShaderGeneratorNames.WorldSpaceTangent + ", " + ShaderGeneratorNames.WorldSpaceBitangent + ", " + ShaderGeneratorNames.WorldSpaceNormal + ");", false);
}
}
bool CheckForCustomData(int id)
{
foreach (var custom in GetCustomDataSlots())
{
if (custom == id)
return true;
return false;
}
}
}

2
MaterialGraphProject/Assets/Matt/AnisotropicMaster.ShaderGraph
文件差异内容过多而无法显示
查看文件

12
MaterialGraphProject/Assets/Matt/AnisotropicMetallicMasterNode.cs


public AnisotropicMetallicMasterNode()
{
name = "AnisotropicMetallicMasterNode";
name = "AnisotropicMetallicMaster";
UpdateNodeAfterDeserialization();
}

}
public override int[] GetCustomDataSlots()
{
return new int[] { };
}
public override string[] GetCustomData()
{
return new string[] { };
}
public sealed override void UpdateNodeAfterDeserialization()

2
MaterialGraphProject/Assets/Matt/New Material.mat


m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: New Material
m_Shader: {fileID: 4800000, guid: 9ab5e16c2083a4fe689209a8c1ae425e, type: 3}
m_Shader: {fileID: 4800000, guid: 4afc3341bed83d34cb1aebb7e98d8751, type: 3}
m_ShaderKeywords:
m_LightmapFlags: 4
m_EnableInstancingVariants: 0

10
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/advancedSubshader.template


float3 SubsurfaceShadingSimple(float3 diffColor, float3 normal, float3 viewDir, float3 thickness, UnityLight light)
{
half3 vLTLight = light.dir + normal * _TDistortion;
half fLTDot = pow(saturate(dot(viewDir, -vLTLight)), _TPower) * _TScale;
half3 fLT = _TAttenuation * (fLTDot + _TAmbient) * (thickness);
return diffColor * ((light.color * fLT) * _TransmissionOverallStrength);
half3 vLTLight = light.dir + normal * 1;
half fLTDot = pow(saturate(dot(viewDir, -vLTLight)), 3.5) * 1.5;
half3 fLT = 1 * (fLTDot + 1.2) * (thickness);
return diffColor * ((light.color * fLT) * 0.4);
}
// ------------------------------------------------------------------

///END
#pragma target 5.0
//#pragma target 5.0
#pragma surface surf ${LightingFunctionName} ${VertexShaderDecl}
#pragma glsl
#pragma debug

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/shader.template


${SubShader}
FallBack "Diffuse"
CustomEditor "LegacyIlluminShaderGUI"
}

12
MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs


get { return new[] { OutputSlotRgbaId }; }
}
public override string GetVariableNameForSlot(int slotId)
{
string slotOutput;
switch (slotId)
{
default:
slotOutput = "";
break;
}
return GetVariableNameForNode() + slotOutput;
}
public override void CollectPreviewMaterialProperties(List<PreviewProperty> properties)
{
properties.Add(GetPreviewProperty());

15
MaterialGraphProject/Assets/Vlad/UVTriPlanar.cs


UpdateNodeAfterDeserialization();
}
protected override string GetFunctionPrototype(string argName)
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get
{
return PreviewMode.Preview3D;
}
}
protected override string GetFunctionPrototype(string argName)
{
return "inline " + precision + outputDimension + " " + GetFunctionName() + " ("
+ "sampler2D " + argName + ", float3 normal, float3 pos)";

46
MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs


using UnityEngine.Graphing;
using System.Linq;
using System.Collections;
namespace UnityEngine.MaterialGraph
{
[Title("ChannelBlend")]
public class ChannelBlend : FunctionNInNOut, IGeneratesFunction
{
public ChannelBlend()
{
name = "ChannelBlend";
AddSlot("Mask", "mask", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("RColor", "rCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("GColor", "gCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BColor", "bCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("AColor", "aCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BGColor", "bgCol", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.zero);
AddSlot("BlendedColor", "blendCol", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero);
}
protected override string GetFunctionName()
{
return "unity_ChannelBlend";
}
public override bool hasPreview
{
get { return true; }
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype(), false);
outputString.AddShaderChunk("{", false);
outputString.AddShaderChunk("float4 background = step(max(mask.r,max(mask.g,mask.b)), 0.001) * bgCol;", false);
outputString.AddShaderChunk("blendCol = mask.r * rCol + mask.g * gCol + mask.b * bCol + mask.a * aCol + background;", false);
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
}
}

12
MaterialGraphProject/Assets/Eduardo/ChannelBlendNode.cs.meta


fileFormatVersion: 2
guid: a3ee559026fa1ca4aab68fafbdcfbc56
timeCreated: 1495618140
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

1
MaterialGraphProject/Assets/Matt/SubsurfaceMaster.ShaderGraph
文件差异内容过多而无法显示
查看文件

9
MaterialGraphProject/Assets/Matt/SubsurfaceMaster.ShaderGraph.meta


fileFormatVersion: 2
guid: 25497a67e7ee41d4c8f2039c1df994a1
timeCreated: 1495614205
licenseType: Pro
ScriptedImporter:
userData:
assetBundleName:
assetBundleVariant:
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3}

86
MaterialGraphProject/Assets/Matt/SubsurfaceMetallicMasterNode.cs


using System;
using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Serializable]
[Title("Master/SubsurfaceMetallic")]
public class SubsurfaceMetallicMasterNode : AbstractAdvancedMasterNode
{
public const string MetallicSlotName = "Metallic";
public const int MetallicSlotId = 2;
public const string TranslucencySlotName = "Translucency";
public const int TranslucencySlotId = 9;
public const string LightFunctionName = "Advanced";
public const string SurfaceOutputStructureName = "SurfaceOutputAdvanced";
public SubsurfaceMetallicMasterNode()
{
name = "SubsurfaceMetallic";
UpdateNodeAfterDeserialization();
}
public override string GetMaterialID()
{
return "SHADINGMODELID_SUBSURFACE";
}
public override int[] GetCustomDataSlots()
{
return new int[] { 9 };
}
public override string[] GetCustomData()
{
string translucencyInput = GetVariableNameForSlotAtId(9);
if (translucencyInput == "")
translucencyInput = "float3(0,0,0)";
else
translucencyInput = translucencyInput + ".rgb";
return new string[] { "o.CustomData = float4(" + translucencyInput + ", 0);" };
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(new MaterialSlot(AlbedoSlotId, AlbedoSlotName, AlbedoSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(NormalSlotId, NormalSlotName, NormalSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(EmissionSlotId, EmissionSlotName, EmissionSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(MetallicSlotId, MetallicSlotName, MetallicSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(SmoothnessSlotId, SmoothnessSlotName, SmoothnessSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(OcclusionSlotId, OcclusionSlotName, OcclusionSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(AnisotropySlotId, AnisotropySlotName, AnisotropySlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(TangentSlotId, TangentSlotName, TangentSlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
AddSlot(new MaterialSlot(AnisotropySlotId, AnisotropySlotName, AnisotropySlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero));
AddSlot(new MaterialSlot(TranslucencySlotId, TranslucencySlotName, TranslucencySlotName, SlotType.Input, SlotValueType.Vector3, Vector4.zero));
// clear out slot names that do not match the slots
// we support
RemoveSlotsNameNotMatching(
new[]
{
AlbedoSlotId,
NormalSlotId,
EmissionSlotId,
MetallicSlotId,
SmoothnessSlotId,
OcclusionSlotId,
AlphaSlotId,
AnisotropySlotId,
TangentSlotId,
TranslucencySlotId
});
}
public override string GetSurfaceOutputName()
{
return SurfaceOutputStructureName;
}
public override string GetLightFunction()
{
return LightFunctionName;
}
}
}

12
MaterialGraphProject/Assets/Matt/SubsurfaceMetallicMasterNode.cs.meta


fileFormatVersion: 2
guid: 7c541e9dc2ccc50469af225259c7cb17
timeCreated: 1478188276
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

202
MaterialGraphProject/Assets/NewNodes/WIP/MultiLayerParallaxNode.cs


using UnityEngine.Graphing;
namespace UnityEngine.MaterialGraph
{
[Title("UV/MultiLayerParallax")]
public class MultiLayerParallaxNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction, IMayRequireMeshUV, IMayRequireViewDirectionTangentSpace
{
protected const string kInputDepthShaderName = "Depth";
protected const string kInputFadeRateShaderName = "FadeRate";
protected const string kInputLayerCountShaderName = "LayerCount";
protected const string kTextureSlotShaderName = "Texture";
protected const string kOutputSlotShaderName = "Result";
public const int InputDepthSlotId = 0; // 'depth'
public const int InputFadeRateSlotId = 1; // 'fade_rate'
public const int InputLayerCountSlotId = 2; // 'layer_count'
public const int TextureSlotId = 3; // 'tex'
public const int OutputSlotId = 4; // 'result'
public override bool hasPreview
{
get { return true; }
}
public override PreviewMode previewMode
{
get
{
return PreviewMode.Preview3D;
}
}
public MultiLayerParallaxNode()
{
name = "MultiLayerParallax";
UpdateNodeAfterDeserialization();
}
public string GetFunctionName()
{
return "unity_multilayer_parallax_" + precision;
}
public sealed override void UpdateNodeAfterDeserialization()
{
AddSlot(GetInputDepthSlot());
AddSlot(GetInputFadeRateSlot());
AddSlot(GetInputLayerCountSlot());
AddSlot(GetTextureSlot());
AddSlot(GetOutputSlot());
RemoveSlotsNameNotMatching(validSlots);
}
protected int[] validSlots
{
get { return new[] { InputDepthSlotId, InputFadeRateSlotId, InputLayerCountSlotId, TextureSlotId, OutputSlotId }; }
}
protected virtual MaterialSlot GetInputDepthSlot()
{
return new MaterialSlot(InputDepthSlotId, GetInputSlot1Name(), kInputDepthShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero);
}
protected virtual MaterialSlot GetInputFadeRateSlot()
{
return new MaterialSlot(InputFadeRateSlotId, GetInputSlot2Name(), kInputFadeRateShaderName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
}
protected virtual MaterialSlot GetInputLayerCountSlot()
{
return new MaterialSlot(InputLayerCountSlotId, GetInputSlot3Name(), kInputLayerCountShaderName, SlotType.Input, SlotValueType.Dynamic, Vector4.zero);
}
protected virtual MaterialSlot GetTextureSlot()
{
return new MaterialSlot(TextureSlotId, GetTextureSlotName(), kTextureSlotShaderName, SlotType.Input, SlotValueType.sampler2D, Vector4.zero);
}
protected virtual MaterialSlot GetOutputSlot()
{
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Dynamic, Vector4.zero);
}
protected virtual string GetInputSlot1Name()
{
return kInputDepthShaderName;
}
protected virtual string GetInputSlot2Name()
{
return kInputFadeRateShaderName;
}
protected virtual string GetInputSlot3Name()
{
return kInputLayerCountShaderName;
}
protected virtual string GetTextureSlotName()
{
return kTextureSlotShaderName;
}
protected virtual string GetOutputSlotName()
{
return kOutputSlotShaderName;
}
private string input1Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputDepthSlotId).concreteValueType); }
}
private string input2Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputFadeRateSlotId).concreteValueType); }
}
private string input3Dimension
{
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputLayerCountSlotId).concreteValueType); }
}
public string outputDimension
{
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); }
}
protected virtual string GetFunctionPrototype(string depth, string fadeRate, string layerCount, string tex, string UVs, string viewTangentSpace)
{
return "inline " + precision + outputDimension + " " + GetFunctionName() + " (" +
precision + input1Dimension + " " + depth + ", " +
precision + input2Dimension + " " + fadeRate + ", " +
precision + input3Dimension + " " + layerCount + ", " +
"sampler2D " + tex + ", " +
precision + "2 " + UVs + ", " +
precision + "3 " + viewTangentSpace + ")";
}
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode)
{
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputDepthSlotId, InputFadeRateSlotId, InputLayerCountSlotId, TextureSlotId }, new[] { OutputSlotId });
string depthValue = GetSlotValue(InputDepthSlotId, generationMode);
string fadeRateValue = GetSlotValue(InputFadeRateSlotId, generationMode);
string layerCountValue = GetSlotValue(InputLayerCountSlotId, generationMode);
string textureValue = GetSlotValue(TextureSlotId, generationMode);
visitor.AddShaderChunk(
precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) +
" = " + GetFunctionCallBody(depthValue, fadeRateValue, layerCountValue, textureValue) + ";", true);
}
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode)
{
var outputString = new ShaderGenerator();
outputString.AddShaderChunk(GetFunctionPrototype("depth", "fadeRate", "layerCount", "tex", "UVs", "viewTangentSpace"), false);
outputString.AddShaderChunk("{", false);
outputString.Indent();
outputString.AddShaderChunk(precision + "2 texcoord = UVs;", false);
outputString.AddShaderChunk(precision + "2 offset = -viewTangentSpace.xy * depth / layerCount;", false);
outputString.AddShaderChunk(precision + outputDimension + " result = 0.0f;", false);
outputString.AddShaderChunk(precision + outputDimension + " fade = 1.0f;", false);
outputString.AddShaderChunk(precision + " alpha = 0.0f;", false);
outputString.AddShaderChunk("for (int i = 0; i < 10; i++) {", false);
outputString.Indent();
outputString.AddShaderChunk("result += fade * tex2D(tex, texcoord);", false);
outputString.AddShaderChunk("texcoord += offset;", false);
outputString.AddShaderChunk("fade *= fadeRate;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
outputString.AddShaderChunk("return result / layerCount;", false);
outputString.Deindent();
outputString.AddShaderChunk("}", false);
visitor.AddShaderChunk(outputString.GetShaderString(0), true);
}
protected virtual string GetFunctionCallBody(string depthValue, string fadeRateValue, string layerCountValue, string texValue)
{
return GetFunctionName() + " (" +
depthValue + ", " +
fadeRateValue + ", " +
layerCountValue + ", " +
texValue + ", " +
UVChannel.uv0.GetUVName() + ", " +
ShaderGeneratorNames.TangentSpaceViewDirection + ")";
}
public bool RequiresMeshUV(UVChannel channel)
{
return channel == UVChannel.uv0;
}
public bool RequiresViewDirectionTangentSpace()
{
return true;
}
}
}

12
MaterialGraphProject/Assets/NewNodes/WIP/MultiLayerParallaxNode.cs.meta


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