Main repository of MikuMikuStudio
Revisão | d0b9fcea331701575ffaf9ddb5a07c08b63e7407 (tree) |
---|---|
Hora | 2013-04-28 01:32:37 |
Autor | remy.bouquet@gmail.com <remy.bouquet@gmai...> |
Commiter | remy.bouquet@gmail.com |
Shadows, SSAO and CartoonEdge now works with HardWareSkinning
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10580 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -192,6 +192,7 @@ MaterialDef Phong Lighting { | ||
192 | 192 | Defines { |
193 | 193 | COLOR_MAP : ColorMap |
194 | 194 | DISCARD_ALPHA : AlphaDiscardThreshold |
195 | + NUM_BONES : NumberOfBones | |
195 | 196 | } |
196 | 197 | |
197 | 198 | ForcedRenderState { |
@@ -218,12 +219,13 @@ MaterialDef Phong Lighting { | ||
218 | 219 | HARDWARE_SHADOWS : HardwareShadows |
219 | 220 | FILTER_MODE : FilterMode |
220 | 221 | PCFEDGE : PCFEdge |
221 | - DISCARD_ALPHA : AlphaDiscardThreshold | |
222 | + DISCARD_ALPHA : AlphaDiscardThreshold | |
222 | 223 | COLOR_MAP : ColorMap |
223 | 224 | SHADOWMAP_SIZE : ShadowMapSize |
224 | 225 | FADE : FadeInfo |
225 | 226 | PSSM : Splits |
226 | 227 | POINTLIGHT : LightViewProjectionMatrix5 |
228 | + NUM_BONES : NumberOfBones | |
227 | 229 | } |
228 | 230 | |
229 | 231 | ForcedRenderState { |
@@ -246,12 +248,13 @@ MaterialDef Phong Lighting { | ||
246 | 248 | HARDWARE_SHADOWS : HardwareShadows |
247 | 249 | FILTER_MODE : FilterMode |
248 | 250 | PCFEDGE : PCFEdge |
249 | - DISCARD_ALPHA : AlphaDiscardThreshold | |
251 | + DISCARD_ALPHA : AlphaDiscardThreshold | |
250 | 252 | COLOR_MAP : ColorMap |
251 | 253 | SHADOWMAP_SIZE : ShadowMapSize |
252 | 254 | FADE : FadeInfo |
253 | 255 | PSSM : Splits |
254 | 256 | POINTLIGHT : LightViewProjectionMatrix5 |
257 | + NUM_BONES : NumberOfBones | |
255 | 258 | } |
256 | 259 | |
257 | 260 | ForcedRenderState { |
@@ -274,10 +277,7 @@ MaterialDef Phong Lighting { | ||
274 | 277 | |
275 | 278 | Defines { |
276 | 279 | DIFFUSEMAP_ALPHA : DiffuseMap |
277 | - } | |
278 | - | |
279 | - RenderState { | |
280 | - | |
280 | + NUM_BONES : NumberOfBones | |
281 | 281 | } |
282 | 282 | |
283 | 283 | } |
@@ -15,6 +15,35 @@ MaterialDef Unshaded { | ||
15 | 15 | // For hardware skinning |
16 | 16 | Int NumberOfBones |
17 | 17 | Matrix4Array BoneMatrices |
18 | + | |
19 | + //Shadows | |
20 | + Int FilterMode | |
21 | + Boolean HardwareShadows | |
22 | + | |
23 | + Texture2D ShadowMap0 | |
24 | + Texture2D ShadowMap1 | |
25 | + Texture2D ShadowMap2 | |
26 | + Texture2D ShadowMap3 | |
27 | + //pointLights | |
28 | + Texture2D ShadowMap4 | |
29 | + Texture2D ShadowMap5 | |
30 | + | |
31 | + Float ShadowIntensity | |
32 | + Vector4 Splits | |
33 | + Vector2 FadeInfo | |
34 | + | |
35 | + Matrix4 LightViewProjectionMatrix0 | |
36 | + Matrix4 LightViewProjectionMatrix1 | |
37 | + Matrix4 LightViewProjectionMatrix2 | |
38 | + Matrix4 LightViewProjectionMatrix3 | |
39 | + //pointLight | |
40 | + Matrix4 LightViewProjectionMatrix4 | |
41 | + Matrix4 LightViewProjectionMatrix5 | |
42 | + Vector3 LightPos | |
43 | + | |
44 | + Float PCFEdge | |
45 | + | |
46 | + Float ShadowMapSize | |
18 | 47 | } |
19 | 48 | |
20 | 49 | Technique { |
@@ -38,21 +67,106 @@ MaterialDef Unshaded { | ||
38 | 67 | Technique { |
39 | 68 | } |
40 | 69 | |
41 | - Technique PreNormalPass { | |
70 | + Technique PreNormalPass { | |
71 | + | |
72 | + VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert | |
73 | + FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag | |
74 | + | |
75 | + WorldParameters { | |
76 | + WorldViewProjectionMatrix | |
77 | + WorldViewMatrix | |
78 | + NormalMatrix | |
79 | + } | |
80 | + | |
81 | + Defines { | |
82 | + NUM_BONES : NumberOfBones | |
83 | + } | |
84 | + } | |
85 | + | |
86 | + Technique PreShadow { | |
87 | + | |
88 | + VertexShader GLSL100 : Common/MatDefs/Shadow/PreShadow.vert | |
89 | + FragmentShader GLSL100 : Common/MatDefs/Shadow/PreShadow.frag | |
90 | + | |
91 | + WorldParameters { | |
92 | + WorldViewProjectionMatrix | |
93 | + WorldViewMatrix | |
94 | + } | |
95 | + | |
96 | + Defines { | |
97 | + COLOR_MAP : ColorMap | |
98 | + DISCARD_ALPHA : AlphaDiscardThreshold | |
99 | + NUM_BONES : NumberOfBones | |
100 | + } | |
101 | + | |
102 | + ForcedRenderState { | |
103 | + FaceCull Off | |
104 | + DepthTest On | |
105 | + DepthWrite On | |
106 | + PolyOffset 5 3 | |
107 | + ColorWrite Off | |
108 | + } | |
109 | + | |
110 | + } | |
111 | + | |
42 | 112 | |
43 | - VertexShader GLSL100 : Common/MatDefs/SSAO/normal.vert | |
44 | - FragmentShader GLSL100 : Common/MatDefs/SSAO/normal.frag | |
113 | + Technique PostShadow15{ | |
114 | + VertexShader GLSL150: Common/MatDefs/Shadow/PostShadow.vert | |
115 | + FragmentShader GLSL150: Common/MatDefs/Shadow/PostShadow15.frag | |
45 | 116 | |
46 | - WorldParameters { | |
47 | - WorldViewProjectionMatrix | |
48 | - WorldViewMatrix | |
49 | - NormalMatrix | |
50 | - } | |
117 | + WorldParameters { | |
118 | + WorldViewProjectionMatrix | |
119 | + WorldMatrix | |
120 | + } | |
121 | + | |
122 | + Defines { | |
123 | + HARDWARE_SHADOWS : HardwareShadows | |
124 | + FILTER_MODE : FilterMode | |
125 | + PCFEDGE : PCFEdge | |
126 | + DISCARD_ALPHA : AlphaDiscardThreshold | |
127 | + COLOR_MAP : ColorMap | |
128 | + SHADOWMAP_SIZE : ShadowMapSize | |
129 | + FADE : FadeInfo | |
130 | + PSSM : Splits | |
131 | + POINTLIGHT : LightViewProjectionMatrix5 | |
132 | + NUM_BONES : NumberOfBones | |
133 | + } | |
51 | 134 | |
52 | - RenderState { | |
53 | - } | |
135 | + ForcedRenderState { | |
136 | + Blend Modulate | |
137 | + DepthWrite Off | |
138 | + PolyOffset -0.1 0 | |
54 | 139 | } |
140 | + } | |
55 | 141 | |
142 | + Technique PostShadow{ | |
143 | + VertexShader GLSL100: Common/MatDefs/Shadow/PostShadow.vert | |
144 | + FragmentShader GLSL100: Common/MatDefs/Shadow/PostShadow.frag | |
145 | + | |
146 | + WorldParameters { | |
147 | + WorldViewProjectionMatrix | |
148 | + WorldMatrix | |
149 | + } | |
150 | + | |
151 | + Defines { | |
152 | + HARDWARE_SHADOWS : HardwareShadows | |
153 | + FILTER_MODE : FilterMode | |
154 | + PCFEDGE : PCFEdge | |
155 | + DISCARD_ALPHA : AlphaDiscardThreshold | |
156 | + COLOR_MAP : ColorMap | |
157 | + SHADOWMAP_SIZE : ShadowMapSize | |
158 | + FADE : FadeInfo | |
159 | + PSSM : Splits | |
160 | + POINTLIGHT : LightViewProjectionMatrix5 | |
161 | + NUM_BONES : NumberOfBones | |
162 | + } | |
163 | + | |
164 | + ForcedRenderState { | |
165 | + Blend Modulate | |
166 | + DepthWrite Off | |
167 | + PolyOffset -0.1 0 | |
168 | + } | |
169 | + } | |
56 | 170 | |
57 | 171 | Technique Glow { |
58 | 172 |
@@ -1,3 +1,4 @@ | ||
1 | +#import "Common/ShaderLib/Skinning.glsllib" | |
1 | 2 | uniform mat4 m_LightViewProjectionMatrix0; |
2 | 3 | uniform mat4 m_LightViewProjectionMatrix1; |
3 | 4 | uniform mat4 m_LightViewProjectionMatrix2; |
@@ -41,7 +42,12 @@ const mat4 biasMat = mat4(0.5, 0.0, 0.0, 0.0, | ||
41 | 42 | |
42 | 43 | |
43 | 44 | void main(){ |
44 | - gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition, 1.0); | |
45 | + vec4 modelSpacePos = vec4(inPosition, 1.0); | |
46 | + | |
47 | + #ifdef NUM_BONES | |
48 | + Skinning_Compute(modelSpacePos); | |
49 | + #endif | |
50 | + gl_Position = g_WorldViewProjectionMatrix * modelSpacePos; | |
45 | 51 | |
46 | 52 | #ifndef POINTLIGHT |
47 | 53 | #ifdef PSSM |
@@ -50,7 +56,7 @@ void main(){ | ||
50 | 56 | vec4 worldPos=vec4(0.0); |
51 | 57 | #endif |
52 | 58 | // get the vertex in world space |
53 | - worldPos = g_WorldMatrix * vec4(inPosition, 1.0); | |
59 | + worldPos = g_WorldMatrix * modelSpacePos; | |
54 | 60 | |
55 | 61 | #ifdef DISCARD_ALPHA |
56 | 62 | texCoord = inTexCoord; |
@@ -1,4 +1,5 @@ | ||
1 | -attribute vec4 inPosition; | |
1 | +#import "Common/ShaderLib/Skinning.glsllib" | |
2 | +attribute vec3 inPosition; | |
2 | 3 | attribute vec2 inTexCoord; |
3 | 4 | |
4 | 5 | uniform mat4 g_WorldViewProjectionMatrix; |
@@ -7,6 +8,11 @@ uniform mat4 g_WorldViewMatrix; | ||
7 | 8 | varying vec2 texCoord; |
8 | 9 | |
9 | 10 | void main(){ |
10 | - gl_Position = g_WorldViewProjectionMatrix * inPosition; | |
11 | + vec4 modelSpacePos = vec4(inPosition, 1.0); | |
12 | + | |
13 | + #ifdef NUM_BONES | |
14 | + Skinning_Compute(modelSpacePos); | |
15 | + #endif | |
16 | + gl_Position = g_WorldViewProjectionMatrix * modelSpacePos; | |
11 | 17 | texCoord = inTexCoord; |
12 | 18 | } |
\ No newline at end of file |
@@ -1,3 +1,4 @@ | ||
1 | +#import "Common/ShaderLib/Skinning.glsllib" | |
1 | 2 | uniform mat4 g_WorldViewProjectionMatrix; |
2 | 3 | uniform mat3 g_NormalMatrix; |
3 | 4 |
@@ -11,6 +12,11 @@ varying vec2 texCoord; | ||
11 | 12 | void main(void) |
12 | 13 | { |
13 | 14 | texCoord=inTexCoord.xy; |
14 | - normal = normalize(g_NormalMatrix * inNormal); | |
15 | - gl_Position = g_WorldViewProjectionMatrix * vec4(inPosition,1.0); | |
15 | + vec4 modelSpacePos = vec4(inPosition, 1.0); | |
16 | + vec3 modelSpaceNormals = inNormal; | |
17 | + #ifdef NUM_BONES | |
18 | + Skinning_Compute(modelSpacePos,modelSpaceNormals); | |
19 | + #endif | |
20 | + normal = normalize(g_NormalMatrix * modelSpaceNormals); | |
21 | + gl_Position = g_WorldViewProjectionMatrix * modelSpacePos; | |
16 | 22 | } |
\ No newline at end of file |