-
Notifications
You must be signed in to change notification settings - Fork 0
/
AniMasa.fxsub
195 lines (150 loc) · 5.13 KB
/
AniMasa.fxsub
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
////////////////////////////////////////////////////////////////////////////////////////////////
//
// "Ani:Masa" shader (https://github.com/KH40-khoast40/AniMasa)
//
// Shader made by: KH40
// Base shader: 舞力介入P
// Inspiration: Animasa (あにまさ)
//
////////////////////////////////////////////////////////////////////////////////////////////////
float4x4 WorldViewProjMatrix : WORLDVIEWPROJECTION;
float4x4 WorldMatrix : WORLD;
float4x4 ViewMatrix : VIEW;
float4 EdgeColor : EDGECOLOR;
float4 GroundShadowColor : GROUNDSHADOWCOLOR;
float3 LightAmbient : AMBIENT < string Object = "Light"; >;
texture2D ShadeMap
<
string ResourceName = "../shading.png";
int MipLevels = 0;
>;
sampler ShadeSamp = sampler_state {
texture = <ShadeMap>;
MINFILTER = ANISOTROPIC;
MAGFILTER = ANISOTROPIC;
MIPFILTER = ANISOTROPIC;
ADDRESSU = CLAMP;
ADDRESSV = CLAMP;
};
texture2D HighlightMap
<
string ResourceName = "../shading.png";
int MipLevels = 0;
int Width = 16;
int Height = 16;
>;
sampler HighlightSamp = sampler_state {
texture = <HighlightMap>;
MINFILTER = ANISOTROPIC;
MAGFILTER = ANISOTROPIC;
MIPFILTER = ANISOTROPIC;
ADDRESSU = CLAMP;
ADDRESSV = CLAMP;
};
texture2D TextureMap : MATERIALTEXTURE;
sampler TextureSamp = sampler_state {
texture = <TextureMap>;
MINFILTER = ANISOTROPIC;
MAGFILTER = ANISOTROPIC;
MIPFILTER = ANISOTROPIC;
ADDRESSU = CLAMP;
ADDRESSV = CLAMP;
};
////////////////////////////////////////////////////////////////////////////////////////////////
float4 ColorRender_VS(float4 Pos : POSITION) : POSITION
{
return mul( Pos, WorldViewProjMatrix );
}
float4 ColorRender_PS() : COLOR
{
return EdgeColor;
}
technique EdgeTec < string MMDPass = "edge"; > {
pass DrawEdge {
VertexShader = compile vs_2_0 ColorRender_VS();
PixelShader = compile ps_2_0 ColorRender_PS();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
float4 Shadow_VS(float4 Pos : POSITION) : POSITION
{
return mul( Pos, WorldViewProjMatrix );
}
float4 Shadow_PS() : COLOR
{
return GroundShadowColor;
}
technique ShadowTec < string MMDPass = "shadow"; > {
pass DrawShadow {
VertexShader = compile vs_2_0 Shadow_VS();
PixelShader = compile ps_2_0 Shadow_PS();
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
struct VS_OUTPUT {
float4 Pos : POSITION; // 射影変換座標
float3 Normal : TEXCOORD1; // 法線
float2 SpTex : TEXCOORD2; // スフィアマップテクスチャ座標
float2 Tex : TEXCOORD3;
};
VS_OUTPUT AniMasa_VS(float4 Pos : POSITION, float3 Normal : NORMAL, float2 Tex : TEXCOORD0)
{
VS_OUTPUT Out = (VS_OUTPUT)0;
Out.Pos = mul( Pos, WorldViewProjMatrix );
Out.Normal = normalize( mul( Normal, (float3x3)WorldMatrix ) );
Out.Normal = Out.Normal;
float2 NormalWV = mul( Out.Normal, (float3x3)ViewMatrix );
Out.SpTex.x = NormalWV.x * 0.5f + 0.5f;
Out.SpTex.y = NormalWV.y * -0.5f + 0.5f;
Out.Tex = Tex;
return Out;
}
float4 AniMasa_PS(VS_OUTPUT IN, uniform bool useTexture) : COLOR0
{
float4 Color = 1;
Color.rgb = Shade_Color/255;
float2 ShadeTex;
ShadeTex.x = (IN.SpTex.x-0.5)* Shade_Scale + 0.5;
ShadeTex.y = (IN.SpTex.y-0.5)* Shade_Scale * Shade_Scale_Y + 0.5;
float Shade_Draw = tex2D(ShadeSamp,ShadeTex).r;
Color.rgb = lerp(Color.rgb,Base_Color/255,Shade_Draw);
#ifdef Highlight
float2 HighlightTex;
HighlightTex.x = (IN.SpTex.x-0.5)* Highlight_Scale + 0.5;
HighlightTex.y = (IN.SpTex.y-0.5)* Highlight_Scale * Highlight_Scale_Y + 0.5;
float Highlight_Draw = tex2D(HighlightSamp,HighlightTex).r;
Color.rgb = lerp(Color.rgb,Highlight_Color/255,Highlight_Draw);
#endif
if ( useTexture )
{
Color *= tex2D(TextureSamp, IN.Tex);
}
Color.rgb *= LightAmbient+0.4;
return Color;
}
///////////////////////////////////////////////////////////////////////////////////////////////
technique MainTec0 < string MMDPass = "object"; bool UseTexture = true; > {
pass DrawObject {
VertexShader = compile vs_3_0 AniMasa_VS();
PixelShader = compile ps_3_0 AniMasa_PS(true);
}
}
technique MainTec1 < string MMDPass = "object"; bool UseTexture = false; > {
pass DrawObject {
VertexShader = compile vs_3_0 AniMasa_VS();
PixelShader = compile ps_3_0 AniMasa_PS(false);
}
}
technique MainTec2 < string MMDPass = "object_ss"; bool UseTexture = true; > {
pass DrawObject {
VertexShader = compile vs_3_0 AniMasa_VS();
PixelShader = compile ps_3_0 AniMasa_PS(true);
}
}
technique MainTec3 < string MMDPass = "object_ss"; bool UseTexture = false; > {
pass DrawObject {
VertexShader = compile vs_3_0 AniMasa_VS();
PixelShader = compile ps_3_0 AniMasa_PS(false);
}
}
///////////////////////////////////////////////////////////////////////////////////////////////