Gregory Igehy

Dancing at hemisphere coordinate

Notes of GPU particles in Unity

Perforce stream

Unity3d Show count operations in Shader

Houdini hipnc to hip(or hiplc)

  • Houdini の hipnc を hip や hiplc に変換する方法
    • ※ 自己責任でお願いします
  • (0) Houdini の非商用版で hscript のコンソールを起動し, $ opscript -G -r / > C:/tmp/hoge.cmd
  • (1) Houdini FX や Houdini Indie で $ cmdread C:/tmo/hoge.cmd とすると, ノードが読み込まれる

Notes of Houdini quickstart

Smoke

Houdini の Rigid Body の Shelf のメモ

RBD Object

  • SOP に追加: Rest, Assemble, DOPimport
  • DOP に追加: RBD Packed Object

RBD Hero Object

  • SOP に追加: Rest, DOPimport
  • DOP に追加: RBD Object

Model Shatter

  • SOP に追加: Voronoi Fracture, IsoOffset, Scatter

RBD Fractured Object (Packed)

  • SOP に追加: Rest, Assemble, DOPimport
  • DOP に追加: RBD Packed Object

RBD Fractured Object (Fractured)

  • SOP に追加: Assemble, Rest, DOP import
  • DOP に追加: RBD Fractured Object

RBD Glued Object

  • SOP に追加:
    • Rest, Assemble, DOPImport
    • UnpackGeometry, Attribute Promote, Contact Adjacent Pieces
    • Attribute Create, Glue Constraint Relationship
  • DOP に追加:
    • RBD Packed Object, Glue Constraint Relationship
    • SOP Solver, Constraint Network

Make Breakable

  • DOP に追加: Voronoi Fracture Configure Object

Glued

  • 新規 SOP: DOP import, Time shift, Connect Adjacent Pieces, Attribute Create, Null
  • DOP に追加: RBD Packed Object

Houdini Help Examples (H16) のメモ

  • Houdini の Help -> Examples で起動

Dynamics Examples

ACTIVE VALUE
  • AnimatedActiveState
    • 球が平面に対して落ちるけど、途中で一瞬止まる
  • AutoFreezeRBD
    • 4x4x4 の小さい直方体を平面に落とす
    • rest state になった直方体を active status を無効化
AFFECTOR
  • SimpleAffector
    • 4 つの球が中心に寄ってぶつかりあう
    • Affector ノードで Affector Matrix(影響のコリジョンフラグ)を切り替える
CONSTRAINT NETWORK
  • ControlledGlueBreaking
    • テーブル(Voronoi Fracture + Glued)が中心から崩れる
    • Glued を球のアニメーションで消している
  • GlueConstraintNetwork
    • Torus(VoronoiFracture + Glued)が平面に落ちて割れるだけ
COPY OBJECTS
  • AutoFracturing
    • 球が平面に落ちてから, 2 つに割れて消すのを active state を無効にして行う
    • 中で multisolver を使っている
  • SimpleCopy
    • 球が 100 個, 平面に落ちる
    • DOP で CopyObjects や RBDState を使っている
FIELD FORCE
  • FieldForceSmoke
    • 直方体の Smoke の速度場に合わせて, パーティクルを動かす
    • SmokeSolver + POPSolver
  • FromRBD
    • 箱の中に 2 つの球があってそれが落下する
    • ある RBD Object が他の RBD Object に対して Field Force DOP で斥力を発生する
  • SimpleField
    • 直方体の力の場に合わせて, 剛体を動かす
    • RBDSolver + FieldForce + Drag
  • FieldForce
    • 球から出る煙に対して, パーティクルを吹き付けて動かす
    • SmokeSolver + FieldForce + SOP (POP を参照)
FILE
  • CacheToDisk
    • 球が平面に落ちてバウンスする. 円錐が 2 個 Fan として動いて力を加える
    • 1-100 フレームをファイルにキャッシュして, それを読み込む
    • Take Ownership of Loaded Object のフラグが有効なときには 100 フレーム以降は計算する
