0% found this document useful (0 votes)
29 views62 pages

GoogleTranslate Reference

The document provides a reference for MMEffect, detailing various versions and their updates, including the addition of new semantics and modifications to existing ones. It outlines the structure of effects files, including techniques, paths, and annotations, and specifies parameters for geometry transformation, light, and materials. Additionally, it includes usage examples and notes on the limitations of certain techniques and parameters in rendering processes.

Uploaded by

vkhanhvy08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views62 pages

GoogleTranslate Reference

The document provides a reference for MMEffect, detailing various versions and their updates, including the addition of new semantics and modifications to existing ones. It outlines the structure of effects files, including techniques, paths, and annotations, and specifies parameters for geometry transformation, light, and materials. Additionally, it includes usage examples and notes on the limitations of certain techniques and parameters in rendering processes.

Uploaded by

vkhanhvy08
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 62

MMEffect Reference

0.1.0.0 (2010/9/18) first edition

0.2.0.0 (2010/12/12) MME Ver0.20

· OFFSCREENRENDERTARGET semantics added

• Adding CONTROLOBJECT semantics can be acquired information

• The ease the constraints of drawing order of objects CONTROLOBJECT semantics references

· EDGECOLOR semantics added

· VIEWPORTPIXELSIZE Fixed description mistake of semantics

• Some Japanese modification

0.2.2.0 (2010/12/16) MME Ver0.22

· RENDERCOLORTARGET and in OFFSCREENRENDERTARGET semantics, and change how to specify the


Miplevels

0.2.3.0 (2010/12/20) MME Ver0.23

· Supplementary postscript of CONTROLOBJECT semantics

0.2.4.0 (2011/02/09) MME Ver0.24

• The special object name that can be specified in CONTROLOBJECT semantics Add "(self)"

· Add TEXTUREVALUE semantics

0.2.6.0 (2010/02/21) MME Ver0.26

· Draw = Geometry modify the description of the command

0.2.7.0 (2011/05/22) MME Ver0.27

· _INDEX Semantics added

· VertexCount Add parameters and SubsetCount parameters

• Adding opadd parameters

· TEXTUREVALUE is appended to the supplement of semantics

0.2.8.0 (2012/03/26) MME Ver0.28


· CONTROLOBJECT Fixed some description of the semantics

0.3.0.0 (2012/09/19) MME Ver0.30

That can be specified in the · OFFSCREENRENDERTARGET semantics DefaultEffect

Add "main_default" as a special effect name

0.3.3.0 (2013/02/13) MME Ver0.33

Texture material morph for semantics of (ADDINGTEXTURE, etc.) add

· PMX corresponding to the sub-texture of the model (UseSphereMap, use_spheremap, see


use_subtexture)

· MATERIALTOONTEXTURE semantics added

· GROUNDSHADOWCOLOR semantics added

· MME_MIPMAP macro added

○ Note

• In this reference, MMEffect is discusses recognize semantics and annotation.

For reference of the effect file itself, see below.

Effects file format http://msdn.microsoft.com/ja-jp/library/bb173005(v=VS.85).aspx

Reference of HLSL http://msdn.microsoft.com/ja-jp/library/bb509638(v=VS.85).aspx

Semantics and annotations specification of development was the NVIDIA of SAS to reference.

http://developer.nvidia.com/object/using_sas.html

However, this is not intended to ensure that FX effect files for Composer operates.

**************************************************
1 technique and path

1.1 configuration

Effects files, such as, has a hierarchical structure by techniques and path.

/ ********************************** /

Parameter declaration 1

Parameter declaration 2

...

