소스 검색

#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 {
 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
      * Special Glow Blur post process only blurring the alpha channel
      * It enforces keeping the most luminous color in the color channel.
      * It enforces keeping the most luminous color in the color channel.
@@ -912,6 +897,7 @@
             this._downSamplePostprocess.dispose();
             this._downSamplePostprocess.dispose();
             this._horizontalBlurPostprocess.dispose();
             this._horizontalBlurPostprocess.dispose();
             this._verticalBlurPostprocess.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;
+}