FLIP SOLVER
  • DensityVicosity
    • 青い水がタンクに貯まっている, 黄色の別の流体が放出される, Solid の Torus が落下する
    • 異なる粘性のデモ
  • FlipColorMix
    • 赤い液体の球と青い液体の球が混ざった際に, 色も混ざる
  • FlipColumn
    • 見えない箱の中で, 赤色と水色の液体が放出される
    • 緑の柱に液体がぶつかると, 液体の色が緑に変わる
  • SpinningFlipCollision
    • 棒が円状に回転し, そのエッジから FLIP 流体を放出する
  • VariableViscosity
    • 見えない箱の中で, 黄・緑・青の液体が放出される
    • その少し下を棒が動いていて, 粘性が違う液体が絡みつく
FLUID FORCE
  • FluidWireInteraction
    • 空っぽの立方体の中に, 球状の液体が入っていてそれが底に落ちる
    • 底には, 上方向に生えた 5x5 のワイヤーがあって液体の影響を受ける
    • FluidSolver + WireSolver
FLIP OBJECT
  • BallinTank
    • タンクのポリゴンの水の中に楕円体が投げ込まれる
    • FluidSolver + rbdsolver
  • FillGlass
    • 空っぽの立方体の中で, 球が水が放出されてそれが容器の中からあふれる
    • RBDObject + FluidSolver
  • FluidFeedback
    • タンクの中に水が詰まっていて, その上に剛体の球が落ちてお互いに影響を受ける
    • FluidSolver + RbdSolver
  • PaintedGrog
    • 筋肉ムキムキのキャラ(Grog)に色がついた Torus を落下して, 衝突したところに色がつく
    • FluidSolver + SOP Solver
    • ノードの構成は複雑
  • RestartFluid
    • タンクの中にある水の中で, 空気が移動する
    • 以前のシミュレーション結果を利用しているらしい
  • RiverBed
    • 溝があるところの上流(緑の直方体)から水が出て, 下流(赤の直方体)に流れて消える
    • FluidSolver + RBD Object
    • ノードの構成はシンプル
  • VariableDrag
    • タンクの真ん中に球が浮いていて, そこから水が出るけど, 一部のところは摩擦が強くて水が流れ込みにくい
    • DOP 内にいくつかサンプルが入っている
    • ノードの構成は複雑
Gas Calculate
  • HotBox
    • からっぽの直方体の中で, 球から煙が出てそれがキーフレームで動く直方体に当たる
    • 内部では温度を調整しているらしい
Gas Diffuse
  • DiffuseSmoke
    • からっぽの直方体の中で球が煙を出す
    • Gas Diffuse DOP ノードを使うやり方
Gas Embed Fluid
  • CombinedSmoke
    • Gas Embed Fluid DOP の使い方の例
Gas Equalize Volume
  • EqualizeFlip
    • タンクの中に液体の粒子が詰まっていて, その上を直方体が円状に動く
    • FlipSolver に Gas Equalize Volume DOP を使って, 流体の体積を維持するために使っているらしい
  • EqualizeLiquid
    • 上と同じだが, 液体のポリゴンになっている
    • FluidSolver を使っている
Gas Net Fetch Data
  • dopexample_gasnetfetchdata
    • Torus が置いてある, 計算が重い
    • Gas Net Fetch Data ノードで 2 つの DOP の結果を使うらしい
Gas Particle To Field
  • TimelessGas
    • Torus がガスの結果によって, 変形した状態のまま
    • Gas Particle To Field ノードの使い方の例
Gas Surface Tension
  • TeapotUnderTension
    • ティーポットから球や楕円体に変形する
    • FluidSolver に Gas Surface Tension ノードを使う例
Gas Up Res
  • UpresRetime
    • Gas Up Res ノードの使い方の例
MultiSolver
  • SimpleMultiple
    • 色がついた Torus が平面に落ちる
    • rbdsolver + sopsolver(色変更) + multisolver
    • ノードの構成はシンプル
POP FORCE
  • CurlForce
    • たくさんのパーティクルを POP Force の Curl で上に押し上げる例
    • 速度場みたいなものもデバッグ表示している
Pyro Solver
  • BillowyTurbine
    • Torus から煙が出て, それがタービンんに当たって流体の動きがわかる
    • 速度場っぽいものもデバッグ表示される
