vault backup: 2024-07-01 12:01:30

This commit is contained in:
BlueRose 2024-07-01 12:01:30 +08:00
parent 8a7604de55
commit a7261d80da
3 changed files with 649 additions and 64 deletions

View File

@ -280,8 +280,6 @@ return Result;
- M_Outline_V01 & M_Outline_V02
- **WPO**引脚逻辑:**描边粗细控制部分逻辑**和V01基本相同除了V01有Minimum Line Thickness这个粗细最小值。剩下的其他逻辑一模一样。
- ***M_Outline_V03***
- 主要实现功能:
-
- **OpacityMask**引脚逻辑与V01、V02略有不同。会将BaseTexture贴图的a通道乘以HideMask然而并没有材质使用。
- **WPO**引脚逻辑V03版本的**描边粗细控制部分逻辑**做了更加合理的改动。VertexColor的RGB通道代替Backface外扩时的VertexNormalWS这样不会影响光照效果。
- MaterialInstance

View File

@ -0,0 +1,639 @@
global proc VertexColorToNormalCommand(int $num)
{
if($num == 1)
{
string $colorSetsMenuItems[] = `optionMenu -q -ill VertexColorToNormalCurrentColorSet_optionMenu1`;
if(size($colorSetsMenuItems))
{
deleteUI $colorSetsMenuItems;
}
string $allColorSets[] = `polyColorSet -q -acs`;
if(size($allColorSets)>0)
{
for($name in $allColorSets)
{
menuItem -label $name -p VertexColorToNormalCurrentColorSet_optionMenu1 ;
}
}
string $CurrentColorSets[] = `polyColorSet -q -ccs`;
if(size($CurrentColorSets))
{
optionMenu -e -v $CurrentColorSets[0] VertexColorToNormalCurrentColorSet_optionMenu1;
}
}
if($num == 2)
{
string $setName = `textField -q -tx VertexColorToNormalCreateColorSet_textField1`;
if(size($setName))
{
polyColorSet -cr -cla 0 -rpt RGBA -cs $setName;
}
else
{
polyColorSet -cr -cla 0 -rpt RGBA -cs "colorSet" ;
}
VertexColorToNormalCommand 1;
}
if($num == 3)
{
string $currentVtxColorSet = `optionMenu -q -v VertexColorToNormalCurrentColorSet_optionMenu1`;
if(size($currentVtxColorSet))
{
polyColorSet -delete -colorSet $currentVtxColorSet;
VertexColorToNormalCommand 1;
}
}
if($num == 4)
{
if(size(`ls -sl`))
{
PolySelectConvert 3;
}
string $selVtx[] = `ls -sl -fl`;
progressWindow -t "执行进度:" -pr 0 -st "当前进度: 0%" -ii 1 -max (size($selVtx));
//for($name in $selVtx)
for($i=0;$i<size($selVtx);$i++)
{
if ( `progressWindow -query -isCancelled` ) break;
if ( `progressWindow -query -progress` >= (size($selVtx)) ) break;
float $vtxColor[] = `polyColorPerVertex -q -rgb $selVtx[$i]`;
polyNormalPerVertex -xyz $vtxColor[0] $vtxColor[1] $vtxColor[2] $selVtx[$i];
progressWindow -e -pr $i -st ("当前进度: "+($i/(size($selVtx)))+"%");
}
progressWindow -ep;
}
if($num == 5)
{
if(size(`ls -sl`))
{
PolySelectConvert 3;
}
string $selVtx[] = `ls -sl -fl`;
progressWindow -t "执行进度:" -pr 0 -st "当前进度: 0%" -ii 1 -max (size($selVtx));
//for($name in $selVtx)
for($i=0;$i<size($selVtx);$i++)
{
if ( `progressWindow -query -isCancelled` ) break;
if ( `progressWindow -query -progress` >= (size($selVtx)) ) break;
float $vtxVector[] = `polyNormalPerVertex -q -xyz $selVtx[$i]`;
polyColorPerVertex -rgb $vtxVector[0] $vtxVector[1] $vtxVector[2] $selVtx[$i];
progressWindow -e -pr $i -st ("当前进度: "+($i/(size($selVtx)))+"%");
}
progressWindow -ep;
}
}
/*
global proc smoothNomalCommand()
{
if(size(`ls -sl`))
{
PolySelectConvert 3;
}
string $selvtx[] = `ls -sl -fl`;
float $smoothNum = `floatSliderGrp -q -v nomalSmoothSet_floatSliderGrp1`;
for($i=0;$i<size($selvtx);$i++)
{
select -r $selvtx[$i];
polySelectConstraint -pp 1 -t 0x0001;
string $result[] = `ls -sl -fl`;
float $interimVector[];
for($ii=0;$ii<size($result);$ii++)
{
float $interimVector1[] = `polyNormalPerVertex -q -xyz $result[$ii]`;
$interimVector[0] = $interimVector[0] + $interimVector1[0];
$interimVector[1] = $interimVector[1] + $interimVector1[1];
$interimVector[2] = $interimVector[2] + $interimVector1[2];
}
$interimVector[0] = $interimVector[0]/size($result);
$interimVector[1] = $interimVector[1]/size($result);
$interimVector[2] = $interimVector[2]/size($result);
for($ii=0;$ii<size($result);$ii++)
{
float $interimVector1[] = `polyNormalPerVertex -q -xyz $result[$ii]`;
polyNormalPerVertex -xyz ($interimVector[0]*$smoothNum + $interimVector1[0]*(1-$smoothNum))
($interimVector[1]*$smoothNum + $interimVector1[1]*(1-$smoothNum))
($interimVector[2]*$smoothNum + $interimVector1[2]*(1-$smoothNum)) $result[$ii];
}
}
select -r $selvtx;
}
*/
global proc smoothNomalCommand()
{
if(size(`ls -sl`))
{
PolySelectConvert 3;
}
string $selvtx[] = `ls -sl -fl`;
float $smoothNum = `floatSliderGrp -q -v nomalSmoothSet_floatSliderGrp1`;
progressWindow -t "执行进度:" -pr 0 -st "当前进度: 0%" -ii 1 -max (size($selvtx));
for($i=0;$i<size($selvtx);$i++)
{
if ( `progressWindow -query -isCancelled` ) break;
if ( `progressWindow -query -progress` >= (size($selvtx)) ) break;
select -r $selvtx[$i];
polySelectConstraint -pp 1 -t 0x0001;
string $result[] = `ls -sl -fl`;
float $interimVector[];
for($ii=0;$ii<size($result);$ii++)
{
float $interimVector1[] = `polyNormalPerVertex -q -xyz $result[$ii]`;
float $interimAveVector[] = `getAverageNormal $interimVector1`;
$interimVector[0] = $interimVector[0] + $interimAveVector[0];
$interimVector[1] = $interimVector[1] + $interimAveVector[1];
$interimVector[2] = $interimVector[2] + $interimAveVector[2];
}
$interimVector[0] = $interimVector[0]/size($result);
$interimVector[1] = $interimVector[1]/size($result);
$interimVector[2] = $interimVector[2]/size($result);
float $interimVector1[] = `polyNormalPerVertex -q -xyz $selvtx[$i]`;
float $interimAveVector1[] = `getAverageNormal $interimVector1`;
polyNormalPerVertex -xyz ($interimVector[0]*$smoothNum + $interimAveVector1[0]*(1-$smoothNum))
($interimVector[1]*$smoothNum + $interimAveVector1[1]*(1-$smoothNum))
($interimVector[2]*$smoothNum + $interimAveVector1[2]*(1-$smoothNum)) $selvtx[$i];
progressWindow -e -pr $i -st ("当前进度: "+($i/(size($selvtx)))+"%");
}
progressWindow -ep;
select -r $selvtx;
}
global proc float [] getAverageNormal(float $getNormalXYZ[])
{
float $interimAveVector1[];
clear $interimAveVector1;
for($i=0;$i<size($getNormalXYZ);$i+=3)
{
$interimAveVector1[0] += $getNormalXYZ[$i];
$interimAveVector1[1] += $getNormalXYZ[$i+1];
$interimAveVector1[2] += $getNormalXYZ[$i+2];
}
$interimAveVector1[0] = $interimAveVector1[0]*3/size($getNormalXYZ);
$interimAveVector1[1] = $interimAveVector1[1]*3/size($getNormalXYZ);
$interimAveVector1[2] = $interimAveVector1[2]*3/size($getNormalXYZ);
return $interimAveVector1;
}
global proc nomalOffsetSpherizeCommand(int $num)
{
if(size(`ls -sl`))
{
PolySelectConvert 3;
}
string $sel[] = `ls -sl -fl`;
float $nomalOffsetSpherizeValue = `floatSliderGrp -q -v nomalOffsetSpherizeNum_floatSliderGrp1`;
float $worldPossition[];
if(`objExists "nomalSpherizeLocator"`)
{
$worldPossition = `xform -q -t nomalSpherizeLocator`;
}
if($num == 1)
{
float $possition[];
if(`objExists "nomalSpherizeLocator"`)
{
delete nomalSpherizeLocator;
}
if(size($sel))
{
string $ncluster[] = `newCluster " -envelope 1"`;
string $nclusterShapes[] = `listRelatives -s $ncluster[1]`;
$possition = `getAttr cluster1HandleShape.origin`;
delete $ncluster;
}
spaceLocator -n "nomalSpherizeLocator";
xform -t $possition[0] $possition[1] $possition[2] nomalSpherizeLocator;
}
else if($num == 11)
{
if(`objExists "nomalSpherizeLocator"`)
{
delete nomalSpherizeLocator;
}
}
else if($num == 2)
{
progressWindow -t "执行进度:" -pr 0 -st "当前进度: 0%" -ii 1 -max (size($sel));
for($i=0;$i<size($sel);$i++)
{
if ( `progressWindow -query -isCancelled` ) break;
if ( `progressWindow -query -progress` >= (size($sel)) ) break;
float $pointPossition[] = `pointPosition -w $sel[$i]`;
float $bigVector[],$SpherizeVector[];
$bigVector[0] = $pointPossition[0] - $worldPossition[0];
$bigVector[1] = $pointPossition[1] - $worldPossition[1];
$bigVector[2] = $pointPossition[2] - $worldPossition[2];
float $max;
if(abs($bigVector[0])>abs($bigVector[1]))
{
$max = abs($bigVector[0]);
}
else
{
$max = abs($bigVector[1]);
}
if($max<abs($bigVector[2]))
{
$max = abs($bigVector[2]);
}
$SpherizeVector[0] = $bigVector[0]/$max;
$SpherizeVector[1] = $bigVector[1]/$max;
$SpherizeVector[2] = $bigVector[2]/$max;
float $oldVector[] = `polyNormalPerVertex -q -xyz $sel[$i]`;
polyNormalPerVertex -xyz ($oldVector[0]*(1-$nomalOffsetSpherizeValue)+$SpherizeVector[0]*$nomalOffsetSpherizeValue)
($oldVector[1]*(1-$nomalOffsetSpherizeValue)+$SpherizeVector[1]*$nomalOffsetSpherizeValue)
($oldVector[2]*(1-$nomalOffsetSpherizeValue)+$SpherizeVector[2]*$nomalOffsetSpherizeValue) $sel[$i];
progressWindow -e -pr $i -st ("当前进度: "+($i/(size($sel)))+"%");
}
progressWindow -ep;
}
else if($num == 3)
{
progressWindow -t "执行进度:" -pr 0 -st "当前进度: 0%" -ii 1 -max (size($sel));
for($i=0;$i<size($sel);$i++)
{
if ( `progressWindow -query -isCancelled` ) break;
if ( `progressWindow -query -progress` >= (size($sel)) ) break;
float $pointPossition[] = `pointPosition -w $sel[$i]`;
float $bigVector[],$SpherizeVector[];
$bigVector[0] = $pointPossition[0] - $worldPossition[0];
$bigVector[1] = $pointPossition[1] - $worldPossition[1];
$bigVector[2] = $pointPossition[2] - $worldPossition[2];
float $max;
if(abs($bigVector[0])>abs($bigVector[1]))
{
$max = abs($bigVector[0]);
}
else
{
$max = abs($bigVector[1]);
}
if($max<abs($bigVector[2]))
{
$max = abs($bigVector[2]);
}
$SpherizeVector[0] = $bigVector[0]/$max;
$SpherizeVector[1] = $bigVector[1]/$max;
$SpherizeVector[2] = $bigVector[2]/$max;
float $oldVector[] = `polyNormalPerVertex -q -xyz $sel[$i]`;
polyNormalPerVertex -xyz ($oldVector[0]-$SpherizeVector[0]*$nomalOffsetSpherizeValue)
($oldVector[1]-$SpherizeVector[1]*$nomalOffsetSpherizeValue)
($oldVector[2]-$SpherizeVector[2]*$nomalOffsetSpherizeValue) $sel[$i];
progressWindow -e -pr $i -st ("当前进度: "+($i/(size($sel)))+"%");
}
progressWindow -ep;
}
}
global proc nomalOffsetxyzCommand(int $num)
{
int $EditMode = `radioButtonGrp -q -sl nomalOffset_radioButtonGrp1`;
float $EditValue = `floatSliderGrp -q -v nomalOffsetNum_floatSliderGrp1`;
if(size(`ls -sl`))
{
PolySelectConvert 3;
}
string $sel[] = `ls -sl -fl`;
if($num == 1)
{
progressWindow -t "执行进度:" -pr 0 -st "当前进度: 0%" -ii 1 -max (size($sel));
for($i=0;$i<size($sel);$i++)
{
if ( `progressWindow -query -isCancelled` ) break;
if ( `progressWindow -query -progress` >= (size($sel)) ) break;
if(`match ".vtx" $sel[$i]`!=".vtx")
{
warning -n "===需要选择模型点再进行操作===";
break;
}
float $lkdasfljasdfje[] = `polyNormalPerVertex -q -xyz $sel[$i]`;
if($EditMode == 1)
{
polyNormalPerVertex -xyz ($lkdasfljasdfje[0] + $EditValue) $lkdasfljasdfje[1] $lkdasfljasdfje[2] $sel[$i];
}
else if($EditMode == 2)
{
polyNormalPerVertex -xyz ($lkdasfljasdfje[0] * (1+$EditValue)) $lkdasfljasdfje[1] $lkdasfljasdfje[2] $sel[$i];
}
progressWindow -e -pr $i -st ("当前进度: "+($i/(size($sel)))+"%");
}
progressWindow -ep;
}
else if($num == 2)
{
progressWindow -t "执行进度:" -pr 0 -st "当前进度: 0%" -ii 1 -max (size($sel));
for($i=0;$i<size($sel);$i++)
{
if ( `progressWindow -query -isCancelled` ) break;
if ( `progressWindow -query -progress` >= (size($sel)) ) break;
if(`match ".vtx" $sel[$i]`!=".vtx")
{
warning -n "===需要选择模型点再进行操作===";
break;
}
float $lkdasfljasdfje[] = `polyNormalPerVertex -q -xyz $sel[$i]`;
if($EditMode == 1)
{
polyNormalPerVertex -xyz $lkdasfljasdfje[0] ($lkdasfljasdfje[1] + $EditValue) $lkdasfljasdfje[2] $sel[$i];
}
else if($EditMode == 2)
{
polyNormalPerVertex -xyz $lkdasfljasdfje[0] ($lkdasfljasdfje[1] * (1+$EditValue)) $lkdasfljasdfje[2] $sel[$i];
}
progressWindow -e -pr $i -st ("当前进度: "+($i/(size($sel)))+"%");
}
progressWindow -ep;
}
else if($num == 3)
{
progressWindow -t "执行进度:" -pr 0 -st "当前进度: 0%" -ii 1 -max (size($sel));
for($i=0;$i<size($sel);$i++)
{
if ( `progressWindow -query -isCancelled` ) break;
if ( `progressWindow -query -progress` >= (size($sel)) ) break;
if(`match ".vtx" $sel[$i]`!=".vtx")
{
warning -n "===需要选择模型点再进行操作===";
break;
}
float $lkdasfljasdfje[] = `polyNormalPerVertex -q -xyz $sel[$i]`;
if($EditMode == 1)
{
polyNormalPerVertex -xyz $lkdasfljasdfje[0] $lkdasfljasdfje[1] ($lkdasfljasdfje[2] + $EditValue) $sel[$i];
}
else if($EditMode == 2)
{
polyNormalPerVertex -xyz $lkdasfljasdfje[0] $lkdasfljasdfje[1] ($lkdasfljasdfje[2] * (1+$EditValue)) $sel[$i];
}
progressWindow -e -pr $i -st ("当前进度: "+($i/(size($sel)))+"%");
}
progressWindow -ep;
}
}
global proc EditVertixNomalUI()
{
if(`window -ex EditVertixNomalWin`)
{
deleteUI EditVertixNomalWin;
}
window -t "舞之动画法线编辑工具V1.0" EditVertixNomalWin;
window -e -wh 400 646 EditVertixNomalWin;
columnLayout -adj 1 -bgc 0.18 0.18 0.18 EditVertixNomalMain_columnLayout1;
separator -h 10 EditVertixNomal_separator0;
text -l "法线偏移" -bgc 0 0 0 nomalOffset_text1;
separator -h 10 EditVertixNomal_separator1;
formLayout -nd 100 nomalOffset_formLayout1;
radioButtonGrp -nrb 2 -l "算法" -la2 "加" "乘" -cal 1 "center" -sl 1 nomalOffset_radioButtonGrp1;
floatSliderGrp -l "幅度:" -f true -cal 1 "center"
-min -1.0 -max 1.0 -fmn -10.0 -fmx 10.0 -v 0.2
-s 0.01 nomalOffsetNum_floatSliderGrp1;
button -l "X" -c "nomalOffsetxyzCommand 1;" nomalOffsetx_button1;
button -l "Y" -c "nomalOffsetxyzCommand 2;" nomalOffsety_button1;
button -l "Z" -c "nomalOffsetxyzCommand 3;" nomalOffsetz_button1;
formLayout -e
-af nomalOffset_radioButtonGrp1 "left" 1
-af nomalOffset_radioButtonGrp1 "right" 1
-af nomalOffsetNum_floatSliderGrp1 "left" 1
-af nomalOffsetNum_floatSliderGrp1 "right" 1
-ac nomalOffsetNum_floatSliderGrp1 "top" 5 nomalOffset_radioButtonGrp1
-af nomalOffsetx_button1 "left" 1
-ap nomalOffsetx_button1 "right" 3 33
-ac nomalOffsetx_button1 "top" 5 nomalOffsetNum_floatSliderGrp1
-ac nomalOffsety_button1 "left" 3 nomalOffsetx_button1
-ap nomalOffsety_button1 "right" 3 66
-ac nomalOffsety_button1 "top" 5 nomalOffsetNum_floatSliderGrp1
-ac nomalOffsetz_button1 "left" 3 nomalOffsety_button1
-af nomalOffsetz_button1 "right" 1
-ac nomalOffsetz_button1 "top" 5 nomalOffsetNum_floatSliderGrp1
nomalOffset_formLayout1;
setParent EditVertixNomalMain_columnLayout1;
separator -h 10 EditVertixNomal_separator2;
text -l "辐射法线" -bgc 0 0 0 nomalOffsetSpherize_text1;
separator -h 10 EditVertixNomal_separator3;
formLayout -nd 100 nomalOffsetSpherize_formLayout1;
button -l "创建中心物体" -c "nomalOffsetSpherizeCommand 1" -ann "创建一个作为球心定位的定位器" createNormalCenter_button1;
button -l "删除中心物体" -c "nomalOffsetSpherizeCommand 11" deleteNormalCenter_button1;
floatSliderGrp -l "幅度:" -f true -cal 1 "center"
-min 0 -max 1.0 -fmn 0 -fmx 1 -v 0.2
-s 0.01 nomalOffsetSpherizeNum_floatSliderGrp1;
button -l "放射" -c "nomalOffsetSpherizeCommand 2" aggregationVertixNomal_button1;
button -l "聚拢" -c "nomalOffsetSpherizeCommand 3" dispersedVertixNomal_button1;
formLayout -e
-af createNormalCenter_button1 "left" 1
-ap createNormalCenter_button1 "right" 3 50
-ac deleteNormalCenter_button1 "left" 3 createNormalCenter_button1
-af deleteNormalCenter_button1 "right" 1
-af nomalOffsetSpherizeNum_floatSliderGrp1 "left" 1
-af nomalOffsetSpherizeNum_floatSliderGrp1 "right" 1
-ac nomalOffsetSpherizeNum_floatSliderGrp1 "top" 1 createNormalCenter_button1
-af aggregationVertixNomal_button1 "left" 1
-ap aggregationVertixNomal_button1 "right" 3 50
-ac aggregationVertixNomal_button1 "top" 1 nomalOffsetSpherizeNum_floatSliderGrp1
-ac dispersedVertixNomal_button1 "left" 3 aggregationVertixNomal_button1
-af dispersedVertixNomal_button1 "right" 1
-ac dispersedVertixNomal_button1 "top" 1 nomalOffsetSpherizeNum_floatSliderGrp1
nomalOffsetSpherize_formLayout1;
setParent EditVertixNomalMain_columnLayout1;
separator -h 10 EditVertixNomal_separator4;
text -l "平滑法线" -bgc 0 0 0 nomalSmoothSet_text1;
separator -h 10 EditVertixNomal_separator5;
formLayout -nd 100 nomalSmoothSet_formLayout1;
floatSliderGrp -l "幅度:" -f true -cal 1 "center"
-min 0 -max 1.0 -fmn 0 -fmx 1 -v 0.2
-s 0.01 nomalSmoothSet_floatSliderGrp1;
button -l "平滑法线" -c "smoothNomalCommand" nomalSmoothSet_button1;
formLayout -e
-af nomalSmoothSet_floatSliderGrp1 "left" 1
-af nomalSmoothSet_floatSliderGrp1 "right" 1
-af nomalSmoothSet_button1 "left" 1
-af nomalSmoothSet_button1 "right" 1
-ac nomalSmoothSet_button1 "top" 5 nomalSmoothSet_floatSliderGrp1
nomalSmoothSet_formLayout1;
setParent EditVertixNomalMain_columnLayout1;
separator -h 10 EditVertixNomal_separator6;
formLayout -nd 100 nomalOffsetReset_formLayout1;
button -l "重置" -c "polySetToFaceNormal" nomalOffsetReset_button1;
button -l "软化" -c "polyAverageNormal -d 0" nomalOffsetSmooth_button1;
button -l "显示法线" -c "polyOptions -dn 1 -pt" disPlayNormal_button1;
button -l "隐藏法线" -c "polyOptions -dn 0 -pt" hideNormal_button1;
floatSliderGrp -l "法线长度:" -f true -cal 1 "center"
-min 0 -max 10.0 -fmn 0 -fmx 10 -v 0.3
-s 0.01 -cc ("polyOptions -activeObjects -sizeNormal `floatSliderGrp -q -v nomalSizeSet_floatSliderGrp1`") nomalSizeSet_floatSliderGrp1;
formLayout -e
-af nomalOffsetReset_button1 "left" 1
-ap nomalOffsetReset_button1 "right" 3 50
-ac nomalOffsetSmooth_button1 "left" 3 nomalOffsetReset_button1
-af nomalOffsetSmooth_button1 "right" 1
-af nomalSizeSet_floatSliderGrp1 "left" 1
-af nomalSizeSet_floatSliderGrp1 "right" 1
-ac nomalSizeSet_floatSliderGrp1 "top" 3 nomalOffsetSmooth_button1
-af disPlayNormal_button1 "left" 1
-ap disPlayNormal_button1 "right" 3 50
-ac disPlayNormal_button1 "top" 3 nomalSizeSet_floatSliderGrp1
-ac hideNormal_button1 "left" 3 disPlayNormal_button1
-af hideNormal_button1 "right" 1
-ac hideNormal_button1 "top" 3 nomalSizeSet_floatSliderGrp1
nomalOffsetReset_formLayout1;
setParent EditVertixNomalMain_columnLayout1;
separator -h 10 EditVertixNomal_separator7;
text -l "顶点色 <=> 法线" -bgc 0 0 0 VertexColorToNormal_text1;
formLayout -nd 100 VertexColorToNormal_formLayout1;
separator -h 10 VertexColorToNormalCurrentColorSet_separator1;
optionMenu -l "当前色集" -cc ("polyColorSet -ccs -cs `optionMenu -q -v VertexColorToNormalCurrentColorSet_optionMenu1`") VertexColorToNormalCurrentColorSet_optionMenu1;
button -l "刷新" -c "VertexColorToNormalCommand 1" VertexColorToNormalRefreshColorSet_button1;
text -l "名称" VertexColorToNormalCreateColorSet_text1;
textField -text "" VertexColorToNormalCreateColorSet_textField1;
button -l "新建色集" -c "VertexColorToNormalCommand 2" VertexColorToNormalCreateColorSet_button1;
button -l "删除当前色集" -c "VertexColorToNormalCommand 3" VertexColorToNormalDeleteColorSet_button1;
separator -h 10 VertexColorToNormalCurrentColorSet_separator2;
button -l "绘制顶点色" -c "PaintVertexColorTool" VertexColorToNormalDrawVertexColor_button1;
button -l "绘制设置" -c "toolPropertyWindow" VertexColorToNormalDrawVertexToolSet_button1;
button -l "顶点色=>法线" -c "VertexColorToNormalCommand 4" VertexColorToNormalConvertToNormal_button1;
button -l "法线=>顶点色" -c "VertexColorToNormalCommand 5" VertexColorToNormalConvertToVertexColor_button1;
separator -h 10 VertexColorToNormalCurrentColorSet_separator3;
formLayout -e
-af VertexColorToNormalCurrentColorSet_separator1 "left" 1
-af VertexColorToNormalCurrentColorSet_separator1 "right" 1
-af VertexColorToNormalCurrentColorSet_optionMenu1 "left" 1
-af VertexColorToNormalCurrentColorSet_optionMenu1 "right" 100
-ac VertexColorToNormalCurrentColorSet_optionMenu1 "top" 5 VertexColorToNormalCurrentColorSet_separator1
-ac VertexColorToNormalRefreshColorSet_button1 "left" 3 VertexColorToNormalCurrentColorSet_optionMenu1
-af VertexColorToNormalRefreshColorSet_button1 "right" 1
-ac VertexColorToNormalRefreshColorSet_button1 "top" 5 VertexColorToNormalCurrentColorSet_separator1
-af VertexColorToNormalCreateColorSet_textField1 "left" 55
-af VertexColorToNormalCreateColorSet_textField1 "right" 100
-ac VertexColorToNormalCreateColorSet_textField1 "top" 5 VertexColorToNormalCurrentColorSet_optionMenu1
-af VertexColorToNormalCreateColorSet_text1 "left" 1
-ac VertexColorToNormalCreateColorSet_text1 "right" 3 VertexColorToNormalCreateColorSet_textField1
-ac VertexColorToNormalCreateColorSet_text1 "top" 5 VertexColorToNormalCurrentColorSet_optionMenu1
-ac VertexColorToNormalCreateColorSet_button1 "left" 3 VertexColorToNormalCreateColorSet_textField1
-af VertexColorToNormalCreateColorSet_button1 "right" 1
-ac VertexColorToNormalCreateColorSet_button1 "top" 5 VertexColorToNormalCurrentColorSet_optionMenu1
-af VertexColorToNormalDeleteColorSet_button1 "left" 1
-af VertexColorToNormalDeleteColorSet_button1 "right" 1
-ac VertexColorToNormalDeleteColorSet_button1 "top" 5 VertexColorToNormalCreateColorSet_button1
-af VertexColorToNormalCurrentColorSet_separator2 "left" 1
-af VertexColorToNormalCurrentColorSet_separator2 "right" 1
-ac VertexColorToNormalCurrentColorSet_separator2 "top" 1 VertexColorToNormalDeleteColorSet_button1
-af VertexColorToNormalDrawVertexColor_button1 "left" 1
-ap VertexColorToNormalDrawVertexColor_button1 "right" 3 50
-ac VertexColorToNormalDrawVertexColor_button1 "top" 5 VertexColorToNormalCurrentColorSet_separator2
-ac VertexColorToNormalDrawVertexToolSet_button1 "left" 3 VertexColorToNormalDrawVertexColor_button1
-af VertexColorToNormalDrawVertexToolSet_button1 "right" 1
-ac VertexColorToNormalDrawVertexToolSet_button1 "top" 5 VertexColorToNormalCurrentColorSet_separator2
-af VertexColorToNormalConvertToNormal_button1 "left" 1
-ap VertexColorToNormalConvertToNormal_button1 "right" 3 50
-ac VertexColorToNormalConvertToNormal_button1 "top" 5 VertexColorToNormalDrawVertexToolSet_button1
-ac VertexColorToNormalConvertToVertexColor_button1 "left" 3 VertexColorToNormalConvertToNormal_button1
-af VertexColorToNormalConvertToVertexColor_button1 "right" 1
-ac VertexColorToNormalConvertToVertexColor_button1 "top" 5 VertexColorToNormalDrawVertexToolSet_button1
-af VertexColorToNormalCurrentColorSet_separator3 "left" 1
-af VertexColorToNormalCurrentColorSet_separator3 "right" 1
-ac VertexColorToNormalCurrentColorSet_separator3 "top" 1 VertexColorToNormalConvertToVertexColor_button1
VertexColorToNormal_formLayout1;
showWindow EditVertixNomalWin;
VertexColorToNormalCommand 1;
}
EditVertixNomalUI;

