Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Translated into English. I encourage people who speak other languages, such as Russian, to translate this reference into their language and distribute it to other people.
- The original file uses character encoding CP932 (an expansion of Shift-JIS encoding), and I have not modified that. It could also be saved in Unicode, like UTF-8. As the guide says, effect files that use Japanese characters as part of a filename or bone name should use CP932, not Unicode, but it is best to avoid Japanese filenames as they won't work properly (MME won't load them) if MMD isn't using Japanese encoding as its environment. In GNU Linux this is done by setting the language environment variable with a command like 'LANG=ja_JP.UTF8 wine MikuMikuDance.exe'; in Windows it's done by setting the locale or using the program AppLocale, I think.
- If you can't get your text editor to use CP932 encoding, try a web browser.
- Translation done with Tagaini Jisho: http://www.tagaini.net
- (In a web browser, the Rikaichan addon uses the same data to translate text on a page.)
- ___
- MMEffect リファレンス
- Reference
- 0.1.0.0 (2010/9/18) 初版
- Initial version
- 0.2.0.0 (2010/12/12) MME Ver0.20
- ・OFFSCREENRENDERTARGETセマンティクス追加
- OFFSCREENRENDERTARGET semantic added
- ・CONTROLOBJECTセマンティクスで取得できる情報の追加
- Added ability to get information using CONTROLOBJECT semantics
- ・CONTROLOBJECTセマンティクスが参照するオブジェクトの描画順序の制約を緩和
- Removed restriction on CONTROLOBJECT based on drawing order
- ・EDGECOLORセマンティクス追加
- Added EDGECOLOR semantics
- ・VIEWPORTPIXELSIZEセマンティクスの記述ミスを修正
- Corrected error in VIEWPORTPIXELSIZE semantics description
- ・一部日本語修正
- Corrected some Japanese language errors
- 0.2.2.0 (2010/12/16) MME Ver0.22
- ・RENDERCOLORTARGETおよびOFFSCREENRENDERTARGETセマンティクスでの、Miplevelsの指定方法を変更
- Changed how to set Miplevels for RENDERCOLORTARGET and OFFSCREENRENDERTARGET semantics
- 0.2.3.0 (2010/12/20) MME Ver0.23
- ・CONTROLOBJECTセマンティクスの補足追記
- Added more to CONTROLOBJECT semantic's supplement (?)
- 0.2.4.0 (2011/02/09) MME Ver0.24
- ・CONTROLOBJECTセマンティクスに指定できる特殊オブジェクト名に"(self)"を追加
- Added "(self)" as a special name for CONTROLOBJECT semantic
- ・TEXTUREVALUEセマンティクスを追加
- Added TEXTUREVALUE semantic
- 0.2.6.0 (2010/02/21) MME Ver0.26
- ・Draw=Geometryコマンドについての記述を修正
- Corrected description for Draw=Geometry command
- 0.2.7.0 (2011/05/22) MME Ver0.27
- ・_INDEXセマンティクス追加
- Added _INDEX semantic
- ・VertexCountパラメータおよびSubsetCountパラメータを追加
- Added VertexCount and SubsetCount parameters
- ・opaddパラメータの追加
- Added opadd parameter
- ・TEXTUREVALUEセマンティクスの補足に追記
- Modified TEXTUREVALUE semantic description
- 0.2.8.0 (2012/03/26) MME Ver0.28
- ・CONTROLOBJECTセマンティクスについての記述を一部修正
- Changed part of CONTROLOBJECT semantic description
- 0.3.0.0 (2012/09/19) MME Ver0.30
- ・OFFSCREENRENDERTARGETセマンティクスのDefaultEffectに指定可能な
- 特殊なエフェクト名として"main_default"を追加
- Added the special name "main_default" to OFFSCREENRENDERTARGET semantic to use an object's default effect
- 0.3.3.0 (2013/02/13) MME Ver0.33
- ・テクスチャの材質モーフ用セマンティクス(ADDINGTEXTURE等)追加
- Added semantics for texture's material morphs, like ADDINGTEXTURE
- ・PMXモデルのサブテクスチャに対応(UseSphereMap, use_spheremap, use_subtexture参照)
- Can deal with PMX model's subtextures, refer to UseSphereMap, use_spheremap, use_subtexture
- ・MATERIALTOONTEXTUREセマンティクス追加
- Added MATERIALTOONTEXTURE semantic
- ・GROUNDSHADOWCOLORセマンティクス追加
- Added GROUNDSHADOWCOLOR semantic
- ・MME_MIPMAPマクロ追加
- Added MME_MIPMAP preprocessor macro
- ○注意
- Warning
- ・このリファレンスでは、MMEffectが認識するセマンティクス&アノテーションについて解説している。
- This reference explains the semantics and annotations that MMEffect recognizes.
- エフェクトファイルそのもののリファレンスについては、以下を参照のこと。
- As a reference for effect files themselves, see the following (links outdated, search or use archive.org)
- エフェクトファイルフォーマット http://msdn.microsoft.com/ja-jp/library/bb173005(v=VS.85).aspx
- Effect file format
- HLSLのリファレンス http://msdn.microsoft.com/ja-jp/library/bb509638(v=VS.85).aspx
- High-level shader language (HLSL) reference
- ・セマンティクス&アノテーションの仕様の策定は、NVIDIAのSASを参考にした。
- Decided to base semantics and annotations on Nvidia's SAS as the reference.
- http://developer.nvidia.com/object/using_sas.html
- ただしこれは、FX Composer用のエフェクトファイルが動作することを保障するものではない。
- However, there is no guarantee that effects from FX Composer will work.
- **************************************************
- 1 テクニックとパス
- Techniques and passes
- 1.1 構成
- Organization
- エフェクトファイルは、以下のような、テクニックとパスによる階層構造になっている。
- An effect file will form a layered structure (?) using techniques and passes in the following way.
- /**********************************/
- パラメータ宣言1
- Parameter declaration 1
- パラメータ宣言2
- Parameter declaration 2
- ...
- (Transliteration of "technique" and "pass")
- technique テクニック1 {
- pass パス1 {
- VertexShader = …
- PixelShader = …
- }
- pass パス2 {
- VertexShader = …
- PixelShader = …
- }
- …
- }
- technique テクニック2 {
- pass パス1 {
- VertexShader = …
- PixelShader = …
- }
- pass パス2 {
- VertexShader = …
- PixelShader = …
- }
- …
- }
- /**********************************/
- テクニックは1つ以上のパスから構成される。
- A technique is made of one or more passes. (*A blank technique disables that output, like ground shadow or edge.)
- 1つのパスは1回のレンダリング処理に対応しており、
- A single pass deals with one round of processing;
- テクニックが複数のパスから構成されている場合は、
- when a technique is organized into several passes,
- そのテクニックがマルチパスレンダリングを使用することを意味している。
- it means it uses "multipass rendering".
- テクニックとパスには、アノテーションと呼ばれる設定値を記述することができる。
- You can use 'annotations' to describe settings for techniques and passes.
- アノテーションは、以下のように、テクニック名・パス名の後ろに、"<"と">"で囲むようにして記述する。
- In the following way, you use "<" and ">" to surround the descriptor.
- なお、アノテーション名の大文字小文字の違いは無視される。
- Also, capitalization doesn't matter for annotation names.
- /******************************************************/
- technique Tech1 < string Subset = "1-6,8"; > {
- pass Pass1 < string Script = "Draw=Buffer;"; > {
- ...
- }
- pass Pass2 {
- ...
- }
- }
- /******************************************************/
- また、テクニックとパスには、スクリプトと呼ばれる特殊なアノテーションを
- 指定することができる。これについては、§3で説明する。
- "Script" is a special annotation for tehcniques and passes that's described in §3 (section 3).
- 1.2 テクニックのアノテーション
- Technique annotations
- テクニックのアノテーションには、
- そのテクニックをどの場面の描画に使用するかの条件を記述する。
- Technique annotations describe the specifics of the case where that technique will be used.
- この条件には、以下のものを指定できる。
- Those conditions can include the following.
- ・オブジェクトのサブセット番号(≒オブジェクトのマテリアルの番号)
- Object subset number (≒, means approximately equal to, the material number
- ・描画対象(オブジェクト本体/影/輪郭/セルフシャドウ用Z値プロット)
- Drawing target (Object itself/ground shadow/edges/the Z-value plot used for self-shadow)
- ・描画フラグ(テクスチャ使用ON/OFF、スフィアマップ使用ON/OFF、トゥーンレンダリング使用ON/OFF)
- Drawing flags (Whether texture is used, whether sphere map is used, whether 'toon' rendering is used)
- 条件の照合は、エフェクトファイルに書かれている順に行われるため、
- Conditions are tested in the order they are written,
- 複数のテクニックで使用条件が重なっている場合は、
- so if there are a bunch of techniques,
- エフェクトファイル上で先に記述されているものが優先される。
- the first applicable one is used.
- 条件に合致するテクニックがエフェクトファイル上に存在しない場合、
- MMD標準のシェーダが使用される。
- If no technique that matches the requirements is found, MMD's default shader is used.
- ○アノテーション
- Annotations
- ・string Subset
- そのテクニックを適用するサブセットの番号を指定する。
- Indicates the numbers of subsets that use the technique.
- PMDモデルの場合、これはモデルの材質番号に対応する。
- For PMD models, this uses the material number.
- アノテーション省略時には、全てのサブセットが適用対象となる。
- If this annotation is omitted, all subsets are valid targets.
- "0,3,5"のように、カンマ区切りで番号を列挙することで、複数の番号を指定できる。
- Using commas to separate (delineate) numbers in a list, you can use multiple numbers, like "0,3,5".
- また、"6-10"などのように、番号をハイフンでつなぐことで、範囲指定ができる。
- You can also select a range using a hyphen, like "6-10".
- "12-"のように、範囲の開始番号のみを指定した場合は、それ以降の全ての番号が対象となる。
- If you only set the range start, all numbers after it are used, like "12-".
- 例: string Subset = "0-6,8";
- Example
- ・string MMDPass
- そのテクニックを適用する描画対象を指定する。
- Indicates the drawing target for this technique.
- 以下のうちいずれかを指定する。この区分は、MMDの描画手順に由来する。
- Specify any/one of the following. This classification is used to derive the drawing procedure used by MMD.
- "object" : オブジェクト本体(セルフシャドウOFF)
- Object itself (self shadow off)
- "zplot" : セルフシャドウ用Z値プロット
- 'Z-value plot' used by self shadow
- "object_ss" : オブジェクト本体(セルフシャドウON)
- Object itself (self shadow on)
- "shadow" : 影(セルフシャドウではない単純な影)
- Ground shadow (Just the shadow, not self-shadow)
- "edge" : 輪郭(PMDモデルのみ)
- Edge/outline (only PMD models *unverified)
- アノテーション省略時には、"object"を指定したとみなされる。
- If this annotation is omitted, it's treated as "object".
- 例: string MMDPass = "object";
- Example
- ・bool UseTexture
- テクスチャ使用の有無を指定する。
- Indicate whether texture is used.
- そのテクニックが、テクスチャを使用するサブセットのみを対象とする場合には、trueを指定する。
- If the technique is only for subsets that use a texture, set this to true.
- 逆に、テクスチャを使用しないサブセットのみを対象とする場合には、falseを指定する。
- Conversely, for subsets that don't use a texture, set it to false.
- アノテーション省略時には、テクスチャの有無は無視される。
- If this annotation is omitted, whether a texture is used is ignored (when selecting a technique).
- 例: bool UseTexture = true;
- Example
- ・bool UseSphereMap
- スフィアマップ使用の有無を指定する。
- Indicate whether sphere map is used.
- そのテクニックが、スフィアマップを使用するサブセットのみを対象とする場合には、trueを指定する。
- If the technique is only for subsets that use a sphere map, set this to true.
- (PMXモデルにおいて、スフィアモードにサブテクスチャを指定した場合も含む)
- (For PMX models, subtexture that's set to sphere mode is included)
- 逆に、スフィアマップを使用しないサブセットのみを対象とする場合には、falseを指定する。
- Conversely, for subsets that don't use a texture, set it to false.
- アノテーション省略時には、スフィアマップの有無は無視される。
- If this annotation is omitted, whether a sphere map is used is ignored (when selecting a technique).
- 例: bool UseSphereMap = false;
- Example
- ・bool UseToon
- トゥーンレンダリング使用の有無を指定する。
- Indicate whether 'toon rendering' is used.
- そのテクニックが、トゥーンレンダリングを使用するオブジェクト(=PMDモデル)を対象とする場合には、trueを指定する。
- If you want the technique to target objects that use 'toon rendering' (=PMD model), set this to true.
- 逆に、トゥーンレンダリングを使用しないオブジェクト(=アクセサリ)を対象とする場合には、falseを指定する。
- If the technique is for objects that don't use 'toon rendering' (accessories), set it to false.
- アノテーション省略時には、トゥーンレンダリング使用の有無は無視される。
- If the annotation is omitted, whether 'toon rendering' is used is ignored (when selecting a technique).
- 例: bool UseToon = true;
- Example
- ○使用例
- Example of use
- //セルフシャドウがONの場合、サブセットのNo.0~6とNo.8には、Tech1が適用され、
- When self-shadow is on, subsets 0~6 and 8 and use Tech 1.
- //サブセットのNo.7とNo.9~には、Tech2が適用される。
- Subset 7 and 9~ (to end) use Tech2.
- //セルフシャドウがOFFの場合、Tech3が適用される。
- When self-shadow is off, all subsets/materials use Tech3.
- technique Tech1 <
- string MMDPass = "object_ss";
- string Subset = "0-6,8";
- > {
- ...
- }
- technique Tech2 <
- string MMDPass = "object_ss";
- string Subset = "7,9-";
- > {
- ...
- }
- technique Tech3 <
- string MMDPass = "object";
- > {
- ...
- }
- ○補足
- Supplement/notes
- ・妥当でないテクニックは除外される。
- Invalid techniques are excluded.
- http://msdn.microsoft.com/ja-jp/library/bb206324(v=VS.85).aspx
- ・MMDPass="object","object_ss"以外のテクニックでは、UseTexture,UseSphereMap,UseToonは正しく機能しない。
- Other than with MMDPass="object" or "object_ss", the annotations UseTexture, UseSphereMap, UseToon won't work properly.
- **************************************************
- 2 パラメータのセマンティクスとアノテーション
- The semantics and annotations of parameters
- 以降では、MMEffect用のエフェクトファイルで使用できる、
- パラメータのセマンティクスとアノテーションについて説明する。
- The following explains the semantics and annotations of parameters that you can use in effect files for MMEffect.
- パラメータの宣言をセマンティクスやアノテーションで修飾することで、
- レンダリングに必要な様々な情報を、そのパラメータを解して取得できる。
- By adding or qualifying parameter (variable) declaration with semantics or annotations, during rendering you can read (解する) those parameters to acquire various essential pieces of information.
- パラメータのセマンティクスとアノテーションは、以下のように記述する。
- These semantics and annotations have the following form.
- 型名 パラメータ名 : セマンティクス名 < 型名 アノテーション1 = 値; 型名 アノテーション2 = 値; ... > ;
- variable_type parameter_name : semantic_name < variable_type annotation1 = value; variable_type annotation2 = value; ... > ;
- セマンティクスによっては、アノテーションを指定しないものもある。
- Some semantics don't let you use annotations.
- なお、セマンティクス名とアノテーション名の大文字小文字の違いは無視される。
- Note: capitalization of semantics and annotations is ignored.
- 2.1 ジオメトリ変換
- Transforming objects
- 参考:http://msdn.microsoft.com/ja-jp/library/bb206269(v=VS.85).aspx
- Reference
- ●WORLD
- ●VIEW
- ●PROJECTION
- ●WORLDVIEW
- ●VIEWPROJECTION
- ●WORLDVIEWPROJECTION
- 頂点の座標変換に使用する変換行列。
- Transformation matrices (matrix) for vertex coordinates
- 座標変換には、ワールド変換、ビュー変換、プロジェクション変換(射影変換)がある。
- For coordinate transformations, there are world transformations, view transformations, and projection transformations.
- 6つのセマンティクスは、それぞれ、
- The six types of semantics are as follows.
- WORLD : ワールド変換行列
- World transformation matrix
- VIEW : ビュー変換行列
- View transformation matrix
- PROJECTION : プロジェクション変換行列
- Projection transformation matrix
- WORLDVIEW : ワールド変換行列×ビュー変換行列
- World transformation matrix times (×) view matrix
- VIEWPROJECTION : ビュー変換行列×プロジェクション変換行列
- View matrix times (×) projection matrix
- WORLDVIEWPROJECTION : ワールド変換行列×ビュー変換行列×プロジェクション変換行列
- World times (×) view times (×) projection matrix
- を表す。
- (literally: signifies.)
- 型はfloat4x4。
- Variable type is float4x4.
- *NOTE: matrix operations are associative or commutative or something, so with matrix math,
- Position × WORLD × VIEW × PROJECTION
- is the same as
- Position × WORLDVIEWPROJECTION
- "WORLDINVERSE"のように、セマンティクスの末尾に"INVERSE"を付加すると、各行列の逆行列が得られる。
- By adding "INVERSE" to the end of the semantic, e.g. "WORLDINVERSE", you can obtain the inverse of each matrix.
- また、"WORLDTRANSPOSE"のように、末尾に"TRANSPOSE"を付加すると、各行列の転置行列が得られる。
- With "TRANSPOSE" at the end, you can obtain the transposed matrix.
- *NOTE: 'Position × WORLD' is equal to 'WORLDTRANSPOSE × Position'.
- 逆行列の転置行列を得るには、末尾に"INVERSETRANSPOSE"を付加する。
- For inverse transpose, add "INVERSETRANSPOSE" to the semantic.
- ○アノテーション
- Annotation
- ・string Object (省略可能)
- (can omit)
- ビュー変換およびプロジェクション変換において、どこを視点とするかを指定する。
- For VIEW and PROJECTION transformations, set where the viewpoint is.
- "Camera"または"Light"が指定できる。デフォルトは"Camera"である。
- "Camera" and "Light" are the valid settings. Default is "Camera".
- 通常の、カメラを視点とした座標変換を行う場合には、"Camera" を指定する。
- For the normal case, use "Camera" to indicate camera as viewpoint.
- セルフシャドウのためのZ値プロット等、光源を視点とした座標変換を行う場合には、"Light"を指定する。
- For the Z-value plot used by self-shadow and such, use "Light" for a coordinate transformation based on the light's source location.
- ○使用例
- Example of use
- float4x4 WorldMatrix : WORLD ;
- float4x4 WorldViewProjMatrix : WORLDVIEWPROJECTION ;
- float4x4 LightViewMatrix : VIEW < string Object = "Light"; > ;
- float4x4 WorldInvMatrix : WORLDINVERSE ;
- float4x4 WorldViewProjTransMatrix : WORLDVIEWPROJECTIONTRANSPOSE ;
- ○補足
- Supplement/notes
- ・Objectアノテーションに"Light"を指定したときに得られる行列は、
- MMDのセルフシャドウ処理に使用している行列と連動しているため、
- [表示(V)]-[セルフシャドウ表示(P)]で、セルフシャドウ機能を完全にOFFにしてしまうと、
- 正しい値を参照できなくなる。
- When you use "Light" as the annotation for a matrix, it's based on the matrix MMD uses for self-shadows. If self-shadows are turned off with menu Show(V) > Self shadow display(P), the value is no longer available.
- 2.2 ライトとマテリアル
- Lights and materials
- 参考:http://msdn.microsoft.com/ja-jp/library/bb174694(v=VS.85).aspx
- Reference
- ●DIFFUSE
- ●AMBIENT
- ●EMISSIVE
- ●SPECULAR
- ●SPECULARPOWER
- ●TOONCOLOR
- ●EDGECOLOR
- ●GROUNDSHADOWCOLOR
- 3Dオブジェクトのマテリアル(材質)の色値、またはライトの色値。
- The color value of a material or a light.
- 6つのセマンティクスは、それぞれ、
- The (literally six) eight semantics are as follows,
- DIFFUSE : ディフューズ色(拡散光)
- Diffuse color (scattered light)
- AMBIENT : アンビエント色(環境光)
- Ambient color (environment light). *Note: affected by light slider.
- EMISSIVE : エミッション色(放射光)
- Emissive color. *Note: not affected by light slider.
- SPECULAR : スペキュラ色(鏡面光)
- Specular color (shiny/mirror)
- SPECULARPOWER : スペキュラの強度
- Specular strength *Note: concentration, not maximum brightness
- TOONCOLOR : トゥーン色
- Toon color
- EDGECOLOR : 輪郭色
- Edge color
- GROUNDSHADOWCOLOR : 地面影色
- Ground shadow color
- を表す。
- (literally: signifies.)
- トゥーン色は、PMDモデルのトゥーンレンダリングにおける、影の色(具体的にはtoon??.bmpの左下隅の色)を表す。
- Toon color is the 'shadow color' for the 'toon rendering' used by PMD (and PMX; non-accessory) models. Specifically, the bottom-left corner of a toon texture like toon??.bmp.
- 型は、"SPECULARPOWER"のみfloatで、それ以外はfloat3またはfloat4ある。
- Variable type for "SPECULARPOWER" is float, the rest are float3 or float4.
- 色は4つの成分(赤・緑・青・アルファ(透明度))で構成される。型にfloat3を指定するとアルファ値が省略される。
- Colors have four components (red, green, blue, alpha (transparency)). When type is specified as float3, alpha is discarded.
- ○アノテーション
- Annotation
- ・string Object (必須)
- (required)
- ライト色と、オブジェクトのマテリアル色のどちらを取得するかを指定する。
- Specify whether to get light or object material color.
- "Light"または"Geometry"が指定できる。
- "Light" and "Geometry" are the valid options.
- オブジェクトのマテリアル色を取得するには、"Geometry"を指定する。
- Use "Geometry" to get the object material's colors.
- ライト色を取得するには、"Light"を指定する。
- Use "Light" to get the light's (multi-component) colors.
- "SPECULARPOWER"と"EMISSIVE"および"TOONCOLOR"には、ライト色がないため、"Light"は指定できない。
- For "SPECULARPOWER", "EMISSIVE", and "TOONCOLOR", these don't apply to lights so "Light" isn't a valid annotation name.
- ○使用例
- Example of use
- float4 MaterialDiffuse : DIFFUSE < string Object = "Geometry"; >;
- float3 MaterialAmbient : AMBIENT < string Object = "Geometry"; >;
- float3 MaterialEmissive : EMISSIVE < string Object = "Geometry"; >;
- float3 MaterialSpecular : SPECULAR < string Object = "Geometry"; >;
- float SpecularPower : SPECULARPOWER < string Object = "Geometry"; >;
- float3 MaterialToon : TOONCOLOR;
- float3 EdgeColor : EDGECOLOR;
- float3 LightDiffuse : DIFFUSE < string Object = "Light"; >;
- float3 LightAmbient : AMBIENT < string Object = "Light"; >;
- float3 LightSpecular : SPECULAR < string Object = "Light"; >;
- static float4 DiffuseColor = MaterialDiffuse * float4(LightDiffuse, 1.0f);
- static float3 AmbientColor = MaterialAmbient * LightAmbient + MaterialEmissive;
- static float3 SpecularColor = MaterialSpecular * LightSpecular;
- float4 GroundShadowColor : GROUNDSHADOWCOLOR;
- // *Fixed spelling error, "Emmisive" > "Emissive"
- ○補足
- Supplement/notes
- ・輪郭色はMMDPass="edge"のTechniqueにおいてしか、正しく取得できない。
- Edge color (EDGECOLOR) cannot be correctly measured except inside a technique with MMDPass="edge".
- ・地面影色はMMDPass="shadow"のTechniqueにおいてしか、正しく取得できない。
- Ground shadow color (GROUNDSHADOWCOLOR) cannot be correctly measured except inside a technique with MMDPass="shadow".
- ・その他の各色値は、MMDPass="zplot"またはMMDPass="edge"のTechniqueにおいては、正しく取得できない。
- Colors other than these can't be acquired inside techniques with MMDPass="zplot" or MMDPass="edge".
- ●POSITION
- ●DIRECTION
- ライトまたはカメラの、ワールド空間内における位置および向き。
- The position or direction of light or camera in world space.
- 型は、float3またはfloat4である。
- Variable type is float3 or float 4.
- ○アノテーション
- Annotation
- ・string Object (必須)
- (required)
- カメラおよびライトのどちらの座標を取得するかを指定する。
- Specify whether to acquire camera or light coordinates.
- "Camera"または"Light"が指定できる。
- "Camera" and "Light" are the options.
- ○使用例
- Example of use
- float3 LightDirection : DIRECTION < string Object = "Light"; >;
- float3 CameraPosition : POSITION < string Object = "Camera"; >;
- ○補足
- Supplement/notes
- ・MMDのライトは、ディレクショナルライトであるため、
- ライトの位置座標は、ライトの向きと逆方向の無限遠点になる。
- Because MMD uses a directional light, the light's position is its vanishing point (infinite distance) in the opposite direction.
- ●MATERIALTEXTURE
- マテリアルに設定されているテクスチャ。
- The texture set for a material.
- ○アノテーション
- なし
- No annotations
- ○使用例
- Example of use
- texture ObjectTexture : MATERIALTEXTURE;
- sampler ObjTexSampler = sampler_state
- {
- texture = <ObjectTexture>;
- MINFILTER = LINEAR;
- MAGFILTER = LINEAR;
- MIPFILTER = LINEAR;
- ADDRESSU = WRAP;
- ADDRESSV = WRAP;
- };
- // tex2D(ObjTexSampler, float2(x,y)) で内容を参照できる
- with this, you can sample the contents
- ○補足
- Supplement/notes
- ・各色値は、MMDPass="zplot"またはMMDPass="edge"のTechniqueにおいては、正しく取得できない。
- (The same warning about "can't get colors with zplot and edge techniques", except no "Other than these"?)
- ●MATERIALSPHEREMAP
- マテリアルに設定されている、スフィアマップテクスチャ。
- The sphere map texture specified for a material.
- ○アノテーション
- なし
- No annotations
- ○使用例
- Example of use
- texture ObjectSphereMap : MATERIALSPHEREMAP;
- sampler ObjSphSampler = sampler_state
- {
- texture = <ObjectSphereMap>;
- MINFILTER = LINEAR;
- MAGFILTER = LINEAR;
- MIPFILTER = LINEAR;
- ADDRESSU = WRAP;
- ADDRESSV = WRAP;
- };
- // tex2D(ObjSphSampler, float2(x,y)) で内容を参照できる
- with this, you can sample the contents
- ○補足
- Supplement/notes
- ・各色値は、MMDPass="zplot"またはMMDPass="edge"のTechniqueにおいては、正しく取得できない。
- (same warning about colors and zplot or edge techniques)
- ●MATERIALTOONTEXTURE
- マテリアルに設定されている、トゥーンマップテクスチャ。
- The 'toon map' texture specified for a material.
- ○アノテーション
- なし
- No annotations
- ○使用例
- Example of use
- texture ObjectToonTexture : MATERIALTOONTEXTURE;
- sampler ObjToonSampler = sampler_state
- {
- texture = <ObjectSphereMap>;
- MINFILTER = LINEAR;
- MAGFILTER = LINEAR;
- MIPFILTER = NONE;
- ADDRESSU = CLAMP;
- ADDRESSV = CLAMP;
- };
- // tex2D(ObjToonSampler, float2(x,y)) で内容を参照できる
- with this, you can sample the contents
- ○補足
- Supplement/notes
- ・各色値は、MMDPass="zplot"またはMMDPass="edge"のTechniqueにおいては、正しく取得できない。
- (same warning about colors and zplot or edge techniques)
- ・また、アクセサリの場合(UseToon=falseの場合)は、正しく取得できない。
- Also, for accessories (UseToon=false technique annotation), this value can't be acquired.
- ・PMDモデルにおいて、トゥーンを使用しないマテリアルの場合は、全面白色のテクスチャとなる。
- For PMD models, materials that don't have a 'toon' texture set will use a pure white texture.
- ●ADDINGTEXTURE
- ●MULTIPLYINGTEXTURE
- ●ADDINGSPHERETEXTURE
- ●MULTIPLYINGSPHERETEXTURE
- PMX材質モーフのための、テクスチャおよびスフィアマップのテクスチャに対しての、
- 加算値および乗算値。
- For PMX material morphs. Texture or sphere's addition value or multiplication value (?).
- ○アノテーション
- なし
- No annotations
- ○使用例
- Example of use
- float4 TextureAddValue : ADDINGTEXTURE;
- float4 TextureMulValue : MULTIPLYINGTEXTURE;
- float4 SphereAddValue : ADDINGSPHERETEXTURE;
- float4 SphereMulValue : MULTIPLYINGSPHERETEXTURE;
- ○補足
- Supplement/notes
- ・各値は、MMDPass="object_ss"の場合でしか、正しく取得できない。
- These values can only be used with MMDPass="object_ss" techniques.
- ・また、アクセサリの場合(UseToon=falseの場合)は、加算値は全て0、乗算値は全て1になる。
- With accessories (UseToon=false annotation), addition values are always 0, multiplication values are always 1.
- 2.3 スクリーン情報
- Screen information
- ●VIEWPORTPIXELSIZE
- レンダリングターゲットのスクリーンのサイズ。
- The current rendering target's screen size.
- 型はfloat2。単位はピクセル。
- Variable type is float2. Unit is pixels.
- ※この値は、MMDのスクリーンもしくはオフスクリーンレンダリングターゲットのサイズを指す。
- (Reference mark/kome) This value shows MMD's screen or offscreen render (rendering) target's size.
- Scriptsの"RenderColorTarget"コマンドで、レンダリングターゲットが変更しても、
- この値は変化しない。
- When you change "RenderColorTarget" in a technique's script, even though the rendering target changes, this value does not.
- ○アノテーション
- なし
- No annotations
- ○使用例
- Example of use
- float2 ScreenSize : VIEWPORTPIXELSIZE;
- ○補足
- Supplement/notes
- ・内部的には、Viewportの.Widthと.Heightの値を参照している。
- The contents of this are taken from Viewport.Width and Viewport.Height.
- 2.4 時間
- Time
- ●TIME
- ●ELAPSEDTIME
- 時間情報。
- Time information.
- 型はfloat。単位は秒。
- Variable type is float. Unit is seconds.
- "TIME"は、0フレーム目からの再生時間を表す。
- "TIME" is playback time relative to frame 0.
- 例えば、0フレーム目では、0.0(秒)となり、45フレーム目では1.5(秒)となる。
- For example, at frame 0, it's 0.0 (seconds). At frame 45, it's 1.5 (seconds).
- "ELAPSEDTIME"は、前回の描画からの経過時間を表す。
- "ELAPSEDTIME" measures time since the previous drawn frame.
- 例えば、60fpsでAVI出力時には、"ELAPSEDTIME"の値は、1/60 で一定になる。
- For example, when outputting to an .avi at 60 fps, "ELAPSEDTIME" will be uniformly 1/60.
- ○アノテーション
- Annotation
- ・bool SyncInEditMode (省略可能)
- (can omit)
- MMDが編集モードである場合でも、フレームと連動するかを指定する。
- Determines whether the time is linked to frame number in edit mode.
- trueまたはfalseを指定する。デフォルトはfalse。
- Can be true or false. Default is false.
- MMDが編集モードのときには、フレームの再生は停止しているため、
- Since in edit mode, the frame is stopped in MMD,
- TIMEの値が常にフレーム時間と連動していると、
- if TIME is linked to frame number,
- 編集モード中は、この値を使用しているアニメーションも停止することになる。
- during edit mode any animations that use this value will be suspended too.
- このアノテーションにfalseが指定されていると、
- If you use false for this annotation,
- 編集モード中、TIMEおよびELAPSEDTIMEの値には、フレーム時間ではなくシステム時間が使用される。
- then rather than frame number, TIME and ELAPSEDTIME will be based on system time.
- これにより、編集モード中でもアニメーションが停止しなくなる。
- Accordingly, even in edit mode animations won't be stopped.
- ○使用例
- Example of use
- float ftime : TIME <bool SyncInEditMode=true;>;
- float elapsed_time : ELAPSEDTIME;
- static float fps = 1.0 / elapsed_time;
- ○補足
- Supplement/notes
- ・SyncInEditMode=trueの場合、ELAPSEDTIMEの値は、MMD上でのフレーム移動操作により、0やマイナスになりうる。
- With SyncInEditMode=true, the value of ELAPSEDTIME can be zero or negative (minus), depending on frame navigation.
- 2.5 マウス
- Mouse
- ●MOUSEPOSITION
- マウスの現在位置。
- Mouse's current position.
- 型はfloat2。
- Variable type is float2.
- MMDの描画領域の中心を(0,0)とし、左下隅が(-1,-1)、右上隅が(1,1)になる。
- The center of MMD's render/drawing output is (0,0). Bottom left corner is (-1,-1), top right corner is (1,1).
- このxy座標の取り方は、プロジェクション変換した後の、頂点座標と同じである。
- These xy coordinates correspond to the positions for vertex coordinates after a projection transformation.
- ○アノテーション
- なし
- No annotations
- ○使用例
- Example of use
- float2 pos : MOUSEPOSITION;
- ●LEFTMOUSEDOWN
- ●MIDDLEMOUSEDOWN
- ●RIGHTMOUSEDOWN
- マウスボタンに関する情報。
- Mouse button information.
- 型はfloat4。
- Variable type is float4.
- 取得できる値は、以下の4成分からなる。
- The obtained value has the following four components.
- ・最後にボタンが押されたときのマウスの座標(xとy)
- Coordinates (x and y) of the location where the button was last pressed
- ・現在ボタンが押されているか (0 or 1)
- Whether the button is currently depressed (0 or 1)
- ・最後にボタンが押された時点のTIME値(秒)
- The TIME value (seconds) for when the button was last pressed
- なお、マウスの座標の取り方は、MOUSEPOSITIONと同じである。
- Note: mouse coordinates are defined/obtained the same as for MOUSEPOSITION.
- ○アノテーション
- なし
- No annotations
- ○使用例
- Example of use
- float4 mouse_down : LEFTMOUSEDOWN;
- static float2 pos = mouse_down.xy;
- static bool is_pressed = (mouse_down.z != 0);
- 2.6 コントロールオブジェクト
- Control object
- ●CONTROLOBJECT
- 指定したオブジェクトの、座標やワールド変換行列を取得する。
- Acquire the coordinates or world transformation matrix of the indicated object.
- 主に、シェーダに必要なパラメータをMMD上から制御する場合に使用する。
- Usually used to get important shader parameters from MMD.
- 型はbool, float, float3, float4またはfloat4x4。
- Variable type can be bool, float, float3, float4, or float4x4.
- 使用する型によって、取得できる情報が異なる。
- Depending on the variable type, the obtained information differs.
- ・bool
- 指定したオブジェクトが表示されているか否か
- Whether the indicated object is visible/displayed or not
- ・float
- 指定したオブジェクトのスケーリング値
- The indicated object's scaling value (*Note: 10x the value of 'Si', used by accessories)
- ・float3, float4
- 指定したオブジェクトの座標(オフセット)
- The object's coordinates (offset)
- ・float4x4
- 指定したオブジェクトのワールド変換行列
- The object's world transformation matrix
- また、itemアノテーションに特殊な文字列を指定することにより、
- Note: using a special string for 'item' annotation,
- In addition, depending on the string used for the 'item' annotation,
- これら以外の値も取得できる。
- you can obtain values other than those here.
- ○アノテーション
- Annotation
- ・string name (必須)
- (required)
- オブジェクトのファイル名を指定する(フォルダパスは含めない)。
- The object's filename (don't include the path to the file)
- 特殊なファイル名"(self)"を指定すると、
- If you use "(self)" for the filename,
- そのエフェクトが割り当てられたオブジェクト自身を対象にできる。
- it will use the object that the effect is applied to.
- また、特殊なファイル名"(OffscreenOwner)"を指定すると、
- If you use "(OffscreenOwner)" for the filename,
- オフスクリーンのオーナーのオブジェクトを対象にできる(オフスクリーンレンダリング中の場合のみ)。
- the offscreen owner will be used (only applies to offscreen rendering)
- ここで、オフスクリーンのオーナーとは、OFFSCREENRENDERTARGETが宣言されているエフェクトが
- 割り当てられたオブジェクトを指す
- This is the object that the effect that declares the OFFSCREENRENDERTARGET is applied to.
- ・string item (省略可能)
- (can omit)
- オブジェクトの特殊な値を取得したい場合に指定する。
- Use this when you want to obtain a special value from the object.
- 以下のうちいずれかを指定する。
- Any of the following can be specified.
- ボーン名 : PMDモデルの指定ボーンの座標またはワールド変換行列を取得する。
- Bone name: (acquires the) PMD (or PMX) model's bone coordinate or world transformation matrix
- 型はfloat3,float4,float4x4のうちいずれか。
- Variable type is float3, float4, or float4x4.
- 表情名 : PMDモデルの指定した表情の値を取得する。型はfloat。
- Expression name: PMD (or PMX) model's expression value. Type is float.
- "X" : アクセサリの位置X(アクセサリパネルのX)。型はfloat。
- Accessory's position X (accessory panel X). Type is float.
- "Y" : アクセサリの位置Y(アクセサリパネルのY)。型はfloat。
- Accessory's position Y (accessory panel Y). Type is float.
- "Z" : アクセサリの位置Z(アクセサリパネルのZ)。型はfloat。
- Accessory's position Z (accessory panel Z). Type is float.
- "XYZ" : アクセサリの位置(アクセサリパネルのX,Y,Z)。型はfloat3。
- Accessory's full position (accessory panel X, Y, Z). Type is float3.
- "Rx" : アクセサリの回転X(アクセサリパネルのRx)。型はfloat。(※1)
- Accessory's rotation X (accessory panel Rx). Type is float. (See note/kome 1)
- "Ry" : アクセサリの回転Y(アクセサリパネルのRy)。型はfloat。
- Accessory's rotation Y (accessory panel Ry). Type is float.
- "Rz" : アクセサリの回転Z(アクセサリパネルのRz)。型はfloat。
- Accessory's rotation Z (accessory panel Rz). Type is float.
- "Rxyz" : アクセサリの回転(アクセサリパネルのRx,Ry,Rz)。型はfloat3。
- Accessory's all rotations (accessory panel Rx, Ry, Rz). Type is float3.
- "Si" : アクセサリのサイズ(アクセサリパネルのSi)。型はfloat。(※2)
- Accessory's size (accessory panel Si). Type is float. (See note/kome 2)
- "Tr" : アクセサリの透明度(アクセサリパネルのTr)。型はfloat。
- Accessory's transparency (accessory panel Tr). Type is float.
- (*Note: fixed typo, アクセサリパネルのSi > Tr)
- (*Note: world matrix includes 'outside parent', XYZ or Rxyz does not)
- ※1 得られる値は、パネル上の値をラジアンで表したものである。
- (Reference mark/kome)1 Obtained value is the panel value converted into (expressed as) radians.
- ※2 得られる値は、パネル上の値を10倍したものである。
- (Reference mark/kome)2 Obtained value is 10 times the panel value.
- ○使用例
- Example of use
- //"stage01.x"が表示されているか否かを取得
- Acquire a value that depends on whether "stage01.x" is displayed
- bool flag : CONTROLOBJECT < string name = "stage01.x"; >;
- //"negi.x"のスケーリング値を取得
- Get scaling value for "negi.x" (*See ※2 above)
- float scaling : CONTROLOBJECT < string name = "negi.x"; >;
- //"negi.x"の回転Xを取得
- Obtain the X-rotation (*panel value) of "negi.x"
- float rot_x : CONTROLOBJECT < string name = "negi.x"; string item = "Rx"; >;
- //"negi.x"の回転Xを度数単位で取得
- Get X-rotaton (*panel value) of "negi.x" in degrees
- float rot_x_rad : CONTROLOBJECT < string name = "negi.x"; string item = "Rx"; >;
- static float rot_x = rot_x_rad * 180 / 3.14159265;
- //"弱音ハク.pmd"のボーン「ポニテIK」の座標取得
- Get the position of "弱音ハク.pmd" (Yowane Haku) bone "ポニテIK" (Ponytail Inverse Kinematics or PoniteIK)
- float3 pos : CONTROLOBJECT < string name = "弱音ハク.pmd"; string item = "ポニテIK"; >;
- //"弱音ハク.pmd"の表情「まばたき」の値取得
- Get the "まばたき" (blinking) expression value from "弱音ハク.pmd" (Yowane Haku)
- float morph : CONTROLOBJECT < string name = "弱音ハク.pmd"; string item = "まばたき"; >;
- ○補足
- Supplement/notes
- ・PMDモデルのワールド変換行列は単位行列で変化しないため、
- Since the world transformation matrix of a PMD (or PMX) model is the identity matrix and therefore never changes,
- 通常は、Xファイル(アクセサリ)に対して使用する。
- this (*world matrix as float4x4) is usually targeted at an X file (accessory).
- ・アクセサリのスケーリング値は、MMD上でアクセサリのSizeに指定した値を10倍した値になる。
- An accessory's obtained scaling value is 10 times the value indicated in MMD's Size/Si field.
- (内部的には、length(world_matrix._11_12_13) で得られる値を使用している)
- (Internally, the value of length(world_matrix._11_12_13) is used)
- (Yes, it's confusing)
- ・指定したファイル名のオブジェクトが存在しない場合、以下の値が設定される。
- When the specified oject doesn't exist, the following values are used.
- Xファイルの場合:
- For an X file:
- スケーリング値 :10
- Scaling value : 10
- オフセット値 :(0,0,0,1)
- Offset/position : (0,0,0,1)
- ワールド変換行列:スケーリング行列(xyz各10倍)
- World transformation matrix: scaling matrix (results in xyz each being multiplied by 10)
- 特殊item値 :0
- Special 'item' value : 0
- PMDファイルの場合:
- For a PMD file:
- スケーリング値 :1
- Scaling value : 1
- オフセット値 :(0,0,0,1)
- Offset/position : (0,0,0,1)
- ワールド変換行列:単位行列
- World transformation matrix: identity matrix
- ボーンの座標 :(0,0,0,1)
- Bone coordinates : (0,0,0,1)
- ボーンの変換行列:単位行列
- Bone transformation matrix : identity matrix
- 表情値 :0
- Expression value : 0
- ・MME ver0.20より、参照先のオブジェクトが参照元のオブジェクトよりも後に描画されていても、
- 値を取得できるようになった。
- Since MME ver0.20, even when the (referent) target object is drawn after the object that's checking the value, it can be acquired.
- ・指定した名前を持つオブジェクトが複数存在する場合、以下の優先順位で選択される。
- When more than one object has the indicated name, priority is determined as follows.
- (1) 参照元のオブジェクトよりも描画順序が先で、かつ最も描画順序が近いもの。
- Starting with (?) or for (?) effects drawn before the querying object, the object with the closest drawing order. (?)
- (2) 描画順序が最後のもの
- Drawing order is latest/most delayed (?)
- ・ダミーボーン.pmdなどのように、頂点を一つも持たないオブジェクトについては、
- 参照先に指定しても座標を取得できない。
- For objects like ダミーボーン.pmd (Dammy_Bone.pmd, dummy) that don't have a single vertex, you can't get any coordinates by referring to them. (*Unverified. So much for using dummy bone for light positions)
- 2.7 テクスチャ関連
- Related to textures
- ●通常テクスチャ
- Normal/usual/basic texture (*note: no semantic)
- テクスチャを生成する。
- Create a texture.
- 型はtexture, texture2D, texture3D, textureCUBEのうちいずれか。
- Variable type can be texture, texture2D, texture3D, or textureCUBE.
- RENDERCOLORTARGET, RENDERDEPTHSTENCILTARGET, ANIMATEDTEXTURE 以外のセマンティクスは指定しても無視される。
- If semantic is other than RENDERCOLORTARGET, RENDERDEPTHSTENCILTARGET, or ANIMATEDTEXTURE, it is ignored.
- 生成したテクスチャの内容は、サンプラを設定した上で、tex2D(s, t)関数などを呼び出すことで参照できる。
- The contents of a created texture can be accessed, after defining a sampler, by calling a function like tex2D(s, t).
- ○アノテーション
- Annotation
- ・string ResourceType
- テクスチャの種類を指定する。"2D", "3D", "CUBE"のうちいずれかを指定する。
- Indicate the texture's variety. "2D", "3D", or "CUBE" can be used.
- 型と矛盾した値は指定できない。
- A value that's inconsistent with variable type can't be used.
- 型が"texture"であり、かつ"2D"以外のテクスチャを生成する場合には、
- When type is "texture" and you want to create a type other than 2D,
- かならずこのアノテーションを指定しなければならない。それ以外では省略可能である。
- make sure to use this annotation. Otherwise, it can be omitted.
- ・string ResourceName
- テクスチャの元になる画像ファイルを指定する。
- Select an image file to use for the texture.
- サポートしているファイルフォーマットは、bmp、.dds、.dib、.jpg、.png、および .tga である。
- Supported formats are bmp, dds, dib, jpg, png and tga.
- 相対パスでファイル名を指定した場合、エフェクトファイルが格納されているフォルダが基準となる。
- When using a relative path to designate the filename, the folder that the effect file is stored in is used as the starting directory.
- ・int Width
- ・int Height
- ・int Depth
- テクスチャの幅、高さ、深さをピクセル単位で指定する。
- Specify the texture's width, height, depth in pixels.
- 深さを指定するのはボリュームテクスチャの場合のみである。
- Depth is specified only for volume (3D) textures.
- Dimensions, ViewportRatio とは同時に指定できない。
- Can't be specified at the same time as Dimensions or ViewportRatio.
- (Width,Height,Depth), Dimensions, ViewportRatioのいずれも指定されていない場合の、
- デフォルト値は、64ピクセルである。
- If none of (Width,Height,Depth), Dimensions, nor (?) ViewportRatio are specified, the default value of 64 pixels is used.
- また、ResourceNameが指定されているならば、画像ファイルからサイズが自動的に取得される。
- However, if ResourceName is specified, image size is automatically obtained from the image file.
- ・int2(or int3) Dimensions
- テクスチャの幅、高さ、深さをピクセル単位で指定する。
- Specify the texture's width, height, depth in pixels.
- 深さを指定するのはボリュームテクスチャの場合のみである。
- Depth is specified only for volume (3D) textures.
- ViewportRatio, Width, Height, Depthとは同時に指定できない。
- Can't be specified at the same time as ViewportRatio, Width, Height, or Depth.
- ・float2 ViewportRatio
- テクスチャの幅、高さを、レンダリングターゲットのスクリーンのサイズとの比で指定する。
- Specify the texture's width and height as a ratio of the render (rendering) target's size.
- スクリーンと同じサイズのテクスチャを生成するには、"float2 ViewportRatio = {1.0, 1.0};" と指定する。
- To make a texture with the same size as the screen, set this as "float2 ViewportRatio = {1.0, 1.0};".
- スクリーンの縦横2倍のサイズのテクスチャを生成するには、"float2 ViewportRatio = {2.0, 2.0};" と指定する。
- To make a texture twice as large as the screen along each dimension (*4x area), set this as "float2 ViewportRatio = {2.0, 2.0};".
- Dimensions, Width, Height, Depthとは同時に指定できない。
- Can't be specified at the same time as Dimensions, Width, Height, or Depth.
- ・string Format
- テクスチャのフォーマットを指定する。
- Specify texture's format.
- 省略した場合、"A8R8G8B8"が使用される。
- If omitted, "A8R8G8B8" is used.
- ResourceNameが指定されているならば、画像ファイルからフォーマットが取得され、
- If ResourceName is set, the format is taken from the image file,
- このアノテーションの設定は無視される。
- and this annotation is ignored.
- 指定可能なフォーマットは、D3DFORMAT(http://msdn.microsoft.com/ja-jp/library/bb172558(v=VS.85).aspx)
- を参照。
- For possible formats, consult D3DFORMAT (outdated link, do a search or use archive.org).
- "A8R8G8B8"、"FMT_A8R8G8B8"、"D3DFMT_A8R8G8B8"のいずれの書式でも指定できる。
- It doesn't matter whether you prepend "FMT_" or "D3DFMT_".
- ・int Miplevels
- ミップマップを指定したレベルで生成する。
- Mipmaps are created to the indicated level.
- 省略するか0を指定した場合、完全なミップマップ チェーンが作成される。
- If omitted or 0, the entire mipmap chain is created.
- 1を指定すると、ミップマップは生成されない。
- If set to 1, mipmaps are not created.
- ・int Levels
- Miplevelsの別名である。
- Another name for Miplevels.
- ○使用例
- Example of use
- texture negi_tex < string ResourceName = "negi.bmp"; >;
- sampler TexSampler = sampler_state {
- texture = <negi_tex>;
- };
- texture2D map_tex <
- string ResourceName = "map.png";
- int Miplevels = 1;
- int Width = 64;
- int Height = 64;
- >;
- ●RENDERCOLORTARGET
- レンダリングターゲットに指定可能なサーフェイスを生成する。
- Create a surface that can be used as a render (rendering) target.
- このセマンティクスを指定して生成したテクスチャは、スクリプトのRenderColorTargetに
- 指定することができる。
- A texture that is created with this semantic can be used in a script (*for a technique) as a RenderColorTarget.
- レンダリング後は、通常のテクスチャと同様に、tex2D()関数で内容を参照できる。
- After rendering, the contents can be accessed with a tex2D() function the same as a normal texture.
- 型はtexture, texture2Dのうちいずれか。
- Variable type can be texture or texture2D.
- ○アノテーション
- Annotation
- ・int Width, int Height, int Depth
- ・int2 Dimensions
- ・float2 ViewportRatio
- "●通常テクスチャ"を参照。
- See normal/usual/basic texture.
- 省略した場合、"float2 ViewportRatio = {1.0, 1.0};" という設定が使用される。
- If omitted, default is "float2 ViewportRatio = {1.0, 1.0};".
- ・string Format
- "●通常テクスチャ"を参照。
- See normal/usual/basic texture.
- 省略した場合、"A8R8G8B8"が使用される。
- If omitted, "A8R8G8B8" is used.
- ・int Miplevels
- ・int Levels
- "●通常テクスチャ"を参照。
- See normal/usual/basic texture.
- 1または0が指定できる。
- 1 and 0 can be selected.
- 0を指定した場合、完全なミップマップ チェーンが作成される。
- If 0, the entire mipmap chain is created.
- 1を指定すると、ミップマップは生成されない(デフォルト)。
- If set to 1, mipmaps are not created (default).
- (*Note: values above 1 are not valid. They will result in 0 mipmaps being created, and tex2Dlod with miplevel above 0, or tex2D, will be messed up in a confusing way but will probably be dark, at least for mipmaps from ScriptExternal=Color. With all miplevels created, miplevel 0 is "no mipmaps". Mipfilter = none disables mipmaps. It seems like if the render target is smaller than the sample texture, mipmap higher than 0 can be restricted to a value above 1. Like if target is 1/4 size of texture with mipmaps, tex2Dlod gives same for miplevel 1 as for 2. For linear filter, 0~1 has changes, but 1~2 does not.)
- ○使用例
- Example of use
- texture2D ScnMap : RENDERCOLORTARGET <
- float2 ViewPortRatio = {1.0,1.0};
- int MipLevels = 1;
- string Format = "A8R8G8B8" ;
- >;
- sampler2D ScnSamp = sampler_state {
- texture = <ScnMap>;
- };
- technique Tech <
- string Script = "RenderColorTarget0=ScnMap;
- ...
- ●RENDERDEPTHSTENCILTARGET
- 深度ステンシルサーフェイス(いわゆるZバッファ)を生成する。
- Create a depth stencil surface (also known as Z-buffer).
- このセマンティクスを指定して生成したテクスチャは、スクリプトのRenderDepthStencilTargetに
- 指定することができる。
- A texture created with this semantic can be used in a script (*for a technique) as a RenderDepthStencilTarget.
- RENDERCOLORTARGETで生成したテクスチャとは違い、このセマンティクスで生成したテクスチャは、
- レンダリング後も、内容を参照することはできない。
- Unlike a texture created with RENDERCOLORTARGET, a texture created with this semantic cannot be sampled from, or accessed, after rendering.
- 型はtexture, texture2Dのうちいずれか。
- Variable type is texture or texture2D.
- ○アノテーション
- Annotation
- ・int Width, int Height, int Depth
- ・int2(or int3) Dimensions
- ・float2 ViewportRatio
- "●通常テクスチャ"を参照。
- See normal/usual/basic texture.
- 省略した場合、"float2 ViewportRatio = {1.0, 1.0};" という設定が使用される。
- If omitted, the default is "float2 ViewportRatio = {1.0, 1.0};".
- ・string Format
- "●通常テクスチャ"を参照。
- See normal/usual/basic texture.
- 省略した場合、"D24S8"が使用される。
- If omitted, the default is "D24S8".
- ○使用例
- Example of use
- texture2D DepthBuffer : RENDERDEPTHSTENCILTARGET <
- float2 ViewPortRatio = {2.0,2.0};
- string Format = "D24S8";
- >;
- technique Tech <
- string Script = "RenderDepthStencilTarget=DepthBuffer;
- ...
- ●ANIMATEDTEXTURE
- アニメーションテクスチャを生成する。
- Creat an animated (animation) texture.
- 型はtexture, texture2Dのうちいずれか。
- Variable type is texture or texture2D.
- デフォルトでは、フレーム時間に連動して自動的にアニメーションするほか、
- コントロールオブジェクトなどの、別のパラメータに連動してアニメーションさせることもできる。
- Besides the default where the animation progresses with the frame time, a control object or some other parameter can be linked to the animation.
- ○アノテーション
- Annotation
- ・string ResourceName (必須)
- (required)
- テクスチャの元になる、アニメーション画像ファイルを指定する。
- Specify animation file used as the texture base.
- サポートしているファイルフォーマットは、.gif(アニメGIF) および .png(APNG)である。
- Supported file formats are gif and png.
- ・float Offset (省略可能)
- (can omit)
- アニメーションの開始時間をずらす。(単位:秒)
- Shift animation start time by this amount. (Unit: seconds)
- 例えば、2.5を指定すると、アニメーション開始を2.5秒遅らせることができる。
- For example, if 2.5 is specified, the animation's start is delayed by 2.5 seconds.
- デフォルト値は0.0。
- Default is 0.0.
- ・float Speed (省略可能)
- (can omit)
- アニメーションの再生スピードを指定する。
- Set the animation's playback speed.
- 例えば、2.0を指定すると、アニメーションの速度が2倍になる。
- For example, if set to 2.0, the animations's speed is doubled.
- デフォルト値は1.0。
- Default is 1.0.
- ・string SeekVariable (省略可能)
- (can omit)
- アニメーションのシーク制御を、フレーム時間以外の方法で行う場合に指定する。
- Use a variable other than frame time to control the animation's seeking.
- パラメータ名を指定すると、そのパラメータの値の変化に連動して、アニメーションが行われる。
- Enter a parameter (variable) name and the animation will change along with that parameter's value.
- デフォルトでは、フレーム時間(TIME<SyncInEditMode=true>)に連動してアニメーションする。
- Default is for animation to be linked to frame time (TIME<SyncInEditMode=true).
- ○使用例
- Example of use
- // オブジェクトseek.xのSizeの変化に連動してアニメーションする
- Animation progresses with the Size of object seek.x.
- float atime: ControlObject < string Name = "seek.x"; >;
- texture AnimeTex : ANIMATEDTEXTURE <
- string ResourceName = "anime.png";
- string SeekVariable="atime";
- >;
- ○補足
- Supplement/notes
- ・アニメーションが要求するfpsを、MMDの描画のfpsが下回った場合、コマ落ちが発生する。
- If MMD's drawing fps falls below that of the animation, frames from the animation will be dropped.
- ・APNGについては、GByte単位の巨大なアニメーションファイルも(一応)再生可能。
- Large APNGs in the gigabyte range may be used (not guaranteed).
- ●OFFSCREENRENDERTARGET
- オフスクリーンレンダリングターゲット生成する。
- Create an offscreen render (rendering) target.
- 型はtexture, texture2Dのうちいずれか。
- Variable type is texture or texture2D.
- オフスクリーンレンダリングターゲットを生成すると、
- When you create an offscreen render target,
- 自動的に、指定した条件で全オブジェクトの描画が、このレンダリングターゲットに対して行われるようになる。
- all objects are automatically rendered/drawn on this target using the render target's specified settings.
- レンダリング結果は、通常のテクスチャと同様にtex2D()関数で参照できる。
- Just like a normal texture, after rendering the offscreen target can be accessed/sampled with the function tex2D().
- ○アノテーション
- Annotation
- ・int Width, int Height, int Depth
- ・int2 Dimensions
- ・float2 ViewportRatio
- "●通常テクスチャ"を参照。
- See normal/usual/basic texture.
- 省略した場合、"float2 ViewportRatio = {1.0, 1.0};" という設定が使用される。
- If omitted, the default is float2 ViewportRatio = {1.0, 1.0};".
- ・string Format
- "●通常テクスチャ"を参照。
- See normal/usual/basic texture.
- 省略した場合、"A8R8G8B8"が使用される。
- If omitted, the default is "A8R8G8B8".
- ・int Miplevels
- ・int Levels
- "●通常テクスチャ"を参照。
- See normal/usual/basic texture.
- 1または0が指定できる。
- 1 or 0 can be selected.
- 0を指定した場合、完全なミップマップ チェーンが作成される。
- If 0 is selected, the entire mipmap chain is created.
- 1を指定すると、ミップマップは生成されない(デフォルト)。
- If 1, no mipmaps are created (default).
- ・float4 ClearColor
- レンダリングターゲットをクリアする色を設定する。
- Set the color used to clear the render (rendering) target.
- ここで指定した色で、レンダリングターゲットは自動的にクリアされる。
- The render (rendering) target is automatically cleared using this color.
- ・float ClearDepth
- 深度ステンシルサーフェイスをクリアするZ値を設定する。
- Set the Z-value used to clear the depth stencil buffer.
- ここで指定したZ値で、深度ステンシルサーフェイスは自動的にクリアされる。
- The depth stencil buffer is automatically cleared using this Z-value.
- ・bool AntiAlias
- レンダリングにアンチエイリアスを使用する。デフォルトはfalse。
- Whether to use antialiasing during rendering. Default is false.
- ※アンチエイリアスが有効の場合、ビデオメモリは多く消費されるため、
- (Reference mark/kome) Since antialiasing uses a lot of video memory,
- テクスチャのサイズには注意すること
- be careful with texture size.
- ・string Description
- オフスクリーンレンダリングターゲットの説明文を指定する。
- The offscreen render (rendering) target's description.
- ここで指定した文字列が、エフェクト割当のGUIダイアログ上で表示される。
- This description/character string is (*supposedly) shown in MME's user interface.
- ・string DefaultEffect
- オフスクリーンレンダリングで使用するエフェクトファイルの割り当て方法を指定する。
- How to determine the effect used for objects during offscreen rendering.
- 1つの割り当ては、以下の書式で記述する。
- The format for selecting an effect is as follows.
- "(オブジェクトファイル名)=(エフェクトファイル名);"
- "Object file name = effect file name;"
- オブジェクト毎に使用するエフェクトファイルを切り替えるには、この割り当てを複数回記述する。
- To use different effects for different objects, repeat this pattern for each object.
- 複数回記述した場合、記述した順でオブジェクトファイル名が比較され、最初にマッチしたものが使用される。
- When there are multiple descriptors, they are checked for an object in the order they are listed, with the first one that matches being used.
- 例: string DefaultEffect = "self=hide; Mirror*.x=hide; *=MirrorObject.fx;";
- Example
- オブジェクトファイル名には"*"と"?"によるワイルドカードが指定できる。
- The wildcards "*" and "?" can be used in a file name. (*Note: "*" replaces any number of characters, "?" replaces a single character.)
- 特殊なオブジェクトファイル名として"self"が指定でき、これは、
- "self" is a special file name,
- このOFFSCREENRENDERTARGETを持つエフェクトが割り当てられたオブジェクト自身を表す。
- that indicates the object that created the OFFSCREENRENDERTARGET.
- エフェクトファイル名に相対パスでファイル名を指定した場合、
- If the file path is inclued in the effect filename,
- 参照元のエフェクトファイルが格納されているフォルダが基準となる。
- the folder with effect that creates the OFFSCREENRENDERTARGET is used as the base directory.
- また、特殊なエフェクトファイル名として"none"と"hide"が指定でき、
- Also, the special file names "none" and "hide"
- これは、「エフェクトなし」と「非表示」を表す。
- indicate "no effect" (*default shader) and "don't display".
- また、"main_default"を指定すると、メインスクリーンでのデフォルト動作と同様な、
- And "main_default" specifies the effect used in the main render screen
- オブジェクトファイルパスに基づくfxファイルやemdファイルの自動割当が行われる。
- based on an object's filename, either .fx or .emd.
- ○使用例
- Example of use
- texture MirrorRT: OFFSCREENRENDERTARGET <
- string Description = "OffScreen RenderTarget for Mirror.fx";
- int Width = 256;
- int Height = 256;
- float4 ClearColor = { 1, 1, 1, 1 };
- float ClearDepth = 1.0;
- bool AntiAlias = true;
- string DefaultEffect =
- "self = hide;"
- "Mirror*.x = hide;"
- "*=MirrorObject.fx;";
- >;
- ●TEXTUREVALUE
- 指定したテクスチャの、テクセル情報を取得して配列に格納する。
- Store the texels of the indicated texture in an array.
- これを使用すると、VTF(Vertex Texture Fetching)に対応しない環境でも、
- With this, even in environments without VTF (Vertex Texture Fetching),
- 頂点シェーダからテクスチャの値を参照できる(※制限あり。補足参照)
- the vertex shader can access the texture values ((Reference mark/kome) see supplement for restrictions)
- 型はfloat4の2次元配列([縦幅][横幅])、もしくは1次元配列。
- Variable type is float4 in a 2-dimensional (2D) array ([height][width]), or a 1D array.
- ○アノテーション
- Annotation
- ・string TextureName (必須)
- (required)
- テクスチャのパラメータ名を指定する。
- The texture's parameter name. (*I think this is a texture you've already created.)
- ○使用例
- Example of use
- float4 ParticleBaseArray[TEX_HEIGHT][TEX_WIDTH] : TEXTUREVALUE <
- string TextureName = "ParticleBaseTex";
- >;
- float4 ParticleBaseArray2[TEX_HEIGHT] : TEXTUREVALUE <
- string TextureName = "ParticleBaseTex2";
- >;
- float4 color1 = ParticleBaseArray[v][u];
- float3 color2 = ParticleBaseArray2[idx].rgb;
- ○補足
- Supplement/notes
- ・定数レジスタで値を渡すため、参照できるテクセル数は200程度が限度。
- Since this data is stored in the constant register, the number of texels that can be accessed is limited to about 200.
- ・配列のサイズがテクスチャのサイズと一致していない場合、正しく値が取得できる保証は無い。
- If the array size is not the same as the texture size, values may not be retrieved properly.
- 一部の環境では、2の累乗のサイズのテクスチャしか作成できず、
- In some environments, texture sizes must be a power of 2,
- それ以外のサイズを指定しても、自動的にサイズが拡張されて作成されることがあるので注意。
- and an invalid size is specified the array size is rounded up, so be careful.
- ・テクスチャからの値の取得は、フレームの開始時に行われます。
- Values are pulled from the texture at the start of the frame.
- そのため、途中で対象のテクスチャを更新しても、次のフレームになるまで値は更新されません。
- As a result, if a texture is updated, the stored values will not change until the next frame.
- 2.8 エフェクトファイル
- Effect files
- ●STANDARDSGLOBAL
- SAS(Standard Annotations and Semantics)のバージョンを指定する。
- Version number of SAS (Standard Annotations and Semantics).
- また、エフェクトファイル全体に関するアノテーションを記述するためにも用いられる。
- Also used for semantics that concern the whole effect file.
- パラメータ名は "Script"、型は float、値としてバージョン番号の 0.8 を指定すること。
- Parameter name is "Script", variable type is float, value is the version number, 0.8.
- ○アノテーション
- Annotation
- ・string ScriptOutput (省略可能)
- (can omit)
- "color"以外の値は指定できない。デフォルト値もこの値である。
- Only "color" can be used here. The default is this as well.
- ・string ScriptClass (省略可能)
- (can omit)
- そのエフェクトファイルの目的(何を描画するエフェクトか)を指定する。
- Indicates the effect file's purpose (what it's drawing).
- 以下のうちいずれかを指定する。
- Use one of the following.
- "object" : オブジェクトを描画する。(デフォルト)
- Draws an object. (default)
- "scene" : スクリーンバッファを描画する。
- Draws screen buffer.
- "sceneorobject" : 上記の両方。
- Either of the above.
- 基本的には、通常のオブジェクト描画用のエフェクトでは、"object"を指定し、
- Basically, for an effect meant for normal object, use "object",
- プリエフェクト、ポストエフェクトでは、"scene"を指定する。
- while for a pre-effect (*couldn't get this to work) or post-effect, use "scene".
- "object"を指定した場合、パスのスクリプトで Draw=Buffer を実行してはならない。
- When "object" is selected, the script for a pass cannot use Draw=Buffer.
- また、"scene"を指定した場合、 Draw=Geometry を実行してはならない。
- And when "scene" is selected, a pass can't use Draw=Geometry.
- "sceneorobject"を指定した場合は、両方を実行できる。
- For "sceneorobject", both ways are valid.
- ・string ScriptOrder (省略可能)
- (can omit)
- そのエフェクトファイルの実行タイミングを指定する。
- Indicate when an effect is executed.
- 以下のうちいずれかを指定する。
- Indicate one of the following.
- "standard" : オブジェクトを描画する。(デフォルト)
- Draw an object. (default)
- "preprocess" : オブジェクトの描画よりも先に描画する。プリエフェクト用。
- Draw before objects are drawn. For pre-effects.
- "postprocess" : オブジェクトの描画の後で描画する。ポストエフェクト用。
- Draw after objects are drawn. For post-effects.
- ※正確には、preprocessのさらに前に、postprocessの前処理(テクニックのスクリプトの先頭から
- "ScriptExternal=Color"まで)が実行される。
- To be more accurate, the first part of postprocess effects (a technique's script from the start to "ScriptExternal=Color") is done before preprocess effects.
- (*fixed missing '"' after Color)
- ・string Script (省略可能)
- (can omit)
- 使用するテクニックの検索順序を指定する。
- Indicate order in which to search for a technique.
- 通常は、エフェクトファイルに記述されている順で、使用可能なテクニックが検索される(1.2)が、
- Normally, possible techniques are tested in order,
- このアノテーションを用いると、その検索順序を明示的に指定できる。
- but with this annotation the search order can be explicitly indicated.
- 以下の書式で指定する。
- Use the following pattern.
- "Technique=Technique?テクニック名1:テクニック名2:~;"
- "Technique=Technique?Technique_Name1:Technique_Name2:~;"
- 例:string Script = "Technique=Technique?SimplePS:TexturedPS:SimpleQuadraticPS:TexturedQuadraticPS;";
- Example
- なお、使用するテクニックが1つの場合には、以下のようにも指定できる。
- In addition, when there's only one technique, this can be indicated as follows. (?)
- string Script = "Technique=MainTech;";
- ○使用例
- Example of use
- //通常エフェクトの場合
- For a normal effect
- float Script : STANDARDSGLOBAL <
- string ScriptOutput = "color";
- string ScriptClass = "object";
- string ScriptOrder = "standard";
- > = 0.8;
- //ポストエフェクトの場合
- For a post-effect
- float Script : STANDARDSGLOBAL <
- string ScriptOutput = "color";
- string ScriptClass = "scene";
- string ScriptOrder = "postprocess";
- > = 0.8;
- 2.9 特殊パラメータ
- Special parameters/variables
- 以下の名前のパラメータは、セマンティクス無しで自動的に値が設定される。
- Parameters with the following names will have their value set automatically without any semantic. (*It's magic)
- ●parthf (bool型)
- (bool type)
- セルフシャドウフラグ。
- Self-shadow flag.
- セルフシャドウのmode1/mode2に対応(falseでmode1)。
- Interacts with self-shadow's mode1/mode2 (false is mode1).
- ●spadd (bool型)
- (bool type)
- スフィアマップ加算合成フラグ(trueで加算合成)。
- Sphere map add flag (true is additive blending)
- ●transp (bool型)
- (bool type)
- 半透明フラグ(trueで半透明化)。
- Half-transparent flag (true is half-transparent)
- [表示(V)]-[半透明化]に対応。
- Interacts with Menu (?) Display(V) > half-transparent (?)
- ●use_texture (bool型)
- (bool type)
- テクスチャ使用フラグ。
- Whether texture is used flag.
- 描画中のマテリアルがテクスチャを使用する場合にtrue。
- If the material being drawn uses a texture, this is true.
- ●use_spheremap (bool型)
- (bool type)
- スフィアマップ使用フラグ。
- Whether sphere map is used flag.
- 描画中のマテリアルがスフィアマップを使用する場合にtrue。
- If the material being drawn uses a sphere map, this is true.
- なお、PMXモデルのサブテクスチャを使用する場合もtrueとなる。
- It's also true for a PMX model with a subtexture.
- (*Compare with UseSphereMap annotation for techniques.)
- ●use_subtexture (bool型)
- (bool type)
- サブテクスチャ使用フラグ。
- Whether subtexture is used flag.
- PMXモデルのサブテクスチャを使用する場合にtrue。
- True for a PMX model with a subtexture.
- ●use_toon (bool型)
- (bool type)
- トゥーンレンダリング使用フラグ。
- Whether 'toon rendering' is used flag.
- PMDモデルの場合にtrue。
- True for PMD models (*and not accessories).
- ●opadd (bool型)
- (bool type)
- 加算合成フラグ。
- Additive blending flag.
- オブジェクトの描画が加算合成モードに設定されている場合にtrue。
- If object's drawing is set to 'Add' (additive blending), this is true.
- ●VertexCount (int型)
- (int type)
- オブジェクトの頂点数。
- Number of vertexes the object has.
- ●SubsetCount (int型)
- (int type)
- オブジェクトのサブセット数。
- Number of subsets the object has.
- ○使用例
- Example of use
- bool parthf;
- bool use_texture;
- bool use_toon;
- int VertexCount;
- ○補足
- Supplement/notes
- ・MMDPass="object","object_ss"以外の場合、これらのパラメータに正しい値が設定される保証はない。
- For techniques other than MMDPass="object" and "object_ss", there's no guarantee that these parameters will be set correctly.
- 2.9 頂点シェーダセマンティクス
- Vertex shader semantics
- ●_INDEX
- 頂点シェーダにおいて、頂点のインデックス値を取得するためのセマンティクス。
- Semantic for getting vertex index number for the vertex shader.
- 頂点シェーダの入力パラメータで使用できる。型はint。
- Can be used as an input parameter (*probably a more accurate name for this) for vertex shader. Variable type is int.
- ○使用例
- Example of use
- VS_OUTPUT Basic_VS(float4 Pos : POSITION, int index: _INDEX) {
- VS_OUTPUT Out;
- Out.Pos = mul( Pos, WorldViewProjMatrix );
- float f = (float)index/VertexCount;
- Out.Color = float4(f,f,f,1);
- return Out;
- }
- ○補足
- Supplement/notes
- ・頂点シェーダに渡す過程で一旦float型に変換しているため、
- Since the value is converted to float temporarily while being passed to the vertex shader,
- インデックス値が 2^24=16777216 を超えると、正確な値を取得できない。
- if the index goes over 2^24=16777216, its value won't always be accurate.
- 2.10 マクロ
- Preprocessor macros
- ●MME_MIPMAP
- MMDが、テクスチャのミップマップに対応している場合に定義される。
- Defined when MMD is using texture mipmaps.
- ○使用例
- Example of use
- sampler ObjTexSampler = sampler_state {
- texture = <ObjectTexture>;
- #ifdef MME_MIPMAP
- MIPFILTER = LINEAR;
- #endif
- };
- ○補足
- Supplement/notes
- (*In a test on my system, an effect with MIPFILTER = LINEAR had lower fps when mip level was a fraction, and higher fps when mip level was an integer. Might have tested as same fps as with MIPFILTER = NONE or POINT; small difference is hard to test. So probably no need to do this if it even works.)
- **************************************************
- 3 スクリプト
- Script
- テクニックとパスには、スクリプトと呼ばれる特殊なアノテーションを指定することができる。
- Scripts are a special annotation for techniques and passes.
- technique テクニック名 < string Script = "コマンド; コマンド; ..." ; > { ... }
- technique Technique_Name < string Script = "command; command; ..." ; > { ... }
- pass パス名 < string Script = "コマンド; コマンド; ..." ; > { ... }
- pass Pass_Name <string Script = "command; command; ..." ; > { ... }
- 実行時には、これらのコマンドが、記述順に逐次実行される。
- During execution, these commands are carried out successively in the order they are listed.
- このスクリプトを使用することで、レンダリングターゲットの変更やクリア、
- Using a script, the render target can be changed and cleared,
- パスのループ処理などを行うことができる。
- and passes can be carried out in a loop, etc.
- ポストエフェクトなどの特殊な処理をしないのであれば、通常、スクリプトの指定は不要である。
- If special processing like a post-effect is not being carried out, normally, it isn't necessary to use a script.
- テクニックのスクリプトを省略した場合、単にテクニックのパスが順に実行される。
- If a technique's script is omitted, all of the script's passes are simply carried out in order.
- また、パスのスクリプトを省略した場合、"Draw=Geometry"が実行される。
- (While) if a pass's script is omitted, "Draw=Geometry" is used.
- ○コマンド
- Command
- ・RenderColorTarget=(テクスチャ名 or 空白)
- ・RenderColorTarget0=(テクスチャ名 or 空白)
- ・RenderColorTarget1=(テクスチャ名 or 空白)
- ・RenderColorTarget2=(テクスチャ名 or 空白)
- ・RenderColorTarget3=(テクスチャ名 or 空白)
- Texture_name or blank
- レンダリングターゲットを設定する。
- Designate the render (rendering) target.
- RenderColorTargetは、RenderColorTarget0の別名である。
- RenderColorTarget is the same as RenderColorTarget0.
- 通常、RenderDepthStencilTargetコマンドとセットで使用する。
- Usually used with RenderDepthStencilTarget as a set. (?)
- また、RenderColorTarget1~3は単独で使用することはできず、必ずRenderColorTarget0とセットで使用する。
- Also, RenderColorTarget1~3 can't be used by themselves; they must be used with RenderColorTarget0 as a set. (Must be set with RenderColorTarget0?) (*When I tried to use RenderColorTarget1, it didn't work for me.)
- 引数には、RENDERCOLORTARGETセマンティクスで宣言されたtextureパラメータの名前を指定する。
- The argument must be the name of a texture parameter that was declared with the RENDERCOLORTARGET semantic.
- (*Note: the script annotation is type string, which uses double quotation marks: "commands". A preprocessor macro can output a string using '#':
- #define toString(x) #x
- )
- デフォルトのレンダリングターゲットにリセットする場合は、空白を指定する。
- To reset the render target to the default one, leave the argument blank.
- (*Note: the default target changes for a post-effect depending on whether another post-effect, that uses ScriptExternal=Color, follows. Only the last one uses MMD's final render target.)
- なお、設定されたレンダリングターゲットは、再度これらのコマンドを実行しなければ、
- テクニックの処理完了まで変更されたままである。
- Also, if the render (rendering) target is not changed again, it will stay the same until the end of the technique.
- ・RenderDepthStencilTarget=(テクスチャ名 or 空白)
- Texture_name or blank
- 深度ステンシルサーフェイス(いわゆるZバッファ)を設定する。
- Designate a depth stencil surface (also known as Z-buffer).
- 通常、RenderColorTarget0コマンドとセットで使用する。
- Normally, used as a set with RenderColorTarget0. (?)
- (*May be able to avoid this in some cases with pass annotations or whatever ZENABLE = FALSE and ZWRITEENABLE = FALSE)
- 引数には、RENDERDEPTHSTENCILTARGETセマンティクスで宣言されたtextureパラメータの名前を指定する。
- The argument must be the name of a texture parameter that was declared with the RENDERDEPTHSTENCILTARGET semantic.
- デフォルトの深度ステンシルサーフェイスにリセットする場合は、空白を指定する。
- To reset the depth stencil target to the default one, leave the argument blank.
- ・ClearSetColor=(パラメータ名)
- Parameter_name
- レンダリングターゲットをクリアする色を設定する。(まだクリアはしない)
- Designate color used when clearing render target. (Does not clear the target.)
- 引数には、float4型のパラメータの名前を指定する。
- The argument is the name of a float4 parameter.
- このパラメータに設定された値が、レンダリングターゲットをクリアする色となる。
- The value of this parameter is the color used when clearing the render (rendering) target.
- ・ClearSetDepth=(パラメータ名)
- Parameter_name
- 深度ステンシルサーフェイスをクリアするZ値を設定する。(まだクリアはしない)
- Designate Z-value used when clearing depth stencil surface. (Does not clear the target.)
- 引数には、float型のパラメータの名前を指定する。
- The argument is the name of a float parameter.
- このパラメータに設定された値が、深度ステンシルサーフェイスをクリアするZ値となる。
- The value of this parameter is the Z-value used when clearing the depth stencil surface.
- ・Clear=Color
- レンダリングターゲットをクリアする。
- Clears the rendering target.
- クリアする色には、ClearSetColorコマンドで設定された値が使用される。
- The clear color is the one set using ClearSetColor.
- ・Clear=Depth
- 深度ステンシルサーフェイスをクリアする。
- Clears the depth stencil surface.
- クリアするZ値には、ClearSetDepthコマンドで設定された値が使用される。
- The Z-value used to clear is the one set using ClearSetDepth.
- ・ScriptExternal=Color
- 他のオブジェクトを描画する。
- Draw other objects. (*Each object is only drawn once in total, but each post-effect must copy its input to the output, which is the render target of this script in the next post-effect. Increases memory and CPU usage.)
- このコマンドは、テクニックのスクリプト上でしか使用できない。
- This command can only be used in a technique's script.
- これは、ポストエフェクト(STANDARDSGLOBALパラメータのScriptOrderアノテーションに
- "postprocess"が指定されたエフェクトファイル)でのみ実行できる。
- It can also only be used in a post-effect (an effect file with ScriptOrder annotation for STANDARDSGLOBAL parameter set to "postprocess").
- 通常、ポストエフェクトでは、入力用のテクスチャをレンダリングターゲットに設定した上で、
- Normally with a post-effect, after setting the input texture as the render (rendering) target,
- そのテクスチャへ、他のオブジェクトをレンダリングさせる。
- other objects are rendered to this texture.
- この、他のオブジェクトをレンダリングさせる際に、このコマンドを実行する。
- This command is executed when these other objects are rendered to the texture.
- (Tipsのポストエフェクトを参照)
- See 'Post-Effect' under Tips
- ポストエフェクトでは、テクニックのスクリプト上で、必ず1回だけ実行しなければならない。
- A post-effect must include this command exactly once in the script for each technique. (*If it doesn't, all commands are done before other effects, and it might mess up in other weird ways.)
- ・Pass=(パス名)
- Pass_name
- 指定したパスを実行する。
- Carry out the designated pass.
- このコマンドは、テクニックのスクリプト上でしか使用できない。
- This command can only be used in a technique's script.
- テクニックにスクリプトを指定した場合、明示的にこのコマンドを使用しない限り、
- いずれのパスも実行されない。
- If a technique has a script, passes will not be executed unless they are explicitly called with this command.
- ・LoopByCount=(パラメータ名)
- Parameter_name
- ・LoopEnd=
- 指定した回数だけ、スクリプトの一部をループする。
- Loop through one part of the script the indicated number of times.
- (*Cannot be a 'static' variable)
- このコマンドは、テクニックのスクリプト上でしか使用できない。
- This command can only be used in a technique's script.
- 引数には、数値型(int,bool,float)のパラメータの名前を指定する。
- The argument must be the name of a parameter with a numeric type (int, bool, float) .
- このパラメータに設定された値の回数だけ、LoopByCountからLoopEndまでにあるコマンド列が
- 繰り返し実行される。
- The command sequence (?) between LoopByCount and LoopEnd will be executed a number of times equal to this parameter.
- ループはネスト可能である。
- Loops can be nested.
- 以下の例では、3回パスp0が実行された後、パスp1が実行される。
- In the following example, pass p0 is executed three (3) times, then pass p1 is executed once.
- /****************************/
- int Count = 3;
- technique TShader <
- string Script =
- "LoopByCount=Count;"
- "Pass=p0;"
- "LoopEnd=;"
- "Pass=p1;";
- > {
- /****************************/
- ・LoopGetIndex=(パラメータ名)
- Parameter_name
- ループ中のループカウンタの値を、指定したパラメータに設定する。
- The indicated parameter is set to the loop counter during a loop. (*Works with nested loops.)
- このコマンドは、LoopByCountからLoopEndまでの間でしか使用できない。
- This command only works between LoopByCount and LoopEnd.
- ・Draw=Geometry
- オブジェクトを描画する。
- Draw the object.
- このコマンドは、パスのスクリプト上でしか使用できない。
- This command can only be used in a pass's script.
- パスのスクリプトを省略した場合、このコマンドが実行される。
- If a pass's script is omitted, this command is used.
- STANDARDSGLOBALのScriptClassに"scene"を指定している場合、
- このコマンドを実行してはならない。
- If STANDARDSGLOBAL's ScriptClass annotation is "scene", this command can't be used. (*Unverified)
- ・Draw=Buffer
- レンダリングターゲットのスクリーンと一致するサイズの、長方形のポリゴンを描画する。
- Draw a rectangular polygon with the same size as the screen.
- このコマンドは、パスのスクリプト上でしか使用できない。
- This command can only be used in a pass's script.
- ポストエフェクトやプリエフェクトで使用する。
- Used in a post-effect or pre-effect.
- STANDARDSGLOBALのScriptClassに"object"を指定している場合、
- このコマンドを実行してはならない。
- If STANDARDSGLOBAL's ScriptClass annotation is "object", this command can't be used. (*Unverified)
- ・RenderPort=*
- 未対応。
- Not implemented, or incompatible.
- ○使用例
- Example of use
- technique TShader <
- /* 2つの文字列表記("~" "~")の間に空白文字しかなければ、
- If two strings (literally 'character strings') ("~" "~") are separated by nothing but whitespace (literally 'blank space'),
- それはひと続きの文字列とみなされるため、以下のように分割して記述できる */
- they are treated as a single string. This can be used to split up a string, as below
- string Script =
- "RenderColorTarget0=RenderTarget;"
- "RenderDepthStencilTarget=DepthBuffer;"
- "ClearSetColor=ClearColor;"
- "ClearSetDepth=ClearDepth;"
- "Clear=Color;"
- "Clear=Depth;"
- "ScriptExternal=color;"
- "Pass=P0;" ;
- > {
- pass P0 < string Script= "RenderColorTarget0=; RenderDepthStencilTarget=; Draw=Buffer;" ; > {
- ...
- }
- }
- **************************************************
- 4 Tips
- ●MMD標準のシェーダを使用する
- Using MMD's default/standard shader
- オブジェクトの描画の一部にのみ、エフェクトを使用し、
- When you want to use an effect on just one part of an object,
- それ以外の描画にはMMD標準のシェーダを使用したい場合には、
- and use the standard shader for the rest,
- MMD標準のシェーダを使用したい場面のテクニックを、エフェクトファイルに記述しなければよい。
- you don't need write this in the technique in the effect file. (?)
- you just leave this technique out of the effect file.
- ("1.2 テクニックのアノテーション"を参照)
- (See "1.2 Technique annotations")
- /************************************************************/
- /* エフェクトファイルにこのテクニックしか無ければ、
- If this technique is the only one in an effect file,
- オブジェクト描画(セルフシャドウON時)以外はMMD標準のシェーダで描画される */
- everything other than object drawing (with self-shadow set to on) is done by MMD's default shader
- technique Tech1 < string MMDPass = "object_ss"; > {
- pass Pass1 {
- ...
- }
- pass Pass2 {
- ...
- }
- }
- /************************************************************/
- また、パスのデフォルトのシェーダはMMD標準のシェーダであるため、
- Furthermore, since the default shader for a pass is the standard MMD shader,
- 以下のように、パスのVertexShaderやPixelShaderを設定しなければ、
- if you omit the VertexShader or PixelShader for a pass, as seen below,
- そのパスの描画にはMMD標準のシェーダが使用される。
- that pass will use MMD's default shader.
- /************************************************************/
- technique Tech1 < string MMDPass = "object_ss"; > {
- pass Pass1 {
- // VertexShader = xxx
- // PixelShader = xxx
- }
- }
- /************************************************************/
- ●空のテクニック
- Empty techniques
- 以下のように、テクニックを空にすると、そのテクニックでは一切描画が行われなくなる。
- As below, if a technique is empty, nothing will be drawn for it.
- これを利用すると、オブジェクトの一部または全部の描画を抑止することができる。
- This can be used to avoid drawing part or all of an object.
- /*********************************************************/
- technique ShadowTech < string MMDPass = "shadow"; > {
- }
- /*********************************************************/
- ●オブジェクトの有無でパスをON/OFF
- Turning a pass on or off based on another object's existence
- 以下のようにスクリプトを記述すると、特定のオブジェクトの表示がONになっている間のみ
- パスを実行させることができる。
- If a script is written like below, it's possible to have a pass be executed only when a specific object's display is turned to on.
- (*Unfortunately, no way to turn off a pass with the same action since 'static' variables can't be used as loop variable)
- これは、真偽値true/falseが数値としては1と0に解釈されることを利用している。
- This uses the fact that boolean true/false is treated as 1 and 0.
- /*********************************************************/
- bool flag : CONTROLOBJECT < string name = "aaa.x"; >;
- technique Tech1 <
- string Script =
- "LoopByCount=flag;"
- "Pass=Pass1;"
- "LoopEnd=;"
- ;
- > {
- pass Pass1 {
- ...
- }
- }
- /*********************************************************/
- ●エフェクトファイル間でパラメータを共有
- Sharing resources/parameters between effect files
- 通常、異なるエフェクトファイル間でパラメータは共有されない。
- Normally, parameters are not shared between different effect files.
- しかし、パラメータの宣言に"shared"キーワードを指定することにより、
- However, by declaring a parameter with "shared" keyword,
- 同じ名前のパラメータをエフェクトファイル間で共有することができる。
- parameters with the same name can be shared between effect files.
- 以下の例では、effect1.fxで生成したテクスチャを、effect2.fxから参照できる。
- In the following example, a texture created in effect1.fx can be accessed/sampled in effect2.fx.
- このように、両方のパラメータ宣言で"shared"キーワードを指定する必要がある。
- When doing this, both parameters must be declared with "shared" keyword.
- また、名前だけでなく、型名とセマンティクスも一致させるひつようがある。
- Furthermore, the variable type and semantic must also match.
- /************** effect1.fx ******************/
- shared texture ShadowBuffer : RENDERCOLORTARGET <
- float2 ViewPortRatio = {2.0,2.0};
- int MipLevels = 1;
- string Format = "A8R8G8B8" ;
- >;
- /********************************************/
- /************** effect2.fx ******************/
- shared texture ShadowBuffer : RENDERCOLORTARGET;
- /********************************************/
- ●if文
- 'if' statement
- 描画を高速にしたければ、シェーダを記述する際に、できるだけif文のような条件分岐は
- 使わないほうがよい。
- If you want drawing to be fast, when writing a shader, avoid 'if' statements/conditional branches as much as possible.
- (*Microsoft documentation says that there are branching 'if' statements and flattened ones. Both sides are evaluated if flattened. Branching statements evaluate only one side but "consume more resources" which "can lead to a compiler error". If not specified, compiler chooses. When I tried to test, no speed change from eliminating 'if' statements, but not a good test. Microsoft documenation says the boolean evaluation "condition ? expression if true : expression if false" evaluates both sides, so using it for simple cases doesn't make a shader faster. It's possible an 'if' could result in slowdown if it delays texture lookup. Compiling techniques multiple times is a way to avoiding run-time 'if' statements, for possible speedup at the cost of longer compile time.)
- テクスチャの有無でシェーダの処理を切り替えるような場合、
- When changing shader processing based on whether a texture is used,
- use_textureパラメータを参照して、シェーダ内のif文で条件分岐するより、
- by consulting the use_texture parameter and following a conditional branch using an 'if' statement,
- テクスチャが有るサブセットと無いサブセットとで、テクニック自体を分けてしまうほうが高速に描画できる。
- with one subset where the texture is used and one where it isn't, drawing will be faster if you split the technique itself into multiple techniques.
- ●uniformキーワード
- uniform keyword
- 関数の引数の宣言に"uniform"キーワードを指定すると、その引数の値をコンパイル時の定数として与えることができる。
- Using the "uniform" keyword during the declaration of a function's arguments, that argument's value can be treated as a constant at compile time.
- 以下の例では、Basic_PS()内のif文が、コンパイル時に除去されるので、
- In the following example, the 'if' statement in Basic_PS() is optimized out, or eliminated, at compile time,
- 条件分岐による速度低下は避けられる(多分)。
- so the slowdown from a conditional branch is averted (probably).
- /*******************************************************************/
- float4 Basic_PS( VS_OUTPUT IN, uniform bool useTexture ) : COLOR0
- {
- float4 Color = IN.Diffuse;
- if ( useTexture ) {
- Color *= tex2D( ObjTexSampler, IN.Tex );
- }
- ...
- }
- technique TechWithTex {
- pass P1 {
- /* useTexture=true でシェーダをコンパイル */
- compile with useTexture=true
- PixelShader = compile ps_2_0 Basic_PS(true);
- ...
- }
- }
- technique TechWithoutTex {
- pass P1 {
- /* useTexture=false でシェーダをコンパイル */
- compile with useTexture=false
- PixelShader = compile ps_2_0 Basic_PS(false);
- ...
- }
- }
- /*******************************************************************/
- (*the technique would be selected with technique annotation, see a popular object shader for an example)
- ●エフェクトファイル内での日本語使用
- Using Japanese inside an effect file
- 基本的に、コメント部分以外では、エフェクトファイル中に日本語の文字を使用することは推奨しない。
- As a general rule, the use of Japanese characters in an effect file, other than in comments, is not recommended.
- あえて使用する場合は、文字コードに注意すること。
- If you intend to do so, a warning on character encoding.
- テクスチャ生成用の画像ファイルのパスやコントロールオブジェクトのオブジェクト名など、
- When the path to (or name of) an image file for a texture, or the object name (or item) used for a control object,
- ファイル名の指定に日本語を使用する場合は、そのエフェクトファイルの文字コードは
- is in Japanese, that effect file's character encoding
- 必ずShift-JISでなければならない。
- must be in Shift-JIS. (*Note: CP932 is a superset of Shift-JIS and is probably the right encoding to use. MMD may have to be using Japanese locale for Japanese characters to be processed correctly by MME. This is set before starting MMD and is different from selecting English as the user interface language.)
- ●ポストエフェクト
- Post-effects
- ポストエフェクト用のエフェクトファイルを作成する場合は、
- When creating an effect file for a post-effect,
- 以下のパラメータがエフェクトファイル中で宣言されている必要がある。
- the following parameters must be declared in the effect file.
- ("●STANDARDSGLOBAL"を参照)
- (see "STANDARDSGLOBAL")
- float Script : STANDARDSGLOBAL <
- string ScriptOutput = "color";
- string ScriptClass = "scene";
- string ScriptOrder = "postprocess";
- > = 0.8;
- また、典型的なポストエフェクトでは、テクニックのスクリプトで以下の処理を行う。
- In addition, for a typical post-effect, the technique's script should perform the following actions.
- (1) レンダリングターゲットを自前のテクスチャに変更し、クリアする。
- Set rendering target to a texture unique to the effect and clear it.
- スクリプト例:
- Script example:
- "RenderColorTarget0=(RENDERCOLORTARGETテクスチャ);"
- texture
- "RenderDepthStencilTarget=(RENDERDEPTHSTENCILTARGETテクスチャ);"
- texture
- "ClearSetColor=(クリアの色);"
- clear color
- "ClearSetDepth=(クリアのZ値);"
- clear Z-value
- "Clear=Color;"
- "Clear=Depth;"
- (2) プリエフェクト,オブジェクト,他のポストエフェクトを描画する。
- Draw pre-effects, objects, other post-effects.
- このとき、描画結果は(1)で指定したテクスチャに保存される。
- At this time, the drawing output is saved to the texture designated in (1).
- (*Note: since a post-effect doesn't control whether its output goes to MMD's default screen which is black or white or to another post-effect that has other objects on it, it can be difficult to use post-effects that use alpha blending for their transparent output. The easiest solution is to turn alpha blending off, but this means transparent background color can't be toggled.)
- スクリプト例:
- Script example:
- "ScriptExternal=Color;"
- (3) レンダリングターゲットを元に戻し、描画結果のテクスチャを入力として、パスを実行する。
- Return rendering target to default, which we can think of as entering the name of the texture that holds the rendering output, and conduct a pass.
- (*Note: depth target is usually unimportant here but can sometimes lead to weird results. It may be possible to disable its use with ZWRITEENABLE = FALSE and ZENABLE = FALSE.)
- スクリプト例:
- Script example:
- "RenderColorTarget0=;"
- "RenderDepthStencilTarget=;"
- "Pass=(パス1);"
- pass1
- "Pass=(パス2);"
- pass2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement