ChrisTchou
8 年前
当前提交
683c517e
共有 886 个文件被更改,包括 4546 次插入 和 387 次删除
-
146MaterialGraphProject/Assets/Andre/Materials/Mat.mat
-
8MaterialGraphProject/Assets/Andre/Nodes/Editor/TransformNodePresenter.cs
-
2MaterialGraphProject/Assets/Andre/Nodes/ToggleNode.cs
-
194MaterialGraphProject/Assets/Andre/Nodes/TransformNode.cs
-
2MaterialGraphProject/Assets/Andre/Shaders/TestingGraph.ShaderGraph
-
1MaterialGraphProject/Assets/Eduardo/ConstantsNode.cs
-
2MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
-
4MaterialGraphProject/Assets/Eduardo/EduardoTestMat.mat
-
54MaterialGraphProject/Assets/Eduardo/FunctionNInNOut.cs
-
26MaterialGraphProject/Assets/Eduardo/HeightToNormalNode.cs
-
127MaterialGraphProject/Assets/GeneratedShader.shader
-
4MaterialGraphProject/Assets/GraphView/Editor.meta
-
2MaterialGraphProject/Assets/Matt/AnisotropicMaster.ShaderGraph
-
2MaterialGraphProject/Assets/Matt/Test.ShaderGraph
-
2MaterialGraphProject/Assets/NewNodes/WIP/MultiLayerParallaxNode.cs
-
5MaterialGraphProject/Assets/TestAssets/Materials/Default.mat
-
2MaterialGraphProject/Assets/TestAssets/Teapot.fbx.meta
-
20MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MaterialGraphPresenter.cs
-
17MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader
-
2MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta
-
3MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/subshader.template
-
29MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/AbstractMaterialNode.cs
-
6MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Function2Input.cs
-
20MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/ScreenPosNode.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Vector/Vector2Node.cs
-
20MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/MaterialSlot.cs
-
7MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Range/RemapNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/CheckerboardNode.cs
-
42MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/VoronoiNoise.cs
-
3MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/PropertyType.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/SlotValue.cs
-
2MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/UVTileNode.cs
-
16MaterialGraphProject/Assets/UnityShaderEditor/Runtime/SurfaceModel/AbstractSurfaceMasterNode.cs
-
35MaterialGraphProject/Assets/Vlad/TextureAssetNode.cs
-
122MaterialGraphProject/Assets/Vlad/UVTriPlanar.cs
-
9MaterialGraphProject/ProjectSettings/ProjectSettings.asset
-
67MaterialGraphProject/ProjectSettings/QualitySettings.asset
-
6MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixMultiplyNode.cs
-
4MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix/MatrixTransposeNode.cs
-
9MaterialGraphProject/Assets/Brandon/Electricity.meta
-
9MaterialGraphProject/Assets/Florent.meta
-
22MaterialGraphProject/Assets/Matt/CommonMatrixType.cs
-
12MaterialGraphProject/Assets/Matt/CommonMatrixType.cs.meta
-
9MaterialGraphProject/Assets/Matt/Examples.meta
-
63MaterialGraphProject/Assets/Matt/UnlitMasterNode.cs
-
12MaterialGraphProject/Assets/Matt/UnlitMasterNode.cs.meta
-
335MaterialGraphProject/Assets/NewNodes/WIP/POMNode.cs
-
12MaterialGraphProject/Assets/NewNodes/WIP/POMNode.cs.meta
-
1MaterialGraphProject/Assets/POM_Graph.ShaderGraph
-
9MaterialGraphProject/Assets/POM_Graph.ShaderGraph.meta
-
9MaterialGraphProject/Assets/Rinaldo/DemoScene.meta
-
1001MaterialGraphProject/Assets/TestAssets/ColorTransparent.tif
-
84MaterialGraphProject/Assets/TestAssets/ColorTransparent.tif.meta
-
21MaterialGraphProject/Assets/TestAssets/TangentMap1.jpg
-
75MaterialGraphProject/Assets/TestAssets/TangentMap1.jpg.meta
-
33MaterialGraphProject/Assets/TestAssets/TangentMap2.jpg
-
75MaterialGraphProject/Assets/TestAssets/TangentMap2.jpg.meta
-
12MaterialGraphProject/Assets/TestAssets/TangentMap3.jpg
-
75MaterialGraphProject/Assets/TestAssets/TangentMap3.jpg.meta
-
151MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ConvolutionFilterNodePresenter.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ConvolutionFilterNodePresenter.cs.meta
-
51MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MatrixCommonNodePresenter.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/MatrixCommonNodePresenter.cs.meta
-
64MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/SamplerStatePresenter.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/SamplerStatePresenter.cs.meta
-
43MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ScatterNodePresenter.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ScatterNodePresenter.cs.meta
-
52MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureSamplerPresenter.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/TextureSamplerPresenter.cs.meta
-
445MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_height.png
-
75MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_height.png.meta
-
137MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_normal.tga
-
75MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_normal.tga.meta
-
1MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/mur_Ambiant.bmp
-
75MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/mur_Ambiant.bmp.meta
-
52MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/tesselationSubshader.template
-
8MaterialGraphProject/Assets/UnityShaderEditor/Editor/Templates/tesselationSubshader.template.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Filters.meta
-
68MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/MatrixCommonNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/Matrix/MatrixCommonNode.cs.meta
-
35MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraDirNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraDirNode.cs.meta
-
36MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraPosNode.cs
-
8MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Input/SceneData/CameraPosNode.cs.meta
-
9MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Math/Matrix.meta
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Procedural/NoiseNode.cs.meta
-
60MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/TwistNode.cs
-
12MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/UV/TwistNode.cs.meta
-
133MaterialGraphProject/Assets/Vlad/SamplerStateNode.cs
-
12MaterialGraphProject/Assets/Vlad/SamplerStateNode.cs.meta
-
246MaterialGraphProject/Assets/Vlad/TextureSamplerNode.cs
-
12MaterialGraphProject/Assets/Vlad/TextureSamplerNode.cs.meta
-
55MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs
-
12MaterialGraphProject/Assets/_MingWai/ColorBalanceNode.cs.meta
|
|||
namespace UnityEngine.MaterialGraph |
|||
using UnityEngine.Graphing; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
public class TransformNode : Function1Input |
|||
public class TransformNode : AbstractMaterialNode, IGeneratesBodyCode, IMayRequireTangent, IMayRequireBitangent, IMayRequireNormal |
|||
[SerializeField] |
|||
private SimpleMatrixType m_spaceListFrom; |
|||
[SerializeField] |
|||
private SimpleMatrixType m_spaceListTo; |
|||
|
|||
private const int InputSlotId = 0; |
|||
private const int OutputSlotId = 1; |
|||
private const string kInputSlotName = "Input"; |
|||
private const string kOutputSlotName = "Output"; |
|||
|
|||
public SimpleMatrixType spaceFrom |
|||
{ |
|||
get { return m_spaceListFrom; } |
|||
set |
|||
{ |
|||
if (m_spaceListFrom == value) |
|||
return; |
|||
|
|||
m_spaceListFrom = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return false; } |
|||
} |
|||
|
|||
public SimpleMatrixType spaceTo |
|||
{ |
|||
get { return m_spaceListTo; } |
|||
set |
|||
{ |
|||
if (m_spaceListTo == value) |
|||
return; |
|||
|
|||
m_spaceListTo = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
UpdateNodeAfterDeserialization (); |
|||
protected override string GetFunctionName () |
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
AddSlot(GetInputSlot()); |
|||
AddSlot(GetOutputSlot()); |
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
//mul(unity_WorldToObject, float4(i.posWorld.rgb,0) ).xyz - world to local
|
|||
//mul( tangentTransform, i.posWorld.rgb ).xyz - world to tangent
|
|||
//mul( UNITY_MATRIX_V, float4(i.posWorld.rgb,0) ).xyz - world to view
|
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] {InputSlotId, OutputSlotId}; } |
|||
} |
|||
//mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to world
|
|||
//mul( tangentTransform, mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to tangent
|
|||
//mul( UNITY_MATRIX_MV, float4(i.posWorld.rgb,0) ).xyz - local to view
|
|||
protected virtual MaterialSlot GetInputSlot() |
|||
{ |
|||
return new MaterialSlot(InputSlotId, GetInputSlotName(), kInputSlotName, SlotType.Input, SlotValueType.Vector3, Vector3.zero); |
|||
} |
|||
//mul( i.posWorld.rgb, tangentTransform ).xyz - tangent to world
|
|||
//mul( unity_WorldToObject, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to local
|
|||
//mul( UNITY_MATRIX_V, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to view
|
|||
protected virtual MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotName, SlotType.Output, SlotValueType.Vector3, Vector4.zero); |
|||
} |
|||
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz - view to world
|
|||
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_MV ).xyz - view to local
|
|||
//mul( tangentTransform, mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz ).xyz - view to tangent
|
|||
protected virtual string GetInputSlotName() |
|||
{ |
|||
return "Input"; |
|||
} |
|||
return "exp"; |
|||
protected virtual string GetOutputSlotName() |
|||
{ |
|||
return "Output"; |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
NodeUtils.SlotConfigurationExceptionIfBadConfiguration(this, new[] { InputSlotId }, new[] { OutputSlotId }); |
|||
string inputValue = GetSlotValue(InputSlotId, generationMode); |
|||
string transformString = ""; |
|||
bool requiresTangentTransform = false; |
|||
|
|||
if(spaceFrom == SimpleMatrixType.World){ |
|||
if (spaceTo == SimpleMatrixType.World) { |
|||
transformString = inputValue; |
|||
} else if (spaceTo == SimpleMatrixType.Local) { |
|||
transformString = "mul(unity_WorldToObject, float4(" + inputValue + ", 0)).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Tangent) { |
|||
requiresTangentTransform = true; |
|||
transformString = "mul(tangentTransform, " + inputValue + ").xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.View) { |
|||
transformString = "mul( UNITY_MATRIX_V, float4(" + inputValue + ", 0)).xyz"; |
|||
} |
|||
}else if(spaceFrom == SimpleMatrixType.Local){ |
|||
if (spaceTo == SimpleMatrixType.World) { |
|||
transformString = "mul(unity_ObjectToWorld, float4(" + inputValue + ", 0)).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Local) { |
|||
transformString = inputValue; |
|||
} else if (spaceTo == SimpleMatrixType.Tangent) { |
|||
requiresTangentTransform = true; |
|||
transformString = "mul( tangentTransform, mul( unity_ObjectToWorld, float4(" + inputValue + ", 0) ).xyz).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.View) { |
|||
transformString = "mul( UNITY_MATRIX_MV, float4(" + inputValue + ", 0)).xyz"; |
|||
} |
|||
}else if(spaceFrom == SimpleMatrixType.Tangent){ |
|||
requiresTangentTransform = true; |
|||
if (spaceTo == SimpleMatrixType.World) { |
|||
transformString = "mul( " + inputValue + ", tangentTransform ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Local) { |
|||
transformString = "mul( unity_WorldToObject, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Tangent) { |
|||
transformString = inputValue; |
|||
} else if (spaceTo == SimpleMatrixType.View) { |
|||
transformString = "mul( UNITY_MATRIX_V, float4(mul(" + inputValue + ", tangentTransform ),0) ).xyz"; |
|||
} |
|||
}else if(spaceFrom == SimpleMatrixType.View){ |
|||
if (spaceTo == SimpleMatrixType.World) { |
|||
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Local) { |
|||
transformString = "mul( float4(" + inputValue + ", 0), UNITY_MATRIX_MV ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.Tangent) { |
|||
requiresTangentTransform = true; |
|||
transformString = "mul( tangentTransform, mul( float4(" + inputValue + ", 0), UNITY_MATRIX_V ).xyz ).xyz"; |
|||
} else if (spaceTo == SimpleMatrixType.View) { |
|||
transformString = inputValue; |
|||
} |
|||
} |
|||
|
|||
if(requiresTangentTransform) |
|||
visitor.AddShaderChunk ("float3x3 tangentTransform = float3x3( worldSpaceTangent, worldSpaceBitangent, worldSpaceNormal);", false); |
|||
|
|||
visitor.AddShaderChunk(precision + outputDimension + " " + GetVariableNameForSlot(OutputSlotId) + " = " + transformString + ";", true); |
|||
} |
|||
|
|||
//float3x3 tangentTransform = float3x3( i.tangentDir, i.bitangentDir, i.normalDir);------
|
|||
|
|||
//mul(unity_WorldToObject, float4(i.posWorld.rgb,0) ).xyz - world to local---------
|
|||
//mul( tangentTransform, i.posWorld.rgb ).xyz - world to tangent-----------------
|
|||
//mul( UNITY_MATRIX_V, float4(i.posWorld.rgb,0) ).xyz - world to view-------------
|
|||
|
|||
//mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to world--------
|
|||
//mul( tangentTransform, mul( unity_ObjectToWorld, float4(i.posWorld.rgb,0) ).xyz - local to tangent------------
|
|||
//mul( UNITY_MATRIX_MV, float4(i.posWorld.rgb,0) ).xyz - local to view--------------
|
|||
|
|||
//mul( i.posWorld.rgb, tangentTransform ).xyz - tangent to world---------
|
|||
//mul( unity_WorldToObject, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to local-----
|
|||
//mul( UNITY_MATRIX_V, float4(mul( i.posWorld.rgb, tangentTransform ),0) ).xyz - tangent to view-------
|
|||
|
|||
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz - view to world
|
|||
//mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_MV ).xyz - view to local
|
|||
//mul( tangentTransform, mul( float4(i.posWorld.rgb,0), UNITY_MATRIX_V ).xyz ).xyz - view to tangent
|
|||
|
|||
|
|||
public string outputDimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindOutputSlot<MaterialSlot>(OutputSlotId).concreteValueType); } |
|||
} |
|||
private string inputDimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(InputSlotId).concreteValueType); } |
|||
} |
|||
|
|||
public bool RequiresTangent() |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
public bool RequiresBitangent() |
|||
{ |
|||
return true; |
|||
} |
|||
|
|||
public bool RequiresNormal(){ |
|||
return true; |
|||
} |
|||
} |
|||
} |
2
MaterialGraphProject/Assets/Andre/Shaders/TestingGraph.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
2
MaterialGraphProject/Assets/Eduardo/EduardoTestGraph.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
Shader "Hidden/PreviewShader/Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output" { |
|||
Properties { |
|||
Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform("", Float) = 0.1 |
|||
Shader "Graph/Generated.MetallicMasterNode554b91b5-7a00-4f5f-b71a-f7729fcbdee8" |
|||
{ |
|||
Properties |
|||
{ |
|||
[NonModifiableTextureData] TextureAsset_8f4a8771_6c8f_4107_9c0b_83da34d57a9b_Uniform("TextureAsset", 2D) = "white" {} |
|||
SubShader { |
|||
// inside SubShader |
|||
SubShader |
|||
{ |
|||
"Queue"="Geometry" |
|||
"IgnoreProjector"="True" |
|||
"Queue"="Geometry" |
|||
// inside Pass |
|||
Blend One Zero |
|||
|
|||
Cull Back |
|||
|
|||
ZTest LEqual |
|||
|
|||
Blend One Zero |
|||
|
|||
Pass { |
|||
CGPROGRAM |
|||
#pragma vertex vert |
|||
#pragma fragment frag |
|||
#include "UnityCG.cginc" |
|||
LOD 200 |
|||
|
|||
CGPROGRAM |
|||
#pragma target 3.0 |
|||
#pragma surface surf Standard vertex:vert |
|||
#pragma glsl |
|||
#pragma debug |
|||
float3 ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25_normalDir; |
|||
float Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform; |
|||
#ifdef UNITY_COMPILER_HLSL |
|||
Texture2D TextureAsset_8f4a8771_6c8f_4107_9c0b_83da34d57a9b_Uniform; |
|||
#endif |
|||
float HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_texOffset; |
|||
float HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_strength; |
|||
#ifdef UNITY_COMPILER_HLSL |
|||
SamplerState my_linear_repeat_sampler; |
|||
#endif |
|||
#ifdef UNITY_COMPILER_HLSL |
|||
#endif |
|||
inline void unity_HeightToNormal (Texture2D heightmap, float2 texCoord, float texOffset, float strength, out float3 normalRes) |
|||
{ |
|||
float2 offsetU = float2(texCoord.x + texOffset, texCoord.y); |
|||
float2 offsetV = float2(texCoord.x, texCoord.y + texOffset); |
|||
float normalSample = 0; |
|||
float uSample = 0; |
|||
float vSample = 0; |
|||
normalSample = heightmap.Sample(my_linear_repeat_sampler, texCoord).r; |
|||
uSample = heightmap.Sample(my_linear_repeat_sampler, offsetU).r; |
|||
vSample = heightmap.Sample(my_linear_repeat_sampler, offsetV).r; |
|||
float uMinusNormal = uSample - normalSample; |
|||
float vMinusNormal = vSample - normalSample; |
|||
uMinusNormal = uMinusNormal * strength; |
|||
vMinusNormal = vMinusNormal * strength; |
|||
float3 va = float3(1, 0, uMinusNormal); |
|||
float3 vb = float3(0, 1, vMinusNormal); |
|||
normalRes = cross(va, vb); |
|||
} |
|||
struct v2f |
|||
{ |
|||
float4 pos : SV_POSITION; |
|||
float4 color : COLOR; |
|||
float3 worldNormal : TEXCOORD1; |
|||
}; |
|||
struct Input |
|||
{ |
|||
float4 color : COLOR; |
|||
half4 meshUV0; |
|||
inline float unity_posterize_float (float input, float stepsize) |
|||
{ |
|||
return floor(input / stepsize) * stepsize; |
|||
} |
|||
}; |
|||
void vert (inout appdata_full v, out Input o) |
|||
{ |
|||
UNITY_INITIALIZE_OUTPUT(Input,o); |
|||
o.meshUV0 = v.texcoord; |
|||
v2f vert (appdata_full v) |
|||
{ |
|||
v2f o = (v2f)0; |
|||
o.pos = UnityObjectToClipPos(v.vertex);; |
|||
float3 worldPos = mul(unity_ObjectToWorld, v.vertex).xyz; |
|||
float3 viewDir = UnityWorldSpaceViewDir(worldPos); |
|||
float4 screenPos = ComputeScreenPos(UnityObjectToClipPos(v.vertex)); |
|||
float3 worldNormal = UnityObjectToWorldNormal(v.normal); |
|||
o.worldNormal = worldNormal; |
|||
} |
|||
|
|||
void surf (Input IN, inout SurfaceOutputStandard o) |
|||
{ |
|||
half4 uv0 = IN.meshUV0; |
|||
float4 UV_de8d7b89_7b50_499d_aa73_0f2a725356e6_UV = uv0; |
|||
float3 HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_normalRes; |
|||
#ifdef UNITY_COMPILER_HLSL |
|||
unity_HeightToNormal (TextureAsset_8f4a8771_6c8f_4107_9c0b_83da34d57a9b_Uniform, UV_de8d7b89_7b50_499d_aa73_0f2a725356e6_UV, HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_texOffset, HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_strength, HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_normalRes); |
|||
#endif |
|||
o.Normal = HeightToNormal_81cdd9a9_500d_41e2_9771_df274a2363bd_normalRes; |
|||
o.Normal += 1e-6; |
|||
return o; |
|||
} |
|||
} |
|||
ENDCG |
|||
} |
|||
half4 frag (v2f IN) : COLOR |
|||
{ |
|||
float3 worldSpaceNormal = normalize(IN.worldNormal); |
|||
float3 ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25 = ShadeSH9(float4(worldSpaceNormal.xyz , 1)); |
|||
float4 Split_f630c862_c9a4_4765_b085_f9b01dd46061 = float4(ReflectionProbe_4f8cb744_19c5_4a6e_9bc1_172200f2fa25, 1.0); |
|||
float Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output = unity_posterize_float (Split_f630c862_c9a4_4765_b085_f9b01dd46061.r, Vector1_20d0d38d_52d0_4444_8ef4_da01a311590e_Uniform); |
|||
return half4(Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output, Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output, Posterize_f232fbec_5ce8_4ba5_8491_a7a66291d45f_Output, 1.0); |
|||
} |
|||
ENDCG |
|||
} |
|||
} |
|||
Fallback Off |
|||
} |
|||
FallBack "Diffuse" |
|||
CustomEditor "LegacyIlluminShaderGUI" |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 7a91bd168256a4fecb2d532dc2f38d8a |
|||
guid: 9635695807dafd94992e8eb6a9346b63 |
|||
timeCreated: 1495668355 |
|||
timeCreated: 1485805545 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
2
MaterialGraphProject/Assets/Matt/AnisotropicMaster.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
2
MaterialGraphProject/Assets/Matt/Test.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 19e252e915115064abad85add7ecd46f |
|||
folderAsset: yes |
|||
timeCreated: 1495737232 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: e9dab59e587c7f244adde1add29b34fc |
|||
folderAsset: yes |
|||
timeCreated: 1495531757 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
public enum CommonMatrixType |
|||
{ |
|||
ModelView, |
|||
View, |
|||
Projection, |
|||
ViewProjection, |
|||
TransposeModelView, |
|||
InverseTransposeModelView, |
|||
ObjectToWorld, |
|||
WorldToObject |
|||
}; |
|||
|
|||
public enum SimpleMatrixType |
|||
{ |
|||
World, |
|||
Local, |
|||
Tangent, |
|||
View |
|||
}; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: e466cff33b1ebe64eb2b897b9534a4a4 |
|||
timeCreated: 1495703998 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 6a5311f2c2db6e34f8da2333309aab50 |
|||
folderAsset: yes |
|||
timeCreated: 1495713891 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Serializable] |
|||
[Title("Master/Unlit")] |
|||
public class UnlitMasterNode : AbstractAdvancedMasterNode |
|||
{ |
|||
public const string LightFunctionName = "Advanced"; |
|||
public const string SurfaceOutputStructureName = "SurfaceOutputAdvanced"; |
|||
|
|||
public UnlitMasterNode() |
|||
{ |
|||
name = "UnlitMaster"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override string GetMaterialID() |
|||
{ |
|||
return "SHADINGMODELID_UNLIT"; |
|||
} |
|||
|
|||
public override int[] GetCustomDataSlots() |
|||
{ |
|||
return new int[] { }; |
|||
} |
|||
|
|||
public override string[] GetCustomData() |
|||
{ |
|||
return new string[] { }; |
|||
} |
|||
|
|||
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(AlphaSlotId, AlphaSlotName, AlphaSlotName, SlotType.Input, SlotValueType.Vector1, Vector4.zero)); |
|||
|
|||
// clear out slot names that do not match the slots
|
|||
// we support
|
|||
RemoveSlotsNameNotMatching( |
|||
new[] |
|||
{ |
|||
AlbedoSlotId, |
|||
NormalSlotId, |
|||
EmissionSlotId, |
|||
AlphaSlotId |
|||
}); |
|||
} |
|||
|
|||
public override string GetSurfaceOutputName() |
|||
{ |
|||
return SurfaceOutputStructureName; |
|||
} |
|||
|
|||
public override string GetLightFunction() |
|||
{ |
|||
return LightFunctionName; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: ea393384786555042850882db80a89d9 |
|||
timeCreated: 1478188276 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("UV/ParallaxOcclusionMapping")] |
|||
public class ParallaxOcclusionMappingNode : |
|||
AbstractMaterialNode, |
|||
IGeneratesBodyCode, |
|||
IGeneratesFunction, |
|||
IMayRequireMeshUV, |
|||
IMayRequireViewDirection, |
|||
IMayRequireNormal, |
|||
IMayRequireViewDirectionTangentSpace |
|||
{ |
|||
protected const string kInputHeightScaleShaderName = "HeightScale"; |
|||
protected const string kTextureSlotShaderName = "Texture"; |
|||
protected const string kOutputSlotShaderName = "UV"; |
|||
|
|||
public const int HeightScaleSlotId = 0; // 'height_scale'
|
|||
public const int TextureSlotId = 1; // 'tex'
|
|||
public const int OutputSlotId = 2; |
|||
|
|||
public override bool hasPreview |
|||
{ |
|||
get { return true; } |
|||
} |
|||
|
|||
public override PreviewMode previewMode |
|||
{ |
|||
get |
|||
{ |
|||
return PreviewMode.Preview3D; |
|||
} |
|||
} |
|||
|
|||
public ParallaxOcclusionMappingNode() |
|||
{ |
|||
name = "ParallaxOcclusionMapping"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public string GetFunctionName() |
|||
{ |
|||
return "unity_parallax_occlusion_mapping_" + precision; |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(GetInputHeightScaleSlot()); |
|||
AddSlot(GetTextureSlot()); |
|||
AddSlot(GetOutputSlot()); |
|||
|
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
|
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] { HeightScaleSlotId, TextureSlotId, OutputSlotId }; } |
|||
} |
|||
protected virtual string GetInputHeightScaleName() |
|||
{ |
|||
return kInputHeightScaleShaderName; |
|||
} |
|||
protected virtual MaterialSlot GetInputHeightScaleSlot() |
|||
{ |
|||
return new MaterialSlot( |
|||
HeightScaleSlotId, GetInputHeightScaleName(), kInputHeightScaleShaderName, SlotType.Input, SlotValueType.Vector1, Vector4.zero); |
|||
} |
|||
protected virtual MaterialSlot GetTextureSlot() |
|||
{ |
|||
return new MaterialSlot(TextureSlotId, GetTextureSlotName(), kTextureSlotShaderName, SlotType.Input, SlotValueType.Texture2D, Vector4.zero); |
|||
} |
|||
|
|||
protected virtual MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector2, Vector4.zero); |
|||
} |
|||
|
|||
protected virtual string GetTextureSlotName() |
|||
{ |
|||
return kTextureSlotShaderName; |
|||
} |
|||
|
|||
protected virtual string GetOutputSlotName() |
|||
{ |
|||
return kOutputSlotShaderName; |
|||
} |
|||
|
|||
private string inputHeightScaleDimension |
|||
{ |
|||
get { return ConvertConcreteSlotValueTypeToString(FindInputSlot<MaterialSlot>(HeightScaleSlotId).concreteValueType); } |
|||
} |
|||
|
|||
protected virtual string GetFunctionPrototype( |
|||
string heightScale, string tex, string UVs, string viewTangentSpace, string worldSpaceNormal, string worldSpaceViewDirection) |
|||
{ |
|||
return "inline " + precision + "2 " + GetFunctionName() + " (" + |
|||
precision + inputHeightScaleDimension + " " + heightScale + ", " + |
|||
"sampler2D " + tex + ", " + |
|||
precision + "2 " + UVs + ", " + |
|||
precision + "3 " + viewTangentSpace + ", " + |
|||
precision + "3 " + worldSpaceNormal + ", " + |
|||
precision + "3 " + worldSpaceViewDirection + ")"; |
|||
} |
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
NodeUtils.SlotConfigurationExceptionIfBadConfiguration( |
|||
this, |
|||
new[] { HeightScaleSlotId, TextureSlotId }, |
|||
new[] { OutputSlotId }); |
|||
string heightScaleValue = GetSlotValue(HeightScaleSlotId, generationMode); |
|||
string textureValue = GetSlotValue(TextureSlotId, generationMode); |
|||
|
|||
visitor.AddShaderChunk(precision + "2 " + GetVariableNameForSlot(OutputSlotId) + " = " + |
|||
GetFunctionCallBody(heightScaleValue, textureValue) + ";", true); |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk( |
|||
GetFunctionPrototype("heightScale", "tex", "UVs", "viewTangentSpace", "worldSpaceNormal", "worldSpaceViewDirection" ), |
|||
false); |
|||
|
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk(precision + "2 " + "height_map_dimensions = " + precision + "2" + "(256.0f, 256.0f); //HARDCODE", false); |
|||
//height_map.tex.GetDimensions(height_map_dimensions.x, height_map_dimensions.y);
|
|||
|
|||
outputString.AddShaderChunk(precision + "2 texcoord= UVs;", false); |
|||
|
|||
// Compute the current gradients:
|
|||
outputString.AddShaderChunk(precision + "2 " + " texcoords_per_size = texcoord * height_map_dimensions;", false); |
|||
|
|||
// Compute all 4 derivatives in x and y in a single instruction to optimize:
|
|||
outputString.AddShaderChunk("float2 dx, dy;", false); |
|||
|
|||
outputString.AddShaderChunk(" float4 temp_ddx = ddx(float4(texcoords_per_size, texcoord));", false); |
|||
|
|||
outputString.AddShaderChunk("dx.xy = temp_ddx.zw;", false); |
|||
|
|||
outputString.AddShaderChunk("float4 temp_ddy = ddy(float4(texcoords_per_size, texcoord));", false); |
|||
|
|||
outputString.AddShaderChunk("dy.xy = temp_ddy.zw;", false); |
|||
|
|||
// Start the current sample located at the input texture coordinate, which would correspond
|
|||
// to computing a bump mapping result:
|
|||
outputString.AddShaderChunk(precision + "2 " + "result_texcoord = texcoord;", false); |
|||
|
|||
outputString.AddShaderChunk("float height_scale_value = heightScale;", false); |
|||
outputString.AddShaderChunk("float height_scale_adjust = height_scale_value;", false); |
|||
|
|||
|
|||
outputString.AddShaderChunk("float per_pixel_height_scale_value = height_scale_value * heightScale;", false); |
|||
|
|||
// Parallax occlusion mapping offset computation
|
|||
//--------------
|
|||
|
|||
// Utilize dynamic flow control to change the number of samples per ray
|
|||
// depending on the viewing angle for the surface. Oblique angles require
|
|||
// smaller step sizes to achieve more accurate precision for computing displacement.
|
|||
// We express the sampling rate as a linear function of the angle between
|
|||
// the geometric normal and the view direction ray:
|
|||
outputString.AddShaderChunk("float max_samples = 30.0f;", false); |
|||
outputString.AddShaderChunk("float min_samples = 4.0f;", false); |
|||
|
|||
outputString.AddShaderChunk("float view_dot_normal= dot(worldSpaceNormal, worldSpaceViewDirection);", false); |
|||
|
|||
outputString.AddShaderChunk("int number_of_steps = (int)lerp(max_samples, min_samples, saturate(view_dot_normal));", false); |
|||
|
|||
// Intersect the view ray with the height field profile along the direction of
|
|||
// the parallax offset ray (computed in the vertex shader. Note that the code is
|
|||
// designed specifically to take advantage of the dynamic flow control constructs
|
|||
// in HLSL and is very sensitive to specific syntax. When converting to other examples,
|
|||
// if still want to use dynamic flow control in the resulting assembly shader,
|
|||
// care must be applied.
|
|||
//
|
|||
// In the below steps we approximate the height field profile as piecewise linear
|
|||
// curve. We find the pair of endpoints between which the intersection between the
|
|||
// height field profile and the view ray is found and then compute line segment
|
|||
// intersection for the view ray and the line segment formed by the two endpoints.
|
|||
// This intersection is the displacement offset from the original texture coordinate.
|
|||
// See the above SI3D 06 paper for more details about the process and derivation.
|
|||
//
|
|||
|
|||
outputString.AddShaderChunk("float current_height = 0.0;", false); |
|||
outputString.AddShaderChunk("float step_size = 1.0 / (float)number_of_steps;", false); |
|||
|
|||
outputString.AddShaderChunk("float previous_height = 1.0;", false); |
|||
outputString.AddShaderChunk("float next_height = 0.0;", false); |
|||
|
|||
|
|||
outputString.AddShaderChunk("int step_index = 0;", false); |
|||
|
|||
// Optimization: this should move to vertex shader, however, we compute it here for simplicity of
|
|||
// integration into our shaders for now.
|
|||
outputString.AddShaderChunk("float3 normalized_view_dir_in_tangent_space = normalize(viewTangentSpace.xyz);", false); |
|||
|
|||
// Compute initial parallax displacement direction:
|
|||
outputString.AddShaderChunk("float2 parallax_direction = normalize(viewTangentSpace.xy);", false); |
|||
|
|||
// The length of this vector determines the furthest amount of displacement:
|
|||
outputString.AddShaderChunk("float parallax_direction_length = length(normalized_view_dir_in_tangent_space);", false); |
|||
|
|||
outputString.AddShaderChunk( |
|||
"float max_parallax_amount = sqrt(parallax_direction_length * parallax_direction_length - viewTangentSpace.z * viewTangentSpace.z) / viewTangentSpace.z;", false); |
|||
|
|||
// Compute the actual reverse parallax displacement vector:
|
|||
outputString.AddShaderChunk("float2 parallax_offset_in_tangent_space = parallax_direction * max_parallax_amount;", false); |
|||
|
|||
// Need to scale the amount of displacement to account for different height ranges
|
|||
// in height maps. This is controlled by an artist-editable parameter:
|
|||
outputString.AddShaderChunk("parallax_offset_in_tangent_space *= saturate(heightScale);", false); |
|||
|
|||
outputString.AddShaderChunk("float2 texcoord_offset_per_step = step_size * parallax_offset_in_tangent_space;", false); |
|||
|
|||
outputString.AddShaderChunk(precision + "2 " + "current_texcoord_offset = texcoord;", false); |
|||
outputString.AddShaderChunk("float current_bound = 1.0;", false); |
|||
|
|||
outputString.AddShaderChunk("float current_parallax_amount = 0.0;", false); |
|||
|
|||
outputString.AddShaderChunk("float2 pt1 = 0;", false); |
|||
outputString.AddShaderChunk("float2 pt2 = 0;", false); |
|||
|
|||
|
|||
outputString.AddShaderChunk(precision + "2 " + "temp_texcoord_offset = 0;", false); |
|||
|
|||
outputString.AddShaderChunk("while (step_index < number_of_steps)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("current_texcoord_offset -= texcoord_offset_per_step;", false); |
|||
|
|||
// Sample height map which in this case is stored in the alpha channel of the normal map:
|
|||
outputString.AddShaderChunk("current_height = tex2Dgrad(tex, current_texcoord_offset, dx, dy).r;", false); |
|||
|
|||
outputString.AddShaderChunk("current_bound -= step_size;", false); |
|||
|
|||
outputString.AddShaderChunk("if (current_height > current_bound)", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("pt1 = float2(current_bound, current_height);", false); |
|||
|
|||
outputString.AddShaderChunk("pt2 = float2(current_bound + step_size, previous_height);", false); |
|||
|
|||
|
|||
outputString.AddShaderChunk("temp_texcoord_offset = current_texcoord_offset - texcoord_offset_per_step;", false); |
|||
|
|||
outputString.AddShaderChunk("step_index = number_of_steps + 1;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
outputString.AddShaderChunk("else", false); |
|||
|
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
|
|||
outputString.AddShaderChunk("step_index++;", false); |
|||
outputString.AddShaderChunk("previous_height = current_height;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("} // End of while ( step_index < number_of_steps)", false); |
|||
|
|||
|
|||
outputString.AddShaderChunk("float delta2 = pt2.x - pt2.y;", false); |
|||
outputString.AddShaderChunk("float delta1 = pt1.x - pt1.y;", false); |
|||
|
|||
outputString.AddShaderChunk("float denominator = delta2 - delta1;", false); |
|||
|
|||
// SM 3.0 and above requires a check for divide by zero since that operation
|
|||
// will generate an 'Inf' number instead of 0
|
|||
outputString.AddShaderChunk("if (denominator== 0.0f) ", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("current_parallax_amount= 0.0f;", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
outputString.AddShaderChunk("else", false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("current_parallax_amount= (pt1.x* delta2 - pt2.x* delta1) / denominator;", false); |
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
outputString.AddShaderChunk("float2 parallax_offset = parallax_offset_in_tangent_space * (1.0f - current_parallax_amount);", false); |
|||
|
|||
// The computed texture offset for the displaced point on the pseudo-extruded surface:
|
|||
outputString.AddShaderChunk("float2 parallaxed_texcoord = texcoord - parallax_offset;", false); |
|||
|
|||
outputString.AddShaderChunk("return parallaxed_texcoord;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
|
|||
protected virtual string GetFunctionCallBody(string heightScale, string texValue) |
|||
{ |
|||
var channel = UVChannel.uv0; |
|||
|
|||
return GetFunctionName() + " (" + |
|||
heightScale + ", " + |
|||
texValue + ", " + |
|||
channel.GetUVName() + ", " + |
|||
ShaderGeneratorNames.TangentSpaceViewDirection + ", " + |
|||
ShaderGeneratorNames.WorldSpaceNormal + ", " + |
|||
ShaderGeneratorNames.WorldSpaceViewDirection + ")"; |
|||
} |
|||
|
|||
public bool RequiresMeshUV(UVChannel channel) |
|||
{ |
|||
return channel == UVChannel.uv0; |
|||
} |
|||
public bool RequiresViewDirectionTangentSpace() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresNormal() |
|||
{ |
|||
return true; |
|||
} |
|||
public bool RequiresViewDirection() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: daac036bc09be70438149124ccd0a11b |
|||
timeCreated: 1495700896 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1
MaterialGraphProject/Assets/POM_Graph.ShaderGraph
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 96bf971901c0d7c468d21e8511ced163 |
|||
timeCreated: 1495479560 |
|||
licenseType: Pro |
|||
ScriptedImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|||
script: {fileID: 11500000, guid: 625f186215c104763be7675aa2d941aa, type: 3} |
|
|||
fileFormatVersion: 2 |
|||
guid: f413b728b2f6460418512648f4132898 |
|||
folderAsset: yes |
|||
timeCreated: 1495695266 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1001
MaterialGraphProject/Assets/TestAssets/ColorTransparent.tif
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: 75446046af0bacb4eac0858374f720b5 |
|||
timeCreated: 1490800222 |
|||
licenseType: Pro |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
serializedVersion: 4 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 0 |
|||
sRGBTexture: 0 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spritePixelsToUnits: 100 |
|||
alphaUsage: 2 |
|||
alphaIsTransparency: 1 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 0 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
- buildTarget: Standalone |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 0 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: fd9dcc0042b460046917799942414fe0 |
|||
timeCreated: 1495721640 |
|||
licenseType: Pro |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
serializedVersion: 4 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spritePixelsToUnits: 100 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: ff1fa8d5d8b0945499c7785f1b0f2a4f |
|||
timeCreated: 1495721640 |
|||
licenseType: Pro |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
serializedVersion: 4 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spritePixelsToUnits: 100 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: cbf25f5368b2350408963109a1c8f22d |
|||
timeCreated: 1495721640 |
|||
licenseType: Pro |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
serializedVersion: 4 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spritePixelsToUnits: 100 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
using UnityEngine.MaterialGraph; |
|||
using UnityEngine; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
class ConvolutionFilterControlPresenter : GraphControlPresenter |
|||
{ |
|||
enum KernelPresets |
|||
{ |
|||
Presets, |
|||
BoxBlur, |
|||
GaussianBlur, |
|||
EdgesDetection, |
|||
EnhanceEdges, |
|||
Sharpen, |
|||
Emboss, |
|||
}; |
|||
|
|||
private void ApplyPreset(KernelPresets preset, ref float[,] values, ref float divisor) |
|||
{ |
|||
if (preset == KernelPresets.BoxBlur) |
|||
{ |
|||
values = new float[,] { {1,1,1,1,1}, |
|||
{1,1,1,1,1}, |
|||
{1,1,1,1,1}, |
|||
{1,1,1,1,1}, |
|||
{1,1,1,1,1} }; |
|||
divisor = 25; |
|||
} |
|||
if (preset == KernelPresets.GaussianBlur) |
|||
{ |
|||
values = new float[,] { { 1, 4, 6, 4, 1}, |
|||
{ 4,16,24,16, 4}, |
|||
{ 6,24,36,24, 6}, |
|||
{ 4,16,24,16, 4}, |
|||
{ 1, 4, 6, 4, 1} }; |
|||
divisor = 256; |
|||
} |
|||
if (preset == KernelPresets.EdgesDetection) |
|||
{ |
|||
values = new float[,] { {-1,-1,-1, -1,-1}, |
|||
{-1,-2,-2, -2,-1}, |
|||
{-1,-2, 33,-2,-1}, |
|||
{-1,-2,-2, -2,-1}, |
|||
{-1,-1,-1, -1,-1} }; |
|||
divisor = 1; |
|||
} |
|||
if (preset == KernelPresets.EnhanceEdges) |
|||
{ |
|||
values = new float[,] { { 0, 0, 0, 0, 0}, |
|||
{ 0, 1, 1, 1, 0}, |
|||
{ 0, 1,-7, 1, 0}, |
|||
{ 0, 1, 1, 1, 0}, |
|||
{ 0, 0, 0, 0, 0} }; |
|||
divisor = 1; |
|||
} |
|||
if (preset == KernelPresets.Sharpen) |
|||
{ |
|||
values = new float[,] { {-1,-1,-1, -1,-1}, |
|||
{-1, 2, 2, 2,-1}, |
|||
{-1, 2, 8, 2,-1}, |
|||
{-1, 2, 2, 2,-1}, |
|||
{-1,-1,-1, -1,-1} }; |
|||
divisor = 8; |
|||
} |
|||
if (preset == KernelPresets.Emboss) |
|||
{ |
|||
values = new float[,] { {-1,-1,-1,-1, 0}, |
|||
{-1,-1,-1, 0, 1}, |
|||
{-1,-1, 0, 1, 1}, |
|||
{-1, 0, 1, 1, 1}, |
|||
{ 0, 1, 1, 1, 1} }; |
|||
divisor = 1; |
|||
} |
|||
} |
|||
|
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var tNode = node as ConvolutionFilterNode; |
|||
if (tNode == null) |
|||
return; |
|||
|
|||
float divisor = tNode.GetConvolutionDivisor(); |
|||
float[,] values = new float[5,5]; |
|||
for (int row = 0; row < 5; ++row) |
|||
{ |
|||
for (int col = 0; col < 5; ++col) |
|||
{ |
|||
values[row,col] = tNode.GetConvolutionWeight(row,col); |
|||
} |
|||
} |
|||
|
|||
EditorGUILayout.BeginVertical(); |
|||
EditorGUI.BeginChangeCheck(); |
|||
|
|||
EditorGUILayout.LabelField("Kernel"); |
|||
KernelPresets kernelPresets = KernelPresets.Presets; |
|||
kernelPresets = (KernelPresets)EditorGUILayout.EnumPopup(kernelPresets); |
|||
ApplyPreset(kernelPresets, ref values, ref divisor); |
|||
|
|||
for (int col = 0; col < 5; ++col) |
|||
{ |
|||
EditorGUILayout.BeginHorizontal(); |
|||
for (int row = 0; row < 5; ++row) |
|||
{ |
|||
values[row, col] = EditorGUILayout.FloatField(values[row, col], GUILayout.Width(35)); |
|||
} |
|||
EditorGUILayout.EndHorizontal(); |
|||
} |
|||
EditorGUILayout.Space(); |
|||
|
|||
divisor = EditorGUILayout.FloatField("Divisor", divisor); |
|||
|
|||
EditorGUILayout.EndVertical(); |
|||
|
|||
if (EditorGUI.EndChangeCheck()) |
|||
{ |
|||
tNode.SetConvolutionDivisor(divisor); |
|||
for (int row = 0; row < 5; ++row) |
|||
{ |
|||
for (int col = 0; col < 5; ++col) |
|||
{ |
|||
tNode.SetConvolutionWeight(row, col, values[row, col]); |
|||
} |
|||
} |
|||
} |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return (EditorGUIUtility.singleLineHeight * 10 + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class ConvolutionFilterNodePresenter : PropertyNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<ConvolutionFilterControlPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter>(base.GetControlData()) { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: f3a416c372d21b6479241e837d4257da |
|||
timeCreated: 1495705790 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.MaterialGraph; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class MatrixCommonContolPresenter : GraphControlPresenter |
|||
{ |
|||
|
|||
private string[] m_MatrixTypeNames; |
|||
private string[] matrixTypeNames |
|||
{ |
|||
get |
|||
{ |
|||
if (m_MatrixTypeNames == null) |
|||
m_MatrixTypeNames = Enum.GetNames(typeof(CommonMatrixType)); |
|||
return m_MatrixTypeNames; |
|||
} |
|||
} |
|||
|
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var cNode = node as UnityEngine.MaterialGraph.MatrixCommonNode; |
|||
if (cNode == null) |
|||
return; |
|||
|
|||
cNode.matrix = (CommonMatrixType)EditorGUILayout.Popup((int)cNode.matrix, matrixTypeNames, EditorStyles.popup); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class MatrixCommonNodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<MatrixCommonContolPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: b7283eb87c37e4a43b5eddbf2d4360d1 |
|||
timeCreated: 1495448531 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using UnityEngine.MaterialGraph; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class SamplerStateControlPresenter : GraphControlPresenter |
|||
{ |
|||
|
|||
private string[] samplerFilterMode; |
|||
private string[] samplerWrapMode; |
|||
|
|||
private string[] _samplerFilterMode |
|||
{ |
|||
get |
|||
{ |
|||
if (samplerFilterMode == null) |
|||
samplerFilterMode = Enum.GetNames(typeof(SamplerStateNode.FilterMode)); |
|||
return samplerFilterMode; |
|||
} |
|||
} |
|||
|
|||
private string[] _samplerWrapMode |
|||
{ |
|||
get |
|||
{ |
|||
if (samplerWrapMode == null) |
|||
samplerWrapMode = Enum.GetNames(typeof(SamplerStateNode.WrapMode)); |
|||
return samplerWrapMode; |
|||
} |
|||
} |
|||
|
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var cNode = node as UnityEngine.MaterialGraph.SamplerStateNode; |
|||
if (cNode == null) |
|||
return; |
|||
|
|||
cNode.filter = (SamplerStateNode.FilterMode)EditorGUILayout.Popup((int)cNode.filter, _samplerFilterMode, EditorStyles.popup); |
|||
cNode.wrap = (SamplerStateNode.WrapMode)EditorGUILayout.Popup((int)cNode.wrap, _samplerWrapMode, EditorStyles.popup); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class SamplerStateNodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<SamplerStateControlPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 8ffcc48ccff1aea44b90acb362bc0dfc |
|||
timeCreated: 1495659152 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
|
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
[Serializable] |
|||
class ScatterContolPresenter : GraphControlPresenter |
|||
{ |
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var cNode = node as UnityEngine.MaterialGraph.ScatterNode; |
|||
if (cNode == null) |
|||
return; |
|||
|
|||
cNode.num = EditorGUILayout.IntField(cNode.num, "Number", null); |
|||
cNode.num = Math.Min(cNode.num, 50); //prevent infinite => hang!
|
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return EditorGUIUtility.singleLineHeight + 10 * EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
|
|||
} |
|||
|
|||
[Serializable] |
|||
public class ScatterNodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<ScatterContolPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter> { instance }; |
|||
} |
|||
} |
|||
|
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 324b6873762a09544a3cebd0f0c7721d |
|||
timeCreated: 1495713547 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using RMGUI.GraphView; |
|||
using UnityEditor.Graphing.Drawing; |
|||
using UnityEngine; |
|||
using UnityEngine.MaterialGraph; |
|||
|
|||
namespace UnityEditor.MaterialGraph.Drawing |
|||
{ |
|||
class TextureSamplerContolPresenter : GraphControlPresenter |
|||
{ |
|||
private string[] m_TextureTypeNames; |
|||
private string[] textureTypeNames |
|||
{ |
|||
get |
|||
{ |
|||
if (m_TextureTypeNames == null) |
|||
m_TextureTypeNames = Enum.GetNames(typeof(TextureType)); |
|||
return m_TextureTypeNames; |
|||
} |
|||
} |
|||
|
|||
public override void OnGUIHandler() |
|||
{ |
|||
base.OnGUIHandler(); |
|||
|
|||
var tNode = node as UnityEngine.MaterialGraph.TextureAssetNode; |
|||
if (tNode == null) |
|||
return; |
|||
|
|||
tNode.exposedState = (PropertyNode.ExposedState)EditorGUILayout.EnumPopup(new GUIContent("Exposed"), tNode.exposedState); |
|||
tNode.defaultTexture = EditorGUILayout.MiniThumbnailObjectField(new GUIContent("Texture"), tNode.defaultTexture, typeof(Texture), null) as Texture; |
|||
tNode.textureType = (TextureType)EditorGUILayout.Popup((int)tNode.textureType, textureTypeNames, EditorStyles.popup); |
|||
} |
|||
|
|||
public override float GetHeight() |
|||
{ |
|||
return 3 * (EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing) + EditorGUIUtility.standardVerticalSpacing; |
|||
} |
|||
} |
|||
|
|||
[Serializable] |
|||
public class TextureSamplerNodePresenter : MaterialNodePresenter |
|||
{ |
|||
protected override IEnumerable<GraphElementPresenter> GetControlData() |
|||
{ |
|||
var instance = CreateInstance<TextureSamplerContolPresenter>(); |
|||
instance.Initialize(node); |
|||
return new List<GraphElementPresenter> { instance }; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 86fe3d2371b24d34399f4b116a238d45 |
|||
timeCreated: 1495638407 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 5d84e1086e00e3347aaa0bbba206bb80 |
|||
timeCreated: 1495717214 |
|||
licenseType: Pro |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
serializedVersion: 4 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spritePixelsToUnits: 100 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
137
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/bricks_normal.tga
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: e017404169662f041a969b0a924cc2ed |
|||
timeCreated: 1495717224 |
|||
licenseType: Pro |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
serializedVersion: 4 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spritePixelsToUnits: 100 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/mur_Ambiant.bmp
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
fileFormatVersion: 2 |
|||
guid: b5a88303611082242a4eb08e645752d2 |
|||
timeCreated: 1495717081 |
|||
licenseType: Pro |
|||
TextureImporter: |
|||
fileIDToRecycleName: {} |
|||
serializedVersion: 4 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 1 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: -1 |
|||
mipBias: -1 |
|||
wrapU: -1 |
|||
wrapV: -1 |
|||
wrapW: -1 |
|||
nPOTScale: 1 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spritePixelsToUnits: 100 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 0 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 0 |
|||
textureShape: 1 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 1 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
spritePackingTag: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
SubShader |
|||
{ |
|||
${Tags} |
|||
${Blending} |
|||
${Culling} |
|||
${ZTest} |
|||
${ZWrite} |
|||
|
|||
LOD ${LOD} |
|||
|
|||
CGPROGRAM |
|||
#include "Tessellation.cginc" |
|||
#pragma target 4.6 |
|||
#pragma surface surf ${LightingFunctionName} ${VertexShaderDecl} vertex:Displacement tessellate:tessEdge tessphong:_Phong |
|||
#pragma glsl |
|||
#pragma debug |
|||
|
|||
|
|||
//Tessellation Edge Function |
|||
float4 tessEdge(appdata v0, appdata v1, appdata v2) |
|||
{ |
|||
float quality = 20-(_Subdivision * 2); |
|||
return UnityEdgeLengthBasedTess(v0.vertex, v1.vertex, v2.vertex, quality); |
|||
} |
|||
|
|||
//Tessellation Vertex Function |
|||
void Displacement (inout appdata v) |
|||
{ |
|||
float d = tex2Dlod(_DisplacementTex, float4(v.texcoord.xy * (_DisplacementTex_ST.xy * float2(_WeaveScale*25, _WeaveScale*25)) + _DisplacementTex_ST.zw, 0, 0)).r * _Displacement*0.1; |
|||
v.vertex.xyz += v.normal * (d * 0.5); |
|||
} |
|||
|
|||
${ShaderFunctions} |
|||
${ShaderPropertyUsages} |
|||
|
|||
struct Input |
|||
{ |
|||
${ShaderInputs} |
|||
}; |
|||
|
|||
void vert (inout appdata_full v, out Input o) |
|||
{ |
|||
UNITY_INITIALIZE_OUTPUT(Input,o); |
|||
${VertexShaderBody} |
|||
} |
|||
|
|||
void surf (Input IN, inout ${SurfaceOutputStructureName} o) |
|||
{ |
|||
${PixelShaderBody} |
|||
} |
|||
ENDCG |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 71a3d46ddb1693340a7de3973be90309 |
|||
timeCreated: 1481194716 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 7ed888a282fe7b54e968311cd68c4862 |
|||
folderAsset: yes |
|||
timeCreated: 1495638073 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.ComponentModel; |
|||
using UnityEngine.Graphing; |
|||
using System.Collections.Generic; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Matrix/CommonMatrix")] |
|||
public class MatrixCommonNode : AbstractMaterialNode |
|||
{ |
|||
static Dictionary<CommonMatrixType, string> m_matrixList = new Dictionary<CommonMatrixType, string> |
|||
{ |
|||
{CommonMatrixType.ModelView, "UNITY_MATRIX_MV"}, |
|||
{CommonMatrixType.View, "UNITY_MATRIX_V"}, |
|||
{CommonMatrixType.Projection, "UNITY_MATRIX_P"}, |
|||
{CommonMatrixType.ViewProjection, "UNITY_MATRIX_VP"}, |
|||
{CommonMatrixType.TransposeModelView, "UNITY_MATRIX_T_MV"}, |
|||
{CommonMatrixType.InverseTransposeModelView, "UNITY_MATRIX_IT_MV"}, |
|||
{CommonMatrixType.ObjectToWorld, "unity_ObjectToWorld"}, |
|||
{CommonMatrixType.WorldToObject, "unity_WorldToObject"}, |
|||
}; |
|||
|
|||
[SerializeField] |
|||
private CommonMatrixType m_matrix = CommonMatrixType.ModelView; |
|||
|
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Output"; |
|||
|
|||
public override bool hasPreview { get { return false; } } |
|||
|
|||
public CommonMatrixType matrix |
|||
{ |
|||
get { return m_matrix; } |
|||
set |
|||
{ |
|||
if (m_matrix == value) |
|||
return; |
|||
|
|||
m_matrix = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public MatrixCommonNode() |
|||
{ |
|||
name = "CommonMatrix"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Matrix4, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return m_matrixList[matrix]; |
|||
} |
|||
|
|||
public bool RequiresVertexColor() |
|||
{ |
|||
return true; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 080829bc2938e23489292a936367364d |
|||
timeCreated: 1481123160 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Scene Data/Camera Direction")] |
|||
public class CamDirNode : AbstractMaterialNode |
|||
{ |
|||
public CamDirNode() |
|||
{ |
|||
name = "CameraDirection"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Output"; |
|||
|
|||
public override bool hasPreview { get { return true; } } |
|||
public override PreviewMode previewMode |
|||
{ |
|||
get { return PreviewMode.Preview2D; } |
|||
} |
|||
|
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return "UNITY_MATRIX_IT_MV [2].xyz"; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: dd27728b9ce314209beef46e595204c5 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Scene Data/Camera Position")] |
|||
public class CamPosNode : AbstractMaterialNode |
|||
{ |
|||
//TODO - should be a global and immpiment a Imayrequire
|
|||
public CamPosNode() |
|||
{ |
|||
name = "CameraPosition"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Output"; |
|||
|
|||
public override bool hasPreview { get { return true; } } |
|||
public override PreviewMode previewMode |
|||
{ |
|||
get { return PreviewMode.Preview2D; } |
|||
} |
|||
|
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.Vector4, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
return "_WorldSpaceCameraPos"; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 27a1751acacc54e278090fb991699a90 |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|
|||
fileFormatVersion: 2 |
|||
guid: bfc8dbcaa9711c945b8fd983b819335d |
|||
folderAsset: yes |
|||
timeCreated: 1495700996 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 3b0333da20fc0bf48a4d9b09a9d8d9db |
|||
timeCreated: 1495718308 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("UV/Twist")] |
|||
public class TwistNode : Function2Input, IGeneratesFunction |
|||
{ |
|||
public TwistNode() |
|||
{ |
|||
name = "Twist"; |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_twist_" + precision; |
|||
} |
|||
|
|||
protected override string GetInputSlot1Name() |
|||
{ |
|||
return "UV"; |
|||
} |
|||
|
|||
protected override string GetInputSlot2Name() |
|||
{ |
|||
return "Twist"; |
|||
} |
|||
|
|||
protected override MaterialSlot GetInputSlot1() |
|||
{ |
|||
return new MaterialSlot(InputSlot1Id, GetInputSlot1Name(), kInputSlot1ShaderName, SlotType.Input, SlotValueType.Vector2, Vector2.zero); |
|||
} |
|||
|
|||
protected override MaterialSlot GetInputSlot2() |
|||
{ |
|||
return new MaterialSlot(InputSlot2Id, GetInputSlot2Name(), kInputSlot2ShaderName, SlotType.Input, SlotValueType.Vector1, Vector2.zero); |
|||
} |
|||
|
|||
protected override MaterialSlot GetOutputSlot() |
|||
{ |
|||
return new MaterialSlot(OutputSlotId, GetOutputSlotName(), kOutputSlotShaderName, SlotType.Output, SlotValueType.Vector2, Vector2.zero); |
|||
} |
|||
|
|||
public void GenerateNodeFunction(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
var outputString = new ShaderGenerator(); |
|||
outputString.AddShaderChunk(GetFunctionPrototype("uv", "twist"), false); |
|||
outputString.AddShaderChunk("{", false); |
|||
outputString.Indent(); |
|||
outputString.AddShaderChunk("float angle = twist * length(uv);", false); |
|||
outputString.AddShaderChunk("float x = cos(angle) * uv.x - sin(angle) * uv.y;", false); |
|||
outputString.AddShaderChunk("float y = sin(angle) * uv.x + cos(angle) * uv.y;", false); |
|||
outputString.AddShaderChunk("return float2(x, y);", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3933f2692da9060438719b86844dcc7e |
|||
timeCreated: 1495718285 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections.Generic; |
|||
using UnityEngine.MaterialGraph; |
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Sampler State")] |
|||
public class SamplerStateNode : AbstractMaterialNode, IGeneratesBodyCode |
|||
{ |
|||
|
|||
public enum FilterMode |
|||
{ |
|||
Linear, |
|||
Point |
|||
} |
|||
|
|||
public enum WrapMode |
|||
{ |
|||
Repeat, |
|||
Clamp |
|||
} |
|||
|
|||
static Dictionary<FilterMode, string> filterMode = new Dictionary<FilterMode, string> |
|||
{ |
|||
{FilterMode.Linear, "_linear"}, |
|||
{FilterMode.Point, "_point"}, |
|||
}; |
|||
|
|||
static Dictionary<WrapMode, string> wrapMode = new Dictionary<WrapMode, string> |
|||
{ |
|||
{WrapMode.Repeat, "_repeat"}, |
|||
{WrapMode.Clamp, "_clamp"}, |
|||
}; |
|||
|
|||
|
|||
[SerializeField] |
|||
private FilterMode m_filter = FilterMode.Linear; |
|||
|
|||
|
|||
public FilterMode filter |
|||
{ |
|||
get { return m_filter; } |
|||
set |
|||
{ |
|||
if (m_filter == value) |
|||
return; |
|||
|
|||
m_filter = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
[SerializeField] |
|||
private WrapMode m_wrap = WrapMode.Repeat; |
|||
|
|||
|
|||
public WrapMode wrap |
|||
{ |
|||
get { return m_wrap; } |
|||
set |
|||
{ |
|||
if (m_wrap == value) |
|||
return; |
|||
|
|||
m_wrap = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public SamplerStateNode() |
|||
{ |
|||
name = "SamplerState"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public override bool hasPreview { get { return false; } } |
|||
|
|||
private const int kOutputSlotId = 0; |
|||
private const string kOutputSlotName = "Sampler Output"; |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(kOutputSlotId, kOutputSlotName, kOutputSlotName, SlotType.Output, SlotValueType.SamplerState, Vector4.zero, false)); |
|||
RemoveSlotsNameNotMatching(new[] { kOutputSlotId }); |
|||
} |
|||
|
|||
/* |
|||
public override PropertyType propertyType |
|||
{ |
|||
get { return PropertyType.SamplerState; } |
|||
} |
|||
|
|||
public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName + "HEEEEEEYYYYY", |
|||
m_PropType = PropertyType.Float, |
|||
// m_Float = filterMode[filter];
|
|||
}; |
|||
} |
|||
|
|||
*/ |
|||
|
|||
|
|||
|
|||
public void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
// GetVariableNameForSlot();
|
|||
} |
|||
|
|||
public override string GetVariableNameForSlot(int slotId) |
|||
{ |
|||
// var slot = FindSlot<MaterialSlot>(slotId);
|
|||
//if (slot == null)
|
|||
// throw new ArgumentException(string.Format("Attempting to use MaterialSlot({0}) on node of type {1} where this slot can not be found", slotId, this), "slotId");
|
|||
|
|||
return GetVariableNameForNode(); |
|||
} |
|||
|
|||
//my_linear_repeat_sampler
|
|||
public override string GetVariableNameForNode() |
|||
{ |
|||
return "my" + filterMode[filter] + wrapMode[wrap] + "_sampler"; |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5fe2c333e043511478cc507ee61a8c21 |
|||
timeCreated: 1495658099 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System; |
|||
using System.Collections.Generic; |
|||
using System.Linq; |
|||
#if UNITY_EDITOR
|
|||
using UnityEditor; |
|||
#endif
|
|||
using UnityEngine.Graphing; |
|||
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Input/Texture/Texture Sampler")] |
|||
public class TextureSamplerNode : PropertyNode, IGeneratesBodyCode, IMayRequireMeshUV |
|||
{ |
|||
private const string kTextureAssetName = "Texture Asset"; |
|||
private const string kUVSlotName = "UV"; |
|||
private const string kSamplerName = "Sampler"; |
|||
protected const string kOutputSlotRGBAName = "RGBA"; |
|||
|
|||
public const int TextureAssetSlotId = 0; |
|||
public const int UVSlotId = 1; |
|||
public const int SamplerSlotId = 2; |
|||
public const int OutputSlotRGBAId = 3; |
|||
|
|||
[SerializeField] |
|||
private string m_SerializedTexture; |
|||
|
|||
[SerializeField] |
|||
private TextureType m_TextureType; |
|||
|
|||
[Serializable] |
|||
private class TextureHelper |
|||
{ |
|||
public Texture2D texture; |
|||
} |
|||
|
|||
public override bool hasPreview { get { return true; } } |
|||
|
|||
#if UNITY_EDITOR
|
|||
public Texture2D defaultTexture |
|||
{ |
|||
get |
|||
{ |
|||
if (string.IsNullOrEmpty(m_SerializedTexture)) |
|||
return null; |
|||
|
|||
var tex = new TextureHelper(); |
|||
EditorJsonUtility.FromJsonOverwrite(m_SerializedTexture, tex); |
|||
return tex.texture; |
|||
} |
|||
set |
|||
{ |
|||
if (defaultTexture == value) |
|||
return; |
|||
|
|||
var tex = new TextureHelper(); |
|||
tex.texture = value; |
|||
m_SerializedTexture = EditorJsonUtility.ToJson(tex, true); |
|||
|
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Node); |
|||
} |
|||
} |
|||
} |
|||
#else
|
|||
public Texture2D defaultTexture {get; set; } |
|||
#endif
|
|||
|
|||
public TextureType textureType |
|||
{ |
|||
get { return m_TextureType; } |
|||
set |
|||
{ |
|||
if (m_TextureType == value) |
|||
return; |
|||
|
|||
|
|||
m_TextureType = value; |
|||
if (onModified != null) |
|||
{ |
|||
onModified(this, ModificationScope.Graph); |
|||
} |
|||
} |
|||
} |
|||
|
|||
public TextureSamplerNode() |
|||
{ |
|||
name = "TextureSamplerNode"; |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
public sealed override void UpdateNodeAfterDeserialization() |
|||
{ |
|||
AddSlot(new MaterialSlot(TextureAssetSlotId, kTextureAssetName, kTextureAssetName, SlotType.Input, SlotValueType.Texture2D, Vector4.zero, false)); |
|||
AddSlot(new MaterialSlot(UVSlotId, kUVSlotName, kUVSlotName, SlotType.Input, SlotValueType.Vector2, Vector4.zero, false)); |
|||
AddSlot(new MaterialSlot(SamplerSlotId, kSamplerName, kSamplerName, SlotType.Input, SlotValueType.SamplerState, Vector4.zero, false)); |
|||
AddSlot(new MaterialSlot(OutputSlotRGBAId, kOutputSlotRGBAName, kOutputSlotRGBAName, SlotType.Output, SlotValueType.Vector4, Vector4.zero)); |
|||
RemoveSlotsNameNotMatching(validSlots); |
|||
} |
|||
|
|||
protected int[] validSlots |
|||
{ |
|||
get { return new[] { OutputSlotRGBAId, SamplerSlotId, UVSlotId, TextureAssetSlotId }; } |
|||
} |
|||
|
|||
// Node generations
|
|||
public virtual void GenerateNodeCode(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
|
|||
//Texture input slot
|
|||
var textureSlot = FindInputSlot<MaterialSlot>(TextureAssetSlotId); |
|||
var textureAssetName = ""; |
|||
var edgesTexture = owner.GetEdges(textureSlot.slotReference).ToList(); |
|||
|
|||
if (edgesTexture.Count > 0) |
|||
{ |
|||
var edge = edgesTexture[0]; |
|||
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid); |
|||
textureAssetName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.Texture2D, true); |
|||
} |
|||
|
|||
//UV input slot
|
|||
var uvSlot = FindInputSlot<MaterialSlot>(UVSlotId); |
|||
var uvName = string.Format("{0}.xy", UVChannel.uv0.GetUVName()); |
|||
if (uvSlot == null) |
|||
return; |
|||
|
|||
var edgesUV = owner.GetEdges(uvSlot.slotReference).ToList(); |
|||
|
|||
if (edgesUV.Count > 0) |
|||
{ |
|||
var edge = edgesUV[0]; |
|||
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid); |
|||
uvName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.Vector2, true); |
|||
} |
|||
|
|||
|
|||
//Sampler input slot
|
|||
var samplerSlot = FindInputSlot<MaterialSlot>(SamplerSlotId); |
|||
var samplerName = "my_linear_repeat_sampler"; |
|||
|
|||
if (samplerSlot == null) |
|||
return; |
|||
|
|||
var edgesSampler = owner.GetEdges(samplerSlot.slotReference).ToList(); |
|||
|
|||
if (edgesSampler.Count > 0) |
|||
{ |
|||
var edge = edgesSampler[0]; |
|||
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid); |
|||
samplerName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.SamplerState, true); |
|||
} |
|||
|
|||
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForNode() + "_Uniform = " + precision + "4(0,0,0,0);", true); |
|||
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", true); |
|||
string body = textureAssetName + ".Sample(" + samplerName + ", " + uvName + ");"; |
|||
if (m_TextureType == TextureType.Bump) |
|||
body = precision + "4(UnpackNormal(" + body + "), 0)"; |
|||
|
|||
visitor.AddShaderChunk(GetVariableNameForNode() + "_Uniform" + " = " + body, true); |
|||
|
|||
visitor.AddShaderChunk("#endif", true); |
|||
} |
|||
|
|||
// Properties
|
|||
public override void GeneratePropertyBlock(PropertyGenerator visitor, GenerationMode generationMode) |
|||
{ /* |
|||
visitor.AddShaderProperty( |
|||
new TexturePropertyChunk( |
|||
propertyName, |
|||
description, |
|||
defaultTexture, m_TextureType, |
|||
PropertyChunk.HideState.Visible, |
|||
exposedState == ExposedState.Exposed ? |
|||
TexturePropertyChunk.ModifiableState.Modifiable |
|||
: TexturePropertyChunk.ModifiableState.NonModifiable)); |
|||
*/ |
|||
} |
|||
|
|||
public override void GeneratePropertyUsages(ShaderGenerator visitor, GenerationMode generationMode) |
|||
{ |
|||
|
|||
//Sampler input slot
|
|||
var samplerSlot = FindInputSlot<MaterialSlot>(SamplerSlotId); |
|||
var samplerName = "my_linear_repeat_sampler"; |
|||
|
|||
if (samplerSlot == null) |
|||
return; |
|||
|
|||
var edgesSampler = owner.GetEdges(samplerSlot.slotReference).ToList(); |
|||
|
|||
if (edgesSampler.Count > 0) |
|||
{ |
|||
var edge = edgesSampler[0]; |
|||
var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid); |
|||
samplerName = ShaderGenerator.AdaptNodeOutput(fromNode, edge.outputSlot.slotId, ConcreteSlotValueType.SamplerState, true); |
|||
} |
|||
|
|||
visitor.AddShaderChunk("#ifdef UNITY_COMPILER_HLSL", false); |
|||
visitor.AddShaderChunk(samplerSlot.valueType + " " + samplerName + ";", true); |
|||
visitor.AddShaderChunk("#endif", false); |
|||
} |
|||
|
|||
|
|||
public override PreviewProperty GetPreviewProperty() |
|||
{ |
|||
return new PreviewProperty |
|||
{ |
|||
m_Name = propertyName, |
|||
m_PropType = PropertyType.Texture, |
|||
m_Texture = defaultTexture |
|||
}; |
|||
} |
|||
|
|||
public override PropertyType propertyType { get { return PropertyType.Texture; } } |
|||
|
|||
public bool RequiresMeshUV(UVChannel channel) |
|||
{ |
|||
if (channel != UVChannel.uv0) |
|||
{ |
|||
return false; |
|||
} |
|||
|
|||
var uvSlot = FindInputSlot<MaterialSlot>(UVSlotId); |
|||
if (uvSlot == null) |
|||
return true; |
|||
|
|||
var edges = owner.GetEdges(uvSlot.slotReference).ToList(); |
|||
return edges.Count == 0; |
|||
} |
|||
|
|||
//prevent validation errors when a sampler2D input is missing
|
|||
//use on any input requiring a TextureAssetNode
|
|||
public override void ValidateNode() |
|||
{ |
|||
base.ValidateNode(); |
|||
var slot = FindInputSlot<MaterialSlot>(TextureAssetSlotId); |
|||
if (slot == null) |
|||
return; |
|||
|
|||
var edges = owner.GetEdges(slot.slotReference).ToList(); |
|||
hasError |= edges.Count == 0; |
|||
} |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 5ca9d434229e11f44888abcbf66062a5 |
|||
timeCreated: 1495637741 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
namespace UnityEngine.MaterialGraph |
|||
{ |
|||
[Title("Art/Adjustments/ColorBalance")] |
|||
public class ColorBalanceNode : FunctionNInNOut, IGeneratesFunction |
|||
{ |
|||
public ColorBalanceNode() |
|||
{ |
|||
name = "ColorBalance"; |
|||
AddSlot("Color", "inputColor", Graphing.SlotType.Input, SlotValueType.Vector4, Vector4.one); |
|||
AddSlot("AdjustRGB", "adjustRGB", Graphing.SlotType.Input, SlotValueType.Vector3, Vector3.zero); |
|||
AddSlot("RGBA", "finalColor", Graphing.SlotType.Output, SlotValueType.Vector4, Vector4.zero); |
|||
UpdateNodeAfterDeserialization(); |
|||
} |
|||
|
|||
protected override string GetFunctionName() |
|||
{ |
|||
return "unity_colorbalance_" + precision; |
|||
} |
|||
|
|||
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.Indent(); |
|||
|
|||
outputString.AddShaderChunk("float red = 0;", false); |
|||
outputString.AddShaderChunk("float green = 0;", false); |
|||
outputString.AddShaderChunk("float blue = 0;", false); |
|||
|
|||
outputString.AddShaderChunk("red = 1.00f / (1-adjustRGB.r) * inputColor.r;", false); |
|||
outputString.AddShaderChunk("green = 1.00f / (1-adjustRGB.g) * inputColor.g;", false); |
|||
outputString.AddShaderChunk("blue = 1.00f / (1-adjustRGB.b) * inputColor.b;", false); |
|||
|
|||
outputString.AddShaderChunk("red = clamp(red,0.00f,1.00f);", false); |
|||
outputString.AddShaderChunk("green = clamp(green,0.00f,1.00f);", false); |
|||
outputString.AddShaderChunk("blue = clamp(blue,0.00f,1.00f);", false); |
|||
|
|||
outputString.AddShaderChunk("finalColor.r = red;", false); |
|||
outputString.AddShaderChunk("finalColor.g = green;", false); |
|||
outputString.AddShaderChunk("finalColor.b = blue;", false); |
|||
outputString.AddShaderChunk("finalColor.a = inputColor.a;", false); |
|||
|
|||
outputString.Deindent(); |
|||
outputString.AddShaderChunk("}", false); |
|||
|
|||
visitor.AddShaderChunk(outputString.GetShaderString(0), true); |
|||
} |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 1e71a86c3ae7610479697effc1e8b703 |
|||
timeCreated: 1495705851 |
|||
licenseType: Pro |
|||
MonoImporter: |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
部分文件因为文件数量过多而无法显示
撰写
预览
正在加载...
取消
保存
Reference in new issue