ソースを参照

refactor smapler uniform binding

David Catuhe 7 年 前
コミット
98ee8e7f60
2 ファイル変更5926 行追加5922 行削除
  1. 5919 5918
      dist/preview release/babylon.d.ts
  2. 7 4
      src/Engine/babylon.engine.ts

ファイルの差分が大きいため隠しています
+ 5919 - 5918
dist/preview release/babylon.d.ts


+ 7 - 4
src/Engine/babylon.engine.ts

@@ -4572,8 +4572,7 @@
 
             if (isTextureForRendering) {
                 texture!._designatedSlot = this._activeChannel;
-                let uniform = this._boundUniforms[texture!._initialSlot];
-                this._gl.uniform1i(uniform, this._activeChannel);
+                this._bindSamplerUniformToChannel(texture!._initialSlot, this._activeChannel);
             }
         }
 
@@ -4644,6 +4643,11 @@
             return channel;
         }
 
+        private _bindSamplerUniformToChannel(sourceSlot: number, destination: number) {
+            let uniform = this._boundUniforms[sourceSlot];
+            this._gl.uniform1i(uniform, destination);
+        }
+
         private _setTexture(channel: number, texture: Nullable<BaseTexture>): boolean {
             // Not ready?
             if (!texture) {
@@ -4686,8 +4690,7 @@
             channel = this._getCorrectTextureChannel(channel, internalTexture);
 
             if (this._boundTexturesCache[channel] === internalTexture) {
-                let uniform = this._boundUniforms[internalTexture._initialSlot];
-                this._gl.uniform1i(uniform, channel);
+                this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
                 return false;
             }