RBD AUTO FREEZE
  • Stack
    • AutoFreeze の例
    • 平面に対して 1 個ずつティーポットが落ちる
    • RBD Configure Object を使っている
RBD FRACTURED OBJECT
  • ShatterDebris
    • 弾丸が 3 つの板(Voronoi Fracture)を貫いて割る
    • 破壊時に debris が飛ぶ
    • 重力でグループ指定を使って, 弾丸だけに適用している
  • StackedBricks
    • 積んであるレンガっぽい直方体の山に対して, 球がぶつかるだけ
/NODES/DOP/RBDGLUEOBJECT
  • BlendSolverWithRBDGlue
    • 外から直方体が飛んできて平面にぶつかって、壊れる
    • RBD Glue Object の結果を, 直方体のフラグメントに混ぜる
    • 中では blendSolver や applyData を利用
  • BreakingRock
    • ごつごつした丸い岩( RBD Glued Object )が地面に落ちて割れる例
  • ChoreographedBreakup
    • 球でできた Torus が Glued でくっついている
    • それを動く板が通り過ぎると, Glued の効果がなくなる例
    • RbdState の Glue Strength を -1 から変化させている
  • ChoreographedTubeBreakup
    • 上の円柱 Fractured Glue 版
  • ShatterGlass
    • 縦に置いた正方形の板ポリゴンに球がぶつかって割れる
    • 板ポリゴンは RbdPinConstraints で四隅を固定
RBD OBJECT
  • DeformingRBD
    • 平面に うねうね動く Torus が落下
  • FrictionBalls
    • 摩擦の違う 2 つのサッカーボールが転がる例
  • RBDInitialState
    • 平面に 1 個の直方体と 2 個の球が落下
    • 速度と回転角度が初期化されている
  • SimpleRBD
    • 剛体の球が平面に落ちるだけ
RBD PACKED OBJECT
  • ActivateObjects
    • 5x5 に浮かんだ Torus がランダムに active になって, 平面に落下する例
  • AnimatedObjects
    • Torus(Voronoi Fracture)が空中でキーフレームアニメーションしてから, 剛体に切り替わって破片が平面に落ちる
  • DeleteObjects
    • 大量の RubberToy が空中に浮いていて, それが坂道から転げ落ちる
    • 青いバウンディングボックス内に入ると, RubberToy が消える(rigidsolver + POP)
  • EmittingObjects
    • ティーポットを大量に放出した結果, 平面に乗っかる
    • 落下中で動きが変化するのは POP Fan Cone で力を発生しているから
    • SOP Solver + Bullet Solver + MultiSolver を使っている
  • SpeedLimit
    • 大量のティーポットが落下するが, 一部のものは速度が制限されている
    • DOP 内で, POP Group で一部のものを選択して POP Speed Limit で最大速度を制限している
RBD POINT OBJECT
  • popswithrbdcollision
    • 散らばった複数の球が, 中心に吸い寄せされながらお互いにぶつかりあう
    • POP をしながら, RBD 計算をする
RBD STATE
  • InheritVelocity
    • 骨の腕(RBD Fractured Object)がアニメーションして, それがアニメーションする球とぶつかって壊れる
    • 速度の伝播には RBD State を使っている
RBD Visulalization
  • Simple
    • 剛体の球が平面に落ちて, 力が赤い線でデバッグ表示される
    • ノードの構成はシンプル
SmokeObject
  • 2dfluid
    • 板の上を球が動いて, 流体の動きが 2D の板に表示される
    • COP で結果を利用している
  • DelayedSmokeHandoff
    • Box が平面に落下した際に, 煙が出る
    • ノードの構成は複雑
  • OpenCL smoke
    • からっぽの直方体の中を球状の煙が出る
    • OpenCL を使っているらしい
  • RBDToSmokeHandoff
    • なめくじが落下して, 煙の円柱を通過する例
    • 内部で ApplyData を使っている
  • SourceVorticlesAndCollision
    • からっぽの立方体の中にある 2 つの直方体がキーフレームで動く
    • 流体がそれの影響を受ける
    • gas や ApplyData のノードを使っている
  • rbdsmokesource
    • からっぽの立方体の中で, 四面体が内部で跳ね返りながら煙を出す
  • RBDtoSmokeHandoff
    • なめくじが煙のところに落下, 煙が影響を受ける
  • rbdsmokesource
    • 四面体が箱の中をバウンスする
    • その際に Tetrahedra が煙を出し続ける
