From 706cd410b6c95470600c20f92754991b4edf6778 Mon Sep 17 00:00:00 2001 From: "rem..om" Date: Fri, 3 May 2013 18:15:07 +0000 Subject: [PATCH] AlphaDiscardTreshold is now supported by the Unshaded material. git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10588 75d07b2b-3a1a-0410-a2c5-0572b91ccdca --- .../src/core-data/Common/MatDefs/Misc/Unshaded.frag | 12 +++++++++++- .../src/core-data/Common/MatDefs/Misc/Unshaded.j3md | 4 ++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/engine/src/core-data/Common/MatDefs/Misc/Unshaded.frag b/engine/src/core-data/Common/MatDefs/Misc/Unshaded.frag index 2ebae6a04..ce8219b6e 100644 --- a/engine/src/core-data/Common/MatDefs/Misc/Unshaded.frag +++ b/engine/src/core-data/Common/MatDefs/Misc/Unshaded.frag @@ -2,6 +2,10 @@ #define NEED_TEXCOORD1 #endif +#if defined(DISCARD_ALPHA) + uniform float m_AlphaDiscardThreshold; +#endif + uniform vec4 m_Color; uniform sampler2D m_ColorMap; uniform sampler2D m_LightMap; @@ -15,7 +19,7 @@ void main(){ vec4 color = vec4(1.0); #ifdef HAS_COLORMAP - color *= texture2D(m_ColorMap, texCoord1); + color *= texture2D(m_ColorMap, texCoord1); #endif #ifdef HAS_VERTEXCOLOR @@ -34,5 +38,11 @@ void main(){ #endif #endif + #if defined(DISCARD_ALPHA) + if(color.a < m_AlphaDiscardThreshold){ + discard; + } + #endif + gl_FragColor = color; } \ No newline at end of file diff --git a/engine/src/core-data/Common/MatDefs/Misc/Unshaded.j3md b/engine/src/core-data/Common/MatDefs/Misc/Unshaded.j3md index 64248ca0c..4c7247ea8 100644 --- a/engine/src/core-data/Common/MatDefs/Misc/Unshaded.j3md +++ b/engine/src/core-data/Common/MatDefs/Misc/Unshaded.j3md @@ -16,6 +16,9 @@ MaterialDef Unshaded { Int NumberOfBones Matrix4Array BoneMatrices + // Apha threshold for fragment discarding + Float AlphaDiscardThreshold (AlphaTestFallOff) + //Shadows Int FilterMode Boolean HardwareShadows @@ -61,6 +64,7 @@ MaterialDef Unshaded { HAS_VERTEXCOLOR : VertexColor HAS_COLOR : Color NUM_BONES : NumberOfBones + DISCARD_ALPHA : AlphaDiscardThreshold } }