From 09499c8b5ba244e7338d6f13f97fdf793a5862fd Mon Sep 17 00:00:00 2001 From: Yun Hsiao Wu Date: Thu, 28 Mar 2019 17:01:26 +0800 Subject: [PATCH] fix sampler LOD (#4115) --- cocos/3d/assets/mesh.ts | 3 +++ cocos/assets/texture-base.ts | 1 + cocos/gfx/sampler.ts | 2 +- cocos/gfx/webgl2/webgl2-commands.ts | 4 ++-- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/cocos/3d/assets/mesh.ts b/cocos/3d/assets/mesh.ts index 9c0a272ec3..bd67cc3423 100644 --- a/cocos/3d/assets/mesh.ts +++ b/cocos/3d/assets/mesh.ts @@ -332,6 +332,9 @@ export class RenderingMesh { @ccclass('cc.Mesh') export class Mesh extends Asset { + public static AttributeBaseType = AttributeBaseType; + public static AttributeType = AttributeType; + get _nativeAsset () { return this._data; } diff --git a/cocos/assets/texture-base.ts b/cocos/assets/texture-base.ts index 48ae0fb130..cca8c6ec11 100644 --- a/cocos/assets/texture-base.ts +++ b/cocos/assets/texture-base.ts @@ -326,6 +326,7 @@ export class TextureBase extends EventTargetFactory(Asset) { */ public setMipFilter (mipFilter: Filter) { this._mipFilter = mipFilter; this._samplerInfo[SamplerInfoIndex.mipFilter] = mipFilter; + this._samplerInfo[SamplerInfoIndex.maxLOD] = mipFilter === Filter.NONE ? 0 : 1000; } /** diff --git a/cocos/gfx/sampler.ts b/cocos/gfx/sampler.ts index cc2f20148b..e56399eb9a 100644 --- a/cocos/gfx/sampler.ts +++ b/cocos/gfx/sampler.ts @@ -29,7 +29,7 @@ export class GFXSamplerState { public cmpFunc: GFXComparisonFunc = GFXComparisonFunc.NEVER; public borderColor: IGFXColor = { r: 0, g: 0, b: 0, a: 0 }; public minLOD: number = 0; - public maxLOD: number = 1000; + public maxLOD: number = 0; public mipLODBias: number = 0.0; public compare (state: GFXSamplerState): boolean { diff --git a/cocos/gfx/webgl2/webgl2-commands.ts b/cocos/gfx/webgl2/webgl2-commands.ts index ca8089d391..13d61501ef 100644 --- a/cocos/gfx/webgl2/webgl2-commands.ts +++ b/cocos/gfx/webgl2/webgl2-commands.ts @@ -1114,8 +1114,8 @@ export function WebGL2CmdFuncCreateSampler (device: WebGL2GFXDevice, gpuSampler: gl.samplerParameteri(glSampler, gl.TEXTURE_WRAP_S, gpuSampler.glWrapS); gl.samplerParameteri(glSampler, gl.TEXTURE_WRAP_T, gpuSampler.glWrapT); gl.samplerParameteri(glSampler, gl.TEXTURE_WRAP_R, gpuSampler.glWrapR); - gl.samplerParameteri(glSampler, gl.TEXTURE_MIN_LOD, gpuSampler.minLOD); - gl.samplerParameteri(glSampler, gl.TEXTURE_MAX_LOD, gpuSampler.maxLOD); + gl.samplerParameterf(glSampler, gl.TEXTURE_MIN_LOD, gpuSampler.minLOD); + gl.samplerParameterf(glSampler, gl.TEXTURE_MAX_LOD, gpuSampler.maxLOD); } }