SOP SOLVER
  • VisualizeImpacts
    • 3 つの Torus が平面に落ちて, 衝突に関する情報がデバッグ表示される
    • SOP で自前でデバッグ情報を作っている
STATIC OBJECT
  • StaticBalls
    • ノイズで凹凸した小さい板が空中にあって, Static な 3 つの球にぶつかりながら落下する
    • DOP 内で Static Object を使っているだけ
VORONOI FRACTURE SOLVER
  • FractureExamples
    • 剛体のボロノイ破砕のサンプル
VORTEX FORCE
  • SimpleVortex
    • 竜巻みたいなものが移動して, パーティクルを上に押し上げる
    • RBDSolver + VortexForce
Wind
  • TurbulentSMoke
    • 筒から上に向かって煙が出るけど, WindForce の影響を受ける
    • Smoke Solver を利用

SOP SOLVER

ASSEMBLE
  • PackedFragments
    • 球(Voronoi Fracture)を前後にアニメーションさせて, 破片が散らばる例
    • MultiSolver + SOP Solver で少しずつ activate
TRANSFORM PIECES
  • TransformFracturedPieces
    • Torus のボロノイ破砕の結果を、より高解像度のメッシュに転送する

Notes of Terrain in Unity and UE4

Houdini の RBD to FBX

  • RBD Packed Obj じゃないとダメ

UE4 でのプレイ中にエディタで編集するとき : F8

ノードベースのビジュアルプログラミングに関する雑感

良い

  • Houdini の Network Editor
    • 理由 : 良い意味で抽象度が高く, 少ないノードで済む デバッグもできる(ブレークポイント=ノードを選択してディスプレイ, 変数=Geometry SpreadSheet)
  • UE4 のマテリアルエディタ
    • 理由 : プレビューをしながらも, 比較的単純なシェーダなら手軽に実装できる

いまいち

  • BluePrint や Scratch
    • 理由 : プログラムの構文を視覚的に置き換えているだけなので, プログラムの方がコンパクトに済むのにとよく思う 特に数値演算やループ処理

Unity のテラインシェーダについて

対象

  • builtin_shaders-2017.1.0f3

Standard-FirstPass.shader ( DefaultResourcesExtra\TerrainShaders\Splats )

  • 頂点シェーダでは ハイトマップを VertexTexture Fetch しているわけではない
  • 従って, ハイトマップを参照してメッシュの高さを CPU で設定してある
  • テラインはいくつかのメッシュで分解されていて, QuadTree でフラスタムカリングや LOD を設定している
#pragma surface surf Standard vertex:SplatmapVert finalcolor:SplatmapFinalColor finalgbuffer:SplatmapFinalGBuffer fullforwardshadows noinstancing

void SplatmapVert(inout appdata_full v, out Input data)
{
    UNITY_INITIALIZE_OUTPUT(Input, data);
    data.tc_Control = TRANSFORM_TEX(v.texcoord, _Control); 
    // Need to manually transform uv here, as we choose not to use 'uv' prefix for this texcoord.
    float4 pos = UnityObjectToClipPos(v.vertex);
    UNITY_TRANSFER_FOG(data, pos);

#ifdef _TERRAIN_NORMAL_MAP
    v.tangent.xyz = cross(v.normal, float3(0,0,1));
    v.tangent.w = -1;
#endif
}

void SplatmapFinalColor(Input IN, TERRAIN_SURFACE_OUTPUT o, inout fixed4 color)
{
    color *= o.Alpha;
    #ifdef TERRAIN_SPLAT_ADDPASS
        UNITY_APPLY_FOG_COLOR(IN.fogCoord, color, fixed4(0,0,0,0));
    #else
        UNITY_APPLY_FOG(IN.fogCoord, color);
    #endif
}

