浏览代码

Channel Mask node to Mask Field (prt 2)

/main
Matt Dean 7 年前
当前提交
29e04332
共有 2 个文件被更改,包括 7 次插入12 次删除
  1. 18
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Mask/ChannelMaskNode.cs
  2. 1
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ChannelEnumMaskControl.cs

18
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Data/Nodes/Artistic/Mask/ChannelMaskNode.cs


using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor.Graphing;
using UnityEditor.ShaderGraph.Drawing.Controls;

string GetFunctionName()
{
string channelSum;
if (channelMask == 0)
channelSum = "None";
else
string channelSum = "None";
if (channelMask != 0)
{
bool red = (channelMask & 1) != 0;
bool green = (channelMask & 2) != 0;

public TextureChannel channel;
[SerializeField]
private int m_ChannelMask = 0;
private int m_ChannelMask = -1;
[ChannelEnumMaskControl("Channel")]
[ChannelEnumMaskControl("Channels")]
public int channelMask
{
get { return m_ChannelMask; }

void ValidateChannelCount()
{
int channelCount = SlotValueHelper.GetChannelCount(FindSlot<MaterialSlot>(InputSlotId).concreteValueType);
if (channelMask > 1 << channelCount)
channelMask = 0;
if (channelMask > 1 << channelCount - 1)
channelMask = -1;
}
string GetFunctionPrototype(string argIn, string argOut)

public void GenerateNodeFunction(FunctionRegistry registry, GenerationMode generationMode)
{
ValidateChannelCount();
registry.ProvideFunction(GetFunctionName(), s =>
{
int channelCount = SlotValueHelper.GetChannelCount(FindSlot<MaterialSlot>(InputSlotId).concreteValueType);

bool green = (channelMask & 2) != 0;
bool blue = (channelMask & 4) != 0;
bool alpha = (channelMask & 8) != 0;
Debug.Log(red + " " + green + " " + blue + " " + alpha);
switch (channelCount)
{

1
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Controls/ChannelEnumMaskControl.cs


using (var changeCheckScope = new EditorGUI.ChangeCheckScope())
{
int channelCount = SlotValueHelper.GetChannelCount(m_Node.FindSlot<MaterialSlot>(m_SlotId).concreteValueType);
var enumEntryCount = m_PropertyInfo.GetValue(m_Node, null);
string[] enumEntryNames = Enum.GetNames(typeof(TextureChannel));
string[] popupEntries = new string[channelCount];
for (int i = 0; i < popupEntries.Length; i++)

正在加载...
取消
保存