View File

@ -50,69 +50,17 @@ Robert算子被应用到图像增强总的锐化其作为一阶微分算子Ro
# 实现记录
[[OutlinePass]]
# BackFace描边
## 调整法线插件
### Blender
【【Blender】三渲二动漫角色脸部法线修改教程】 https://www.bilibili.com/video/BV1bX4y1y7pP/?share_source=copy_web&vd_source=fe8142e8e12816535feaeabd6f6cdc8e
### Maya
法线编辑工具:https://www.bilibili.com/video/BV1uW411w7tp/?spm_id_from=333.337.search-card.all.click&vd_source=d47c0bb42f9c72fd7d74562185cee290
作者还提供代码:![[NomalEditor.mel]]
# 杂项
## 李兄实现Outline思路
### Depth与Normal描边
ToonOutlineMain()
```c++
float3x3 laplacianOperator = float3x3(-1, -1, -1,
-1, 8, -1,
float3x3 Gx = float3x3( -1, +0, +1,
-1, -1, -1);
-2, +0, +2,
-1, +0, +1);
float3x3 Gy = float3x3( +1, +2, +1,
+0, +0, +0,
-1, -2, -1);
```
使用GetPixelValue()取得Normal与Depth之后使用拉普拉斯算子与Sobel算子进行边缘检测
```c++
float4 fs0 = s0 * laplacianOperator[0][0];
float4 fs1 = s1 * laplacianOperator[0][1];
float4 fs2 = s2 * laplacianOperator[0][2];
float4 fs3 = s3 * laplacianOperator[1][0];
float4 fs4 = s4 * laplacianOperator[1][1];
float4 fs5 = s5 * laplacianOperator[1][2];
float4 fs6 = s6 * laplacianOperator[2][0];
float4 fs7 = s7 * laplacianOperator[2][1];
float4 fs8 = s8 * laplacianOperator[2][2];
float4 sampledValue = fs0 + fs1 + fs2 + fs3 + fs4 + fs5 + fs6 + fs7 + fs8;
OutlineMask0 = saturate(1.0 - length(sampledValue)); //Line is black
```
```c++
float4 ds0x = s0 * Gx[0][0];
float4 ds1x = s1 * Gx[0][1];
float4 ds2x = s2 * Gx[0][2];
float4 ds3x = s3 * Gx[1][0];
float4 ds4x = s4 * Gx[1][1];
float4 ds5x = s5 * Gx[1][2];
float4 ds6x = s6 * Gx[2][0];
float4 ds7x = s7 * Gx[2][1];
float4 ds8x = s8 * Gx[2][2];
float4 SGX = ds0x + ds1x + ds2x + ds3x + ds4x + ds5x + ds6x + ds7x + ds8x;
float4 ds0y = s0 * Gy[0][0];
float4 ds1y = s1 * Gy[0][1];
float4 ds2y = s2 * Gy[0][2];
float4 ds3y = s3 * Gy[1][0];
float4 ds4y = s4 * Gy[1][1];
float4 ds5y = s5 * Gy[1][2];
float4 ds6y = s6 * Gy[2][0];
float4 ds7y = s7 * Gy[2][1];
float4 ds8y = s8 * Gy[2][2];
float4 SGY = ds0y + ds1y + ds2y + ds3y + ds4y + ds5y + ds6y + ds7y + ds8y;
OutlineMask1 = saturate(2.0 - step(0.9, length(sqrt(SGX * SGX + SGY * SGY))));
```
这个算法巧妙的地方在于对计算卷积核之后使用length(float4(Normal,Depth))来取得结果Sobel也是length(sqrt(SGX * SGX + SGY * SGY)。
最后使用```OutColor.rgba = OutlineMask0;//lerp(OutlineMask0, OutlineMask1, 0.5);```进行混合。使用OutlineIDMap.a作为宽度控制项并乘以通过Depth重映射后的变量作为宽度Fix因子。
### ID描边
对ToonIDTexture进行Sobel描边。只使用了Sobel
### 混合结果
## 蓝色协议的做法
### 模型外扩