void SplatmapFinalGBuffer(Input IN, TERRAIN_SURFACE_OUTPUT o, inout half4 outGBuffer0, inout half4 outGBuffer1, inout half4 outGBuffer2, inout half4 emission)
{
    UnityStandardDataApplyWeightToGbuffer(outGBuffer0, outGBuffer1, outGBuffer2, o.Alpha);
    emission *= o.Alpha;
}
  • ベースカラーマップ 4 枚 ( _Splat0,1,2,3 )
  • 法線マップ 4枚 (_Normal0,1,2,3 )
  • 混ぜ方 _Control の 1 枚
  • メタルネスのパラメータ 4 つ
  • スムースネスのパラメータ 4 つ
  • マテリアルの混ぜ方については TerrainSplatmapCommon.cginc の SplatmapMix()
// 下の定義が有効なとき
#ifdef TERRAIN_STANDARD_SHADER
void SplatmapMix(Input IN, half4 defaultAlpha, out half4 splat_control, out half weight, out fixed4 mixedDiffuse, inout fixed3 mixedNormal)
// そうでないとき
#else
void SplatmapMix(Input IN, out half4 splat_control, out half weight, out fixed4 mixedDiffuse, inout fixed3 mixedNormal)
#endif
{
    splat_control = tex2D(_Control, IN.tc_Control);
    weight = dot(splat_control, half4(1,1,1,1));

    #if !defined(SHADER_API_MOBILE) && defined(TERRAIN_SPLAT_ADDPASS)
        clip(weight == 0.0f ? -1 : 1);
    #endif

    // Normalize weights before lighting and restore weights in final modifier functions so that the overal
    // lighting result can be correctly weighted.
    splat_control /= (weight + 1e-3f);

    mixedDiffuse = 0.0f;
    #ifdef TERRAIN_STANDARD_SHADER
        mixedDiffuse += splat_control.r * tex2D(_Splat0, IN.uv_Splat0) * half4(1.0, 1.0, 1.0, defaultAlpha.r);
        mixedDiffuse += splat_control.g * tex2D(_Splat1, IN.uv_Splat1) * half4(1.0, 1.0, 1.0, defaultAlpha.g);
        mixedDiffuse += splat_control.b * tex2D(_Splat2, IN.uv_Splat2) * half4(1.0, 1.0, 1.0, defaultAlpha.b);
        mixedDiffuse += splat_control.a * tex2D(_Splat3, IN.uv_Splat3) * half4(1.0, 1.0, 1.0, defaultAlpha.a);
    #else
        mixedDiffuse += splat_control.r * tex2D(_Splat0, IN.uv_Splat0);
        mixedDiffuse += splat_control.g * tex2D(_Splat1, IN.uv_Splat1);
        mixedDiffuse += splat_control.b * tex2D(_Splat2, IN.uv_Splat2);
        mixedDiffuse += splat_control.a * tex2D(_Splat3, IN.uv_Splat3);
    #endif

    #ifdef _TERRAIN_NORMAL_MAP
        fixed4 nrm = 0.0f;
        nrm += splat_control.r * tex2D(_Normal0, IN.uv_Splat0);
        nrm += splat_control.g * tex2D(_Normal1, IN.uv_Splat1);
        nrm += splat_control.b * tex2D(_Normal2, IN.uv_Splat2);
        nrm += splat_control.a * tex2D(_Normal3, IN.uv_Splat3);
        mixedNormal = UnpackNormal(nrm);
    #endif
}

UE4 ゲームインスタンス

Notes of DOF

Notes of shadows in UE4

Notse of UE4 for mobile

Notes of UE4

Notes of UE4 Post effects

Notes of UE4 Instance mesh

Notes of UE4 C++ API

UActorComponent

USceneComponent

UPrimitiveComponents

  • https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Components/UPrimitiveComponent/index.html
  • PrimitiveComponents are SceneComponents that contain or generate some sort of geometry, generally to be rendered or used as collision data. There are several subclasses for the various types of geometry, but the most common by far are the ShapeComponents (Capsule, Sphere, Box), StaticMeshComponent, and SkeletalMeshComponent. ShapeComponents generate geometry that is used for collision detection but are not rendered, while StaticMeshComponents and SkeletalMeshComponents contain pre-built geometry that is rendered, but can also be used for collision detection.

UShapeComponent

UMeshComponent

UStaticMeshComponent

