インクジオメトリパイプラインとレンダリング
さまざまなrendering modesが既に導入されています。 本ガイドでは、パイプラインとレンダリングのセットアップ方法を段階的に説明します。
視覚的な結果はブラシ設定、パイプライン設定、およびプラットフォームレンダリングの設定により変化します。
Raster Ink
本セクションでは、ラスターインクのジオメトリおよびレンダリングパイプラインをセットアップする場合のベストプラクティスについて、順を追って説明します。
ブラシ設定
ラスターパーティクルブラシをセットアップするには、2つのテクスチャが必要です。

図形と塗りつぶしのテクスチャ:
shapeパラメータはパーティクルの形状を指定します。
不透明のピクセルによってパーティクルの形状を定義する画像を取得します。
fillパラメータは図形の塗りつぶしパターンを指定します。
パターンをサンプリングする画像を取得します。
両方のテクスチャでは、このパラメータで画像シーケンスを渡すこともできます。 この場合、メソッドは画像をミップマップとして解釈します。
- Kotlin
- C#
- JavaScript
...
fun pencil(context: Context): RasterBrush {
val opts = BitmapFactory.Options()
opts.inSampleSize = 1
opts.inScaled = false
// Texture for shape
val shapeTexture =
BitmapFactory.decodeResource(context.resources, R.drawable.essential_shape, opts)
// Texture for fill
val fillTexture =
BitmapFactory.decodeResource(context.resources, R.drawable.essential_fill_11, opts)
// Convert to PNG
val stream = ByteArrayOutputStream()
shapeTexture!!.compress(Bitmap.CompressFormat.PNG, 100, stream)
val shapeTextureByteArray = stream.toByteArray()
val stream2 = ByteArrayOutputStream()
fillTexture!!.compress(Bitmap.CompressFormat.PNG, 100, stream2)
val fillTextureByteArray = stream2.toByteArray()
// Create the raster brush
var brush = RasterBrush(
URIBuilder.getBrushURI("raster", "Pencil"), // name of the brush
0.15f, // spacing
0.15f, // scattering
RotationMode.RANDOM, // rotation mode
listOf(shapeTextureByteArray), // shape texture
listOf(), fillTextureByteArray, // fill texture
"", // fill texture URI
fillTexture.width.toFloat(), // width of texture
fillTexture.height.toFloat(), // height of texture
false, // randomized fill
BlendMode.MAX // mode of blending
)
shapeTexture.recycle()
fillTexture.recycle()
return brush
}
...
public PencilTool(Graphics graphics)
{
Fill = new PixelInfo(new Uri("ms-appx:///Assets/textures/essential_fill_11.png"));
Shape = new PixelInfo(new Uri("ms-appx:///Assets/textures/essential_shape.png"));
Brush.Scattering = 0.05f;
Brush.RotationMode = ParticleRotationMode.RotateRandom;
Brush.FillTileSize = new Size(32.0f, 32.0f);
Brush.FillTexture = graphics.CreateTexture(Fill.PixelData);
Brush.ShapeTexture = graphics.CreateTexture(Shape.PixelData);
ParticleSpacing = 0.3f;
}
/* **************** RASTER BRUSH configuration **************** */
pencil: new BrushGL(
URIBuilder.getBrushURI("raster", "Pencil"),
"/images/textures/essential_shape.png",
"/images/textures/essential_fill_11.png",
{
spacing: 0.15,
scattering: 0.15
}),
...
PathPoint 計算機
関連するすべてのブラシを定義したら、センサーデータによるインクストロークの幅、濃度、および傾きの変化に影響を与えるPathPoint calculators を設定する必要があります。
最初に、レイアウトの設定が必要です。 レイアウトは、入力元に応じて調整することができます。 たとえば、タッチ入力の場合は傾きも筆圧情報も取得しません。
- Kotlin
- C#
- JavaScript
...
import com.wacom.ink.PathPointLayout
...
override fun getLayout(): PathPointLayout {
// Define different layouts for stylus and touch input
if (isStylus) {
return PathPointLayout(
PathPoint.Property.X,
PathPoint.Property.Y,
PathPoint.Property.SIZE,
PathPoint.Property.ALPHA,
PathPoint.Property.ROTATION,
PathPoint.Property.OFFSET_X
)
} else {
return PathPointLayout(
PathPoint.Property.X,
PathPoint.Property.Y,
PathPoint.Property.SIZE,
PathPoint.Property.ALPHA
)
}
}
...
...
using Wacom.Ink.Geometry;
using Wacom.Ink.Rendering;
...
public override PathPointLayout GetLayout(Windows.Devices.Input.PointerDeviceType deviceType)
{
switch (deviceType)
{
case Windows.Devices.Input.PointerDeviceType.Mouse:
case Windows.Devices.Input.PointerDeviceType.Touch:
return new PathPointLayout(PathPoint.Property.X,
PathPoint.Property.Y,
PathPoint.Property.Size,
PathPoint.Property.Alpha);
case Windows.Devices.Input.PointerDeviceType.Pen:
return new PathPointLayout(PathPoint.Property.X,
PathPoint.Property.Y,
PathPoint.Property.Size,
PathPoint.Property.Alpha,
PathPoint.Property.OffsetX,
PathPoint.Property.OffsetY);
default:
throw new Exception("Unknown input device type");
}
}
// In the JavaScript implementation layout is predefined within PathPointContext
let context = new PathPointContext();
タッチ入力およびスタイラス入力は各種の入力センサーデータに合わせて最適化できるため、以前、現在、および次のセンサーデータ入力を取得する計算機を定義し、適切な@@@を算出する必要があります。PathPoint.
たとえば、タッチデータには、スタイラスのような筆圧情報も傾斜の向きも含まれません。
そのため、同様のアルファ強度やインクストローク幅の変化を実現する場合、使用できるのは速度情報のみです。
入力データの現在の速度に基づいて幅を計算する機能は、エンジンが提供します。
ここでは、