Main repository of MikuMikuStudio
Révision | c15a3088a2d548f8c178f407a1afe2ab834627fb (tree) |
---|---|
l'heure | 2013-05-04 03:15:07 |
Auteur | remy.bouquet@gmail.com <remy.bouquet@gmai...> |
Commiter | remy.bouquet@gmail.com |
AlphaDiscardTreshold is now supported by the Unshaded material.
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@10588 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
@@ -2,6 +2,10 @@ | ||
2 | 2 | #define NEED_TEXCOORD1 |
3 | 3 | #endif |
4 | 4 | |
5 | +#if defined(DISCARD_ALPHA) | |
6 | + uniform float m_AlphaDiscardThreshold; | |
7 | +#endif | |
8 | + | |
5 | 9 | uniform vec4 m_Color; |
6 | 10 | uniform sampler2D m_ColorMap; |
7 | 11 | uniform sampler2D m_LightMap; |
@@ -15,7 +19,7 @@ void main(){ | ||
15 | 19 | vec4 color = vec4(1.0); |
16 | 20 | |
17 | 21 | #ifdef HAS_COLORMAP |
18 | - color *= texture2D(m_ColorMap, texCoord1); | |
22 | + color *= texture2D(m_ColorMap, texCoord1); | |
19 | 23 | #endif |
20 | 24 | |
21 | 25 | #ifdef HAS_VERTEXCOLOR |
@@ -34,5 +38,11 @@ void main(){ | ||
34 | 38 | #endif |
35 | 39 | #endif |
36 | 40 | |
41 | + #if defined(DISCARD_ALPHA) | |
42 | + if(color.a < m_AlphaDiscardThreshold){ | |
43 | + discard; | |
44 | + } | |
45 | + #endif | |
46 | + | |
37 | 47 | gl_FragColor = color; |
38 | 48 | } |
\ No newline at end of file |
@@ -16,6 +16,9 @@ MaterialDef Unshaded { | ||
16 | 16 | Int NumberOfBones |
17 | 17 | Matrix4Array BoneMatrices |
18 | 18 | |
19 | + // Apha threshold for fragment discarding | |
20 | + Float AlphaDiscardThreshold (AlphaTestFallOff) | |
21 | + | |
19 | 22 | //Shadows |
20 | 23 | Int FilterMode |
21 | 24 | Boolean HardwareShadows |
@@ -61,6 +64,7 @@ MaterialDef Unshaded { | ||
61 | 64 | HAS_VERTEXCOLOR : VertexColor |
62 | 65 | HAS_COLOR : Color |
63 | 66 | NUM_BONES : NumberOfBones |
67 | + DISCARD_ALPHA : AlphaDiscardThreshold | |
64 | 68 | } |
65 | 69 | } |
66 | 70 |