Advertisement
Guest User

MMEffect for MikuMikuDance | REFERENCE_v0.33_English.txt

a guest
Jul 12th, 2019
1,101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 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.
  2.  
  3. 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.
  4.  
  5. If you can't get your text editor to use CP932 encoding, try a web browser.
  6.  
  7. Translation done with Tagaini Jisho: http://www.tagaini.net
  8. (In a web browser, the Rikaichan addon uses the same data to translate text on a page.)
  9.  
  10. ___
  11.  
  12.  
  13. MMEffect リファレンス
  14. Reference
  15.  
  16. 0.1.0.0 (2010/9/18) 初版
  17. Initial version
  18. 0.2.0.0 (2010/12/12) MME Ver0.20
  19.  ・OFFSCREENRENDERTARGETセマンティクス追加
  20. OFFSCREENRENDERTARGET semantic added
  21.  ・CONTROLOBJECTセマンティクスで取得できる情報の追加
  22. Added ability to get information using CONTROLOBJECT semantics
  23.  ・CONTROLOBJECTセマンティクスが参照するオブジェクトの描画順序の制約を緩和
  24. Removed restriction on CONTROLOBJECT based on drawing order
  25.  ・EDGECOLORセマンティクス追加
  26. Added EDGECOLOR semantics
  27.  ・VIEWPORTPIXELSIZEセマンティクスの記述ミスを修正
  28. Corrected error in VIEWPORTPIXELSIZE semantics description
  29.  ・一部日本語修正
  30. Corrected some Japanese language errors
  31. 0.2.2.0 (2010/12/16) MME Ver0.22
  32.  ・RENDERCOLORTARGETおよびOFFSCREENRENDERTARGETセマンティクスでの、Miplevelsの指定方法を変更
  33. Changed how to set Miplevels for RENDERCOLORTARGET and OFFSCREENRENDERTARGET semantics
  34. 0.2.3.0 (2010/12/20) MME Ver0.23
  35.  ・CONTROLOBJECTセマンティクスの補足追記
  36. Added more to CONTROLOBJECT semantic's supplement (?)
  37. 0.2.4.0 (2011/02/09) MME Ver0.24
  38.  ・CONTROLOBJECTセマンティクスに指定できる特殊オブジェクト名に"(self)"を追加
  39. Added "(self)" as a special name for CONTROLOBJECT semantic
  40.  ・TEXTUREVALUEセマンティクスを追加
  41. Added TEXTUREVALUE semantic
  42. 0.2.6.0 (2010/02/21) MME Ver0.26
  43.  ・Draw=Geometryコマンドについての記述を修正
  44. Corrected description for Draw=Geometry command
  45. 0.2.7.0 (2011/05/22) MME Ver0.27
  46.  ・_INDEXセマンティクス追加
  47. Added _INDEX semantic
  48.  ・VertexCountパラメータおよびSubsetCountパラメータを追加
  49. Added VertexCount and SubsetCount parameters
  50.  ・opaddパラメータの追加
  51. Added opadd parameter
  52.  ・TEXTUREVALUEセマンティクスの補足に追記
  53. Modified TEXTUREVALUE semantic description
  54. 0.2.8.0 (2012/03/26) MME Ver0.28
  55.  ・CONTROLOBJECTセマンティクスについての記述を一部修正
  56. Changed part of CONTROLOBJECT semantic description
  57. 0.3.0.0 (2012/09/19) MME Ver0.30
  58.  ・OFFSCREENRENDERTARGETセマンティクスのDefaultEffectに指定可能な
  59.   特殊なエフェクト名として"main_default"を追加
  60. Added the special name "main_default" to OFFSCREENRENDERTARGET semantic to use an object's default effect
  61. 0.3.3.0 (2013/02/13) MME Ver0.33
  62.  ・テクスチャの材質モーフ用セマンティクス(ADDINGTEXTURE等)追加
  63. Added semantics for texture's material morphs, like ADDINGTEXTURE
  64.  ・PMXモデルのサブテクスチャに対応(UseSphereMap, use_spheremap, use_subtexture参照)
  65. Can deal with PMX model's subtextures, refer to UseSphereMap, use_spheremap, use_subtexture
  66.  ・MATERIALTOONTEXTUREセマンティクス追加
  67. Added MATERIALTOONTEXTURE semantic
  68.  ・GROUNDSHADOWCOLORセマンティクス追加
  69. Added GROUNDSHADOWCOLOR semantic
  70.  ・MME_MIPMAPマクロ追加
  71. Added MME_MIPMAP preprocessor macro
  72.  
  73.  
  74. ○注意
  75. Warning
  76. ・このリファレンスでは、MMEffectが認識するセマンティクス&アノテーションについて解説している。
  77. This reference explains the semantics and annotations that MMEffect recognizes.
  78.  エフェクトファイルそのもののリファレンスについては、以下を参照のこと。
  79. As a reference for effect files themselves, see the following (links outdated, search or use archive.org)
  80.  
  81.   エフェクトファイルフォーマット http://msdn.microsoft.com/ja-jp/library/bb173005(v=VS.85).aspx
  82. Effect file format
  83.   HLSLのリファレンス http://msdn.microsoft.com/ja-jp/library/bb509638(v=VS.85).aspx
  84. High-level shader language (HLSL) reference
  85.  
  86. ・セマンティクス&アノテーションの仕様の策定は、NVIDIAのSASを参考にした。
  87. Decided to base semantics and annotations on Nvidia's SAS as the reference.
  88.   http://developer.nvidia.com/object/using_sas.html
  89.  ただしこれは、FX Composer用のエフェクトファイルが動作することを保障するものではない。
  90. However, there is no guarantee that effects from FX Composer will work.
  91.  
  92. **************************************************
  93.  
  94. 1 テクニックとパス
  95. Techniques and passes
  96.  
  97. 1.1 構成
  98. Organization
  99.  
  100. エフェクトファイルは、以下のような、テクニックとパスによる階層構造になっている。
  101. An effect file will form a layered structure (?) using techniques and passes in the following way.
  102.  
  103. /**********************************/
  104. パラメータ宣言1
  105. Parameter declaration 1
  106. パラメータ宣言2
  107. Parameter declaration 2
  108. ...
  109.  
  110. (Transliteration of "technique" and "pass")
  111. technique テクニック1 {
  112. pass パス1 {
  113. VertexShader = …
  114. PixelShader = …
  115. }
  116. pass パス2 {
  117. VertexShader = …
  118. PixelShader = …
  119. }
  120. }
  121.  
  122. technique テクニック2 {
  123. pass パス1 {
  124. VertexShader = …
  125. PixelShader = …
  126. }
  127. pass パス2 {
  128. VertexShader = …
  129. PixelShader = …
  130. }
  131. }
  132. /**********************************/
  133.  
  134. テクニックは1つ以上のパスから構成される。
  135. A technique is made of one or more passes. (*A blank technique disables that output, like ground shadow or edge.)
  136. 1つのパスは1回のレンダリング処理に対応しており、
  137. A single pass deals with one round of processing;
  138. テクニックが複数のパスから構成されている場合は、
  139. when a technique is organized into several passes,
  140. そのテクニックがマルチパスレンダリングを使用することを意味している。
  141. it means it uses "multipass rendering".
  142.  
  143.  
  144. テクニックとパスには、アノテーションと呼ばれる設定値を記述することができる。
  145. You can use 'annotations' to describe settings for techniques and passes.
  146. アノテーションは、以下のように、テクニック名・パス名の後ろに、"<"と">"で囲むようにして記述する。
  147. In the following way, you use "<" and ">" to surround the descriptor.
  148. なお、アノテーション名の大文字小文字の違いは無視される。
  149. Also, capitalization doesn't matter for annotation names.
  150.  
  151. /******************************************************/
  152. technique Tech1 < string Subset = "1-6,8"; > {
  153. pass Pass1 < string Script = "Draw=Buffer;"; > {
  154. ...
  155. }
  156. pass Pass2 {
  157. ...
  158. }
  159. }
  160. /******************************************************/
  161.  
  162. また、テクニックとパスには、スクリプトと呼ばれる特殊なアノテーションを
  163. 指定することができる。これについては、§3で説明する。
  164. "Script" is a special annotation for tehcniques and passes that's described in §3 (section 3).
  165.  
  166.  
  167. 1.2 テクニックのアノテーション
  168. Technique annotations
  169.  
  170. テクニックのアノテーションには、
  171. そのテクニックをどの場面の描画に使用するかの条件を記述する。
  172. Technique annotations describe the specifics of the case where that technique will be used.
  173.  
  174.  
  175. この条件には、以下のものを指定できる。
  176. Those conditions can include the following.
  177.  
  178. ・オブジェクトのサブセット番号(≒オブジェクトのマテリアルの番号)
  179. Object subset number (≒, means approximately equal to, the material number
  180. ・描画対象(オブジェクト本体/影/輪郭/セルフシャドウ用Z値プロット)
  181. Drawing target (Object itself/ground shadow/edges/the Z-value plot used for self-shadow)
  182. ・描画フラグ(テクスチャ使用ON/OFF、スフィアマップ使用ON/OFF、トゥーンレンダリング使用ON/OFF)
  183. Drawing flags (Whether texture is used, whether sphere map is used, whether 'toon' rendering is used)
  184.  
  185. 条件の照合は、エフェクトファイルに書かれている順に行われるため、
  186. Conditions are tested in the order they are written,
  187. 複数のテクニックで使用条件が重なっている場合は、
  188. so if there are a bunch of techniques,
  189. エフェクトファイル上で先に記述されているものが優先される。
  190. the first applicable one is used.
  191. 条件に合致するテクニックがエフェクトファイル上に存在しない場合、
  192. MMD標準のシェーダが使用される。
  193. If no technique that matches the requirements is found, MMD's default shader is used.
  194.  
  195.  
  196. ○アノテーション
  197. Annotations
  198.  
  199. ・string Subset
  200.   そのテクニックを適用するサブセットの番号を指定する。
  201. Indicates the numbers of subsets that use the technique.
  202.   PMDモデルの場合、これはモデルの材質番号に対応する。
  203. For PMD models, this uses the material number.
  204.   
  205.   アノテーション省略時には、全てのサブセットが適用対象となる。
  206. If this annotation is omitted, all subsets are valid targets.
  207.   
  208.   "0,3,5"のように、カンマ区切りで番号を列挙することで、複数の番号を指定できる。
  209. Using commas to separate (delineate) numbers in a list, you can use multiple numbers, like "0,3,5".
  210.   また、"6-10"などのように、番号をハイフンでつなぐことで、範囲指定ができる。
  211. You can also select a range using a hyphen, like "6-10".
  212.   "12-"のように、範囲の開始番号のみを指定した場合は、それ以降の全ての番号が対象となる。
  213. If you only set the range start, all numbers after it are used, like "12-".
  214.  
  215.   例: string Subset = "0-6,8";
  216. Example
  217.  
  218. ・string MMDPass
  219.   そのテクニックを適用する描画対象を指定する。
  220. Indicates the drawing target for this technique.
  221.   以下のうちいずれかを指定する。この区分は、MMDの描画手順に由来する。
  222. Specify any/one of the following. This classification is used to derive the drawing procedure used by MMD.
  223.  
  224.   "object" : オブジェクト本体(セルフシャドウOFF)
  225. Object itself (self shadow off)
  226.   "zplot" : セルフシャドウ用Z値プロット
  227. 'Z-value plot' used by self shadow
  228.   "object_ss" : オブジェクト本体(セルフシャドウON)
  229. Object itself (self shadow on)
  230.   "shadow" : 影(セルフシャドウではない単純な影)
  231. Ground shadow (Just the shadow, not self-shadow)
  232.   "edge" : 輪郭(PMDモデルのみ)
  233. Edge/outline (only PMD models *unverified)
  234.  
  235.   アノテーション省略時には、"object"を指定したとみなされる。
  236. If this annotation is omitted, it's treated as "object".
  237.  
  238.   例: string MMDPass = "object";
  239. Example
  240.  
  241. ・bool UseTexture
  242.   テクスチャ使用の有無を指定する。
  243. Indicate whether texture is used.
  244.   そのテクニックが、テクスチャを使用するサブセットのみを対象とする場合には、trueを指定する。
  245. If the technique is only for subsets that use a texture, set this to true.
  246.   逆に、テクスチャを使用しないサブセットのみを対象とする場合には、falseを指定する。
  247. Conversely, for subsets that don't use a texture, set it to false.
  248.  
  249.   アノテーション省略時には、テクスチャの有無は無視される。
  250. If this annotation is omitted, whether a texture is used is ignored (when selecting a technique).
  251.  
  252.   例: bool UseTexture = true;
  253. Example
  254.  
  255. ・bool UseSphereMap
  256.   スフィアマップ使用の有無を指定する。
  257. Indicate whether sphere map is used.
  258.   そのテクニックが、スフィアマップを使用するサブセットのみを対象とする場合には、trueを指定する。
  259. If the technique is only for subsets that use a sphere map, set this to true.
  260.   (PMXモデルにおいて、スフィアモードにサブテクスチャを指定した場合も含む)
  261. (For PMX models, subtexture that's set to sphere mode is included)
  262.   逆に、スフィアマップを使用しないサブセットのみを対象とする場合には、falseを指定する。
  263. Conversely, for subsets that don't use a texture, set it to false.
  264.  
  265.   アノテーション省略時には、スフィアマップの有無は無視される。
  266. If this annotation is omitted, whether a sphere map is used is ignored (when selecting a technique).
  267.  
  268.   例: bool UseSphereMap = false;
  269. Example
  270.  
  271. ・bool UseToon
  272.   トゥーンレンダリング使用の有無を指定する。
  273. Indicate whether 'toon rendering' is used.
  274.   そのテクニックが、トゥーンレンダリングを使用するオブジェクト(=PMDモデル)を対象とする場合には、trueを指定する。
  275. If you want the technique to target objects that use 'toon rendering' (=PMD model), set this to true.
  276.   逆に、トゥーンレンダリングを使用しないオブジェクト(=アクセサリ)を対象とする場合には、falseを指定する。
  277. If the technique is for objects that don't use 'toon rendering' (accessories), set it to false.
  278.  
  279.   アノテーション省略時には、トゥーンレンダリング使用の有無は無視される。
  280. If the annotation is omitted, whether 'toon rendering' is used is ignored (when selecting a technique).
  281.  
  282.   例: bool UseToon = true;
  283. Example
  284.  
  285.  
  286. ○使用例
  287. Example of use
  288.  
  289. //セルフシャドウがONの場合、サブセットのNo.0~6とNo.8には、Tech1が適用され、
  290. When self-shadow is on, subsets 0~6 and 8 and use Tech 1.
  291. //サブセットのNo.7とNo.9~には、Tech2が適用される。
  292. Subset 7 and 9~ (to end) use Tech2.
  293. //セルフシャドウがOFFの場合、Tech3が適用される。
  294. When self-shadow is off, all subsets/materials use Tech3.
  295.  
  296. technique Tech1 <
  297. string MMDPass = "object_ss";
  298. string Subset = "0-6,8";
  299. > {
  300. ...
  301. }
  302.  
  303. technique Tech2 <
  304. string MMDPass = "object_ss";
  305. string Subset = "7,9-";
  306. > {
  307. ...
  308. }
  309.  
  310. technique Tech3 <
  311. string MMDPass = "object";
  312. > {
  313. ...
  314. }
  315.  
  316. ○補足
  317. Supplement/notes
  318.  ・妥当でないテクニックは除外される。
  319. Invalid techniques are excluded.
  320.   http://msdn.microsoft.com/ja-jp/library/bb206324(v=VS.85).aspx
  321.  ・MMDPass="object","object_ss"以外のテクニックでは、UseTexture,UseSphereMap,UseToonは正しく機能しない。
  322. Other than with MMDPass="object" or "object_ss", the annotations UseTexture, UseSphereMap, UseToon won't work properly.
  323.  
  324.  
  325. **************************************************
  326.  
  327. 2 パラメータのセマンティクスとアノテーション
  328. The semantics and annotations of parameters
  329.  
  330. 以降では、MMEffect用のエフェクトファイルで使用できる、
  331. パラメータのセマンティクスとアノテーションについて説明する。
  332. The following explains the semantics and annotations of parameters that you can use in effect files for MMEffect.
  333.  
  334. パラメータの宣言をセマンティクスやアノテーションで修飾することで、
  335. レンダリングに必要な様々な情報を、そのパラメータを解して取得できる。
  336. 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.
  337.  
  338.  
  339. パラメータのセマンティクスとアノテーションは、以下のように記述する。
  340. These semantics and annotations have the following form.
  341.  
  342. 型名 パラメータ名 : セマンティクス名 < 型名 アノテーション1 = 値; 型名 アノテーション2 = 値; ... > ;
  343. variable_type parameter_name : semantic_name < variable_type annotation1 = value; variable_type annotation2 = value; ... > ;
  344.  
  345. セマンティクスによっては、アノテーションを指定しないものもある。
  346. Some semantics don't let you use annotations.
  347.  
  348.  
  349. なお、セマンティクス名とアノテーション名の大文字小文字の違いは無視される。
  350. Note: capitalization of semantics and annotations is ignored.
  351.  
  352.  
  353. 2.1 ジオメトリ変換
  354. Transforming objects
  355. 参考:http://msdn.microsoft.com/ja-jp/library/bb206269(v=VS.85).aspx
  356. Reference
  357.  
  358. ●WORLD
  359. ●VIEW
  360. ●PROJECTION
  361. ●WORLDVIEW
  362. ●VIEWPROJECTION
  363. ●WORLDVIEWPROJECTION
  364.  
  365.  頂点の座標変換に使用する変換行列。
  366. Transformation matrices (matrix) for vertex coordinates
  367.  
  368.  座標変換には、ワールド変換、ビュー変換、プロジェクション変換(射影変換)がある。
  369. For coordinate transformations, there are world transformations, view transformations, and projection transformations.
  370.  
  371. 6つのセマンティクスは、それぞれ、
  372. The six types of semantics are as follows.
  373.   WORLD : ワールド変換行列
  374. World transformation matrix
  375.   VIEW : ビュー変換行列
  376. View transformation matrix
  377.   PROJECTION : プロジェクション変換行列
  378. Projection transformation matrix
  379.   WORLDVIEW : ワールド変換行列×ビュー変換行列
  380. World transformation matrix times (×) view matrix
  381.   VIEWPROJECTION : ビュー変換行列×プロジェクション変換行列
  382. View matrix times (×) projection matrix
  383.   WORLDVIEWPROJECTION : ワールド変換行列×ビュー変換行列×プロジェクション変換行列
  384. World times (×) view times (×) projection matrix
  385.  を表す。
  386. (literally: signifies.)
  387.  型はfloat4x4。
  388. Variable type is float4x4.
  389.  
  390. *NOTE: matrix operations are associative or commutative or something, so with matrix math,
  391. Position × WORLD × VIEW × PROJECTION
  392. is the same as
  393. Position × WORLDVIEWPROJECTION
  394.  
  395.  "WORLDINVERSE"のように、セマンティクスの末尾に"INVERSE"を付加すると、各行列の逆行列が得られる。
  396. By adding "INVERSE" to the end of the semantic, e.g. "WORLDINVERSE", you can obtain the inverse of each matrix.
  397.  また、"WORLDTRANSPOSE"のように、末尾に"TRANSPOSE"を付加すると、各行列の転置行列が得られる。
  398. With "TRANSPOSE" at the end, you can obtain the transposed matrix.
  399. *NOTE: 'Position × WORLD' is equal to 'WORLDTRANSPOSE × Position'.
  400.  逆行列の転置行列を得るには、末尾に"INVERSETRANSPOSE"を付加する。
  401. For inverse transpose, add "INVERSETRANSPOSE" to the semantic.
  402.  
  403.  
  404.  ○アノテーション
  405. Annotation
  406.  ・string Object (省略可能)
  407. (can omit)
  408.    ビュー変換およびプロジェクション変換において、どこを視点とするかを指定する。
  409. For VIEW and PROJECTION transformations, set where the viewpoint is.
  410.    "Camera"または"Light"が指定できる。デフォルトは"Camera"である。
  411. "Camera" and "Light" are the valid settings. Default is "Camera".
  412.  
  413.    通常の、カメラを視点とした座標変換を行う場合には、"Camera" を指定する。
  414. For the normal case, use "Camera" to indicate camera as viewpoint.
  415.    セルフシャドウのためのZ値プロット等、光源を視点とした座標変換を行う場合には、"Light"を指定する。
  416. For the Z-value plot used by self-shadow and such, use "Light" for a coordinate transformation based on the light's source location.
  417.  
  418. ○使用例
  419. Example of use
  420. float4x4 WorldMatrix : WORLD ;
  421. float4x4 WorldViewProjMatrix : WORLDVIEWPROJECTION ;
  422. float4x4 LightViewMatrix : VIEW < string Object = "Light"; > ;
  423. float4x4 WorldInvMatrix : WORLDINVERSE ;
  424. float4x4 WorldViewProjTransMatrix : WORLDVIEWPROJECTIONTRANSPOSE ;
  425.  
  426.  ○補足
  427. Supplement/notes
  428.   ・Objectアノテーションに"Light"を指定したときに得られる行列は、
  429.    MMDのセルフシャドウ処理に使用している行列と連動しているため、
  430.    [表示(V)]-[セルフシャドウ表示(P)]で、セルフシャドウ機能を完全にOFFにしてしまうと、
  431.    正しい値を参照できなくなる。
  432. 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.
  433.  
  434.  
  435. 2.2 ライトとマテリアル
  436. Lights and materials
  437. 参考:http://msdn.microsoft.com/ja-jp/library/bb174694(v=VS.85).aspx
  438. Reference
  439.  
  440. ●DIFFUSE
  441. ●AMBIENT
  442. ●EMISSIVE
  443. ●SPECULAR
  444. ●SPECULARPOWER
  445. ●TOONCOLOR
  446. ●EDGECOLOR
  447. ●GROUNDSHADOWCOLOR
  448.  
  449.  3Dオブジェクトのマテリアル(材質)の色値、またはライトの色値。
  450. The color value of a material or a light.
  451.  
  452.  6つのセマンティクスは、それぞれ、
  453. The (literally six) eight semantics are as follows,
  454.   DIFFUSE   : ディフューズ色(拡散光)
  455. Diffuse color (scattered light)
  456.   AMBIENT   : アンビエント色(環境光)
  457. Ambient color (environment light). *Note: affected by light slider.
  458.   EMISSIVE   : エミッション色(放射光)
  459. Emissive color. *Note: not affected by light slider.
  460.   SPECULAR   : スペキュラ色(鏡面光)
  461. Specular color (shiny/mirror)
  462.   SPECULARPOWER   : スペキュラの強度
  463. Specular strength *Note: concentration, not maximum brightness
  464.   TOONCOLOR   : トゥーン色
  465. Toon color
  466.   EDGECOLOR   : 輪郭色
  467. Edge color
  468.   GROUNDSHADOWCOLOR : 地面影色
  469. Ground shadow color
  470.  を表す。
  471. (literally: signifies.)
  472.  
  473.  トゥーン色は、PMDモデルのトゥーンレンダリングにおける、影の色(具体的にはtoon??.bmpの左下隅の色)を表す。
  474. 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.
  475.  
  476.  型は、"SPECULARPOWER"のみfloatで、それ以外はfloat3またはfloat4ある。
  477. Variable type for "SPECULARPOWER" is float, the rest are float3 or float4.
  478.  色は4つの成分(赤・緑・青・アルファ(透明度))で構成される。型にfloat3を指定するとアルファ値が省略される。
  479. Colors have four components (red, green, blue, alpha (transparency)). When type is specified as float3, alpha is discarded.
  480.  
  481.  
  482.  ○アノテーション
  483. Annotation
  484.  ・string Object (必須)
  485. (required)
  486.    ライト色と、オブジェクトのマテリアル色のどちらを取得するかを指定する。
  487. Specify whether to get light or object material color.
  488.    "Light"または"Geometry"が指定できる。
  489. "Light" and "Geometry" are the valid options.
  490.  
  491.    オブジェクトのマテリアル色を取得するには、"Geometry"を指定する。
  492. Use "Geometry" to get the object material's colors.
  493.    ライト色を取得するには、"Light"を指定する。
  494. Use "Light" to get the light's (multi-component) colors.
  495.    "SPECULARPOWER"と"EMISSIVE"および"TOONCOLOR"には、ライト色がないため、"Light"は指定できない。
  496. For "SPECULARPOWER", "EMISSIVE", and "TOONCOLOR", these don't apply to lights so "Light" isn't a valid annotation name.
  497.  
  498. ○使用例
  499. Example of use
  500. float4 MaterialDiffuse : DIFFUSE < string Object = "Geometry"; >;
  501. float3 MaterialAmbient : AMBIENT < string Object = "Geometry"; >;
  502. float3 MaterialEmissive : EMISSIVE < string Object = "Geometry"; >;
  503. float3 MaterialSpecular : SPECULAR < string Object = "Geometry"; >;
  504. float SpecularPower : SPECULARPOWER < string Object = "Geometry"; >;
  505. float3 MaterialToon : TOONCOLOR;
  506. float3 EdgeColor : EDGECOLOR;
  507. float3 LightDiffuse : DIFFUSE < string Object = "Light"; >;
  508. float3 LightAmbient : AMBIENT < string Object = "Light"; >;
  509. float3 LightSpecular : SPECULAR < string Object = "Light"; >;
  510. static float4 DiffuseColor = MaterialDiffuse * float4(LightDiffuse, 1.0f);
  511. static float3 AmbientColor = MaterialAmbient * LightAmbient + MaterialEmissive;
  512. static float3 SpecularColor = MaterialSpecular * LightSpecular;
  513. float4 GroundShadowColor : GROUNDSHADOWCOLOR;
  514.  
  515. // *Fixed spelling error, "Emmisive" > "Emissive"
  516.  
  517.  ○補足
  518. Supplement/notes
  519.   ・輪郭色はMMDPass="edge"のTechniqueにおいてしか、正しく取得できない。
  520. Edge color (EDGECOLOR) cannot be correctly measured except inside a technique with MMDPass="edge".
  521.   ・地面影色はMMDPass="shadow"のTechniqueにおいてしか、正しく取得できない。
  522. Ground shadow color (GROUNDSHADOWCOLOR) cannot be correctly measured except inside a technique with MMDPass="shadow".
  523.   ・その他の各色値は、MMDPass="zplot"またはMMDPass="edge"のTechniqueにおいては、正しく取得できない。
  524. Colors other than these can't be acquired inside techniques with MMDPass="zplot" or MMDPass="edge".
  525.  
  526.  
  527. ●POSITION
  528. ●DIRECTION
  529.  
  530.  ライトまたはカメラの、ワールド空間内における位置および向き。
  531. The position or direction of light or camera in world space.
  532.  型は、float3またはfloat4である。
  533. Variable type is float3 or float 4.
  534.  
  535.  
  536.  ○アノテーション
  537. Annotation
  538.  ・string Object (必須)
  539. (required)
  540.    カメラおよびライトのどちらの座標を取得するかを指定する。
  541. Specify whether to acquire camera or light coordinates.
  542.    "Camera"または"Light"が指定できる。
  543. "Camera" and "Light" are the options.
  544.  
  545. ○使用例
  546. Example of use
  547. float3 LightDirection : DIRECTION < string Object = "Light"; >;
  548. float3 CameraPosition : POSITION < string Object = "Camera"; >;
  549.  
  550.  ○補足
  551. Supplement/notes
  552.   ・MMDのライトは、ディレクショナルライトであるため、
  553.    ライトの位置座標は、ライトの向きと逆方向の無限遠点になる。
  554. Because MMD uses a directional light, the light's position is its vanishing point (infinite distance) in the opposite direction.
  555.  
  556.  
  557. ●MATERIALTEXTURE
  558.  
  559.  マテリアルに設定されているテクスチャ。
  560. The texture set for a material.
  561.  
  562.  ○アノテーション
  563.   なし
  564. No annotations
  565.  
  566. ○使用例
  567. Example of use
  568. texture ObjectTexture : MATERIALTEXTURE;
  569.  
  570. sampler ObjTexSampler = sampler_state
  571. {
  572. texture = <ObjectTexture>;
  573. MINFILTER = LINEAR;
  574. MAGFILTER = LINEAR;
  575. MIPFILTER = LINEAR;
  576. ADDRESSU = WRAP;
  577. ADDRESSV = WRAP;
  578. };
  579. // tex2D(ObjTexSampler, float2(x,y)) で内容を参照できる
  580. with this, you can sample the contents
  581.  
  582.  ○補足
  583. Supplement/notes
  584.   ・各色値は、MMDPass="zplot"またはMMDPass="edge"のTechniqueにおいては、正しく取得できない。
  585. (The same warning about "can't get colors with zplot and edge techniques", except no "Other than these"?)
  586.  
  587.  
  588. ●MATERIALSPHEREMAP
  589.  
  590.  マテリアルに設定されている、スフィアマップテクスチャ。
  591. The sphere map texture specified for a material.
  592.  
  593.  ○アノテーション
  594.   なし
  595. No annotations
  596.  
  597. ○使用例
  598. Example of use
  599. texture ObjectSphereMap : MATERIALSPHEREMAP;
  600.  
  601. sampler ObjSphSampler = sampler_state
  602. {
  603. texture = <ObjectSphereMap>;
  604. MINFILTER = LINEAR;
  605. MAGFILTER = LINEAR;
  606. MIPFILTER = LINEAR;
  607. ADDRESSU = WRAP;
  608. ADDRESSV = WRAP;
  609. };
  610. // tex2D(ObjSphSampler, float2(x,y)) で内容を参照できる
  611. with this, you can sample the contents
  612.  
  613.  ○補足
  614. Supplement/notes
  615.   ・各色値は、MMDPass="zplot"またはMMDPass="edge"のTechniqueにおいては、正しく取得できない。
  616. (same warning about colors and zplot or edge techniques)
  617.  
  618. ●MATERIALTOONTEXTURE
  619.  
  620.  マテリアルに設定されている、トゥーンマップテクスチャ。
  621. The 'toon map' texture specified for a material.
  622.  
  623.  ○アノテーション
  624.   なし
  625. No annotations
  626.  
  627. ○使用例
  628. Example of use
  629. texture ObjectToonTexture : MATERIALTOONTEXTURE;
  630.  
  631. sampler ObjToonSampler = sampler_state
  632. {
  633. texture = <ObjectSphereMap>;
  634. MINFILTER = LINEAR;
  635. MAGFILTER = LINEAR;
  636. MIPFILTER = NONE;
  637. ADDRESSU = CLAMP;
  638. ADDRESSV = CLAMP;
  639. };
  640. // tex2D(ObjToonSampler, float2(x,y)) で内容を参照できる
  641. with this, you can sample the contents
  642.  
  643.  ○補足
  644. Supplement/notes
  645.   ・各色値は、MMDPass="zplot"またはMMDPass="edge"のTechniqueにおいては、正しく取得できない。
  646. (same warning about colors and zplot or edge techniques)
  647.   ・また、アクセサリの場合(UseToon=falseの場合)は、正しく取得できない。
  648. Also, for accessories (UseToon=false technique annotation), this value can't be acquired.
  649.   ・PMDモデルにおいて、トゥーンを使用しないマテリアルの場合は、全面白色のテクスチャとなる。
  650. For PMD models, materials that don't have a 'toon' texture set will use a pure white texture.
  651.  
  652. ●ADDINGTEXTURE
  653. ●MULTIPLYINGTEXTURE
  654. ●ADDINGSPHERETEXTURE
  655. ●MULTIPLYINGSPHERETEXTURE
  656.  
  657.  PMX材質モーフのための、テクスチャおよびスフィアマップのテクスチャに対しての、
  658.  加算値および乗算値。
  659. For PMX material morphs. Texture or sphere's addition value or multiplication value (?).
  660.  
  661.  ○アノテーション
  662.   なし
  663. No annotations
  664.  
  665. ○使用例
  666. Example of use
  667. float4 TextureAddValue : ADDINGTEXTURE;
  668. float4 TextureMulValue : MULTIPLYINGTEXTURE;
  669. float4 SphereAddValue : ADDINGSPHERETEXTURE;
  670. float4 SphereMulValue : MULTIPLYINGSPHERETEXTURE;
  671.  
  672.  ○補足
  673. Supplement/notes
  674.   ・各値は、MMDPass="object_ss"の場合でしか、正しく取得できない。
  675. These values can only be used with MMDPass="object_ss" techniques.
  676.   ・また、アクセサリの場合(UseToon=falseの場合)は、加算値は全て0、乗算値は全て1になる。
  677. With accessories (UseToon=false annotation), addition values are always 0, multiplication values are always 1.
  678.  
  679.  
  680. 2.3 スクリーン情報
  681. Screen information
  682.  
  683. ●VIEWPORTPIXELSIZE
  684.  
  685.  レンダリングターゲットのスクリーンのサイズ。
  686. The current rendering target's screen size.
  687.  型はfloat2。単位はピクセル。
  688. Variable type is float2. Unit is pixels.
  689.  
  690.  ※この値は、MMDのスクリーンもしくはオフスクリーンレンダリングターゲットのサイズを指す。
  691. (Reference mark/kome) This value shows MMD's screen or offscreen render (rendering) target's size.
  692.   Scriptsの"RenderColorTarget"コマンドで、レンダリングターゲットが変更しても、
  693.   この値は変化しない。
  694. When you change "RenderColorTarget" in a technique's script, even though the rendering target changes, this value does not.
  695.  
  696.  ○アノテーション
  697.   なし
  698. No annotations
  699.  
  700. ○使用例
  701. Example of use
  702. float2 ScreenSize : VIEWPORTPIXELSIZE;
  703.  
  704.  ○補足
  705. Supplement/notes
  706.   ・内部的には、Viewportの.Widthと.Heightの値を参照している。
  707. The contents of this are taken from Viewport.Width and Viewport.Height.
  708.  
  709.  
  710. 2.4 時間
  711. Time
  712.  
  713. ●TIME
  714. ●ELAPSEDTIME
  715.  
  716.  時間情報。
  717. Time information.
  718.  型はfloat。単位は秒。
  719. Variable type is float. Unit is seconds.
  720.  
  721.  "TIME"は、0フレーム目からの再生時間を表す。
  722. "TIME" is playback time relative to frame 0.
  723.  例えば、0フレーム目では、0.0(秒)となり、45フレーム目では1.5(秒)となる。
  724. For example, at frame 0, it's 0.0 (seconds). At frame 45, it's 1.5 (seconds).
  725.  
  726.  "ELAPSEDTIME"は、前回の描画からの経過時間を表す。
  727. "ELAPSEDTIME" measures time since the previous drawn frame.
  728.  
  729.  例えば、60fpsでAVI出力時には、"ELAPSEDTIME"の値は、1/60 で一定になる。
  730. For example, when outputting to an .avi at 60 fps, "ELAPSEDTIME" will be uniformly 1/60.
  731.  
  732.  ○アノテーション
  733. Annotation
  734.  ・bool SyncInEditMode (省略可能)
  735. (can omit)
  736.    MMDが編集モードである場合でも、フレームと連動するかを指定する。
  737. Determines whether the time is linked to frame number in edit mode.
  738.    trueまたはfalseを指定する。デフォルトはfalse。
  739. Can be true or false. Default is false.
  740.    
  741.    MMDが編集モードのときには、フレームの再生は停止しているため、
  742. Since in edit mode, the frame is stopped in MMD,
  743.    TIMEの値が常にフレーム時間と連動していると、
  744. if TIME is linked to frame number,
  745.    編集モード中は、この値を使用しているアニメーションも停止することになる。
  746. during edit mode any animations that use this value will be suspended too.
  747.    
  748.    このアノテーションにfalseが指定されていると、
  749. If you use false for this annotation,
  750.    編集モード中、TIMEおよびELAPSEDTIMEの値には、フレーム時間ではなくシステム時間が使用される。
  751. then rather than frame number, TIME and ELAPSEDTIME will be based on system time.
  752.    これにより、編集モード中でもアニメーションが停止しなくなる。
  753. Accordingly, even in edit mode animations won't be stopped.
  754.  
  755. ○使用例
  756. Example of use
  757. float ftime : TIME <bool SyncInEditMode=true;>;
  758. float elapsed_time : ELAPSEDTIME;
  759. static float fps = 1.0 / elapsed_time;
  760.  
  761.  ○補足
  762. Supplement/notes
  763.   ・SyncInEditMode=trueの場合、ELAPSEDTIMEの値は、MMD上でのフレーム移動操作により、0やマイナスになりうる。
  764. With SyncInEditMode=true, the value of ELAPSEDTIME can be zero or negative (minus), depending on frame navigation.
  765.  
  766.  
  767. 2.5 マウス
  768. Mouse
  769.  
  770. ●MOUSEPOSITION
  771.  
  772.  マウスの現在位置。
  773. Mouse's current position.
  774.  型はfloat2。
  775. Variable type is float2.
  776.  
  777.  MMDの描画領域の中心を(0,0)とし、左下隅が(-1,-1)、右上隅が(1,1)になる。
  778. The center of MMD's render/drawing output is (0,0). Bottom left corner is (-1,-1), top right corner is (1,1).
  779.  このxy座標の取り方は、プロジェクション変換した後の、頂点座標と同じである。
  780. These xy coordinates correspond to the positions for vertex coordinates after a projection transformation.
  781.  
  782.  ○アノテーション
  783.   なし
  784. No annotations
  785.  
  786. ○使用例
  787. Example of use
  788. float2 pos : MOUSEPOSITION;
  789.  
  790.  
  791. ●LEFTMOUSEDOWN
  792. ●MIDDLEMOUSEDOWN
  793. ●RIGHTMOUSEDOWN
  794.  
  795.  マウスボタンに関する情報。
  796. Mouse button information.
  797.  型はfloat4。
  798. Variable type is float4.
  799.  
  800.  取得できる値は、以下の4成分からなる。
  801. The obtained value has the following four components.
  802.  ・最後にボタンが押されたときのマウスの座標(xとy)
  803. Coordinates (x and y) of the location where the button was last pressed
  804.  ・現在ボタンが押されているか (0 or 1)
  805. Whether the button is currently depressed (0 or 1)
  806.  ・最後にボタンが押された時点のTIME値(秒)
  807. The TIME value (seconds) for when the button was last pressed
  808.  
  809.  なお、マウスの座標の取り方は、MOUSEPOSITIONと同じである。
  810. Note: mouse coordinates are defined/obtained the same as for MOUSEPOSITION.
  811.  
  812.  ○アノテーション
  813.   なし
  814. No annotations
  815.  
  816. ○使用例
  817. Example of use
  818. float4 mouse_down : LEFTMOUSEDOWN;
  819. static float2 pos = mouse_down.xy;
  820. static bool is_pressed = (mouse_down.z != 0);
  821.  
  822.  
  823. 2.6 コントロールオブジェクト
  824. Control object
  825.  
  826. ●CONTROLOBJECT
  827.  
  828.  指定したオブジェクトの、座標やワールド変換行列を取得する。
  829. Acquire the coordinates or world transformation matrix of the indicated object.
  830.  主に、シェーダに必要なパラメータをMMD上から制御する場合に使用する。
  831. Usually used to get important shader parameters from MMD.
  832.  
  833.  型はbool, float, float3, float4またはfloat4x4。
  834. Variable type can be bool, float, float3, float4, or float4x4.
  835.  
  836.  使用する型によって、取得できる情報が異なる。
  837. Depending on the variable type, the obtained information differs.
  838.  
  839.  ・bool
  840.    指定したオブジェクトが表示されているか否か
  841. Whether the indicated object is visible/displayed or not
  842.  ・float
  843.    指定したオブジェクトのスケーリング値
  844. The indicated object's scaling value (*Note: 10x the value of 'Si', used by accessories)
  845.  ・float3, float4
  846.    指定したオブジェクトの座標(オフセット)
  847. The object's coordinates (offset)
  848.  ・float4x4
  849.    指定したオブジェクトのワールド変換行列
  850. The object's world transformation matrix
  851.  
  852.  また、itemアノテーションに特殊な文字列を指定することにより、
  853. Note: using a special string for 'item' annotation,
  854. In addition, depending on the string used for the 'item' annotation,
  855.  これら以外の値も取得できる。
  856. you can obtain values other than those here.
  857.  
  858.  ○アノテーション
  859. Annotation
  860.  ・string name (必須)
  861. (required)
  862.    オブジェクトのファイル名を指定する(フォルダパスは含めない)。
  863. The object's filename (don't include the path to the file)
  864.    
  865.    特殊なファイル名"(self)"を指定すると、
  866. If you use "(self)" for the filename,
  867.    そのエフェクトが割り当てられたオブジェクト自身を対象にできる。
  868. it will use the object that the effect is applied to.
  869.    
  870.    また、特殊なファイル名"(OffscreenOwner)"を指定すると、
  871. If you use "(OffscreenOwner)" for the filename,
  872.    オフスクリーンのオーナーのオブジェクトを対象にできる(オフスクリーンレンダリング中の場合のみ)。
  873. the offscreen owner will be used (only applies to offscreen rendering)
  874.    ここで、オフスクリーンのオーナーとは、OFFSCREENRENDERTARGETが宣言されているエフェクトが
  875.    割り当てられたオブジェクトを指す
  876. This is the object that the effect that declares the OFFSCREENRENDERTARGET is applied to.
  877.    
  878.  ・string item (省略可能)
  879. (can omit)
  880.    オブジェクトの特殊な値を取得したい場合に指定する。
  881. Use this when you want to obtain a special value from the object.
  882.    
  883.    以下のうちいずれかを指定する。
  884. Any of the following can be specified.
  885.     ボーン名 : PMDモデルの指定ボーンの座標またはワールド変換行列を取得する。
  886. Bone name: (acquires the) PMD (or PMX) model's bone coordinate or world transformation matrix
  887.           型はfloat3,float4,float4x4のうちいずれか。
  888. Variable type is float3, float4, or float4x4.
  889.     表情名  : PMDモデルの指定した表情の値を取得する。型はfloat。
  890. Expression name: PMD (or PMX) model's expression value. Type is float.
  891.     
  892.     "X" : アクセサリの位置X(アクセサリパネルのX)。型はfloat。
  893. Accessory's position X (accessory panel X). Type is float.
  894.     "Y" : アクセサリの位置Y(アクセサリパネルのY)。型はfloat。
  895. Accessory's position Y (accessory panel Y). Type is float.
  896.     "Z" : アクセサリの位置Z(アクセサリパネルのZ)。型はfloat。
  897. Accessory's position Z (accessory panel Z). Type is float.
  898.     "XYZ" : アクセサリの位置(アクセサリパネルのX,Y,Z)。型はfloat3。
  899. Accessory's full position (accessory panel X, Y, Z). Type is float3.
  900.     "Rx" : アクセサリの回転X(アクセサリパネルのRx)。型はfloat。(※1)
  901. Accessory's rotation X (accessory panel Rx). Type is float. (See note/kome 1)
  902.     "Ry" : アクセサリの回転Y(アクセサリパネルのRy)。型はfloat。
  903. Accessory's rotation Y (accessory panel Ry). Type is float.
  904.     "Rz" : アクセサリの回転Z(アクセサリパネルのRz)。型はfloat。
  905. Accessory's rotation Z (accessory panel Rz). Type is float.
  906.     "Rxyz" : アクセサリの回転(アクセサリパネルのRx,Ry,Rz)。型はfloat3。
  907. Accessory's all rotations (accessory panel Rx, Ry, Rz). Type is float3.
  908.     "Si" : アクセサリのサイズ(アクセサリパネルのSi)。型はfloat。(※2)
  909. Accessory's size (accessory panel Si). Type is float. (See note/kome 2)
  910.     "Tr" : アクセサリの透明度(アクセサリパネルのTr)。型はfloat。
  911. Accessory's transparency (accessory panel Tr). Type is float.
  912.      
  913. (*Note: fixed typo, アクセサリパネルのSi > Tr)
  914. (*Note: world matrix includes 'outside parent', XYZ or Rxyz does not)
  915.  
  916.      ※1 得られる値は、パネル上の値をラジアンで表したものである。
  917. (Reference mark/kome)1 Obtained value is the panel value converted into (expressed as) radians.
  918.      ※2 得られる値は、パネル上の値を10倍したものである。
  919. (Reference mark/kome)2 Obtained value is 10 times the panel value.
  920.      
  921. ○使用例
  922. Example of use
  923. //"stage01.x"が表示されているか否かを取得
  924. Acquire a value that depends on whether "stage01.x" is displayed
  925. bool flag : CONTROLOBJECT < string name = "stage01.x"; >;
  926.  
  927. //"negi.x"のスケーリング値を取得
  928. Get scaling value for "negi.x" (*See ※2 above)
  929. float scaling : CONTROLOBJECT < string name = "negi.x"; >;
  930.  
  931. //"negi.x"の回転Xを取得
  932. Obtain the X-rotation (*panel value) of "negi.x"
  933. float rot_x : CONTROLOBJECT < string name = "negi.x"; string item = "Rx"; >;
  934.  
  935. //"negi.x"の回転Xを度数単位で取得
  936. Get X-rotaton (*panel value) of "negi.x" in degrees
  937. float rot_x_rad : CONTROLOBJECT < string name = "negi.x"; string item = "Rx"; >;
  938. static float rot_x = rot_x_rad * 180 / 3.14159265;
  939.  
  940. //"弱音ハク.pmd"のボーン「ポニテIK」の座標取得
  941. Get the position of "弱音ハク.pmd" (Yowane Haku) bone "ポニテIK" (Ponytail Inverse Kinematics or PoniteIK)
  942. float3 pos : CONTROLOBJECT < string name = "弱音ハク.pmd"; string item = "ポニテIK"; >;
  943.  
  944. //"弱音ハク.pmd"の表情「まばたき」の値取得
  945. Get the "まばたき" (blinking) expression value from "弱音ハク.pmd" (Yowane Haku)
  946. float morph : CONTROLOBJECT < string name = "弱音ハク.pmd"; string item = "まばたき"; >;
  947.  
  948.  ○補足
  949. Supplement/notes
  950.   ・PMDモデルのワールド変換行列は単位行列で変化しないため、
  951. Since the world transformation matrix of a PMD (or PMX) model is the identity matrix and therefore never changes,
  952.    通常は、Xファイル(アクセサリ)に対して使用する。
  953. this (*world matrix as float4x4) is usually targeted at an X file (accessory).
  954.   ・アクセサリのスケーリング値は、MMD上でアクセサリのSizeに指定した値を10倍した値になる。
  955. An accessory's obtained scaling value is 10 times the value indicated in MMD's Size/Si field.
  956.    (内部的には、length(world_matrix._11_12_13) で得られる値を使用している)
  957. (Internally, the value of length(world_matrix._11_12_13) is used)
  958. (Yes, it's confusing)
  959.   ・指定したファイル名のオブジェクトが存在しない場合、以下の値が設定される。
  960. When the specified oject doesn't exist, the following values are used.
  961.     Xファイルの場合:
  962. For an X file:
  963.      スケーリング値 :10
  964. Scaling value : 10
  965.      オフセット値  :(0,0,0,1)
  966. Offset/position : (0,0,0,1)
  967.      ワールド変換行列:スケーリング行列(xyz各10倍)
  968. World transformation matrix: scaling matrix (results in xyz each being multiplied by 10)
  969.      特殊item値   :0
  970. Special 'item' value : 0
  971.     PMDファイルの場合:
  972. For a PMD file:
  973.      スケーリング値 :1
  974. Scaling value : 1
  975.      オフセット値  :(0,0,0,1)
  976. Offset/position : (0,0,0,1)
  977.      ワールド変換行列:単位行列
  978. World transformation matrix: identity matrix
  979.      ボーンの座標  :(0,0,0,1)
  980. Bone coordinates : (0,0,0,1)
  981.      ボーンの変換行列:単位行列
  982. Bone transformation matrix : identity matrix
  983.      表情値     :0
  984. Expression value : 0
  985.  
  986.   ・MME ver0.20より、参照先のオブジェクトが参照元のオブジェクトよりも後に描画されていても、
  987.    値を取得できるようになった。
  988. Since MME ver0.20, even when the (referent) target object is drawn after the object that's checking the value, it can be acquired.
  989.    
  990.   ・指定した名前を持つオブジェクトが複数存在する場合、以下の優先順位で選択される。
  991. When more than one object has the indicated name, priority is determined as follows.
  992.     (1) 参照元のオブジェクトよりも描画順序が先で、かつ最も描画順序が近いもの。
  993. Starting with (?) or for (?) effects drawn before the querying object, the object with the closest drawing order. (?)
  994.     (2) 描画順序が最後のもの
  995. Drawing order is latest/most delayed (?)
  996.  
  997.   ・ダミーボーン.pmdなどのように、頂点を一つも持たないオブジェクトについては、
  998.    参照先に指定しても座標を取得できない。
  999. 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)
  1000.  
  1001.  
  1002. 2.7 テクスチャ関連
  1003. Related to textures
  1004.  
  1005. ●通常テクスチャ
  1006. Normal/usual/basic texture (*note: no semantic)
  1007.  
  1008.  テクスチャを生成する。
  1009. Create a texture.
  1010.  
  1011.  型はtexture, texture2D, texture3D, textureCUBEのうちいずれか。
  1012. Variable type can be texture, texture2D, texture3D, or textureCUBE.
  1013.  RENDERCOLORTARGET, RENDERDEPTHSTENCILTARGET, ANIMATEDTEXTURE 以外のセマンティクスは指定しても無視される。
  1014. If semantic is other than RENDERCOLORTARGET, RENDERDEPTHSTENCILTARGET, or ANIMATEDTEXTURE, it is ignored.
  1015.  
  1016.  生成したテクスチャの内容は、サンプラを設定した上で、tex2D(s, t)関数などを呼び出すことで参照できる。
  1017. The contents of a created texture can be accessed, after defining a sampler, by calling a function like tex2D(s, t).
  1018.  
  1019.  
  1020.  ○アノテーション
  1021. Annotation
  1022.  ・string ResourceType
  1023.    テクスチャの種類を指定する。"2D", "3D", "CUBE"のうちいずれかを指定する。
  1024. Indicate the texture's variety. "2D", "3D", or "CUBE" can be used.
  1025.    型と矛盾した値は指定できない。
  1026. A value that's inconsistent with variable type can't be used.
  1027.  
  1028.    型が"texture"であり、かつ"2D"以外のテクスチャを生成する場合には、
  1029. When type is "texture" and you want to create a type other than 2D,
  1030.    かならずこのアノテーションを指定しなければならない。それ以外では省略可能である。
  1031. make sure to use this annotation. Otherwise, it can be omitted.
  1032.  
  1033.  ・string ResourceName
  1034.    テクスチャの元になる画像ファイルを指定する。
  1035. Select an image file to use for the texture.
  1036.    サポートしているファイルフォーマットは、bmp、.dds、.dib、.jpg、.png、および .tga である。
  1037. Supported formats are bmp, dds, dib, jpg, png and tga.
  1038.    相対パスでファイル名を指定した場合、エフェクトファイルが格納されているフォルダが基準となる。
  1039. When using a relative path to designate the filename, the folder that the effect file is stored in is used as the starting directory.
  1040.  
  1041.  ・int Width
  1042.  ・int Height
  1043.  ・int Depth
  1044.    テクスチャの幅、高さ、深さをピクセル単位で指定する。
  1045. Specify the texture's width, height, depth in pixels.
  1046.    深さを指定するのはボリュームテクスチャの場合のみである。
  1047. Depth is specified only for volume (3D) textures.
  1048.    
  1049.    Dimensions, ViewportRatio とは同時に指定できない。
  1050. Can't be specified at the same time as Dimensions or ViewportRatio.
  1051.    
  1052.    (Width,Height,Depth), Dimensions, ViewportRatioのいずれも指定されていない場合の、
  1053.    デフォルト値は、64ピクセルである。
  1054. If none of (Width,Height,Depth), Dimensions, nor (?) ViewportRatio are specified, the default value of 64 pixels is used.
  1055.    また、ResourceNameが指定されているならば、画像ファイルからサイズが自動的に取得される。
  1056. However, if ResourceName is specified, image size is automatically obtained from the image file.
  1057.    
  1058.  ・int2(or int3) Dimensions
  1059.    テクスチャの幅、高さ、深さをピクセル単位で指定する。
  1060. Specify the texture's width, height, depth in pixels.
  1061.    深さを指定するのはボリュームテクスチャの場合のみである。
  1062. Depth is specified only for volume (3D) textures.
  1063.    
  1064.    ViewportRatio, Width, Height, Depthとは同時に指定できない。
  1065. Can't be specified at the same time as ViewportRatio, Width, Height, or Depth.
  1066.    
  1067.  ・float2 ViewportRatio
  1068.    テクスチャの幅、高さを、レンダリングターゲットのスクリーンのサイズとの比で指定する。
  1069. Specify the texture's width and height as a ratio of the render (rendering) target's size.
  1070.    スクリーンと同じサイズのテクスチャを生成するには、"float2 ViewportRatio = {1.0, 1.0};" と指定する。
  1071. To make a texture with the same size as the screen, set this as "float2 ViewportRatio = {1.0, 1.0};".
  1072.    スクリーンの縦横2倍のサイズのテクスチャを生成するには、"float2 ViewportRatio = {2.0, 2.0};" と指定する。
  1073. To make a texture twice as large as the screen along each dimension (*4x area), set this as "float2 ViewportRatio = {2.0, 2.0};".
  1074.  
  1075.    Dimensions, Width, Height, Depthとは同時に指定できない。
  1076. Can't be specified at the same time as Dimensions, Width, Height, or Depth.
  1077.    
  1078.  ・string Format
  1079.    テクスチャのフォーマットを指定する。
  1080. Specify texture's format.
  1081.    
  1082.    省略した場合、"A8R8G8B8"が使用される。
  1083. If omitted, "A8R8G8B8" is used.
  1084.    ResourceNameが指定されているならば、画像ファイルからフォーマットが取得され、
  1085. If ResourceName is set, the format is taken from the image file,
  1086.    このアノテーションの設定は無視される。
  1087. and this annotation is ignored.
  1088.    
  1089.    指定可能なフォーマットは、D3DFORMAT(http://msdn.microsoft.com/ja-jp/library/bb172558(v=VS.85).aspx)
  1090.    を参照。
  1091. For possible formats, consult D3DFORMAT (outdated link, do a search or use archive.org).
  1092.    
  1093.    "A8R8G8B8"、"FMT_A8R8G8B8"、"D3DFMT_A8R8G8B8"のいずれの書式でも指定できる。
  1094. It doesn't matter whether you prepend "FMT_" or "D3DFMT_".
  1095.  
  1096.  ・int Miplevels
  1097.    ミップマップを指定したレベルで生成する。
  1098. Mipmaps are created to the indicated level.
  1099.    省略するか0を指定した場合、完全なミップマップ チェーンが作成される。
  1100. If omitted or 0, the entire mipmap chain is created.
  1101.    1を指定すると、ミップマップは生成されない。
  1102. If set to 1, mipmaps are not created.
  1103.  
  1104.  ・int Levels
  1105.    Miplevelsの別名である。
  1106. Another name for Miplevels.
  1107.  
  1108. ○使用例
  1109. Example of use
  1110.  
  1111. texture negi_tex < string ResourceName = "negi.bmp"; >;
  1112. sampler TexSampler = sampler_state {
  1113. texture = <negi_tex>;
  1114. };
  1115.  
  1116. texture2D map_tex <
  1117. string ResourceName = "map.png";
  1118. int Miplevels = 1;
  1119. int Width = 64;
  1120. int Height = 64;
  1121. >;
  1122.  
  1123.  
  1124. ●RENDERCOLORTARGET
  1125.  
  1126.  レンダリングターゲットに指定可能なサーフェイスを生成する。
  1127. Create a surface that can be used as a render (rendering) target.
  1128.  このセマンティクスを指定して生成したテクスチャは、スクリプトのRenderColorTargetに
  1129.  指定することができる。
  1130. A texture that is created with this semantic can be used in a script (*for a technique) as a RenderColorTarget.
  1131.  レンダリング後は、通常のテクスチャと同様に、tex2D()関数で内容を参照できる。
  1132. After rendering, the contents can be accessed with a tex2D() function the same as a normal texture.
  1133.  
  1134.  型はtexture, texture2Dのうちいずれか。
  1135. Variable type can be texture or texture2D.
  1136.  
  1137.  ○アノテーション
  1138. Annotation
  1139.  
  1140.  ・int Width, int Height, int Depth
  1141.  ・int2 Dimensions
  1142.  ・float2 ViewportRatio
  1143.    "●通常テクスチャ"を参照。
  1144. See normal/usual/basic texture.
  1145.    省略した場合、"float2 ViewportRatio = {1.0, 1.0};" という設定が使用される。
  1146. If omitted, default is "float2 ViewportRatio = {1.0, 1.0};".
  1147.  
  1148.  ・string Format
  1149.    "●通常テクスチャ"を参照。
  1150. See normal/usual/basic texture.
  1151.    省略した場合、"A8R8G8B8"が使用される。
  1152. If omitted, "A8R8G8B8" is used.
  1153.  
  1154.  ・int Miplevels
  1155.  ・int Levels
  1156.    "●通常テクスチャ"を参照。
  1157. See normal/usual/basic texture.
  1158.    1または0が指定できる。
  1159. 1 and 0 can be selected.
  1160.    0を指定した場合、完全なミップマップ チェーンが作成される。
  1161. If 0, the entire mipmap chain is created.
  1162.    1を指定すると、ミップマップは生成されない(デフォルト)。
  1163. If set to 1, mipmaps are not created (default).
  1164.  
  1165. (*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.)
  1166.  
  1167. ○使用例
  1168. Example of use
  1169.  
  1170. texture2D ScnMap : RENDERCOLORTARGET <
  1171. float2 ViewPortRatio = {1.0,1.0};
  1172. int MipLevels = 1;
  1173. string Format = "A8R8G8B8" ;
  1174. >;
  1175. sampler2D ScnSamp = sampler_state {
  1176. texture = <ScnMap>;
  1177. };
  1178.  
  1179. technique Tech <
  1180. string Script = "RenderColorTarget0=ScnMap;
  1181. ...
  1182.  
  1183.  
  1184. ●RENDERDEPTHSTENCILTARGET
  1185.  
  1186.  深度ステンシルサーフェイス(いわゆるZバッファ)を生成する。
  1187. Create a depth stencil surface (also known as Z-buffer).
  1188.  このセマンティクスを指定して生成したテクスチャは、スクリプトのRenderDepthStencilTargetに
  1189.  指定することができる。
  1190. A texture created with this semantic can be used in a script (*for a technique) as a RenderDepthStencilTarget.
  1191.  
  1192.  RENDERCOLORTARGETで生成したテクスチャとは違い、このセマンティクスで生成したテクスチャは、
  1193.  レンダリング後も、内容を参照することはできない。
  1194. Unlike a texture created with RENDERCOLORTARGET, a texture created with this semantic cannot be sampled from, or accessed, after rendering.
  1195.  
  1196.  型はtexture, texture2Dのうちいずれか。
  1197. Variable type is texture or texture2D.
  1198.  
  1199.  ○アノテーション
  1200. Annotation
  1201.  
  1202.  ・int Width, int Height, int Depth
  1203.  ・int2(or int3) Dimensions
  1204.  ・float2 ViewportRatio
  1205.    "●通常テクスチャ"を参照。
  1206. See normal/usual/basic texture.
  1207.    省略した場合、"float2 ViewportRatio = {1.0, 1.0};" という設定が使用される。
  1208. If omitted, the default is "float2 ViewportRatio = {1.0, 1.0};".
  1209.  
  1210.  ・string Format
  1211.    "●通常テクスチャ"を参照。
  1212. See normal/usual/basic texture.
  1213.    省略した場合、"D24S8"が使用される。
  1214. If omitted, the default is "D24S8".
  1215.  
  1216. ○使用例
  1217. Example of use
  1218.  
  1219. texture2D DepthBuffer : RENDERDEPTHSTENCILTARGET <
  1220. float2 ViewPortRatio = {2.0,2.0};
  1221. string Format = "D24S8";
  1222. >;
  1223.  
  1224. technique Tech <
  1225. string Script = "RenderDepthStencilTarget=DepthBuffer;
  1226. ...
  1227.  
  1228.  
  1229. ●ANIMATEDTEXTURE
  1230.  
  1231.  アニメーションテクスチャを生成する。
  1232. Creat an animated (animation) texture.
  1233.  
  1234.  型はtexture, texture2Dのうちいずれか。
  1235. Variable type is texture or texture2D.
  1236.  
  1237.  デフォルトでは、フレーム時間に連動して自動的にアニメーションするほか、
  1238.  コントロールオブジェクトなどの、別のパラメータに連動してアニメーションさせることもできる。
  1239. Besides the default where the animation progresses with the frame time, a control object or some other parameter can be linked to the animation.
  1240.  
  1241.  ○アノテーション
  1242. Annotation
  1243.  
  1244.  ・string ResourceName (必須)
  1245. (required)
  1246.    テクスチャの元になる、アニメーション画像ファイルを指定する。
  1247. Specify animation file used as the texture base.
  1248.    サポートしているファイルフォーマットは、.gif(アニメGIF) および .png(APNG)である。
  1249. Supported file formats are gif and png.
  1250.  
  1251.  ・float Offset (省略可能)
  1252. (can omit)
  1253.    アニメーションの開始時間をずらす。(単位:秒)
  1254. Shift animation start time by this amount. (Unit: seconds)
  1255.    例えば、2.5を指定すると、アニメーション開始を2.5秒遅らせることができる。
  1256. For example, if 2.5 is specified, the animation's start is delayed by 2.5 seconds.
  1257.    デフォルト値は0.0。
  1258. Default is 0.0.
  1259.  
  1260.  ・float Speed (省略可能)
  1261. (can omit)
  1262.    アニメーションの再生スピードを指定する。
  1263. Set the animation's playback speed.
  1264.    例えば、2.0を指定すると、アニメーションの速度が2倍になる。
  1265. For example, if set to 2.0, the animations's speed is doubled.
  1266.    デフォルト値は1.0。
  1267. Default is 1.0.
  1268.  
  1269.  ・string SeekVariable (省略可能)
  1270. (can omit)
  1271.    アニメーションのシーク制御を、フレーム時間以外の方法で行う場合に指定する。
  1272. Use a variable other than frame time to control the animation's seeking.
  1273.    パラメータ名を指定すると、そのパラメータの値の変化に連動して、アニメーションが行われる。
  1274. Enter a parameter (variable) name and the animation will change along with that parameter's value.
  1275.  
  1276.    デフォルトでは、フレーム時間(TIME<SyncInEditMode=true>)に連動してアニメーションする。
  1277. Default is for animation to be linked to frame time (TIME<SyncInEditMode=true).
  1278.  
  1279. ○使用例
  1280. Example of use
  1281.  
  1282. // オブジェクトseek.xのSizeの変化に連動してアニメーションする
  1283. Animation progresses with the Size of object seek.x.
  1284.  
  1285. float atime: ControlObject < string Name = "seek.x"; >;
  1286.  
  1287. texture AnimeTex : ANIMATEDTEXTURE <
  1288. string ResourceName = "anime.png";
  1289. string SeekVariable="atime";
  1290. >;
  1291.  
  1292.  ○補足
  1293. Supplement/notes
  1294.   ・アニメーションが要求するfpsを、MMDの描画のfpsが下回った場合、コマ落ちが発生する。
  1295. If MMD's drawing fps falls below that of the animation, frames from the animation will be dropped.
  1296.   ・APNGについては、GByte単位の巨大なアニメーションファイルも(一応)再生可能。
  1297. Large APNGs in the gigabyte range may be used (not guaranteed).
  1298.  
  1299.  
  1300. ●OFFSCREENRENDERTARGET
  1301.  
  1302.  オフスクリーンレンダリングターゲット生成する。
  1303. Create an offscreen render (rendering) target.
  1304.  
  1305.  型はtexture, texture2Dのうちいずれか。
  1306. Variable type is texture or texture2D.
  1307.  
  1308.  オフスクリーンレンダリングターゲットを生成すると、
  1309. When you create an offscreen render target,
  1310.  自動的に、指定した条件で全オブジェクトの描画が、このレンダリングターゲットに対して行われるようになる。
  1311. all objects are automatically rendered/drawn on this target using the render target's specified settings.
  1312.  
  1313.  レンダリング結果は、通常のテクスチャと同様にtex2D()関数で参照できる。
  1314. Just like a normal texture, after rendering the offscreen target can be accessed/sampled with the function tex2D().
  1315.  
  1316.  ○アノテーション
  1317. Annotation
  1318.  
  1319.  ・int Width, int Height, int Depth
  1320.  ・int2 Dimensions
  1321.  ・float2 ViewportRatio
  1322.    "●通常テクスチャ"を参照。
  1323. See normal/usual/basic texture.
  1324.    省略した場合、"float2 ViewportRatio = {1.0, 1.0};" という設定が使用される。
  1325. If omitted, the default is float2 ViewportRatio = {1.0, 1.0};".
  1326.  
  1327.  ・string Format
  1328.    "●通常テクスチャ"を参照。
  1329. See normal/usual/basic texture.
  1330.    省略した場合、"A8R8G8B8"が使用される。
  1331. If omitted, the default is "A8R8G8B8".
  1332.  
  1333.  ・int Miplevels
  1334.  ・int Levels
  1335.    "●通常テクスチャ"を参照。
  1336. See normal/usual/basic texture.
  1337.    1または0が指定できる。
  1338. 1 or 0 can be selected.
  1339.    0を指定した場合、完全なミップマップ チェーンが作成される。
  1340. If 0 is selected, the entire mipmap chain is created.
  1341.    1を指定すると、ミップマップは生成されない(デフォルト)。
  1342. If 1, no mipmaps are created (default).
  1343.  
  1344.  ・float4 ClearColor
  1345.    レンダリングターゲットをクリアする色を設定する。
  1346. Set the color used to clear the render (rendering) target.
  1347.    ここで指定した色で、レンダリングターゲットは自動的にクリアされる。
  1348. The render (rendering) target is automatically cleared using this color.
  1349.  
  1350.  ・float ClearDepth
  1351.    深度ステンシルサーフェイスをクリアするZ値を設定する。
  1352. Set the Z-value used to clear the depth stencil buffer.
  1353.    ここで指定したZ値で、深度ステンシルサーフェイスは自動的にクリアされる。
  1354. The depth stencil buffer is automatically cleared using this Z-value.
  1355.  
  1356.  ・bool AntiAlias
  1357.    レンダリングにアンチエイリアスを使用する。デフォルトはfalse。
  1358. Whether to use antialiasing during rendering. Default is false.
  1359.    ※アンチエイリアスが有効の場合、ビデオメモリは多く消費されるため、
  1360. (Reference mark/kome) Since antialiasing uses a lot of video memory,
  1361.     テクスチャのサイズには注意すること
  1362. be careful with texture size.
  1363.  
  1364.  
  1365.  ・string Description
  1366.    オフスクリーンレンダリングターゲットの説明文を指定する。
  1367. The offscreen render (rendering) target's description.
  1368.    ここで指定した文字列が、エフェクト割当のGUIダイアログ上で表示される。
  1369. This description/character string is (*supposedly) shown in MME's user interface.
  1370.  
  1371.  ・string DefaultEffect
  1372.    オフスクリーンレンダリングで使用するエフェクトファイルの割り当て方法を指定する。
  1373. How to determine the effect used for objects during offscreen rendering.
  1374.    1つの割り当ては、以下の書式で記述する。
  1375. The format for selecting an effect is as follows.
  1376.    
  1377.      "(オブジェクトファイル名)=(エフェクトファイル名);"
  1378. "Object file name = effect file name;"
  1379.    
  1380.    オブジェクト毎に使用するエフェクトファイルを切り替えるには、この割り当てを複数回記述する。
  1381. To use different effects for different objects, repeat this pattern for each object.
  1382.    複数回記述した場合、記述した順でオブジェクトファイル名が比較され、最初にマッチしたものが使用される。
  1383. 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.
  1384.    
  1385.     例: string DefaultEffect = "self=hide; Mirror*.x=hide; *=MirrorObject.fx;";
  1386. Example
  1387.    
  1388.    オブジェクトファイル名には"*"と"?"によるワイルドカードが指定できる。
  1389. The wildcards "*" and "?" can be used in a file name. (*Note: "*" replaces any number of characters, "?" replaces a single character.)
  1390.    特殊なオブジェクトファイル名として"self"が指定でき、これは、
  1391. "self" is a special file name,
  1392.    このOFFSCREENRENDERTARGETを持つエフェクトが割り当てられたオブジェクト自身を表す。
  1393. that indicates the object that created the OFFSCREENRENDERTARGET.
  1394.    
  1395.    エフェクトファイル名に相対パスでファイル名を指定した場合、
  1396. If the file path is inclued in the effect filename,
  1397.    参照元のエフェクトファイルが格納されているフォルダが基準となる。
  1398. the folder with effect that creates the OFFSCREENRENDERTARGET is used as the base directory.
  1399.    
  1400.    また、特殊なエフェクトファイル名として"none"と"hide"が指定でき、
  1401. Also, the special file names "none" and "hide"
  1402.    これは、「エフェクトなし」と「非表示」を表す。
  1403. indicate "no effect" (*default shader) and "don't display".
  1404.    また、"main_default"を指定すると、メインスクリーンでのデフォルト動作と同様な、
  1405. And "main_default" specifies the effect used in the main render screen
  1406.    オブジェクトファイルパスに基づくfxファイルやemdファイルの自動割当が行われる。
  1407. based on an object's filename, either .fx or .emd.
  1408.    
  1409. ○使用例
  1410. Example of use
  1411.  
  1412. texture MirrorRT: OFFSCREENRENDERTARGET <
  1413. string Description = "OffScreen RenderTarget for Mirror.fx";
  1414. int Width = 256;
  1415. int Height = 256;
  1416. float4 ClearColor = { 1, 1, 1, 1 };
  1417. float ClearDepth = 1.0;
  1418. bool AntiAlias = true;
  1419. string DefaultEffect =
  1420. "self = hide;"
  1421. "Mirror*.x = hide;"
  1422. "*=MirrorObject.fx;";
  1423. >;
  1424.  
  1425. ●TEXTUREVALUE
  1426.  
  1427.  指定したテクスチャの、テクセル情報を取得して配列に格納する。
  1428. Store the texels of the indicated texture in an array.
  1429.  これを使用すると、VTF(Vertex Texture Fetching)に対応しない環境でも、
  1430. With this, even in environments without VTF (Vertex Texture Fetching),
  1431.  頂点シェーダからテクスチャの値を参照できる(※制限あり。補足参照)
  1432. the vertex shader can access the texture values ((Reference mark/kome) see supplement for restrictions)
  1433.  
  1434.  型はfloat4の2次元配列([縦幅][横幅])、もしくは1次元配列。
  1435. Variable type is float4 in a 2-dimensional (2D) array ([height][width]), or a 1D array.
  1436.  
  1437.  ○アノテーション
  1438. Annotation
  1439.  ・string TextureName (必須)
  1440. (required)
  1441.    テクスチャのパラメータ名を指定する。
  1442. The texture's parameter name. (*I think this is a texture you've already created.)
  1443.    
  1444. ○使用例
  1445. Example of use
  1446. float4 ParticleBaseArray[TEX_HEIGHT][TEX_WIDTH] : TEXTUREVALUE <
  1447. string TextureName = "ParticleBaseTex";
  1448. >;
  1449. float4 ParticleBaseArray2[TEX_HEIGHT] : TEXTUREVALUE <
  1450. string TextureName = "ParticleBaseTex2";
  1451. >;
  1452.  
  1453. float4 color1 = ParticleBaseArray[v][u];
  1454. float3 color2 = ParticleBaseArray2[idx].rgb;
  1455.  
  1456.  ○補足
  1457. Supplement/notes
  1458.   ・定数レジスタで値を渡すため、参照できるテクセル数は200程度が限度。
  1459. Since this data is stored in the constant register, the number of texels that can be accessed is limited to about 200.
  1460.   ・配列のサイズがテクスチャのサイズと一致していない場合、正しく値が取得できる保証は無い。
  1461. If the array size is not the same as the texture size, values may not be retrieved properly.
  1462.    一部の環境では、2の累乗のサイズのテクスチャしか作成できず、
  1463. In some environments, texture sizes must be a power of 2,
  1464.    それ以外のサイズを指定しても、自動的にサイズが拡張されて作成されることがあるので注意。
  1465. and an invalid size is specified the array size is rounded up, so be careful.
  1466.   ・テクスチャからの値の取得は、フレームの開始時に行われます。
  1467. Values are pulled from the texture at the start of the frame.
  1468.    そのため、途中で対象のテクスチャを更新しても、次のフレームになるまで値は更新されません。
  1469. As a result, if a texture is updated, the stored values will not change until the next frame.
  1470.  
  1471. 2.8 エフェクトファイル
  1472. Effect files
  1473.  
  1474. ●STANDARDSGLOBAL
  1475.  
  1476.  SAS(Standard Annotations and Semantics)のバージョンを指定する。
  1477. Version number of SAS (Standard Annotations and Semantics).
  1478.  また、エフェクトファイル全体に関するアノテーションを記述するためにも用いられる。
  1479. Also used for semantics that concern the whole effect file.
  1480.  
  1481.  パラメータ名は "Script"、型は float、値としてバージョン番号の 0.8 を指定すること。
  1482. Parameter name is "Script", variable type is float, value is the version number, 0.8.
  1483.  
  1484.  
  1485.  ○アノテーション
  1486. Annotation
  1487.  
  1488.  ・string ScriptOutput (省略可能)
  1489. (can omit)
  1490.    "color"以外の値は指定できない。デフォルト値もこの値である。
  1491. Only "color" can be used here. The default is this as well.
  1492.    
  1493.  ・string ScriptClass (省略可能)
  1494. (can omit)
  1495.    そのエフェクトファイルの目的(何を描画するエフェクトか)を指定する。
  1496. Indicates the effect file's purpose (what it's drawing).
  1497.    
  1498.    以下のうちいずれかを指定する。
  1499. Use one of the following.
  1500.    
  1501.     "object" : オブジェクトを描画する。(デフォルト)
  1502. Draws an object. (default)
  1503.     "scene" : スクリーンバッファを描画する。
  1504. Draws screen buffer.
  1505.     "sceneorobject" : 上記の両方。
  1506. Either of the above.
  1507.    
  1508.    基本的には、通常のオブジェクト描画用のエフェクトでは、"object"を指定し、
  1509. Basically, for an effect meant for normal object, use "object",
  1510.    プリエフェクト、ポストエフェクトでは、"scene"を指定する。
  1511. while for a pre-effect (*couldn't get this to work) or post-effect, use "scene".
  1512.    
  1513.    "object"を指定した場合、パスのスクリプトで Draw=Buffer を実行してはならない。
  1514. When "object" is selected, the script for a pass cannot use Draw=Buffer.
  1515.    また、"scene"を指定した場合、 Draw=Geometry を実行してはならない。
  1516. And when "scene" is selected, a pass can't use Draw=Geometry.
  1517.    "sceneorobject"を指定した場合は、両方を実行できる。
  1518. For "sceneorobject", both ways are valid.
  1519.    
  1520.  ・string ScriptOrder (省略可能)
  1521. (can omit)
  1522.    そのエフェクトファイルの実行タイミングを指定する。
  1523. Indicate when an effect is executed.
  1524.    
  1525.    以下のうちいずれかを指定する。
  1526. Indicate one of the following.
  1527.    
  1528.     "standard" : オブジェクトを描画する。(デフォルト)
  1529. Draw an object. (default)
  1530.     "preprocess" : オブジェクトの描画よりも先に描画する。プリエフェクト用。
  1531. Draw before objects are drawn. For pre-effects.
  1532.     "postprocess" : オブジェクトの描画の後で描画する。ポストエフェクト用。
  1533. Draw after objects are drawn. For post-effects.
  1534.    
  1535.    ※正確には、preprocessのさらに前に、postprocessの前処理(テクニックのスクリプトの先頭から
  1536.     "ScriptExternal=Color"まで)が実行される。
  1537. 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.
  1538. (*fixed missing '"' after Color)
  1539.    
  1540.  ・string Script (省略可能)
  1541. (can omit)
  1542.    使用するテクニックの検索順序を指定する。
  1543. Indicate order in which to search for a technique.
  1544.    通常は、エフェクトファイルに記述されている順で、使用可能なテクニックが検索される(1.2)が、
  1545. Normally, possible techniques are tested in order,
  1546.    このアノテーションを用いると、その検索順序を明示的に指定できる。
  1547. but with this annotation the search order can be explicitly indicated.
  1548.    
  1549.    以下の書式で指定する。
  1550. Use the following pattern.
  1551.     "Technique=Technique?テクニック名1:テクニック名2:~;"
  1552. "Technique=Technique?Technique_Name1:Technique_Name2:~;"
  1553.    
  1554.     例:string Script = "Technique=Technique?SimplePS:TexturedPS:SimpleQuadraticPS:TexturedQuadraticPS;";
  1555. Example
  1556.    
  1557.    なお、使用するテクニックが1つの場合には、以下のようにも指定できる。
  1558. In addition, when there's only one technique, this can be indicated as follows. (?)
  1559.     string Script = "Technique=MainTech;";
  1560.  
  1561.  
  1562. ○使用例
  1563. Example of use
  1564.  
  1565.   //通常エフェクトの場合
  1566. For a normal effect
  1567. float Script : STANDARDSGLOBAL <
  1568. string ScriptOutput = "color";
  1569. string ScriptClass = "object";
  1570. string ScriptOrder = "standard";
  1571. > = 0.8;
  1572.  
  1573.   //ポストエフェクトの場合
  1574. For a post-effect
  1575. float Script : STANDARDSGLOBAL <
  1576. string ScriptOutput = "color";
  1577. string ScriptClass = "scene";
  1578. string ScriptOrder = "postprocess";
  1579. > = 0.8;
  1580.  
  1581.  
  1582. 2.9 特殊パラメータ
  1583. Special parameters/variables
  1584.  
  1585. 以下の名前のパラメータは、セマンティクス無しで自動的に値が設定される。
  1586. Parameters with the following names will have their value set automatically without any semantic. (*It's magic)
  1587.  
  1588. ●parthf (bool型)
  1589. (bool type)
  1590.  セルフシャドウフラグ。
  1591. Self-shadow flag.
  1592.  セルフシャドウのmode1/mode2に対応(falseでmode1)。
  1593. Interacts with self-shadow's mode1/mode2 (false is mode1).
  1594.  
  1595. ●spadd (bool型)
  1596. (bool type)
  1597.  スフィアマップ加算合成フラグ(trueで加算合成)。
  1598. Sphere map add flag (true is additive blending)
  1599.  
  1600. ●transp (bool型)
  1601. (bool type)
  1602.  半透明フラグ(trueで半透明化)。
  1603. Half-transparent flag (true is half-transparent)
  1604.  [表示(V)]-[半透明化]に対応。
  1605. Interacts with Menu (?) Display(V) > half-transparent (?)
  1606.  
  1607. ●use_texture (bool型)
  1608. (bool type)
  1609.  テクスチャ使用フラグ。
  1610. Whether texture is used flag.
  1611.  描画中のマテリアルがテクスチャを使用する場合にtrue。
  1612. If the material being drawn uses a texture, this is true.
  1613.  
  1614. ●use_spheremap (bool型)
  1615. (bool type)
  1616.  スフィアマップ使用フラグ。
  1617. Whether sphere map is used flag.
  1618.  描画中のマテリアルがスフィアマップを使用する場合にtrue。
  1619. If the material being drawn uses a sphere map, this is true.
  1620.  なお、PMXモデルのサブテクスチャを使用する場合もtrueとなる。
  1621. It's also true for a PMX model with a subtexture.
  1622. (*Compare with UseSphereMap annotation for techniques.)
  1623.  
  1624. ●use_subtexture (bool型)
  1625. (bool type)
  1626.  サブテクスチャ使用フラグ。
  1627. Whether subtexture is used flag.
  1628.  PMXモデルのサブテクスチャを使用する場合にtrue。
  1629. True for a PMX model with a subtexture.
  1630.  
  1631. ●use_toon (bool型)
  1632. (bool type)
  1633.  トゥーンレンダリング使用フラグ。
  1634. Whether 'toon rendering' is used flag.
  1635.  PMDモデルの場合にtrue。
  1636. True for PMD models (*and not accessories).
  1637.  
  1638. ●opadd (bool型)
  1639. (bool type)
  1640.  加算合成フラグ。
  1641. Additive blending flag.
  1642.  オブジェクトの描画が加算合成モードに設定されている場合にtrue。
  1643. If object's drawing is set to 'Add' (additive blending), this is true.
  1644.  
  1645. ●VertexCount (int型)
  1646. (int type)
  1647.  オブジェクトの頂点数。
  1648. Number of vertexes the object has.
  1649.  
  1650. ●SubsetCount (int型)
  1651. (int type)
  1652.  オブジェクトのサブセット数。
  1653. Number of subsets the object has.
  1654.  
  1655. ○使用例
  1656. Example of use
  1657. bool parthf;
  1658. bool use_texture;
  1659. bool use_toon;
  1660. int VertexCount;
  1661.  
  1662. ○補足
  1663. Supplement/notes
  1664.  ・MMDPass="object","object_ss"以外の場合、これらのパラメータに正しい値が設定される保証はない。
  1665. For techniques other than MMDPass="object" and "object_ss", there's no guarantee that these parameters will be set correctly.
  1666.  
  1667.  
  1668. 2.9 頂点シェーダセマンティクス
  1669. Vertex shader semantics
  1670.  
  1671. ●_INDEX
  1672.  
  1673.  頂点シェーダにおいて、頂点のインデックス値を取得するためのセマンティクス。
  1674. Semantic for getting vertex index number for the vertex shader.
  1675.  頂点シェーダの入力パラメータで使用できる。型はint。
  1676. Can be used as an input parameter (*probably a more accurate name for this) for vertex shader. Variable type is int.
  1677.  
  1678. ○使用例
  1679. Example of use
  1680.  
  1681. VS_OUTPUT Basic_VS(float4 Pos : POSITION, int index: _INDEX) {
  1682. VS_OUTPUT Out;
  1683. Out.Pos = mul( Pos, WorldViewProjMatrix );
  1684.  
  1685. float f = (float)index/VertexCount;
  1686. Out.Color = float4(f,f,f,1);
  1687.  
  1688. return Out;
  1689. }
  1690.  
  1691.  ○補足
  1692. Supplement/notes
  1693.   ・頂点シェーダに渡す過程で一旦float型に変換しているため、
  1694. Since the value is converted to float temporarily while being passed to the vertex shader,
  1695.    インデックス値が 2^24=16777216 を超えると、正確な値を取得できない。
  1696. if the index goes over 2^24=16777216, its value won't always be accurate.
  1697.  
  1698.  
  1699. 2.10 マクロ
  1700. Preprocessor macros
  1701.  
  1702. ●MME_MIPMAP
  1703.  
  1704.  MMDが、テクスチャのミップマップに対応している場合に定義される。
  1705. Defined when MMD is using texture mipmaps.
  1706.  
  1707.  ○使用例
  1708. Example of use
  1709.  
  1710. sampler ObjTexSampler = sampler_state {
  1711.   texture = <ObjectTexture>;
  1712. #ifdef MME_MIPMAP
  1713. MIPFILTER = LINEAR;
  1714. #endif
  1715. };
  1716.  
  1717.  ○補足
  1718. Supplement/notes
  1719.  
  1720. (*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.)
  1721.  
  1722.  
  1723. **************************************************
  1724.  
  1725. 3 スクリプト
  1726. Script
  1727.  
  1728. テクニックとパスには、スクリプトと呼ばれる特殊なアノテーションを指定することができる。
  1729. Scripts are a special annotation for techniques and passes.
  1730.  
  1731. technique テクニック名 < string Script = "コマンド; コマンド; ..." ; > { ... }
  1732. technique Technique_Name < string Script = "command; command; ..." ; > { ... }
  1733. pass パス名 < string Script = "コマンド; コマンド; ..." ; > { ... }
  1734. pass Pass_Name <string Script = "command; command; ..." ; > { ... }
  1735.  
  1736. 実行時には、これらのコマンドが、記述順に逐次実行される。
  1737. During execution, these commands are carried out successively in the order they are listed.
  1738.  
  1739. このスクリプトを使用することで、レンダリングターゲットの変更やクリア、
  1740. Using a script, the render target can be changed and cleared,
  1741. パスのループ処理などを行うことができる。
  1742. and passes can be carried out in a loop, etc.
  1743.  
  1744. ポストエフェクトなどの特殊な処理をしないのであれば、通常、スクリプトの指定は不要である。
  1745. If special processing like a post-effect is not being carried out, normally, it isn't necessary to use a script.
  1746. テクニックのスクリプトを省略した場合、単にテクニックのパスが順に実行される。
  1747. If a technique's script is omitted, all of the script's passes are simply carried out in order.
  1748. また、パスのスクリプトを省略した場合、"Draw=Geometry"が実行される。
  1749. (While) if a pass's script is omitted, "Draw=Geometry" is used.
  1750.  
  1751.  
  1752. ○コマンド
  1753. Command
  1754.  
  1755. ・RenderColorTarget=(テクスチャ名 or 空白)
  1756. ・RenderColorTarget0=(テクスチャ名 or 空白)
  1757. ・RenderColorTarget1=(テクスチャ名 or 空白)
  1758. ・RenderColorTarget2=(テクスチャ名 or 空白)
  1759. ・RenderColorTarget3=(テクスチャ名 or 空白)
  1760. Texture_name or blank
  1761.   
  1762.   レンダリングターゲットを設定する。
  1763. Designate the render (rendering) target.
  1764.   RenderColorTargetは、RenderColorTarget0の別名である。
  1765. RenderColorTarget is the same as RenderColorTarget0.
  1766.   
  1767.   通常、RenderDepthStencilTargetコマンドとセットで使用する。
  1768. Usually used with RenderDepthStencilTarget as a set. (?)
  1769.   また、RenderColorTarget1~3は単独で使用することはできず、必ずRenderColorTarget0とセットで使用する。
  1770. 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.)
  1771.   
  1772.   引数には、RENDERCOLORTARGETセマンティクスで宣言されたtextureパラメータの名前を指定する。
  1773. The argument must be the name of a texture parameter that was declared with the RENDERCOLORTARGET semantic.
  1774. (*Note: the script annotation is type string, which uses double quotation marks: "commands". A preprocessor macro can output a string using '#':
  1775. #define toString(x) #x
  1776. )
  1777.   デフォルトのレンダリングターゲットにリセットする場合は、空白を指定する。
  1778. To reset the render target to the default one, leave the argument blank.
  1779. (*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.)
  1780.   
  1781.   なお、設定されたレンダリングターゲットは、再度これらのコマンドを実行しなければ、
  1782.   テクニックの処理完了まで変更されたままである。
  1783. Also, if the render (rendering) target is not changed again, it will stay the same until the end of the technique.
  1784.  
  1785. ・RenderDepthStencilTarget=(テクスチャ名 or 空白)
  1786. Texture_name or blank
  1787.   
  1788.   深度ステンシルサーフェイス(いわゆるZバッファ)を設定する。
  1789. Designate a depth stencil surface (also known as Z-buffer).
  1790.   通常、RenderColorTarget0コマンドとセットで使用する。
  1791. Normally, used as a set with RenderColorTarget0. (?)
  1792. (*May be able to avoid this in some cases with pass annotations or whatever ZENABLE = FALSE and ZWRITEENABLE = FALSE)
  1793.   
  1794.   引数には、RENDERDEPTHSTENCILTARGETセマンティクスで宣言されたtextureパラメータの名前を指定する。
  1795. The argument must be the name of a texture parameter that was declared with the RENDERDEPTHSTENCILTARGET semantic.
  1796.   デフォルトの深度ステンシルサーフェイスにリセットする場合は、空白を指定する。
  1797. To reset the depth stencil target to the default one, leave the argument blank.
  1798.  
  1799. ・ClearSetColor=(パラメータ名)
  1800. Parameter_name
  1801.   
  1802.   レンダリングターゲットをクリアする色を設定する。(まだクリアはしない)
  1803. Designate color used when clearing render target. (Does not clear the target.)
  1804.   
  1805.   引数には、float4型のパラメータの名前を指定する。
  1806. The argument is the name of a float4 parameter.
  1807.   このパラメータに設定された値が、レンダリングターゲットをクリアする色となる。
  1808. The value of this parameter is the color used when clearing the render (rendering) target.
  1809.  
  1810. ・ClearSetDepth=(パラメータ名)
  1811. Parameter_name
  1812.   
  1813.   深度ステンシルサーフェイスをクリアするZ値を設定する。(まだクリアはしない)
  1814. Designate Z-value used when clearing depth stencil surface. (Does not clear the target.)
  1815.   
  1816.   引数には、float型のパラメータの名前を指定する。
  1817. The argument is the name of a float parameter.
  1818.   このパラメータに設定された値が、深度ステンシルサーフェイスをクリアするZ値となる。
  1819. The value of this parameter is the Z-value used when clearing the depth stencil surface.
  1820.  
  1821. ・Clear=Color
  1822.   
  1823.   レンダリングターゲットをクリアする。
  1824. Clears the rendering target.
  1825.   クリアする色には、ClearSetColorコマンドで設定された値が使用される。
  1826. The clear color is the one set using ClearSetColor.
  1827.  
  1828. ・Clear=Depth
  1829.   
  1830.   深度ステンシルサーフェイスをクリアする。
  1831. Clears the depth stencil surface.
  1832.   クリアするZ値には、ClearSetDepthコマンドで設定された値が使用される。
  1833. The Z-value used to clear is the one set using ClearSetDepth.
  1834.  
  1835. ・ScriptExternal=Color
  1836.   
  1837.   他のオブジェクトを描画する。
  1838. 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.)
  1839.   このコマンドは、テクニックのスクリプト上でしか使用できない。
  1840. This command can only be used in a technique's script.
  1841.   
  1842.   これは、ポストエフェクト(STANDARDSGLOBALパラメータのScriptOrderアノテーションに
  1843.   "postprocess"が指定されたエフェクトファイル)でのみ実行できる。
  1844. It can also only be used in a post-effect (an effect file with ScriptOrder annotation for STANDARDSGLOBAL parameter set to "postprocess").
  1845.   
  1846.   通常、ポストエフェクトでは、入力用のテクスチャをレンダリングターゲットに設定した上で、
  1847. Normally with a post-effect, after setting the input texture as the render (rendering) target,
  1848.   そのテクスチャへ、他のオブジェクトをレンダリングさせる。
  1849. other objects are rendered to this texture.
  1850.   この、他のオブジェクトをレンダリングさせる際に、このコマンドを実行する。
  1851. This command is executed when these other objects are rendered to the texture.
  1852.   (Tipsのポストエフェクトを参照)
  1853. See 'Post-Effect' under Tips
  1854.   
  1855.   ポストエフェクトでは、テクニックのスクリプト上で、必ず1回だけ実行しなければならない。
  1856. 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.)
  1857.  
  1858. ・Pass=(パス名)
  1859. Pass_name
  1860.   
  1861.   指定したパスを実行する。
  1862. Carry out the designated pass.
  1863.   このコマンドは、テクニックのスクリプト上でしか使用できない。
  1864. This command can only be used in a technique's script.
  1865.   
  1866.   テクニックにスクリプトを指定した場合、明示的にこのコマンドを使用しない限り、
  1867.   いずれのパスも実行されない。
  1868. If a technique has a script, passes will not be executed unless they are explicitly called with this command.
  1869.  
  1870. ・LoopByCount=(パラメータ名)
  1871. Parameter_name
  1872. ・LoopEnd=
  1873.   
  1874.   指定した回数だけ、スクリプトの一部をループする。
  1875. Loop through one part of the script the indicated number of times.
  1876. (*Cannot be a 'static' variable)
  1877.   このコマンドは、テクニックのスクリプト上でしか使用できない。
  1878. This command can only be used in a technique's script.
  1879.   
  1880.   引数には、数値型(int,bool,float)のパラメータの名前を指定する。
  1881. The argument must be the name of a parameter with a numeric type (int, bool, float) .
  1882.   このパラメータに設定された値の回数だけ、LoopByCountからLoopEndまでにあるコマンド列が
  1883.   繰り返し実行される。
  1884. The command sequence (?) between LoopByCount and LoopEnd will be executed a number of times equal to this parameter.
  1885.   ループはネスト可能である。
  1886. Loops can be nested.
  1887.   
  1888.   以下の例では、3回パスp0が実行された後、パスp1が実行される。
  1889. In the following example, pass p0 is executed three (3) times, then pass p1 is executed once.
  1890.  
  1891. /****************************/
  1892. int Count = 3;
  1893.  
  1894. technique TShader <
  1895. string Script =
  1896. "LoopByCount=Count;"
  1897. "Pass=p0;"
  1898. "LoopEnd=;"
  1899. "Pass=p1;";
  1900. > {
  1901. /****************************/
  1902.  
  1903. ・LoopGetIndex=(パラメータ名)
  1904. Parameter_name
  1905.   
  1906.   ループ中のループカウンタの値を、指定したパラメータに設定する。
  1907. The indicated parameter is set to the loop counter during a loop. (*Works with nested loops.)
  1908.   このコマンドは、LoopByCountからLoopEndまでの間でしか使用できない。
  1909. This command only works between LoopByCount and LoopEnd.
  1910.  
  1911. ・Draw=Geometry
  1912.   
  1913.   オブジェクトを描画する。
  1914. Draw the object.
  1915.   このコマンドは、パスのスクリプト上でしか使用できない。
  1916. This command can only be used in a pass's script.
  1917.   
  1918.   パスのスクリプトを省略した場合、このコマンドが実行される。
  1919. If a pass's script is omitted, this command is used.
  1920.   STANDARDSGLOBALのScriptClassに"scene"を指定している場合、
  1921.   このコマンドを実行してはならない。
  1922. If STANDARDSGLOBAL's ScriptClass annotation is "scene", this command can't be used. (*Unverified)
  1923.  
  1924. ・Draw=Buffer
  1925.   
  1926.   レンダリングターゲットのスクリーンと一致するサイズの、長方形のポリゴンを描画する。
  1927. Draw a rectangular polygon with the same size as the screen.
  1928.   このコマンドは、パスのスクリプト上でしか使用できない。
  1929. This command can only be used in a pass's script.
  1930.   
  1931.   ポストエフェクトやプリエフェクトで使用する。
  1932. Used in a post-effect or pre-effect.
  1933.   STANDARDSGLOBALのScriptClassに"object"を指定している場合、
  1934.   このコマンドを実行してはならない。
  1935. If STANDARDSGLOBAL's ScriptClass annotation is "object", this command can't be used. (*Unverified)
  1936.  
  1937. ・RenderPort=*
  1938.   
  1939.   未対応。
  1940. Not implemented, or incompatible.
  1941.  
  1942.  
  1943. ○使用例
  1944. Example of use
  1945. technique TShader <
  1946. /* 2つの文字列表記("~" "~")の間に空白文字しかなければ、
  1947. If two strings (literally 'character strings') ("~" "~") are separated by nothing but whitespace (literally 'blank space'),
  1948. それはひと続きの文字列とみなされるため、以下のように分割して記述できる */
  1949. they are treated as a single string. This can be used to split up a string, as below
  1950. string Script =
  1951. "RenderColorTarget0=RenderTarget;"
  1952. "RenderDepthStencilTarget=DepthBuffer;"
  1953. "ClearSetColor=ClearColor;"
  1954. "ClearSetDepth=ClearDepth;"
  1955. "Clear=Color;"
  1956. "Clear=Depth;"
  1957. "ScriptExternal=color;"
  1958. "Pass=P0;" ;
  1959. > {
  1960. pass P0 < string Script= "RenderColorTarget0=; RenderDepthStencilTarget=; Draw=Buffer;" ; > {
  1961. ...
  1962. }
  1963. }
  1964.  
  1965.  
  1966. **************************************************
  1967.  
  1968. 4 Tips
  1969.  
  1970. ●MMD標準のシェーダを使用する
  1971. Using MMD's default/standard shader
  1972.  
  1973.  オブジェクトの描画の一部にのみ、エフェクトを使用し、
  1974. When you want to use an effect on just one part of an object,
  1975.  それ以外の描画にはMMD標準のシェーダを使用したい場合には、
  1976. and use the standard shader for the rest,
  1977.  MMD標準のシェーダを使用したい場面のテクニックを、エフェクトファイルに記述しなければよい。
  1978. you don't need write this in the technique in the effect file. (?)
  1979. you just leave this technique out of the effect file.
  1980.  ("1.2 テクニックのアノテーション"を参照)
  1981. (See "1.2 Technique annotations")
  1982.  
  1983.   /************************************************************/
  1984. /* エフェクトファイルにこのテクニックしか無ければ、
  1985. If this technique is the only one in an effect file,
  1986. オブジェクト描画(セルフシャドウON時)以外はMMD標準のシェーダで描画される */
  1987. everything other than object drawing (with self-shadow set to on) is done by MMD's default shader
  1988. technique Tech1 < string MMDPass = "object_ss"; > {
  1989. pass Pass1 {
  1990. ...
  1991. }
  1992. pass Pass2 {
  1993. ...
  1994. }
  1995. }
  1996. /************************************************************/
  1997.  
  1998.  また、パスのデフォルトのシェーダはMMD標準のシェーダであるため、
  1999. Furthermore, since the default shader for a pass is the standard MMD shader,
  2000.  以下のように、パスのVertexShaderやPixelShaderを設定しなければ、
  2001. if you omit the VertexShader or PixelShader for a pass, as seen below,
  2002.  そのパスの描画にはMMD標準のシェーダが使用される。
  2003. that pass will use MMD's default shader.
  2004.  
  2005.   /************************************************************/
  2006. technique Tech1 < string MMDPass = "object_ss"; > {
  2007. pass Pass1 {
  2008. // VertexShader = xxx
  2009. // PixelShader = xxx
  2010. }
  2011. }
  2012. /************************************************************/
  2013.  
  2014.  
  2015. ●空のテクニック
  2016. Empty techniques
  2017.  
  2018.  以下のように、テクニックを空にすると、そのテクニックでは一切描画が行われなくなる。
  2019. As below, if a technique is empty, nothing will be drawn for it.
  2020.  これを利用すると、オブジェクトの一部または全部の描画を抑止することができる。
  2021. This can be used to avoid drawing part or all of an object.
  2022.  
  2023.   /*********************************************************/
  2024. technique ShadowTech < string MMDPass = "shadow"; > {
  2025.  
  2026. }
  2027.   /*********************************************************/
  2028.  
  2029.  
  2030. ●オブジェクトの有無でパスをON/OFF
  2031. Turning a pass on or off based on another object's existence
  2032.  
  2033.  以下のようにスクリプトを記述すると、特定のオブジェクトの表示がONになっている間のみ
  2034.  パスを実行させることができる。
  2035. 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.
  2036. (*Unfortunately, no way to turn off a pass with the same action since 'static' variables can't be used as loop variable)
  2037.  これは、真偽値true/falseが数値としては1と0に解釈されることを利用している。
  2038. This uses the fact that boolean true/false is treated as 1 and 0.
  2039.  
  2040.   /*********************************************************/
  2041. bool flag : CONTROLOBJECT < string name = "aaa.x"; >;
  2042.  
  2043. technique Tech1 <
  2044. string Script =
  2045. "LoopByCount=flag;"
  2046. "Pass=Pass1;"
  2047. "LoopEnd=;"
  2048. ;
  2049. > {
  2050. pass Pass1 {
  2051. ...
  2052. }
  2053. }
  2054.   /*********************************************************/
  2055.  
  2056.  
  2057. ●エフェクトファイル間でパラメータを共有
  2058. Sharing resources/parameters between effect files
  2059.  
  2060.  通常、異なるエフェクトファイル間でパラメータは共有されない。
  2061. Normally, parameters are not shared between different effect files.
  2062.  しかし、パラメータの宣言に"shared"キーワードを指定することにより、
  2063. However, by declaring a parameter with "shared" keyword,
  2064.  同じ名前のパラメータをエフェクトファイル間で共有することができる。
  2065. parameters with the same name can be shared between effect files.
  2066.  
  2067.  以下の例では、effect1.fxで生成したテクスチャを、effect2.fxから参照できる。
  2068. In the following example, a texture created in effect1.fx can be accessed/sampled in effect2.fx.
  2069.  このように、両方のパラメータ宣言で"shared"キーワードを指定する必要がある。
  2070. When doing this, both parameters must be declared with "shared" keyword.
  2071.  また、名前だけでなく、型名とセマンティクスも一致させるひつようがある。
  2072. Furthermore, the variable type and semantic must also match.
  2073.  
  2074.   /************** effect1.fx ******************/
  2075.  
  2076.    shared texture ShadowBuffer : RENDERCOLORTARGET <
  2077. float2 ViewPortRatio = {2.0,2.0};
  2078. int MipLevels = 1;
  2079. string Format = "A8R8G8B8" ;
  2080. >;
  2081.  
  2082.   /********************************************/
  2083.  
  2084.   /************** effect2.fx ******************/
  2085.  
  2086.    shared texture ShadowBuffer : RENDERCOLORTARGET;
  2087.  
  2088.   /********************************************/
  2089.  
  2090.  
  2091. ●if文
  2092. 'if' statement
  2093.  
  2094.  描画を高速にしたければ、シェーダを記述する際に、できるだけif文のような条件分岐は
  2095.  使わないほうがよい。
  2096. If you want drawing to be fast, when writing a shader, avoid 'if' statements/conditional branches as much as possible.
  2097. (*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.)
  2098.  
  2099.  テクスチャの有無でシェーダの処理を切り替えるような場合、
  2100. When changing shader processing based on whether a texture is used,
  2101.  use_textureパラメータを参照して、シェーダ内のif文で条件分岐するより、
  2102. by consulting the use_texture parameter and following a conditional branch using an 'if' statement,
  2103.  テクスチャが有るサブセットと無いサブセットとで、テクニック自体を分けてしまうほうが高速に描画できる。
  2104. 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.
  2105.  
  2106.  
  2107. ●uniformキーワード
  2108. uniform keyword
  2109.  
  2110. 関数の引数の宣言に"uniform"キーワードを指定すると、その引数の値をコンパイル時の定数として与えることができる。
  2111. 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.
  2112.  
  2113.  以下の例では、Basic_PS()内のif文が、コンパイル時に除去されるので、
  2114. In the following example, the 'if' statement in Basic_PS() is optimized out, or eliminated, at compile time,
  2115.  条件分岐による速度低下は避けられる(多分)。
  2116. so the slowdown from a conditional branch is averted (probably).
  2117.  
  2118.   /*******************************************************************/
  2119.   float4 Basic_PS( VS_OUTPUT IN, uniform bool useTexture ) : COLOR0
  2120. {
  2121. float4 Color = IN.Diffuse;
  2122. if ( useTexture ) {
  2123. Color *= tex2D( ObjTexSampler, IN.Tex );
  2124. }
  2125. ...
  2126. }
  2127.  
  2128. technique TechWithTex {
  2129. pass P1 {
  2130. /* useTexture=true でシェーダをコンパイル */
  2131. compile with useTexture=true
  2132. PixelShader = compile ps_2_0 Basic_PS(true);
  2133. ...
  2134. }
  2135. }
  2136.  
  2137. technique TechWithoutTex {
  2138. pass P1 {
  2139. /* useTexture=false でシェーダをコンパイル */
  2140. compile with useTexture=false
  2141. PixelShader = compile ps_2_0 Basic_PS(false);
  2142. ...
  2143. }
  2144. }
  2145.   /*******************************************************************/
  2146.  
  2147. (*the technique would be selected with technique annotation, see a popular object shader for an example)
  2148.  
  2149.  
  2150. ●エフェクトファイル内での日本語使用
  2151. Using Japanese inside an effect file
  2152.  
  2153.  基本的に、コメント部分以外では、エフェクトファイル中に日本語の文字を使用することは推奨しない。
  2154. As a general rule, the use of Japanese characters in an effect file, other than in comments, is not recommended.
  2155.  
  2156.  あえて使用する場合は、文字コードに注意すること。
  2157. If you intend to do so, a warning on character encoding.
  2158.  テクスチャ生成用の画像ファイルのパスやコントロールオブジェクトのオブジェクト名など、
  2159. When the path to (or name of) an image file for a texture, or the object name (or item) used for a control object,
  2160.  ファイル名の指定に日本語を使用する場合は、そのエフェクトファイルの文字コードは
  2161. is in Japanese, that effect file's character encoding
  2162.  必ずShift-JISでなければならない。
  2163. 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.)
  2164.  
  2165.  
  2166. ●ポストエフェクト
  2167. Post-effects
  2168.  
  2169.  ポストエフェクト用のエフェクトファイルを作成する場合は、
  2170. When creating an effect file for a post-effect,
  2171.  以下のパラメータがエフェクトファイル中で宣言されている必要がある。
  2172. the following parameters must be declared in the effect file.
  2173.  ("●STANDARDSGLOBAL"を参照)
  2174. (see "STANDARDSGLOBAL")
  2175.  
  2176. float Script : STANDARDSGLOBAL <
  2177. string ScriptOutput = "color";
  2178. string ScriptClass = "scene";
  2179. string ScriptOrder = "postprocess";
  2180. > = 0.8;
  2181.  
  2182.  
  2183.  また、典型的なポストエフェクトでは、テクニックのスクリプトで以下の処理を行う。
  2184. In addition, for a typical post-effect, the technique's script should perform the following actions.
  2185.  
  2186.  (1) レンダリングターゲットを自前のテクスチャに変更し、クリアする。
  2187. Set rendering target to a texture unique to the effect and clear it.
  2188.  
  2189.    スクリプト例:
  2190. Script example:
  2191. "RenderColorTarget0=(RENDERCOLORTARGETテクスチャ);"
  2192. texture
  2193. "RenderDepthStencilTarget=(RENDERDEPTHSTENCILTARGETテクスチャ);"
  2194. texture
  2195. "ClearSetColor=(クリアの色);"
  2196. clear color
  2197. "ClearSetDepth=(クリアのZ値);"
  2198. clear Z-value
  2199. "Clear=Color;"
  2200. "Clear=Depth;"
  2201.  
  2202.  (2) プリエフェクト,オブジェクト,他のポストエフェクトを描画する。
  2203. Draw pre-effects, objects, other post-effects.
  2204.    このとき、描画結果は(1)で指定したテクスチャに保存される。
  2205. At this time, the drawing output is saved to the texture designated in (1).
  2206. (*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.)
  2207.  
  2208.    スクリプト例:
  2209. Script example:
  2210. "ScriptExternal=Color;"
  2211.  
  2212.  (3) レンダリングターゲットを元に戻し、描画結果のテクスチャを入力として、パスを実行する。
  2213. 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.
  2214. (*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.)
  2215.  
  2216.    スクリプト例:
  2217. Script example:
  2218. "RenderColorTarget0=;"
  2219. "RenderDepthStencilTarget=;"
  2220. "Pass=(パス1);"
  2221. pass1
  2222. "Pass=(パス2);"
  2223. pass2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement