瀏覽代碼

#3277 Enables disposing thresholdPass, moves shader to a separate file

pixelscommander 7 年之前
父節點
當前提交
81fd5f3309
共有 2 個文件被更改,包括 14 次插入15 次删除
  1. 1 15
      src/Layer/babylon.highlightlayer.ts
  2. 13 0
      src/Shaders/highlightLayerThreshold.fragment.fx

+ 1 - 15
src/Layer/babylon.highlightlayer.ts

@@ -1,19 +1,4 @@
 module BABYLON {
-    BABYLON.Effect.ShadersStore["highlightLayerThresholdFragmentShader"] = "\r\n" +
-        "precision highp float;\r\n" +
-
-        "varying vec2 vUV;\r\n" +
-
-        "uniform float threshold;\r\n" +
-        "uniform sampler2D textureSampler;\r\n" +
-
-        "void main(void) {\r\n" +
-        "   vec4 color = texture2D(textureSampler, vUV);" +
-        "   float alpha = smoothstep(.0, threshold, color.a);" +
-        "   color.a = alpha;" +
-        "    gl_FragColor = color * alpha;\r\n" +
-        "}\r\n";
-
     /**
      * Special Glow Blur post process only blurring the alpha channel
      * It enforces keeping the most luminous color in the color channel.
@@ -912,6 +897,7 @@
             this._downSamplePostprocess.dispose();
             this._horizontalBlurPostprocess.dispose();
             this._verticalBlurPostprocess.dispose();
+            this._thresholdPostProcess.dispose();
         }
 
         /**

+ 13 - 0
src/Shaders/highlightLayerThreshold.fragment.fx

@@ -0,0 +1,13 @@
+precision highp float;
+
+varying vec2 vUV;
+
+uniform float threshold;
+uniform sampler2D textureSampler;
+
+void main(void) {
+    vec4 color = texture2D(textureSampler, vUV);
+    float alpha = smoothstep(.0, threshold, color.a);
+    color.a = alpha;
+    gl_FragColor = color * alpha;
+}