소스 검색

PreNormalPass fix for Unshaded and PBRLighting (#1512)

* Update GLImageFormats.java

* Modified JmeBatchRenderBackend to clear the inner buffer of the image in the atlases instead of setting a predefined byte buffer
on disposal that made all atlases in the backend use the same buffer and generated rendering issues.

* First impl of testcasefor multiple atlases issue. Still missing to add more images to the screens so it really uses more atlases

* Manual merge pending stuff from jme3 base

* Manual merge

* Fix PreNormalPass for transparent unshaded materials having issues with ssao filter

* Fixed proper ssao on transparent pbr materials

Co-authored-by: joliver82 <[email protected]>
joliver82 4 년 전
부모
커밋
9dd7dbc0f9

+ 1 - 0
jme3-core/src/main/resources/Common/MatDefs/Light/PBRLighting.j3md

@@ -245,6 +245,7 @@ MaterialDef PBR Lighting {
         }
 
         Defines {
+            BASECOLORMAP_ALPHA : BaseColorMap            
             NUM_BONES : NumberOfBones
             INSTANCING : UseInstancing
             NUM_MORPH_TARGETS: NumberOfMorphTargets

+ 1 - 0
jme3-core/src/main/resources/Common/MatDefs/Misc/Unshaded.j3md

@@ -104,6 +104,7 @@ MaterialDef Unshaded {
         }
 
         Defines {
+            COLORMAP_ALPHA : ColorMap
             NUM_BONES : NumberOfBones
             INSTANCING : UseInstancing
             NUM_MORPH_TARGETS: NumberOfMorphTargets

+ 21 - 0
jme3-effects/src/main/resources/Common/MatDefs/SSAO/normal.frag

@@ -5,6 +5,17 @@ varying vec2 texCoord;
 
 #ifdef DIFFUSEMAP_ALPHA
     uniform sampler2D m_DiffuseMap;
+#endif
+
+#ifdef COLORMAP_ALPHA
+    uniform sampler2D m_ColorMap;
+#endif
+
+#ifdef BASECOLORMAP_ALPHA
+    uniform sampler2D m_BaseColorMap;
+#endif
+
+#if defined DIFFUSEMAP_ALPHA || defined COLORMAP_ALPHA || defined BASECOLORMAP_ALPHA
     uniform float m_AlphaDiscardThreshold;
 #endif
 
@@ -16,6 +27,16 @@ void main(void)
             discard;
         }
     #endif
+    #ifdef COLORMAP_ALPHA
+        if(texture2D(m_ColorMap,texCoord).a<m_AlphaDiscardThreshold){
+            discard;
+        }
+    #endif
+    #ifdef BASECOLORMAP_ALPHA
+        if(texture2D(m_BaseColorMap,texCoord).a<m_AlphaDiscardThreshold){
+            discard;
+        }
+    #endif
     gl_FragColor = vec4(normal.xy* 0.5 + 0.5,-normal.z* 0.5 + 0.5, 1.0);
 
 }