소스 검색

Check support of standard derivatives for detail map

Popov72 5 년 전
부모
커밋
c1520f611e
2개의 변경된 파일12개의 추가작업 그리고 11개의 파일을 삭제
  1. 7 6
      src/Materials/PBR/pbrBaseMaterial.ts
  2. 5 5
      src/Materials/standardMaterial.ts

+ 7 - 6
src/Materials/PBR/pbrBaseMaterial.ts

@@ -977,12 +977,6 @@ export abstract class PBRBaseMaterial extends PushMaterial {
                     }
                 }
 
-                if (this._detailTexture && MaterialFlags.DetailTextureEnabled) {
-                    if (!this._detailTexture.isReadyOrNotBlocking()) {
-                        return false;
-                    }
-                }
-
                 if (this._ambientTexture && MaterialFlags.AmbientTextureEnabled) {
                     if (!this._ambientTexture.isReadyOrNotBlocking()) {
                         return false;
@@ -1049,6 +1043,13 @@ export abstract class PBRBaseMaterial extends PushMaterial {
                     }
                 }
 
+                if (engine.getCaps().standardDerivatives && this._detailTexture && MaterialFlags.DetailTextureEnabled) {
+                    // Detail texture cannot be not blocking.
+                    if (!this._detailTexture.isReady()) {
+                        return false;
+                    }
+                }
+
                 if (this._environmentBRDFTexture && MaterialFlags.ReflectionTextureEnabled) {
                     // This is blocking.
                     if (!this._environmentBRDFTexture.isReady()) {

+ 5 - 5
src/Materials/standardMaterial.ts

@@ -1425,7 +1425,7 @@ export class StandardMaterial extends PushMaterial {
                     }
 
                     if (this._detailTexture && StandardMaterial.DetailTextureEnabled) {
-                        ubo.updateFloat3("vDetailInfos", this._detailTexture.coordinatesIndex, 1 - this.detailDiffuseBlendLevel, this.detailBumpLevel);
+                        ubo.updateFloat3("vDetailInfos", this._detailTexture.coordinatesIndex, this.detailDiffuseBlendLevel, this.detailBumpLevel);
                         MaterialHelper.BindTextureMatrix(this._detailTexture, ubo, "detail");
                     }
 
@@ -1513,10 +1513,6 @@ export class StandardMaterial extends PushMaterial {
                     effect.setTexture("diffuseSampler", this._diffuseTexture);
                 }
 
-                if (this._detailTexture && StandardMaterial.DetailTextureEnabled) {
-                    effect.setTexture("detailSampler", this._detailTexture);
-                }
-
                 if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
                     effect.setTexture("ambientSampler", this._ambientTexture);
                 }
@@ -1549,6 +1545,10 @@ export class StandardMaterial extends PushMaterial {
                     effect.setTexture("bumpSampler", this._bumpTexture);
                 }
 
+                if (this._detailTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.DetailTextureEnabled) {
+                    effect.setTexture("detailSampler", this._detailTexture);
+                }
+
                 if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
                     var depth = 1.0;
                     if (this._refractionTexture.isCube) {