浏览代码

Add Dither node

/main
Matt Dean 7 年前
当前提交
c119f05e
共有 4 个文件被更改,包括 58 次插入0 次删除
  1. 8
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Filter.meta
  2. 39
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Filter/DitherNode.cs
  3. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Filter/DitherNode.cs.meta

8
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Filter.meta


fileFormatVersion: 2
guid: e005d19f5315e44bc9f50b3f6f8e50b2
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

39
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Filter/DitherNode.cs


using System.Reflection;
using UnityEngine;
using UnityEditor.Graphing;
namespace UnityEditor.ShaderGraph
{
[Title("Artistic", "Filter", "Dither")]
public class DitherNode : CodeFunctionNode
{
public DitherNode()
{
name = "Dither";
UpdateNodeAfterDeserialization();
}
protected override MethodInfo GetFunctionToConvert()
{
return GetType().GetMethod("Unity_Dither", BindingFlags.Static | BindingFlags.NonPublic);
}
static string Unity_Dither(
[Slot(0, Binding.None)] DynamicDimensionVector In,
[Slot(1, Binding.ScreenPosition)] Vector2 UV,
[Slot(2, Binding.None)] out DynamicDimensionVector Out)
{
return
@"
{
{precision}2 uv = (UV.xy / UV.w) * _ScreenParams.xy;
{precision} DITHER_THRESHOLDS[16] =
{
1.0 / 17.0, 9.0 / 17.0, 3.0 / 17.0, 11.0 / 17.0,
13.0 / 17.0, 5.0 / 17.0, 15.0 / 17.0, 7.0 / 17.0,
4.0 / 17.0, 12.0 / 17.0, 2.0 / 17.0, 10.0 / 17.0,
16.0 / 17.0, 8.0 / 17.0, 14.0 / 17.0, 6.0 / 17.0
};
uint index = (uint(uv.x) % 4) * 4 + uint(uv.y) % 4;
Out = In - DITHER_THRESHOLDS[index];
}";
}
}
}

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Filter/DitherNode.cs.meta


fileFormatVersion: 2
guid: 40b83fe632985494f96d2211c1963835
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存