technique technique 1 {

pass path 1 {

VertexShader = ...

PixelShader = ...

pass pass 2 {

VertexShader = ...

PixelShader = ...

...

technique technique 2 {

pass path 1 {
VertexShader = ...

PixelShader = ...

pass pass 2 {

VertexShader = ...

PixelShader = ...

...

/ ********************************** /

Technique consists of one or more paths.

One path corresponds to one of the rendering process,

If the technique is composed of multiple paths,

The techniques I means that uses the multi-pass rendering.

The techniques and path, it is possible to describe a set value called the annotation.

Annotation, as follows, after the technique name, path name, describing so as to surround with "<" and
">".

The difference between the case of the annotation name is ignored.

/ ************************************************* ***** /

technique Tech1 <string Subset = "1-6,8";> {

pass Pass1 <string Script = "Draw = Buffer;";> {

...
}

pass Pass2 {

...

/ ************************************************* ***** /

Moreover, the techniques and path, and a special annotation called Script

Can be specified. This will, I described in §3.

1.2 Techniques annotations

The annotation of technique,

Describe one of the conditions to use the technique to draw any scene.

This condition, I can specify the following.

Objects subset number of (material number of ≒ object)

And drawing object (object body / shadow / outline / self-shadowing for Z-value plot)

And drawing flag (texture use ON / OFF, Sphere map use ON / OFF, toon rendering use ON / OFF)

For verification of conditions, to be performed in the order in which they are written to the effect file,

If the conditions of use are overlapped in several techniques,


Those described earlier in the effect file takes precedence.

If the technique for this type does not exist on the effects file,

MMD standard shader is used.

○ annotation

· String Subset

I specify the number of subsets to apply the technique.

For PMD model, which corresponds to the model number of the material.

At the time of annotation omitted, all of the subset is applied.

"0, 3, 5" as in, it is possible to enumerate the numbers separated by commas, can be specified multiple
numbers.

In addition, "6-10" as such, it is possible to connect a number by a hyphen, and can range specified.

"12" as in, if you specify only the starting number for the range, all of number of later becomes the
target.

Example: string Subset = "0-6,8";

· String MMDPass

I specify the drawing object to apply the technique.

Specify one of the following. This classification is derived from the procedure of drawing MMD.

"object": object body (self-shadowing OFF)


"zplot": self-shadowing for Z-value plot

"object_ss": object body (self-shadowing ON)

"shadow": shadow (Simple shadow is not a self-shadowing)

"edge": outline (PMD models only)

During the annotation is omitted, it is considered to have a specified "object".

Example: string MMDPass = "object";

· Bool UseTexture

I specify the presence or absence of texture use.

The technique is, when it is intended for only a subset that uses texture specifies a true.

Conversely, if it is intended for only a subset that does not use texture, specify false.

During the annotation is omitted, the presence or absence of texture is ignored.

Example: bool UseTexture = true;

· Bool UseSphereMap

I specify the presence or absence of a sphere map use.

As techniques, only the case of a target subset using the sphere mapping specifies true.

(In PMX model, including even if you specify a sub-texture to Sphere mode)

Conversely, if it is intended for only a subset that does not use the sphere map, specify false.

During the annotation is omitted, the presence or absence of sphere mapping is ignored.
Example: bool UseSphereMap = false;

· Bool UseToon

I specify the presence or absence of Cel shading use.

The technique is, in the case of interest the object (= PMD model) to use the toon rendering, I specify
the true.

Conversely, if it is intended for objects that do not use Cel shading (= accessory), specify false.

At the time of annotation omitted, the presence or absence of Cel shading use is ignored.

Example: bool UseToon = true;

○ use cases

// If self-shadowing is ON, the subset of No.0 ~ 6 and No.8, is applied Tech1,

// The No.7 and No.9 ~ subset, Tech2 is applied.

// If self-shadowing is OFF, are applied 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

· Reasonable and not technique are excluded.

http://msdn.microsoft.com/ja-jp/library/bb206324(v=VS.85).aspx

· MMDPass = "object", in the technique other than "object_ss", UseTexture, UseSphereMap, UseToon
not function correctly.

**************************************************

2 parameters of semantics and annotations

In the following, I can be used in the effect file for MMEffect,


About the parameters of semantics and annotations I described.

By modifying the declaration of parameters in the semantics and annotation,

A variety of information necessary to render, can be retrieved to be construed its parameters.

Parameters of semantics and annotations, described as follows.

Model Parameter name: Semantics name <type name annotation 1 = value; type name annotation 2 =
value; ...>;

Depending on the semantics, and some you do not specify the annotation.

The difference between the case of semantics name and the annotation name is ignored.

2.1 geometry transformation

Reference: http: //msdn.microsoft.com/ja-jp/library/bb206269 (v = VS.85) .aspx

● WORLD

● VIEW

● PROJECTION

● WORLDVIEW

● VIEWPROJECTION

● WORLDVIEWPROJECTION
Transformation matrix to be used for coordinate transformation of the vertex.

The coordinate transformation, there is a world transformation, view transformation, projection


transformation (homography).

Six of semantics, respectively,

WORLD: world transformation matrix

VIEW: view transformation matrix

PROJECTION: Projection transformation matrix

WORLDVIEW: world transformation matrix × view transformation matrix

VIEWPROJECTION: view transformation matrix × projection transformation matrix

WORLDVIEWPROJECTION: world transformation matrix × view transformation matrix × projection


transformation matrix

The I represent.

Type float4x4.

As "WORLDINVERSE", when adding "INVERSE" to the end of the semantics, the inverse matrix of the
matrix is obtained.

Also, as in the "WORLDTRANSPOSE", when adding "TRANSPOSE" to the end, the transposed matrix of
the matrix is obtained.

In order to obtain the transposed matrix of the inverse matrix, adding "INVERSETRANSPOSE" at the end.

○ annotation

· String Object (optional)

In view transformation and projection conversion, I will specify where or to the viewpoint.
"Camera" or "Light" can be specified. The default is "Camera".

Normally, in the case performs coordinate transformation that the viewpoint of the camera, I specify the
"Camera".

Z value plot, etc. for self-shadowing, when the source performs coordinate transformations and
viewpoint, I specify the "Light".

○ use cases

float4x4 WorldMatrix: WORLD;

float4x4 WorldViewProjMatrix: WORLDVIEWPROJECTION;

float4x4 LightViewMatrix: VIEW <string Object = "Light";>;

float4x4 WorldInvMatrix: WORLDINVERSE;

float4x4 WorldViewProjTransMatrix: WORLDVIEWPROJECTIONTRANSPOSE;

○ supplement

It is the matrix that obtained when you have specified the "Light" in · Object annotation,

Because it is in conjunction with the matrix you are using self-shadowing of MMD,

[Display (V)] - in the self-shadowing Display (P)], when fully would OFF the self-shadowing function,

I will not be able to see the correct value.

2.2 Light and materials

Reference: http: //msdn.microsoft.com/ja-jp/library/bb174694 (v = VS.85) .aspx

● DIFFUSE

● AMBIENT
● EMISSIVE

● SPECULAR

● SPECULARPOWER

● TOONCOLOR

● EDGECOLOR

● GROUNDSHADOWCOLOR

Color values of material of 3D objects (material) or color values of light,.

Six of semantics, respectively,

DIFFUSE: diffuse color (diffused light)

AMBIENT: Ambient color (ambient light)

EMISSIVE: emission color (synchrotron radiation)

SPECULAR: Specular color (specular)

SPECULARPOWER: the intensity of the specular

TOONCOLOR: Thun color

EDGECOLOR: outline color

GROUNDSHADOWCOLOR: ground shadow color

The I represent.

Thun color, represent in Cel shading of PMD model, the shadow of color (specifically, toon ??. Bmp
lower left corner of the color of).

Type, "SPECULARPOWER" only in the float, otherwise there float3 or float4.

The color is composed of four components (red, green, blue, and alpha (transparency)). Alpha value is
omitted If you specify a float3 to type.
○ annotation

· String Object (required)

And light color, and specify whether to retrieve either the material color of the object.

"Light" or "Geometry" can be specified.

To get the material color of the object, specify the "Geometry".

To get a light color, to specify the "Light".

The "SPECULARPOWER" and "EMISSIVE" and "TOONCOLOR", because there is no light color, "Light" can
not be specified.

○ use cases

float4 MaterialDiffuse: DIFFUSE <string Object = "Geometry";>;

float3 MaterialAmbient: AMBIENT <string Object = "Geometry";>;

float3 MaterialEmmisive: 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 + MaterialEmmisive;

static float3 SpecularColor = MaterialSpecular * LightSpecular;


float4 GroundShadowColor: GROUNDSHADOWCOLOR;

○ supplement

· Outline color only in the Technique of MMDPass = "edge", can not be properly obtained.

-Ground shadow color only in the Technique of MMDPass = "shadow", can not be properly obtained.

Other each color value of, in the Technique of MMDPass = "zplot" or MMDPass = "edge", can not be
properly obtained.

● POSITION

● DIRECTION

Of light or camera, the position and orientation within the world space.

Type is a float3 or float4.

○ annotation

· String Object (required)

Specifies whether to acquire either the coordinates of the camera and light.

"Camera" or "Light" can be specified.

○ use cases

float3 LightDirection: DIRECTION <string Object = "Light";>;

float3 CameraPosition: POSITION <string Object = "Camera";>;

○ supplement
For · MMD of lights, is a directional light,

Position coordinates of the light, an infinite far point direction opposite to the direction of the light.

● MATERIALTEXTURE

Texture is set to the material.

○ annotation

None

○ use cases

texture ObjectTexture: MATERIALTEXTURE;

sampler ObjTexSampler = sampler_state

texture = <ObjectTexture>;

MINFILTER = LINEAR;

MAGFILTER = LINEAR;

MIPFILTER = LINEAR;

ADDRESSU = WRAP;

ADDRESSV = WRAP;

};

// Tex2D (ObjTexSampler, float2 (x, y)) I can see the contents in


○ supplement

• Each color value, in the Technique of MMDPass = "zplot" or MMDPass = "edge", can not be properly
obtained.

● MATERIALSPHEREMAP

Is set to the material, sphere map texture.

○ annotation

None

○ use cases

texture ObjectSphereMap: MATERIALSPHEREMAP;

sampler ObjSphSampler = sampler_state

texture = <ObjectSphereMap>;

MINFILTER = LINEAR;

MAGFILTER = LINEAR;

MIPFILTER = LINEAR;

ADDRESSU = WRAP;

ADDRESSV = WRAP;

};

// Tex2D (ObjSphSampler, float2 (x, y)) I can see the contents in

○ supplement
• Each color value, in the Technique of MMDPass = "zplot" or MMDPass = "edge", can not be properly
obtained.

● MATERIALTOONTEXTURE

Is set to the material, Thun map texture.

○ annotation

None

○ use cases

texture ObjectToonTexture: MATERIALTOONTEXTURE;

sampler ObjToonSampler = sampler_state

texture = <ObjectSphereMap>;

MINFILTER = LINEAR;

MAGFILTER = LINEAR;

MIPFILTER = NONE;

ADDRESSU = CLAMP;

ADDRESSV = CLAMP;

};

// Tex2D (ObjToonSampler, float2 (x, y)) I can see the contents in

○ supplement
• Each color value, in the Technique of MMDPass = "zplot" or MMDPass = "edge", can not be properly
obtained.

Moreover, when the accessory (for UseToon = false) is not correctly acquired.

· In PMD model, in the case of materials that do not use Thun, it is entirely white texture.

● ADDINGTEXTURE

● MULTIPLYINGTEXTURE

● ADDINGSPHERETEXTURE

● MULTIPLYINGSPHERETEXTURE

For PMX material morph, with respect to the texture of the texture and sphere mapping,

Added value and multiplication value.

○ annotation

None

○ use cases

float4 TextureAddValue: ADDINGTEXTURE;

float4 TextureMulValue: MULTIPLYINGTEXTURE;

float4 SphereAddValue: ADDINGSPHERETEXTURE;

float4 SphereMulValue: MULTIPLYINGSPHERETEXTURE;

○ supplement

• Each value is only in the case of MMDPass = "object_ss", can not be properly obtained.

· In addition, (in the case of UseToon = false) case of accessories, all adding value is 0, become all
multiplication value is 1.
2.3 screen information

● VIEWPORTPIXELSIZE

Screen size of the render target.

Type float2. In pixels.

※ This value refers to the size of the screen or off-screen render target of MMD.

In Scripts of "RenderColorTarget" command, if you change the render target,

This value does not change.

○ annotation

None

○ use cases

float2 ScreenSize: VIEWPORTPIXELSIZE;

○ supplement

· Internally, I'm referring to the value of .Width and .Height of Viewport.

2.4 hours
● TIME

● ELAPSEDTIME

Time information.

Type float. In seconds.

"TIME" represents the playback time from 0-th frame.

For example, the 0-th frame, 0.0 (seconds), and the 1.5 (sec) in 45 th frame.

"ELAPSEDTIME" represents the elapsed time from the previous drawing.

For example, when the AVI output at 60fps, the value of "ELAPSEDTIME", it becomes constant at 1/60.

○ annotation

· Bool SyncInEditMode (optional)

Even if MMD is in edit mode, you specify whether to work with the frame.

I specify a true or false. The default is false.

Since MMD is at the edit mode, the reproduction of the frame is stopped,

When the value of TIME is always in conjunction with the frame time,

In edit mode, even animations using this value will be stopped.

If false is specified in this annotation,

Editing mode, the value of TIME and ELAPSEDTIME, not the frame time is the system time is used.

As a result, the animation will not stop even during the editing mode.
○ use cases

float ftime: TIME <bool SyncInEditMode = true;>;

float elapsed_time: ELAPSEDTIME;

static float fps = 1.0 / elapsed_time;

○ supplement

· SyncInEditMode = If true, the value of ELAPSEDTIME is, by the frame move operation on the MMD, can
be a 0 or negative.

2.5 mouse

● MOUSEPOSITION

Current position of the mouse.

Type float2.

The center of the drawing area of the MMD is a (0,0), the lower left corner (-1, -1), made in the upper
right corner is (1,1).

How to take this xy coordinates, after the projection transformation, is the same as the vertex
coordinates.

○ annotation

None

○ use cases

float2 pos: MOUSEPOSITION;


● LEFTMOUSEDOWN

● MIDDLEMOUSEDOWN

● RIGHTMOUSEDOWN

Information about the mouse button.

Type float4.

Can be acquired values, consists of the following four components.

· Finally the mouse when the button is pressed in the coordinates (x and y)

- Current or button is pressed (0 or 1)

- Finally TIME value at the time the button is pressed (in seconds)

In addition, how to take the mouse coordinates, is the same as the MOUSEPOSITION.

○ annotation

None

○ use cases

float4 mouse_down: LEFTMOUSEDOWN;

static float2 pos = mouse_down.xy;

static bool is_pressed = (! mouse_down.z = 0);


2.6 Control Objects

● CONTROLOBJECT

Of the specified object, I get the coordinates and world transformation matrix.

Mainly, to be used if you want to control the parameters necessary to the shader from the MMD.

Type bool, float, float3, float4 or float4x4.

The type to be used, can be acquired information is different.

· Bool

Whether or not the specified object is displayed

· Float

Scaling value of the specified object

· Float3, float4

Coordinates of the specified object (offset)

· Float4x4

World transformation matrix of the specified object

Also, by specifying a special string item annotation

These other values can also be acquired.

○ annotation

· String name (required)


To specify the file name of the object (folder path is not included).

If you specify a special file name "(self)",

The object itself that its effect is assigned I can be targeted.

Also, if you specify a special file name "(OffscreenOwner)",

Can be an off-screen of the owner of the object to the target (in the case of during the off-screen
rendering only).

Here, the off-screen owners, the effect that OFFSCREENRENDERTARGET is declared

I refer to allocated objects

· String item (optional)

Specify if you want to get the special value of the object.

Specify one of the following.

Bone names: I get the coordinates or world transformation matrix of the specified bone of PMD model.

Type float3, float4, one of float4x4.

Expression name: I get the value of the specified expression of PMD model. Type float.

"X": (X accessory panel) position X of the accessory. Type float.

"Y": (Y accessory panel) position Y of accessories. Type float.

"Z": (Z accessory panel) position Z of accessories. Type float.

"XYZ": position of the accessory (accessory panel X, Y, Z). Type float3.

"Rx": (Rx accessory panel) rotation X accessories. Type float. (※ 1)

"Ry": (Ry accessory panel) rotation Y accessories. Type float.

"Rz": (Rz of accessory panel) rotation Z accessories. Type float.


"Rxyz": rotation of accessories (accessory panel of Rx, Ry, Rz). Type float3.

"Si": the size of the accessory (Si accessories panel). Type float. (※ 2)

"Tr": transparency of accessories (Si accessories panel). Type float.

※ 1 resulting values are a representation of the value on the panel in radians.

※ 2 resulting values are those where the value of the panel 10 times.

○ use cases

Get whether //"stage01.x "is displayed

bool flag: CONTROLOBJECT <string name = "stage01.x";>;

Get the scaling value of //"negi.x "

float scaling: CONTROLOBJECT <string name = "negi.x";>;

Get rotation X of //"negi.x "

float rot_x: CONTROLOBJECT <string name = "negi.x"; string item = "Rx";>;

Get rotation X of //"negi.x "in degrees Unit

float rot_x_rad: CONTROLOBJECT <string name = "negi.x"; string item = "Rx";>;

static float rot_x = rot_x_rad * 180 / 3.14159265;

Coordinate acquisition of bone "Ponite IK" of // "Haku Yowane .pmd"

float3 pos: CONTROLOBJECT <string name = "Haku Yowane .pmd"; string item = "Ponite IK";>;

Value acquisition of expression "blink" of // "Haku Yowane .pmd"


float morph: CONTROLOBJECT <string name = "Haku Yowane .pmd"; string item = "blink";>;

○ supplement

· For world transformation matrix of PMD model does not change in the identity matrix,

Normally, it is used for X-Files (accessory).

Scaling value of accessories, made the value specified in the Size of the accessory on the MMD to 10
times the value.

(Internally, I have been using the value obtained by the length (world_matrix._11_12_13))

• If the object of the specified file name does not exist, the following values are set.

In the case of X-Files:

Scaling value: 10

Offset value: (0, 0, 0, 1)

World transformation matrix: scaling matrix (xyz each 10-fold)

Special item: 0

In the case of PMD file:

Scaling value: 1

Offset value: (0, 0, 0, 1)

World transformation matrix: identity matrix

Bone of coordinates: (0, 0, 0, 1)

Bone of transformation matrix: identity matrix

Expression values: 0

-Than MME ver0.20, even if the referenced object has not been drawn in the later than the reference
the original object,

I came to the value can be obtained.


• If an object with the specified name there is more than one, it is selected in the following order of
priority.

(1) See the original in the drawing order is earlier than the object, and most drawing order is close.

(2) those drawing order is the last

- Such as the dummy bone .pmd, for objects that do not have even one vertex,

I can not get the coordinates to be specified in the referenced.

2.7 texture related

● Normal texture

I generate texture.

Type texture, texture2D, texture3D, one of textureCUBE.

RENDERCOLORTARGET, RENDERDEPTHSTENCILTARGET, semantics other than ANIMATEDTEXTURE is


ignored if specified.

The contents of the generated texture, upon setting the sampler, can refer by calling like tex2D (s, t)
function.

○ annotation

· String ResourceType

I will specify the type of texture. "2D", "3D", to specify one of the "CUBE".

Type as inconsistent value can not be specified.


The type is a "texture", and in the case of generating the texture other than cutlet "2D" is

Always you must specify this annotation. Otherwise it can be omitted.

· String ResourceName

I specify the image file that is in the texture of the original.

Supported file formats, bmp, .dds, .dib, .jpg, .png, and a .tga.

If you specify a file name with a relative path, the folder where the effect file is stored is the reference.

· Int Width

· Int Height

· Int Depth

Texture of width, I specifies the height, the depth, in pixels.

To specify the depth is only when the volume textures.

Dimensions, can not be specified at the same time and ViewportRatio.

(Width, Height, Depth), Dimensions, when none of ViewportRatio not specified,

The default value is 64 pixels.

In addition, if ResourceName is specified, the size from the image file is automatically retrieved.

· Int2 (or int3) Dimensions

Texture of width, I specifies the height, the depth, in pixels.

To specify the depth is only when the volume textures.


ViewportRatio, Width, Height, can not be specified at the same time and Depth.

· Float2 ViewportRatio

Texture of width, the height, I specify the ratio of the screen size of the render target.

To generate the texture of the same size as the screen, "float2 ViewportRatio = {1.0, 1.0};" and is
specified.

To generate the texture of the screen vertically and horizontally twice the size of, "float2 ViewportRatio
= {2.0, 2.0};" and is specified.

Dimensions, Width, Height, can not be specified at the same time and Depth.

· String Format

I specify the format of the texture.

If it is omitted, "A8R8G8B8" is used.

ResourceName if is specified, the format is obtained from the image file,

The setting of this annotation is ignored.

Possible formats, D3DFORMAT (http://msdn.microsoft.com/ja-jp/library/bb172558 (v = VS.85) .aspx)

See.

"A8R8G8B8", "FMT_A8R8G8B8", I can be specified in any of the format of "D3DFMT_A8R8G8B8".

· Int Miplevels

I generate a mipmap at the specified level.

If you specify 0 or omitted, complete mipmap chain is created.


If you specify 1, mipmap is not generated.

· Int Levels

It is an alias of Miplevels.

○ use cases

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

I generated that can be specified surface to render target.

Texture that was generated by specifying the semantics, the script of RenderColorTarget

Can be specified.
After rendering, as well as the normal texture, I can see the contents in tex2D () function.

Type texture, one of texture2D.

○ annotation

· Int Width, int Height, int Depth

· Int2 Dimensions

· Float2 ViewportRatio

See "● Normal texture".

If it is omitted, "float2 ViewportRatio = {1.0, 1.0};" setting that is used.

· String Format

See "● Normal texture".

If it is omitted, "A8R8G8B8" is used.

· Int Miplevels

· Int Levels

See "● Normal texture".

1 or 0 is I can be specified.

If you specify 0, complete mipmap chain is created.

If you specify 1, mipmap is not generated (default).

○ use cases
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

I generate a depth stencil surface (so-called Z-buffer).

Texture that was generated by specifying the semantics, the script of RenderDepthStencilTarget

Can be specified.

Unlike texture that generated by RENDERCOLORTARGET, texture produced by this semantics,

After rendering also, it is not possible to view the contents.

Type texture, one of texture2D.


○ annotation

· Int Width, int Height, int Depth

· Int2 (or int3) Dimensions

· Float2 ViewportRatio

See "● Normal texture".

If it is omitted, "float2 ViewportRatio = {1.0, 1.0};" setting that is used.

· String Format

See "● Normal texture".

If it is omitted, "D24S8" is used.

○ use cases

texture2D DepthBuffer: RENDERDEPTHSTENCILTARGET <

float2 ViewPortRatio = {2.0,2.0};

string Format = "D24S8";

>;

technique Tech <

string Script = "RenderDepthStencilTarget = DepthBuffer;

...

● ANIMATEDTEXTURE
I to generate the animation texture.

Type texture, one of texture2D.

By default, in addition to automatically animate in conjunction with the frame time,

Such as a control object can also be animated in conjunction with another parameter.

○ annotation

· String ResourceName (required)

Made to the texture of the original, I specify the animation image files.

Supported file formats are .gif (animated GIF) and .png (APNG).

· Float Offset (Optional)

I stagger the start time of the animation. (In seconds)

For example, specifying a 2.5, it is possible to delay the animation start 2.5 seconds.

The default value is 0.0.

· Float Speed (optional)

I specify the playback speed of animation.

For example, if you specify the 2.0, the speed of the animation is doubled.

The default value is 1.0.

· String SeekVariable (optional)


The seek control of the animation, it is specified when performing a method other than the frame time.

If you specify the name of the parameter, in conjunction with the change in the value of the parameter,
animation is performed.

By default, it is animation in conjunction with the frame time (TIME <SyncInEditMode = true>).

○ use cases

To animate in conjunction with the changes in the Size of the // object seek.x

float atime: ControlObject <string Name = "seek.x";>;

texture AnimeTex: ANIMATEDTEXTURE <

string ResourceName = "anime.png";

string SeekVariable = "atime";

>;

○ supplement

• If the animation is the fps to request, was lower than the fps of MMD of drawing, dropped frames
occur.

For APNG ·, huge animation files of GByte unit also (once) can be played.

● OFFSCREENRENDERTARGET

Off-screen render target to generate.


Type texture, one of texture2D.

When you generate an off-screen render target,

Automatically, drawing of all objects in the specified conditions, come to be performed on the render
target.

Rendering results, as well as the normal texture I can be referenced in tex2D () function.

○ annotation

· Int Width, int Height, int Depth

· Int2 Dimensions

· Float2 ViewportRatio

See "● Normal texture".

If it is omitted, "float2 ViewportRatio = {1.0, 1.0};" setting that is used.

· String Format

See "● Normal texture".

If it is omitted, "A8R8G8B8" is used.

· Int Miplevels

· Int Levels

See "● Normal texture".

1 or 0 is I can be specified.

If you specify 0, complete mipmap chain is created.


If you specify 1, mipmap is not generated (default).

· Float4 ClearColor

I set the color to clear the render target.

With the color specified here, rendering the target is automatically cleared.

· Float ClearDepth

I set the Z value to clear the depth stencil surface.

In Z value specified here, depth stencil surface is automatically cleared.

· Bool AntiAlias

I use anti-aliasing to rendering. The default is false.

※ If anti-aliasing is enabled, for the video memory is often consumed,

Thing to note is the size of the texture

· String Description

I specify a description of off-screen render target.

String that you specify here is displayed on the GUI dialog effects assignment.

· String DefaultEffect

To specify the allocation method of the effect file to be used in the off-screen rendering.

One assignment describes in the following format.

"(Object file name) = (Effect file name);"


To switch the effect file to be used for each object, and describes several times this assignment.

If multiple times described are compared object file name in the order described, that the first match is
employed.

Example: string DefaultEffect = "self = hide; Mirror * .x = hide; * = MirrorObject.fx;";

The object file name "*" and "?" Wildcard is I can be specified by.

As a special object file name "self" can be specified, this is,

I represent the object itself the effect is assigned with this OFFSCREENRENDERTARGET.

If you specify a file name with a relative path to the effect file name,

Folder in which the reference source of the effect file is stored is the reference.

In addition, as a special effect file name "none" and "hide" can be specified,

This represents a "no effect" "hidden".

Also, if you specify the "main_default", is the same as the default behavior of the main screen,

Automatic assignment of fx files and emd file based on the object file path is performed.

○ use cases

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

Of the specified texture, to be stored in the array to get the texel information.

If you use this, even in an environment that does not correspond to the VTF (Vertex Texture Fetching),

You can see from the vertex shader texture value (※ There limit. See Supplement)

Type two-dimensional array of float4 ([height] [width]), or a one-dimensional array.

○ annotation

· String TextureName (required)

I specify the parameter name of the texture.

○ use cases

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

• In order to pass the value in the constant register, texel number you can see the limit is about 200.

- If the size of the array does not match the size of the texture, there is no guarantee that the correct
value can be obtained.

In some environments, only it is not possible to create a power of 2 sizes of the texture,

Note also specify the size of the other, so automatically have the size is created is expanded.

And acquisition of values from the texture, is done at the start of the frame.

Therefore, updating the texture of the object in the middle, and the value is not updated until the next
frame.

2.8 Effects file

● STANDARDSGLOBAL

I specify the version of SAS (Standard Annotations and Semantics).

In addition, it is also used to describe the annotation for the entire effect file.

The parameter name "Script", type that you specify the 0.8 version number float, as the value.

○ annotation
· String ScriptOutput (optional)

"color" than the value can not be specified. The default value is also this value.

· String ScriptClass (optional)

I specify the purpose (what effect that drawing) of the effect file.

Specify one of the following.

"object": I draw the object. (Default)

"scene": I draw the screen buffer.

"sceneorobject": both of the above.

Basically, in the normal effects of objects for drawing, specify the "object",

Pre-effects, in the post-effects, I specify the "scene".

If you specify the "object", is not to be running Draw = Buffer in the path of the script.

Also, if you specify a "scene", is not to be running Draw = Geometry.

If you specify the "sceneorobject", you can run both.

· String ScriptOrder (optional)

I specify the execution timing of the effect file.

Specify one of the following.


"standard": I draw the object. (Default)

"preprocess": to draw before the drawing of the object. For pre-effects.

"postprocess": I draw after the drawing of the object. For post effects.

To be exact ※, to further before the preprocess, from the beginning of the script of the pre-processing
(technique of postprocess

"ScriptExternal = until Color) is executed.

· String Script (optional)

To specify the search order of the techniques to be used.

Typically, in the order listed in the effect file available technique is retrieved (1.2) is

With this annotation can be explicitly specify the search order.

I specified in the following format.

"? Technique = Technique Technique Name 1: Techniques name 2: ~;"

Example: string Script = "? Technique = Technique SimplePS: TexturedPS: SimpleQuadraticPS:


TexturedQuadraticPS;";

In addition, if techniques to be used is the one, can also be specified as follows.

string Script = "Technique = MainTech;";

○ use cases

// If the normal effect


float Script: STANDARDSGLOBAL <

string ScriptOutput = "color";

string ScriptClass = "object";

string ScriptOrder = "standard";

> = 0.8;

// In the case of post-effects

float Script: STANDARDSGLOBAL <

string ScriptOutput = "color";

string ScriptClass = "scene";

string ScriptOrder = "postprocess";

> = 0.8;

2.9 special parameter

Parameters following names automatically value without semantics are set.

● parthf (bool type)

Self-shadowing flag.

Corresponding to the self-shadowing of mode1 / mode2 (mode1 in false).

● spadd (bool type)

Sphere map additive synthesis flag (additive synthesis in true).


● transp (bool type)

Semi-transparent flag (semi-transparent in true).

[Display (V)] - corresponding to the semi-transparent.

● use_texture (bool type)

Texture use flag.

True if the material in the drawing is to use a texture.

● use_spheremap (bool type)

Sphere map use flag.

True if the material in the drawing is to use a sphere map.

In addition, it is true even when using the sub-texture PMX model.

● use_subtexture (bool type)

Subtexture use flag.

True if you want to use the sub-texture of PMX model.

● use_toon (bool type)

Cel shading use flag.

True if the PMD model.

● opadd (bool type)

Additive synthesis flag.

True if the drawing of the object is set to additive synthesis mode.


● VertexCount (int type)

Number of vertices of the object.

● SubsetCount (int type)

Subset number of objects.

○ use cases

bool parthf;

bool use_texture;

bool use_toon;

int VertexCount;

○ supplement

· MMDPass = "object", if other than "object_ss", there is no guarantee that the correct values for these
parameters are set.

2.9 vertex shader semantics

● _INDEX

In the vertex shader, and semantics for obtaining the index value of the vertex.

I can be used in the input parameters of the vertex shader. Type int.

○ use cases
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

· Because you are once converted to a float type in the process of passing the vertex shader,

If the index value exceeds 2 ^ 24 = 16777216, it is not possible to get the exact value.

2.10 macro

● MME_MIPMAP

MMD is, it is defined if correspond to the mip map texture.

○ use cases

sampler ObjTexSampler = sampler_state {

texture = <ObjectTexture>;
#ifdef MME_MIPMAP

MIPFILTER = LINEAR;

#endif

};

○ supplement

**************************************************

3 script

The techniques and path, it is possible to specify a special annotation called script.

technique technique name <string Script = "command; command; ...";> {...}

pass path name <string Script = "command; command; ...";> {...}

At runtime, these commands are executed sequentially in the described order.

By using this script, rendering the target of change and clear,

It is possible to perform such loop path.

As long as no special processing such as post-effects usually specified script is not required.

If you omit the technique of script, simply path techniques are executed in the order.

Also, if it is omitted the path of the script, "Draw = Geometry" is executed.


○ command

· RenderColorTarget = (texture name or blank)

· RenderColorTarget0 = (texture name or blank)

· RenderColorTarget1 = (texture name or blank)

· RenderColorTarget2 = (texture name or blank)

· RenderColorTarget3 = (texture name or blank)

I set the rendering target.

RenderColorTarget is an alias of RenderColorTarget0.

Normally, I use in RenderDepthStencilTarget command and set.

Also, RenderColorTarget1 ~ 3 can not be used alone and must be used in a set RenderColorTarget0.

The argument, I want to specify the name of the texture parameters that are declared in
RENDERCOLORTARGET semantics.

If you want to reset to the default rendering target, specify the blank.

Note that render target set, unless run these command again,

Until completion of processing techniques to remain is changed.

· RenderDepthStencilTarget = (texture name or blank)

I set the depth stencil surface (so-called Z-buffer).


Normally, I use in RenderColorTarget0 command and set.

The argument, I want to specify the name of the texture parameters that are declared in
RENDERDEPTHSTENCILTARGET semantics.

If you want to reset to the default depth stencil surface, specify the blank.

· ClearSetColor = (parameter name)

I set the color to clear the render target. (Not yet clear)

The argument, I want to specify the name of the float4 type of parameters.

The value set in this parameter, the color to clear the render target.

· ClearSetDepth = (parameter name)

I set the Z value to clear the depth stencil surface. (Not yet clear)

The argument, I specify the name of the float type of the parameter.

The value set in this parameter, the Z value to clear the depth stencil surface.

· Clear = Color

I clear the render target.

The color to clear, the value set in ClearSetColor command is used.

· Clear = Depth
I clear the depth stencil surface.

The Z value to clear, the value set in ClearSetDepth command is used.

· ScriptExternal = Color

I draw the other object.

This command can not be used only on the technique of the script.

This is, in ScriptOrder annotation of post effects (STANDARDSGLOBAL parameters

"postprocess" is I can only run in the specified effect file).

Typically, the post-effects, it did on set texture for input to the render target,

To the texture, I to render other objects.

In this, when to render the other objects, and to execute the command.

(See the post effects of Tips)

The post-effects, on the technique of the script, it must be always performed only one time.

· Pass = (path name)

To perform the specified path.

This command can not be used only on the technique of the script.

If you specify a script technique, unless explicitly use this command,


Any path is also not run.

· LoopByCount = (parameter name)

· LoopEnd =

Only the number of times specified, to loop a part of the script.

This command can not be used only on the technique of the script.

The argument, numeric (int, bool, float) I specify the name of the parameter of.

Only the number of times of the value set in this parameter, the command string in from LoopByCount
to LoopEnd

Is repeatedly executed.

Loop can be nested.

In the following example, after 3 passes p0 is performed, the path p1 is performed.

/ **************************** /

int Count = 3;

technique TShader <

string Script =

"LoopByCount = Count;"

"Pass = p0;"

"LoopEnd =;"

"Pass = p1;";

>{
/ **************************** /

· LoopGetIndex = (parameter name)

The value of the loop counter in the loop is set to the specified parameters.

This command can not be used only between from LoopByCount to LoopEnd.

· Draw = Geometry

I draw the object.

This command can not be used only on the path of the script.

If you omit the path of the script, this command is executed.

If you have specified a "scene" to ScriptClass of STANDARDSGLOBAL,

Is not to be run this command.

· Draw = Buffer

Of size that matches the render target of the screen, I draw a rectangular polygon.

This command can not be used only on the path of the script.

I want to use in the post-effects and pre-effects.

If you have specified the "object" to ScriptClass of STANDARDSGLOBAL,

Is not to be run this command.


· RenderPort = *

Not supported.

○ use cases

technique TShader <

/ * Two string representation ("~" "~") If there is only blank characters between,

Because it is considered as one continuous string, can be described by dividing as follows * /

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

● I use the MMD standard shader

Only a portion of the drawing objects, using the effect,

If you want to use the MMD standard shaders in the other drawing,

The scene of the techniques that you want to use the MMD standard shader, it may have to describe the
effect file.

(See "1.2 technique of annotation")

/ ************************************************* *********** /

/ * If there is only this technique to the effect file,

* Than the object drawing (at the time of self-shadowing ON) is drawn in MMD standard shader /

technique Tech1 <string MMDPass = "object_ss";> {

pass Pass1 {

...

pass Pass2 {

...

/ ************************************************* *********** /

In addition, because the default shader path is the shader of MMD standard,
As follows, If you do not set the VertexShader and PixelShader of path,

MMD standards shader is used to draw the path.

/ ************************************************* *********** /

technique Tech1 <string MMDPass = "object_ss";> {

pass Pass1 {

// VertexShader = xxx

// PixelShader = xxx

/ ************************************************* *********** /

● empty technique

As follows, empty the technique is not performed at all the drawing in that technique.

That way, it is possible to suppress the drawing of some objects or all.

/ ************************************************* ******** /

technique ShadowTech <string MMDPass = "shadow";> {

/ ************************************************* ******** /
The ON / OFF the path in the presence of an object ●

When you write a script as follows, only while the display of a particular object is ON

It is possible to execute the path.

This is utilized to be construed to 1 and 0 as a numerical value is boolean true / false.

/ ************************************************* ******** /

bool flag: CONTROLOBJECT <string name = "aaa.x";>;

technique Tech1 <

string Script =

"LoopByCount = flag;"

"Pass = Pass1;"

"LoopEnd =;"

>{

pass Pass1 {

...

/ ************************************************* ******** /

● Share parameters between the effect file


Typically, the parameters are not shared between different effects file.

However, by specifying the "shared" keyword in the declaration of parameters,

It is possible to share the parameters of the same name across the effect file.

In the following example, a texture is generated by effect1.fx, can be referenced by effect2.fx.

Thus, it is necessary to specify a "shared" keyword in both parameter declaration.

Moreover, not only the name, the type name and semantics 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 statement

If you want to draw in high speed, when you are writing a shader, the conditional branch like as much as
possible if statement

Better you do not use is.

If in the presence or absence of texture, such as switching the processing of shader,

by referring to the use_texture parameters, rather than conditional branch in the if statement in the
shader,

In that there is no subset a subset texture there, more can be drawn as fast you would divide the
technique itself.

● uniform keyword

Specifying a "uniform" keyword argument of the function declaration, it is possible to give the value of
the argument as a compile-time constant.

In the following example, the if statement in the Basic_PS () is removed at compile time,

Speed reduction due to conditional branch is avoided (maybe).

/ ************************************************* ****************** /

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 = compiled shaders in true * /

PixelShader = compile ps_2_0 Basic_PS (true);

...

technique TechWithoutTex {

pass P1 {

/ * UseTexture = compiled shaders in false * /

PixelShader = compile ps_2_0 Basic_PS (false);

...

/ ************************************************* ****************** /

● Japanese use of the effect in the file

Basically, in a non-comment portion, it is not recommended that you use the Japanese characters in the
effect file.
Dare If used, it can be noted the character code.

Such as object name of the path and the control object of image file for the texture generation,

If you want to use the Japanese to specify the file name, the character code of the effect file

Sure it must be a Shift-JIS.

● Post Effects

If you want to create an effect file for post effects,

There is a need of the following parameters are declared in effect file.

(See "● STANDARDSGLOBAL")

float Script: STANDARDSGLOBAL <

string ScriptOutput = "color";

string ScriptClass = "scene";

string ScriptOrder = "postprocess";

> = 0.8;

Also, in a typical post-effects, i performs the following processing in the script techniques.

(1) The render target is changed to own texture and clear.

Script example:
"RenderColorTarget0 = (RENDERCOLORTARGET texture);"

"RenderDepthStencilTarget = (RENDERDEPTHSTENCILTARGET texture);"

"ClearSetColor = (clear color);"

"ClearSetDepth = (Z value of clear);"

"Clear = Color;"

"Clear = Depth;"

(2) I draw pre-effects, objects, other post effects.

In this case, drawing results are stored in a texture that is specified in (1).

Script example:

"ScriptExternal = Color;"

(3) render target was returned to the original, as input texture rendering result, and executes the path.

Script example:

"RenderColorTarget0 =;"

"RenderDepthStencilTarget =;"

"Pass = (path 1);"

"Pass = (path 2);"

You might also like