mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-02 00:22:43 +08:00
fix mip filter in GL1 (#5512)
* fix skybox * missing default clip hint * fix mip filter in GL1
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -116,10 +116,10 @@ export class SkeletalAnimationComponent extends AnimationComponent {
|
||||
}
|
||||
|
||||
public querySockets () {
|
||||
const animPaths = this._defaultClip && Object.keys((this._defaultClip as SkeletalAnimationClip).convertedData).sort().reduce((acc, cur) =>
|
||||
cur.startsWith(acc[acc.length - 1]) ? acc : (acc.push(cur), acc), [] as string[]) || [];
|
||||
if (!animPaths.length) { return ['default animation clip missing/invalid']; }
|
||||
const out: string[] = [];
|
||||
if (!this._defaultClip) { return out; }
|
||||
const animPaths = Object.keys((this._defaultClip as SkeletalAnimationClip).convertedData).sort().reduce((acc, cur) =>
|
||||
cur.startsWith(acc[acc.length - 1]) ? acc : (acc.push(cur), acc), [] as string[]);
|
||||
for (let i = 0; i < animPaths.length; i++) {
|
||||
const path = animPaths[i];
|
||||
const node = this.node.getChildByPath(path);
|
||||
|
||||
@@ -34,7 +34,6 @@ import { builtinResMgr } from '../3d/builtin';
|
||||
import { RenderableComponent } from '../3d/framework/renderable-component';
|
||||
import { GFXBindingType } from '../gfx/define';
|
||||
import { GFXTextureView } from '../gfx/texture-view';
|
||||
import { BatchedBuffer } from '../pipeline/batched-buffer';
|
||||
import { IDefineMap, Pass, PassOverrides } from '../renderer/core/pass';
|
||||
import { samplerLib } from '../renderer/core/sampler-lib';
|
||||
import { Asset } from './asset';
|
||||
|
||||
@@ -38,6 +38,15 @@ export type PresumedGFXTextureInfo = Pick<IGFXTextureInfo, 'usage' | 'flags' | '
|
||||
|
||||
export type PresumedGFXTextureViewInfo = Pick<IGFXTextureViewInfo, 'texture' | 'format'>;
|
||||
|
||||
function getMipLevel (width: number, height: number) {
|
||||
let size = Math.max(width, height);
|
||||
let level = 0;
|
||||
while (size) { size >>= 1; level++; }
|
||||
return level;
|
||||
}
|
||||
|
||||
function isPOT (n: number) { return n && (n & (n - 1)) === 0; }
|
||||
|
||||
/**
|
||||
* 简单贴图基类。
|
||||
* 简单贴图内部创建了 GFX 贴图和该贴图上的 GFX 贴图视图。
|
||||
@@ -198,11 +207,16 @@ export class SimpleTexture extends TextureBase {
|
||||
}
|
||||
|
||||
protected _createTexture (device: GFXDevice) {
|
||||
let flags = GFXTextureFlagBit.NONE;
|
||||
if (this._mipFilter !== Filter.NONE && isPOT(this._width) && isPOT(this._height)) {
|
||||
this._mipmapLevel = getMipLevel(this._width, this._height);
|
||||
flags = GFXTextureFlagBit.GEN_MIPMAP;
|
||||
}
|
||||
const textureCreateInfo = this._getGfxTextureCreateInfo({
|
||||
usage: GFXTextureUsageBit.SAMPLED | GFXTextureUsageBit.TRANSFER_DST,
|
||||
format: this._getGFXFormat(),
|
||||
mipLevel: this._mipmapLevel,
|
||||
flags: (this._mipFilter !== Filter.NONE ? GFXTextureFlagBit.GEN_MIPMAP : GFXTextureFlagBit.NONE),
|
||||
flags,
|
||||
});
|
||||
if (!textureCreateInfo) {
|
||||
return;
|
||||
|
||||
@@ -77,6 +77,7 @@ export class Texture2D extends SimpleTexture {
|
||||
|
||||
set mipmaps (value) {
|
||||
this._mipmaps = value;
|
||||
this._setMipmapLevel(this._mipmaps.length);
|
||||
if (this._mipmaps.length > 0) {
|
||||
const imageAsset: ImageAsset = this._mipmaps[0];
|
||||
this.reset({
|
||||
|
||||
@@ -42,13 +42,13 @@ import { Camera } from '../../renderer/scene/camera';
|
||||
import { Model } from '../../renderer/scene/model';
|
||||
import { RenderScene } from '../../renderer/scene/render-scene';
|
||||
import { Root } from '../../root';
|
||||
import { Layers } from '../../scene-graph';
|
||||
import { INode } from '../../utils/interfaces';
|
||||
import { MeshBuffer } from './mesh-buffer';
|
||||
import { StencilManager } from './stencil-manager';
|
||||
import { UIBatchModel } from './ui-batch-model';
|
||||
import { UIMaterial } from './ui-material';
|
||||
import * as UIVertexFormat from './ui-vertex-format';
|
||||
import { Layers } from '../../scene-graph';
|
||||
|
||||
export class UIDrawBatch {
|
||||
public camera: Camera | null = null;
|
||||
@@ -509,7 +509,6 @@ export class UI {
|
||||
}
|
||||
|
||||
private _preprocess (c: INode) {
|
||||
// ts-ignore
|
||||
const render = c._uiComp;
|
||||
if (render && render.enabledInHierarchy) {
|
||||
render.updateAssembler(this);
|
||||
@@ -565,7 +564,7 @@ export class UI {
|
||||
}
|
||||
}
|
||||
|
||||
private _screenSort(a: CanvasComponent, b: CanvasComponent){
|
||||
private _screenSort (a: CanvasComponent, b: CanvasComponent){
|
||||
return a.priority - b.priority;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user