UStaticMesh

  • https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UStaticMesh/index.html
  • A StaticMesh is a piece of geometry that consists of a static set of polygons. Static Meshes can be translated, rotated, and scaled, but they cannot have their vertices animated in any way. As such, they are more efficient to render than other types of geometry such as USkeletalMesh , and they are often the basic building block of levels created in the engine.

USkinnedMeshComponent

USkeletalMeshComponent

USkeletalMesh

  • https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/USkeletalMesh/index.html
  • SkeletalMesh is geometry bound to a hierarchical skeleton of bones which can be animated for the purpose of deforming the mesh. Skeletal Meshes are built up of two parts; a set of polygons composed to make up the surface of the mesh, and a hierarchical skeleton which can be used to animate the polygons. The 3D models, rigging, and animations are created in an external modeling and animation application (3DSMax, Maya, Softimage, etc).

UCameraComponent

UWorld

  • https://docs.unrealengine.com/latest/INT/API/Runtime/Engine/Engine/UWorld/
  • The World is the top level object representing a map or a sandbox in which Actors and Components will exist and be rendered.
  • A World can be a single Persistent Level with an optional list of streaming levels that are loaded and unloaded via volumes and blueprint functions or it can be a collection of levels organized with a World Composition.
  • In a standalone game, generally only a single World exists except during seamless area transitions when both a destination and current world exists. In the editor many Worlds exist: The level being edited, each PIE instance, each editor tool which has an interactive rendered viewport, and many more.

FPrimitiveSceneProxy

FPrimitiveSceneInfo

FBoxSphereBounds

FBox

  • https://docs.unrealengine.com/latest/INT/API/Runtime/Core/Math/FBox/
  • Implements an axis-aligned box. Boxes describe an axis-aligned extent in three dimensions. They are used for many different things in the Engine and in games, such as bounding volumes, collision detection and visibility calculation. A bounding box. The full C++ class is located here: Engine\Source\Runtime\Core\Public\Math\Box.h

FLine, FPlane, FCapsule, FSphere

Notes of Graphics commands in UE4

  • r.RHICmdBasePassDeferredContexts True to use deferred contexts to parallelize base pass command list execution.
  • r.RHICmdBypass Whether to bypass the rhi command list and send the rhi commands immediately. 0: Disable, 1: Enable
  • r.RHICmdForceRHIFlush Force a flush for every task sent to the RHI thread. 0: Disable, 1: Enable
  • r.RHICmdPrePassDeferredContexts True to use deferred contexts to parallelize prepass command list execution.
  • r.RHICmdShadowDeferredContexts True to use deferred contexts to parallelize shadow command list execution.
  • r.RHICmdTranslucencyPassDeferredContexts True to use deferred contexts to parallelize base pass command list execution.
  • r.RHICmdUseParallelAlgorithms True to use parallel algorithms. Ignored if r.RHICmdBypass is 1.
  • r.RHICmdUseThread Uses the RHI thread. 0: Disable, 1: Enable
  • r.RHICmdVelocityPassDeferredContexts True to use deferred contexts to parallelize velocity pass command list execution.
  • r.RHICmdWidth Number of threads.

[Startup]
; Uncomment to get detailed logs on shader compiles and the opportunity to retry on errors
; r.ShaderDevelopmentMode=1
; Uncomment to dump shaders in the Saved folder
; Warning: leaving this on for a while will fill your hard drive with many small files and folders
;r.DumpShaderDebugInfo=1
; When this is enabled, dumped shader paths will get collapsed (in the cases where paths are longer than the OS's max)
;r.DumpShaderDebugShortNames=1
; When this is enabled, when dumping shaders an additional file to use with ShaderCompilerWorker -direct mode will be generated
;r.DumpShaderDebugWorkerCommandLine=1
; Uncomment to enable parallel rendering at startup
;r.RHICmdBypass=0

; Uncomment to enable XGE shader compilation.
;r.XGEShaderCompile = 1
; Uncomment when running with a graphical debugger (but not when profiling)
;r.Shaders.Optimize=0
;r.Shaders.KeepDebugInfo=1

; If Linux editor crashes in FMallocBinned with callstack that mentions MeshUtilities, you may need to uncomment this.
;r.TriangleOrderOptimization=2