浏览代码

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

/main
bfogerty 8 年前
当前提交
6259f4aa
共有 6 个文件被更改,包括 77 次插入74 次删除
  1. 21
      MaterialGraphProject/Assets/Andre/CubemapNode.cs
  2. 4
      MaterialGraphProject/Assets/Andre/New Material.mat
  3. 2
      MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph
  4. 8
      MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs
  5. 114
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader
  6. 2
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta

21
MaterialGraphProject/Assets/Andre/CubemapNode.cs


if (lodID == null)
return;
var uvName = string.Format("{0}.xyz", UVChannel.uv0.GetUVName());
var uvName = "reflect(-worldSpaceViewDirection, worldSpaceNormal).xyz";
var lodValue = lodID.currentValue.x.ToString ();
var edgesUV = owner.GetEdges(uvSlot.slotReference).ToList();
var edgesLOD = owner.GetEdges (lodID.slotReference).ToList ();

var fromNode = owner.GetNodeFromGuid<AbstractMaterialNode>(edge.outputSlot.nodeGuid);
lodValue = GetSlotValue (edge.inputSlot.slotId, GenerationMode.ForReals);
}
string body = "texCUBElod (" + propertyName + ", " + precision + "4(reflect(-IN.worldViewDir, normalize(IN.worldNormal)).xyz," + lodValue + "))";
//reflect(-IN.worldViewDir, normalize(IN.worldNormal)).xyz
string body = "texCUBElod (" + propertyName + ", " + precision + "4(" + uvName + "," + lodValue + "))";
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForNode() + " = " + body + ";", true);
}

{
return true;
}
/*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;
}*/
}
}

4
MaterialGraphProject/Assets/Andre/New Material.mat


m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- Texture_5537060b_db74_4900_8f2b_178ba97b7f11_Uniform:
m_Texture: {fileID: 2800000, guid: 506344993fb95dd46856ac1f9f5a5be0, type: 3}
m_Scale: {x: 1, y: 1}
m_Texture: {fileID: 2800000, guid: 6e8d12f68bae2294da814f9d4c81b29a, type: 3}
m_Scale: {x: 1, y: 2}
m_Offset: {x: 0, y: 0}
- _BumpMap:
m_Texture: {fileID: 0}

2
MaterialGraphProject/Assets/Andre/New Shader Graph.ShaderGraph
文件差异内容过多而无法显示
查看文件

8
MaterialGraphProject/Assets/Matt&Andre/RemapNode.cs


public class RemapNode : AbstractMaterialNode, IGeneratesBodyCode, IGeneratesFunction
{
protected const string kInputSlot1ShaderName = "Input1";
protected const string kInputSlot2ShaderName = "InMin";
protected const string kInputSlot3ShaderName = "InMax";
protected const string kInputSlot2ShaderName = "InMinMax";
protected const string kInputSlot3ShaderName = "OutMinMax";
protected const string kOutputSlotShaderName = "Output";
public const int InputSlot1Id = 0;

protected virtual string GetInputSlot2Name()
{
return "InMin/Max";
return "InMinMax";
return "OutMin/Max";
return "OutMinMax";
}
protected virtual string GetOutputSlotName()

114
MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader


Shader "Unlit/NewUnlitShader"
Shader "Graph/UnityEngine.MaterialGraph.MetallicMasterNodefb4e5d27-b55b-4c39-84a8-ae6dcd6d7631"
Properties
Properties
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
[NonModifiableTextureData] Texture_5537060b_db74_4900_8f2b_178ba97b7f11_Uniform("", 2D) = "white" {}
Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9_Uniform("", Cube) = "" {}
Pass
}
SubShader
{
Tags
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
// make fog work
#pragma multi_compile_fog
#include "UnityCG.cginc"
"RenderType"="Opaque"
"Queue"="Geometry"
}
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
Blend One Zero
struct v2f
{
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
float4 vertex : SV_POSITION;
};
Cull Back
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// sample the texture
fixed4 col = tex2D(_MainTex, i.uv);
// apply fog
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}
ENDCG
ZTest LEqual
ZWrite On
LOD 200
CGPROGRAM
#pragma target 3.0
#pragma surface surf Standard vertex:vert
#pragma glsl
#pragma debug
inline float unity_remap_float (float arg1, float2 arg2, float2 arg3)
{
return arg1 * ((arg3.y - arg3.x) / (arg2.y - arg2.x)) + arg3.x;
sampler2D Texture_5537060b_db74_4900_8f2b_178ba97b7f11_Uniform;
samplerCUBE Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9_Uniform;
struct Input
{
float4 color : COLOR;
half4 meshUV0;
float3 worldViewDir;
float3 worldNormal;
};
void vert (inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
o.meshUV0 = v.texcoord;
void surf (Input IN, inout SurfaceOutputStandard o)
{
half4 uv0 = IN.meshUV0;
float3 worldSpaceViewDirection = IN.worldViewDir;
float3 worldSpaceNormal = normalize(IN.worldNormal);
float4 Texture_5537060b_db74_4900_8f2b_178ba97b7f11 = tex2D (Texture_5537060b_db74_4900_8f2b_178ba97b7f11_Uniform, uv0.xy);
float Remap_26b4b7a4_1c55_4c03_9830_fc5d53b3a504_Output = unity_remap_float (Texture_5537060b_db74_4900_8f2b_178ba97b7f11.r, float2 (0,1), float2 (7,-2));
float4 Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9 = texCUBElod (Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9_Uniform, float4(reflect(-IN.worldViewDir, normalize(IN.worldNormal)).xyz,Remap_26b4b7a4_1c55_4c03_9830_fc5d53b3a504_Output));
o.Emission = Cubemap_ee09e335_3be2_46ee_9d59_ce2673aeedf9;
}
ENDCG
}
FallBack "Diffuse"
}

2
MaterialGraphProject/Assets/UnityShaderEditor/Editor/HelperShader.shader.meta


fileFormatVersion: 2
guid: 9ab5e16c2083a4fe689209a8c1ae425e
timeCreated: 1495489744
timeCreated: 1495490387
licenseType: Pro
ShaderImporter:
defaultTextures: []

正在加载...
取消
保存