More Related Content
Similar to HoloLens x Graphics 入門 (9)
HoloLens x Graphics 入門
- 6. HoloLens に見られる表現
• VR や普通のゲームとは違う表現の仕方・工夫が色々とある
• こういった表現のうち基本的な幾つかを紹介・解説
• バーチャルなオブジェクトを実在感を高める
• バーチャルなオブジェクトの実在感を損なわないようにする
- 13. 別の世界への入り口をつくる
// a = オブジェクトのアルファ
(現実の色 × (1 - a)) +オブジェクトの色 × a
(現実の色 × バイザの黒半透明)+ オブジェクトの色
目に見える情報
キャプチャの情報
簡単な説明(※正確ではないので注意)
※ https://developer.microsoft.com/ja-jp/windows/holographic/case_study_-_looking_through_holes_in_your_reality
• ただし黒を描画するとキャプチャ時に黒になってしまう
- 22. 空間マッピングの提示
• ワールド座標を使えば色々と面白表現ができる
• ここでいうワールド座標はゲーム内だけでなく現実の座標とも考えられる
struct v2f
{
float3 worldPos : TEXCOORD0;
...
};
v2f vert(appdata_base v)
{
...
o.worldPos = mul(unity_ObjectToWorld, v.vertex);
...
}
inline float toIntensity(float3 pos)
{
return frac(length(pos) - _Time.y);
}
fixed4 frag(v2f i) : SV_Target
{
float3 worldIndex =
floor(i.worldPos.xyz * _TilesPerMeter);
float3 boxelCenter = worldIndex / _TilesPerMeter;
float intensity = toIntensity(boxelCenter);
return _Color * intensity;
}
ワールド座標を使って空間をボクセルに区切る
- 31. ニアクリップ表現の工夫
[maxvertexcount(3)]
void geom(triangle appdata_t input[3], inout TriangleStream<g2f> stream)
{
for (int i = 0; i < 3; ++i)
{
...
float4 worldPos = mul(unity_ObjectToWorld, v.vertex);
float3 dist = length(_WorldSpaceCameraPos - worldPos);
fixed destruction = clamp((_Start - dist) / (_Start - _End), 0.0, 1.0);
...
v.vertex.xyz = (v.vertex.xyz - center) * (1.0 - destruction * _Scale) + center;
v.vertex.xyz = rotate(v.vertex.xyz - center, random * destruction * _Rotation) + center;
v.vertex.xyz += v.normal.xyz * destruction * _Position * random;
o.vertex = UnityObjectToClipPos(v.vertex);
...
stream.Append(o);
}
stream.RestartStrip();
}
• ポリゴン分解はジオメトリシェーダを経由すると簡単
自動で頂点がバラバラになってくれる