浏览代码

convolve filter step2 (plug weights)

/main
Florent Guinier 8 年前
当前提交
1d20711e
共有 1 个文件被更改,包括 5 次插入11 次删除
  1. 16
      MaterialGraphProject/Assets/UnityShaderEditor/Runtime/Nodes/Art/Filters/ConvolutionFilterNode.cs

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


outputString.Indent();
outputString.AddShaderChunk("fixed4 fetches = fixed4(0,0,0,0);", false);
/*for (int i = 0; i < (kNumConvolutionVector4 - 1); ++i)
{
outputString.AddShaderChunk("fetches += tex2D(textSampler, baseUv) * weights" + i + ".x;", false);
outputString.AddShaderChunk("fetches += tex2D(textSampler, baseUv) * weights" + i + ".y;", false);
outputString.AddShaderChunk("fetches += tex2D(textSampler, baseUv) * weights" + i + ".z;", false);
outputString.AddShaderChunk("fetches += tex2D(textSampler, baseUv) * weights" + i + ".w;", false);
}
outputString.AddShaderChunk("fetches += tex2D(textSampler, baseUv) * weights6.x;", false);
outputString.AddShaderChunk("fetches *= weights6.w;", false);*/
outputString.AddShaderChunk("fixed weight = 1;", false);
string[] channelNames = { ".x", ".y", ".z", ".w" };
for(int col=0; col < 5; ++col)
{
for(int row=0; row < 5; ++row)

int vectorOffset = valueIndex % 4;
outputString.AddShaderChunk("fetches += tex2D(textSampler, baseUv + texelSize * fixed2("+(row-2)+","+(col-2)+"));", false);
outputString.AddShaderChunk("weight = weights" + vectorIndex + channelNames[vectorOffset] + ";", false);
outputString.AddShaderChunk("fetches += weight * tex2D(textSampler, baseUv + texelSize * fixed2("+(row-2)+","+(col-2)+"));", false);
outputString.AddShaderChunk("fetches /= 25;", false);
outputString.AddShaderChunk("fetches *= weights6.w;", false);
outputString.AddShaderChunk("return fetches;", false);
outputString.Deindent();

正在加载...
取消
保存