Browse Source

Fix Highlight and alpha test

sebavan 5 years ago
parent
commit
24d07d2153
2 changed files with 23 additions and 1 deletions
  1. 8 0
      src/Layers/highlightLayer.ts
  2. 15 1
      src/Shaders/glowMapGeneration.fragment.fx

+ 8 - 0
src/Layers/highlightLayer.ts

@@ -512,6 +512,14 @@ export class HighlightLayer extends EffectLayer {
     }
 
     /**
+     * Adds specific effects defines.
+     * @param defines The defines to add specifics to.
+     */
+    protected _addCustomEffectDefines(defines: string[]): void {
+        defines.push("#define HIGHLIGHT");
+    }
+
+    /**
      * Sets the required values for both the emissive texture and and the main color.
      */
     protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void {

+ 15 - 1
src/Shaders/glowMapGeneration.fragment.fx

@@ -28,7 +28,16 @@ vec4 finalColor = glowColor;
 // _____________________________ Alpha Information _______________________________
 #ifdef DIFFUSE
     vec4 albedoTexture = texture2D(diffuseSampler, vUVDiffuse);
-    finalColor.a *= albedoTexture.a;
+
+    #ifdef GLOW
+        // In glow mode a is used to dim the opacity
+        finalColor.a *= albedoTexture.a;
+    #endif
+
+    #ifdef HIGHLIGHT
+        // While in highlight mode we only use the 3 colors
+        finalColor.a = albedoTexture.a;
+    #endif
 #endif
 
 #ifdef OPACITY
@@ -57,4 +66,9 @@ vec4 finalColor = glowColor;
 #else
     gl_FragColor = finalColor;
 #endif
+
+#ifdef HIGHLIGHT
+    // a should stay untouched from the setup in highlight mode.
+    gl_FragColor.a = glowColor.a;
+#endif
 }