Skip to content

Draw_Shape

haw2fregel edited this page Mar 21, 2025 · 4 revisions
Draw_Shape
シェイプを描画します
image

目次

Draw

Shape

UVDeform

Opacity

Draw

Draw
描画カラーを制御します
image
操作例 画面録画 2025-03-21 175041
Draw Color
描画カラーを制御します
Draw *= DrawColor image

Shape

Shape
Shape形状を調整します
image
操作例 画面録画 2025-03-21 180406
Shape Type
Shapeの生成方法を変更します
Distance Power:Pivotからの距離計算でShapeを生成します
Polygon:多角形頂点からの距離計算でShapeを生成します
Distance Power
float dist = lengthN(uv - _ShapeCenter, _ShapeDistancePower) * 2;
dist = saturate(dist);
int samplePoint = (int) (dist * 511);
samplePoint = clamp(samplePoint, 0, 511);
float drawColor1 = _ShapeCurveArray[samplePoint];
float drawColor2 = _ShapeCurveArray[min(511, samplePoint + 1)];
float drawColor = lerp(drawColor1, drawColor2, frac(dist * 511));
return drawColor;

Polygon
p -= _ShapeCenter;
p.x = p.x == 0 ? EPSILON : p.x;
p.y = p.y == 0 ? EPSILON : p.y;
float arctan2 = atan2(p.x, p.y) + PI;
float r = PI * 2.0 / float(_PolygonCount);
float dist = cos(floor(0.5 + arctan2 / r) * r - arctan2) * max(length(p) - _PolygonBump, EPSILON) / (1.0 - _PolygonBump);
int samplePoint = (int) (dist * 511);
samplePoint = clamp(samplePoint, 0, 511);
float drawColor1 = _ShapeCurveArray[samplePoint];
float drawColor2 = _ShapeCurveArray[min(511, samplePoint + 1)];
float drawColor = lerp(drawColor1, drawColor2, frac(dist * 511));
return drawColor;
image
Curve
Curveを利用してShapeのグラデーションを調整します
image
Center
Shapeの中心点を変更します
image
Power
距離計算の累乗値を変更します
Shapeの形状が変わります
float2 tmp = pow(abs(p) + 0.0001, Power);
return pow(tmp.x + tmp.y, 1.0 / Power);
image
Polygon Count
多角形Shapeの角数を変更します
image
Bump
Shapeの膨張度合を調整します
+にすると膨らみ、-にすると凹んでいきます
image

UVDeform

UVDeform
UVを変形します
image
操作例 画面録画 2025-03-21 175416
Pivot
変形の原点を変更します
これ単体では変化はありません
image
Tile
UVのサイズを変更します
return (uv - _UVPivot) * _UVScale + _UVPivot; image
Rotate
UVを回転します
float rotate = value * (3.1415926f / 180.0f);
float2 result = uv - center;<brfloat s = sin(rotate);<brfloat c = cos(rotate);
float2x2 rMatrix = float2x2(c, -s, s, c);<brrMatrix *= 0.5;
rMatrix += 0.5;
rMatrix = rMatrix * 2 - 1;
result.xy = mul(result.xy, rMatrix);
result += center;
return result;
image
Bend
UVを傾けます
Pivotから遠いほどズレます
return uv + float2(abs(uv.y - _UVPivot.x) * _UVBend.x, abs(uv.x - _UVPivot.y) * _UVBend.y); image
Polar
極座標に変換します
float2 delta = uv - float2(0.5, 0.5)
delta.x = delta.x == 0 ? EPSILON : delta.x
delta.y = delta.y == 0 ? EPSILON : delta.y
float radius = lengthN(delta, 2) * 2
float angle = atan2(delta.x, delta.y) * (1.0 / 6.28) + 0.5
return _UVPolar == 0 ? uv : float2(radius, angle);
image
Repeat
UV0~1で繰り返すようになります
frac(uv) image

Opacity

Opacity
前Layerとの合成方法を制御します
image
操作例 画面録画 2025-03-21 180004
Blend Mode
合成モードを変更します



※1:乗算の逆バージョンのイメージ
背景が暗いほど描画色が明るく反映されます

※2:ScreenとMultipleの合わせ技
背景が暗い場所は乗算、明るい場所はスクリーン
コントラストが強くなります
白黒背景にOverlayを重ねると明暗を維持して色味を反映できます

※3:背景と描画色の差分出力します
Overrite:BG * (1-opacity) + Draw * opacity
Add:BG + Draw * Opacity
Subrtuct:BG - Draw * Opacity
Multiple:BG * (1-opacity) + BG * Draw * opacity
Divid:BG * (1-opacity) + BG / Draw * opacity
Max:BG * (1-opacity) + max(BG ,Draw)* opacity
Min:BG * (1-opacity) + min(BG ,Draw)* opacity
Screen:※1
BG * (1-opacity) + (1-(1-BG)*(1-Draw))* opacity
Overlay:※2 
screen = (1-(1-BG)*(1-Draw))
multiple = 2.0 * BG * Draw
overlay = multiple * (1-step(BG,0.5)) + screen * step(BG,0.5)
BG * (1-opacity) + overlay * opacity
Difference:※3
BG * (1-opacity) + abs(Draw - BG) + opacity
image
Draw Channel
描画時に利用するチャンネルを切り替えます
R:赤
G:緑
B:青
A:アルファ
Luminance:明るさ
1:描画カラーを無視して1で描画します
0:描画カラーを無視して0で描画します
None:描画カラーを無視して背景色のままになります

特定チャンネルのみを描画したり、チャンネルを入れ替えたい場合に利用します
image
Opacity
合成割合を調整します
BlendModeに合わせた計算に利用されます
opacity *= drawColor.w image
Power
累乗計算します
Draw^power
image
Multiply Alpha
opacityに対して描画カラーのアルファを乗算します
image
OneMinus
描画カラーを反転します
1 - Draw image
Contrast
描画カラーのコントラストを調整します
0.5以下はより暗く、0.5以上はより明るく
saturate((Draw- 0.5) * _Contrast + 0.5) image
Draw_Noise Layer Draw_TileAndOffset

Clone this wiki locally