Skip to content

Commit

Permalink
depth texture cannot have mipmap filtering type
Browse files Browse the repository at this point in the history
  • Loading branch information
baothientran committed Jun 19, 2020
1 parent e206240 commit 5dec949
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions Source/Renderer/Texture.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Cartesian2 from "../Core/Cartesian2.js";
import Check from "../Core/Check.js";
import createGuid from "../Core/createGuid.js";
import WebGLConstants from "../Core/WebGLConstants";
import defaultValue from "../Core/defaultValue.js";
import defined from "../Core/defined.js";
import destroyObject from "../Core/destroyObject.js";
Expand Down Expand Up @@ -496,6 +495,9 @@ Object.defineProperties(Texture.prototype, {
set: function (sampler) {
var minificationFilter = sampler.minificationFilter;
var magnificationFilter = sampler.magnificationFilter;
var context = this._context;
var pixelFormat = this._pixelFormat;
var pixelDatatype = this._pixelDatatype;

var mipmap =
minificationFilter ===
Expand All @@ -506,10 +508,6 @@ Object.defineProperties(Texture.prototype, {
TextureMinificationFilter.LINEAR_MIPMAP_NEAREST ||
minificationFilter === TextureMinificationFilter.LINEAR_MIPMAP_LINEAR;

var context = this._context;
var internalFormat = this._internalFormat;
var pixelDatatype = this._pixelDatatype;

// float textures only support nearest filtering unless the linear extensions are supported, so override the sampler's settings
if (
(pixelDatatype === PixelDatatype.FLOAT &&
Expand All @@ -525,18 +523,8 @@ Object.defineProperties(Texture.prototype, {

// WebGL 2 depth texture only support nearest filtering. See section 3.8.13 OpenGL ES 3 spec
if (context.webgl2) {
if (
internalFormat === WebGLConstants.DEPTH_COMPONENT ||
internalFormat === WebGLConstants.DEPTH_STENCIL ||
internalFormat === WebGLConstants.DEPTH_COMPONENT16 ||
internalFormat === WebGLConstants.DEPTH_COMPONENT24 ||
internalFormat === WebGLConstants.DEPTH_COMPONENT32F ||
internalFormat === WebGLConstants.DEPTH24_STENCIL8 ||
internalFormat === WebGLConstants.DEPTH32F_STENCIL8
) {
minificationFilter = mipmap
? TextureMinificationFilter.NEAREST_MIPMAP_NEAREST
: TextureMinificationFilter.NEAREST;
if (PixelFormat.isDepthFormat(pixelFormat)) {
minificationFilter = TextureMinificationFilter.NEAREST;
magnificationFilter = TextureMagnificationFilter.NEAREST;
}
}
Expand Down

0 comments on commit 5dec949

Please sign in to comment.