浏览代码

Convolution filter : fix preview

/main
Florent Guinier 7 年前
当前提交
ff74ebd2
共有 2 个文件被更改,包括 13 次插入11 次删除
  1. 11
      MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ConvolutionFilterNodePresenter.cs
  2. 13
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Filters/ConvolutionFilterNode.cs

11
MaterialGraphProject/Assets/UnityShaderEditor/Editor/Drawing/Presenters/ConvolutionFilterNodePresenter.cs


EditorGUILayout.BeginVertical();
EditorGUI.BeginChangeCheck();
KernelPresets kernelPresets = KernelPresets.Presets;
kernelPresets = (KernelPresets)EditorGUILayout.EnumPopup(kernelPresets);
ApplyPreset(kernelPresets, ref values, ref divisor);
for (int col = 0; col < 5; ++col)
{
EditorGUILayout.BeginHorizontal();

EditorGUILayout.Space();
divisor = EditorGUILayout.FloatField("Divisor", divisor);
EditorGUILayout.Space();
KernelPresets kernelPresets = KernelPresets.Presets;
kernelPresets = (KernelPresets)EditorGUILayout.EnumPopup(kernelPresets);
ApplyPreset(kernelPresets, ref values, ref divisor);
EditorGUILayout.EndVertical();

13
MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Filters/ConvolutionFilterNode.cs


public void SetConvolutionDivisor(float value)
{
if (value == m_ConvolutionFilter[6].w)
return;
if (onModified != null)
onModified(this, ModificationScope.Node);
}
public float GetConvolutionWeight(int row, int col)

string propGuid = guid.ToString().Replace("-", "_");
for (int i = 0; i < kNumConvolutionVector4; ++i)
{
visitor.AddShaderChunk(precision + " " + GetPropertyName(i, propGuid) + ";", true);
visitor.AddShaderChunk(precision + "4 " + GetPropertyName(i, propGuid) + ";", true);
}
}
}

string samplerName = GetSlotValue(InputSlot1Id, generationMode);
//uv
//string input2Value = GetSlotValue(InputSlot2Id, generationMode);
var uvSlot = FindInputSlot<MaterialSlot>(InputSlot2Id);
if (uvSlot == null)
return;

//texelSize
string texelSize = samplerName + "_TexelSize.xy";
visitor.AddShaderChunk(precision + "4 " + GetVariableNameForSlot(OutputSlotId) + " = " + GetFunctionCallBody(samplerName, baseUV, texelSize) + ";", true);

int valueIndex = col * 5 + row;
int vectorIndex = valueIndex / 4;
int vectorOffset = valueIndex % 4;
outputString.AddShaderChunk("fetches *= weights6.w;", false);
outputString.AddShaderChunk("fetches /= weights6.w;", false);
outputString.AddShaderChunk("return fetches;", false);
outputString.Deindent();

正在加载...
取消
保存